Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion crates/bevy_ecs/src/system/system_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,16 @@ impl<'w, T: Component> ResMut<'w, T> {
self.ticks
.is_changed(self.last_change_tick, self.change_tick)
}

/// Flags this resource as having been changed.
///
/// **Note**: this operation is irreversible.
/// You should generally prefer to use [`ResMut::as_mut`], as this returns
/// the contained value _and_ sets this resource as changed.
#[inline]
pub fn set_changed(&mut self) {
self.ticks.set_changed(self.change_tick);
}
}

impl<'w, T: Component> Deref for ResMut<'w, T> {
Expand All @@ -381,7 +391,7 @@ impl<'w, T: Component> Deref for ResMut<'w, T> {

impl<'w, T: Component> DerefMut for ResMut<'w, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
self.ticks.set_changed(self.change_tick);
self.set_changed();
self.value
}
}
Expand Down
12 changes: 11 additions & 1 deletion crates/bevy_ecs/src/world/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ impl<'a, T> Mut<'a, T> {
self.component_ticks.set_changed(self.change_tick);
self.value
}

/// Flags this component as having been changed.
///
/// **Note**: this operation is irreversible.
/// You should generally prefer to use [`Mut::as_mut`], as this returns
/// the component _and_ sets it as changed.
#[inline]
pub fn set_changed(&mut self) {
self.component_ticks.set_changed(self.change_tick);
}
}

impl<'a, T> Deref for Mut<'a, T> {
Expand All @@ -28,7 +38,7 @@ impl<'a, T> Deref for Mut<'a, T> {
impl<'a, T> DerefMut for Mut<'a, T> {
#[inline]
fn deref_mut(&mut self) -> &mut T {
self.component_ticks.set_changed(self.change_tick);
self.set_changed();
self.value
}
}
Expand Down