-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Add a new almost_finish method for Timer with immediate first tick action
#21983
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
base: main
Are you sure you want to change the base?
Conversation
action Resolves bevyengine#21860 This new method would tick the timer by `duration - 1 ns` leaving a very short waiting time for the first tick initiated by the user allowing immediate action.
543f66c to
1382f97
Compare
| } | ||
|
|
||
| /// Almost finishes the timer leaving 1 ns of remaining 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.
Please add another line here explaining why this method would be useful.
| duration: Duration, | ||
| mode: TimerMode, | ||
| finished: bool, | ||
| almost_finished: bool, |
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.
I don't think we need this field at all: simply setting the duration remaining to 1 ns should do the trick directly without adding complexity / wasted data.
alice-i-cecile
left a comment
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.
I think we can + should get rid of the bool, but I like the 1 ns solution!
Objective
Resolves #21860
This new method would tick the timer by
duration - 1 nsleaving a very short waiting time for the first tick initiated by the user allowing immediate action.Solution
The
almost_finishmethod updates the timer by ticking it with1nsremaining.Testing
Tests have been added in
almost_finished_repeating.