# 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 in `World::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: ```rs use bevy_ecs::prelude::*; use bevy_ecs::component::CheckChangeTicks; #[derive(Resource)] struct CustomSchedule(Schedule); let mut world = World::new(); world.add_observer(|tick: Trigger<CheckChangeTicks>, mut schedule: ResMut<CustomSchedule>| { schedule.0.check_change_ticks(tick.get()); }); ``` --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> |
||
|---|---|---|
| .. | ||
| command_queue.rs | ||
| component_constants.rs | ||
| deferred_world.rs | ||
| entity_fetch.rs | ||
| entity_ref.rs | ||
| error.rs | ||
| filtered_resource.rs | ||
| identifier.rs | ||
| mod.rs | ||
| reflect.rs | ||
| spawn_batch.rs | ||
| unsafe_world_cell.rs | ||