New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: update grenade.rs to use bones timer. #740
Conversation
core/src/elements/grenade.rs
Outdated
lit.insert( | ||
entity, | ||
LitGrenade { | ||
damage_delay: Timer::new(Duration::from_secs_f32(4.0), TimerMode::Once), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This 4.0
should come from the fuse_time
out of the grenade meta.
core/src/elements/grenade.rs
Outdated
@@ -215,7 +224,7 @@ fn update_lit_grenades( | |||
} | |||
|
|||
// If it's time to explode | |||
if grenade.age >= *fuse_time { | |||
if grenade.damage_delay.elapsed_secs() >= *fuse_time { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once we set the timer duratino from the fuse_time
, we can just do this:
if grenade.damage_delay.elapsed_secs() >= *fuse_time { | |
if grenade.damage_delay.is_finished() { |
core/src/elements/grenade.rs
Outdated
/// How long the grenade has been lit. | ||
pub age: f32, | ||
pub damage_delay: Timer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last change! Could you re-name this to fuse_time
, and remove the comment, or update it with a new description.
…ed comment on ln 20
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
thanks for the help ! |
updated grenade.rs to use bones timer instead of manually setting time to 4.0 seconds
attempts to resolve #739