From 6c2d73c35753d21dce7d0d34bd2337d5464bfa24 Mon Sep 17 00:00:00 2001 From: gGmMsS123 <82216659+gGmMsS123@users.noreply.github.com> Date: Thu, 22 Apr 2021 12:28:13 +0300 Subject: [PATCH] Changed M2 Sceptre from a beam to a hitscan --- common/src/comp/ability.rs | 5 ++--- common/src/event.rs | 4 ++++ common/src/states/targeted_effect.rs | 12 ++++++------ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/common/src/comp/ability.rs b/common/src/comp/ability.rs index 30a2383d2c..bb7d4a1372 100644 --- a/common/src/comp/ability.rs +++ b/common/src/comp/ability.rs @@ -268,7 +268,6 @@ pub enum CharacterAbility { buildup_duration: f32, recover_duration: f32, max_range: f32, - // TODO: Replace with effect when targeted system created heal: f32, }, } @@ -1625,13 +1624,13 @@ impl From<(&CharacterAbility, AbilityInfo)> for CharacterState { CharacterAbility::TargetedEffect { buildup_duration, recover_duration, - max_range, - } => CharacterState::TargetedEffect(targeted_effect::Data { + max_range, heal } => CharacterState::TargetedEffect(targeted_effect::Data { static_data: targeted_effect::StaticData { buildup_duration: Duration::from_secs_f32(*buildup_duration), recover_duration: Duration::from_secs_f32(*recover_duration), max_range: *max_range, ability_info, + heal, }, timer: Duration::default(), stage_section: StageSection::Buildup, diff --git a/common/src/event.rs b/common/src/event.rs index f537e02150..7aaccffa6f 100644 --- a/common/src/event.rs +++ b/common/src/event.rs @@ -35,6 +35,10 @@ pub enum LocalEvent { #[allow(clippy::large_enum_variant)] // TODO: Pending review in #587 pub enum ServerEvent { + HealthChange { + entity: EcsEntity, + change: comp::HealthChange, + }, Explosion { pos: Vec3, explosion: Explosion, diff --git a/common/src/states/targeted_effect.rs b/common/src/states/targeted_effect.rs index 4c5a353d1c..59f63f9a12 100644 --- a/common/src/states/targeted_effect.rs +++ b/common/src/states/targeted_effect.rs @@ -1,5 +1,5 @@ use crate::{ - comp::{CharacterState, StateUpdate}, + comp::{CharacterState, HealthSource, StateUpdate, HealthChange}, event::ServerEvent, states::{ behavior::{CharacterBehavior, JoinData}, @@ -20,6 +20,8 @@ pub struct StaticData { pub max_range: f32, /// Miscellaneous information about the ability pub ability_info: AbilityInfo, + /// Heal + pub heal: HealthChange, } #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] @@ -32,7 +34,6 @@ pub struct Data { /// What section the character stage is in pub stage_section: StageSection, } - impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); @@ -56,11 +57,10 @@ impl CharacterBehavior for Data { entity: target, change: HealthChange { amount: self.static_data.heal as i32, - cause: HealthSource::Heal { by: Some(data.uid) }, - })}; + cause: HealthSource::Heal { by: Some(*data.uid) }, + }}); } } - } // Transitions to recover section of stage update.character = CharacterState::TargetedEffect(Data { timer: Duration::default(), @@ -92,4 +92,4 @@ impl CharacterBehavior for Data { update } -} +}