Introduce CheckChangeTicks
event that is triggered by World::check_change_ticks
#19274
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
In the past I had custom data structures containing
Tick
s. I learned that these need to be regularly checked to clamp them. But there was no way to hook into that logic so I abandoned storing ticks since then.Another motivation to open this up some more is to be more able to do a correct implementation of
System::check_ticks
.Solution
Add
CheckChangeTicks
and trigger it inWorld::check_change_ticks
.Make
Tick::check_tick
public.This event makes it possible to store ticks in components or resources and have them checked.
I also made
Schedules::check_change_ticks
public so users can store schedules in custom resources/components for whatever reasons.Testing
The logic boils down to a single
World::trigger
call and I don't think this needs more tests.Alternatives
Making this obsolete like with #15683.
Showcase
From the added docs: