mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Made pets healable
This commit is contained in:
parent
55852f9bc7
commit
99a526f702
@ -40,6 +40,16 @@ impl Alignment {
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Remove this hack
|
||||
pub fn is_friendly_to_players(&self) -> bool {
|
||||
match self {
|
||||
Alignment::Npc
|
||||
| Alignment::Tame
|
||||
| Alignment::Owned(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Component for Alignment {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
comp::{
|
||||
Agent, Attacking, Body, CharacterState, HealthChange, HealthSource, Ori, Pos, Scale, Stats,
|
||||
Alignment, Attacking, Body, CharacterState, HealthChange, HealthSource, Ori, Pos, Scale, Stats,
|
||||
},
|
||||
event::{EventBus, LocalEvent, ServerEvent},
|
||||
sync::Uid,
|
||||
@ -25,7 +25,7 @@ impl<'a> System<'a> for Sys {
|
||||
ReadStorage<'a, Pos>,
|
||||
ReadStorage<'a, Ori>,
|
||||
ReadStorage<'a, Scale>,
|
||||
ReadStorage<'a, Agent>,
|
||||
ReadStorage<'a, Alignment>,
|
||||
ReadStorage<'a, Body>,
|
||||
ReadStorage<'a, Stats>,
|
||||
WriteStorage<'a, Attacking>,
|
||||
@ -42,7 +42,7 @@ impl<'a> System<'a> for Sys {
|
||||
positions,
|
||||
orientations,
|
||||
scales,
|
||||
agents,
|
||||
alignments,
|
||||
bodies,
|
||||
stats,
|
||||
mut attacking_storage,
|
||||
@ -74,7 +74,7 @@ impl<'a> System<'a> for Sys {
|
||||
pos_b,
|
||||
ori_b,
|
||||
scale_b_maybe,
|
||||
agent_b_maybe,
|
||||
alignment_b_maybe,
|
||||
character_b,
|
||||
stats_b,
|
||||
body_b,
|
||||
@ -84,7 +84,7 @@ impl<'a> System<'a> for Sys {
|
||||
&positions,
|
||||
&orientations,
|
||||
scales.maybe(),
|
||||
agents.maybe(),
|
||||
alignments.maybe(),
|
||||
character_states.maybe(),
|
||||
&stats,
|
||||
&bodies,
|
||||
@ -120,7 +120,7 @@ impl<'a> System<'a> for Sys {
|
||||
|
||||
// TODO: remove this when there is a better way to target healing
|
||||
// Don't heal npc's hp
|
||||
if agent_b_maybe.is_some() && healthchange > 0.0 {
|
||||
if alignment_b_maybe.map(|a| !a.is_friendly_to_players()).unwrap_or(true) && healthchange > 0.0 {
|
||||
healthchange = 0.0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user