diff options
author | David <david003@gmx.net> | 2022-07-16 21:02:56 +0200 |
---|---|---|
committer | David <david003@gmx.net> | 2022-07-16 21:02:56 +0200 |
commit | f561a1f69d5fda68e0a23ab04f448e9364b2968c (patch) | |
tree | 193175713911f4813e3fd5e1b44ac0af65d932e1 /rust | |
parent | d1bac1c41a75fdf901e1f7c5f604783f0685190a (diff) | |
download | 2022-f561a1f69d5fda68e0a23ab04f448e9364b2968c.tar.gz 2022-f561a1f69d5fda68e0a23ab04f448e9364b2968c.tar.bz2 2022-f561a1f69d5fda68e0a23ab04f448e9364b2968c.zip |
deactivate ball after 5s
Diffstat (limited to '')
-rw-r--r-- | rust/src/basic_die.rs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/rust/src/basic_die.rs b/rust/src/basic_die.rs index dc425b4..dbcccc8 100644 --- a/rust/src/basic_die.rs +++ b/rust/src/basic_die.rs @@ -13,7 +13,7 @@ enum InputState { Shooting, Moving } - + type SpatialRef = Option<Ref<Spatial>>; @@ -37,7 +37,7 @@ pub struct BasicDie { #[property(path="input/shoot_sensitivity")] shoot_sensitivity: f32, #[property(path="input/current_buff_index")] - current_buff_index: i8, + current_buff_index: i32, all_buffs: [Option<Box<dyn Buff>>; 5], @@ -144,6 +144,7 @@ impl BasicDie { Some(Box::new(BuffExtra ::new())), ]; + godot_print!("Current Buff: {}", self.current_buff_index); godot_print!("Player is ready"); } @@ -166,8 +167,19 @@ impl BasicDie { } } - // detect if the die stops moving let delta_ms = OS::godot_singleton().get_ticks_msec() - self.last_shot_time; + + // deactivate the Ball Buff after 5 seconds + if matches!(self.input_state, InputState::Moving) + && delta_ms > 5000 + && self.current_buff_index == 1 { + match self.all_buffs[1] { + Some(ref mut buff) => buff.revert_buff(), + None => {} + } + } + + // detect if the die stops moving if matches!(self.input_state, InputState::Moving) && (delta_ms > self.stopping_min_ms) { @@ -178,6 +190,7 @@ impl BasicDie { godot_print!("Die stopped moving at velocity {} after {} ms", current_vel, delta_ms); //deactivate the old buff + godot_print!("Current Buff: {}", self.current_buff_index); match self.all_buffs[self.current_buff_index as usize] { Some(ref mut buff) => buff.revert_buff(), None => {} @@ -349,6 +362,7 @@ impl BasicDie { }; // apply the current buff + godot_print!("Current Buff: {}", self.current_buff_index); match self.all_buffs[self.current_buff_index as usize] { Some(ref mut buff) => buff.execute_buff(), None => {} |