Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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)
}

/// Manually flags this resource as having been changed. This normally isn't
/// required because accessing this pointer mutably automatically flags this
/// resource as "changed".
///
/// **Note**: This operation is irreversible.
#[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
}

/// Manually flags this value as having been changed. This normally isn't
/// required because accessing this pointer mutably automatically flags this
/// value as "changed".
///
/// **Note**: This operation is irreversible.
#[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