bevy
bevy copied to clipboard
Increase type safety and clarity for change detection
Objective
- We have the type
Tickfor dealing with change ticks, but most of the engine still just usesu32. - The names
last_change_tickandchange_tickoften appear together, however the meaning of these names is unclear.
Solution
- Use the
Ticktype throughout the engine. - Rename
last_change_tickandchange_ticktolast_runandthis_run, respectively.
Changelog
- Change detection now uses the strongly-typed
Tickinstead ofu32.
Migration Guide
The engine now uses the type Tick for dealing with change ticks, instead of u32. Any code that interfaced with engine internals will need to be updated, including:
- The traits
SystemParam,WorldQuery,DetectChanges, andDetectChangesMut. - The methods
World::change_tickandread_change_tick. System::set_last_change_tickandget_last_change_tick. Also, these methods have also been renamed toset_last_runandget_last_run, respectively.- The methods
SystemChangeTick::change_tickandlast_change_tick. These methods have been renamed tothis_runandlast_run, respectively. - The method
Tick::set_changed, which has been renamed to justset.
I've encapsulated the field on Tick, which I think makes this even cleaner. I want to do a bit of file re-organization, but I'll leave it for a follow-up so the diffs aren't horrible.
I have no idea why CI is failing now.
CI failure looks like #8002.