Skip to content
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

Merged
merged 6 commits into from Mar 29, 2023

Conversation

lvllvl
Copy link
Contributor

@lvllvl lvllvl commented Mar 26, 2023

updated grenade.rs to use bones timer instead of manually setting time to 4.0 seconds

attempts to resolve #739

lit.insert(
entity,
LitGrenade {
damage_delay: Timer::new(Duration::from_secs_f32(4.0), TimerMode::Once),
Copy link
Member

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.

@@ -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 {
Copy link
Member

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:

Suggested change
if grenade.damage_delay.elapsed_secs() >= *fuse_time {
if grenade.damage_delay.is_finished() {

Comment on lines 20 to 21
/// How long the grenade has been lit.
pub age: f32,
pub damage_delay: Timer,
Copy link
Member

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.

@zicklag zicklag changed the title fix: updated grenade.rs to use bones timer refactor: update grenade.rs to use bones timer. Mar 29, 2023
Copy link
Member

@zicklag zicklag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@zicklag zicklag enabled auto-merge March 29, 2023 02:29
@zicklag zicklag added this pull request to the merge queue Mar 29, 2023
Merged via the queue into fishfolk:main with commit cbf8822 Mar 29, 2023
9 checks passed
@lvllvl
Copy link
Contributor Author

lvllvl commented Mar 29, 2023

Looks good!

thanks for the help !

@lvllvl lvllvl deleted the grenade_timer branch March 29, 2023 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update grenade to use Bones time resource instead of manually setting the time
2 participants