TinyEcs
TinyEcs copied to clipboard
Component Lifecycle Terms
Hey I really like the direction you're taking this library! I've been bouncing between different ECS libs and this seems like a great option.
It would be very helpful if queries had support for defining filters based on the lifecycle of components.
Mainly:
-
Changed<T> - Evaluates to true when component T was accessed mutably or set for the entity since the last execution of the query
-
Added<T> - Evaluates to true when component T was added to an entity since the last execution of the query
I'm not fully sure how bevy does this but it seems like they store a vec of watermarks alongside each column that gets updated each time an entry in the column is accessed mutably or added. Then each query tracks a watermark of when it was last ran it uses for comparison. https://github.com/bevyengine/bevy/blob/main/crates/bevy_ecs/src/change_detection.rs https://bevy-cheatbook.github.io/programming/change-detection.html
- Removed<T> - Evaluates to true when component T was removed from an entity since the last execution of the query
In bevy, removals publish out an event that systems can read if they run the next frame https://github.com/bevyengine/bevy/blob/main/crates/bevy_ecs/src/removal_detection.rs