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