From 7321f25174c64350fbc91f3fcb580cb1cb189b4e Mon Sep 17 00:00:00 2001 From: Winston Hartnett Date: Sat, 7 Jan 2023 03:38:44 -0600 Subject: [PATCH] Expose SystemMeta field accessors (#5497) --- crates/bevy_ecs/src/system/function_system.rs | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/crates/bevy_ecs/src/system/function_system.rs b/crates/bevy_ecs/src/system/function_system.rs index 2cc88f9e30b77..bd7b25ee41120 100644 --- a/crates/bevy_ecs/src/system/function_system.rs +++ b/crates/bevy_ecs/src/system/function_system.rs @@ -43,6 +43,36 @@ impl SystemMeta { &self.name } + /// Returns the system's component access set. + #[inline] + pub fn component_access_set(&self) -> &FilteredAccessSet { + &self.component_access_set + } + + /// Returns a mutable reference to the system's component access set. + /// + /// # Safety + /// This allows unsafe modifications to the component access set that can violate Bevy's scheduling soundness. + #[inline] + pub unsafe fn component_access_set_mut(&mut self) -> &mut FilteredAccessSet { + &mut self.component_access_set + } + + /// Returns the system's archetype component access set. + #[inline] + pub fn archetype_component_access(&self) -> &Access { + &self.archetype_component_access + } + + /// Returns a mutable reference to this system's archetype component access set. + /// + /// # Safety + /// This allows unsafe modifications to the archetype component access set that can violate Bevy's scheduling soundness. + #[inline] + pub unsafe fn archetype_component_access_mut(&mut self) -> &mut Access { + &mut self.archetype_component_access + } + /// Returns true if the system is [`Send`]. #[inline] pub fn is_send(&self) -> bool { @@ -56,6 +86,18 @@ impl SystemMeta { pub fn set_non_send(&mut self) { self.is_send = false; } + + /// Returns this system's last change tick. + #[inline] + pub fn last_change_tick(&self) -> u32 { + self.last_change_tick + } + + /// Set this system's last change tick. + #[inline] + pub fn set_last_change_tick(&mut self, last_change_tick: u32) { + self.last_change_tick = last_change_tick; + } } // TODO: Actually use this in FunctionSystem. We should probably only do this once Systems are constructed using a World reference