Merge branch 'acrimon/925-campfire-fix' into 'master'

Don't apply campfire healing buff if the player is at maximum health.

Closes #925

See merge request veloren/veloren!1690
This commit is contained in:
Acrimon 2021-01-14 15:19:49 +00:00
commit 69476f46af

View File

@ -1,6 +1,7 @@
use common::{
comp::{
aura::AuraKey, buff, AuraChange, AuraKind, Auras, BuffKind, Buffs, CharacterState, Pos,
aura::AuraKey, buff, AuraChange, AuraKind, Auras, BuffKind, Buffs, CharacterState, Health,
Pos,
},
event::{EventBus, ServerEvent},
resources::DeltaTime,
@ -19,11 +20,12 @@ impl<'a> System<'a> for Sys {
ReadStorage<'a, CharacterState>,
WriteStorage<'a, Auras>,
WriteStorage<'a, Buffs>,
ReadStorage<'a, Health>,
);
fn run(
&mut self,
(entities, dt, positions, server_bus, character_states, mut auras, mut buffs): Self::SystemData,
(entities, dt, positions, server_bus, character_states, mut auras, mut buffs, health): Self::SystemData,
) {
let mut server_emitter = server_bus.emitter();
@ -45,8 +47,20 @@ impl<'a> System<'a> for Sys {
expired_auras.push(key);
}
}
for (target_entity, target_pos, target_character_state_maybe, target_buffs) in
(&entities, &positions, character_states.maybe(), &mut buffs).join()
for (
target_entity,
target_pos,
target_character_state_maybe,
target_buffs,
health,
) in (
&entities,
&positions,
character_states.maybe(),
&mut buffs,
&health,
)
.join()
{
// Ensure entity is within the aura radius
if target_pos.0.distance_squared(pos.0) < aura.radius.powi(2) {
@ -67,10 +81,12 @@ impl<'a> System<'a> for Sys {
// Conditions for different buffs are in this match
// statement
let apply_buff = match kind {
BuffKind::CampfireHeal => matches!(
target_character_state_maybe,
Some(CharacterState::Sit)
),
BuffKind::CampfireHeal => {
matches!(
target_character_state_maybe,
Some(CharacterState::Sit)
) && health.current() < health.maximum()
},
// Add other specific buff conditions here
_ => true,
};