Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose method to update the internal ticks of Ref and Mut #17716

Merged
merged 1 commit into from
Feb 11, 2025
Merged
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
18 changes: 18 additions & 0 deletions crates/bevy_ecs/src/change_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,15 @@ impl<'w, T: ?Sized> Ref<'w, T> {
changed_by: caller,
}
}

/// Overwrite the `last_run` and `this_run` tick that are used for change detection.
///
/// This is an advanced feature. `Ref`s are usually _created_ by engine-internal code and
/// _consumed_ by end-user code.
pub fn set_ticks(&mut self, last_run: Tick, this_run: Tick) {
self.ticks.last_run = last_run;
self.ticks.this_run = this_run;
}
}

impl<'w, 'a, T> IntoIterator for &'a Ref<'w, T>
Expand Down Expand Up @@ -978,6 +987,15 @@ impl<'w, T: ?Sized> Mut<'w, T> {
changed_by: caller,
}
}

/// Overwrite the `last_run` and `this_run` tick that are used for change detection.
///
/// This is an advanced feature. `Mut`s are usually _created_ by engine-internal code and
/// _consumed_ by end-user code.
pub fn set_ticks(&mut self, last_run: Tick, this_run: Tick) {
self.ticks.last_run = last_run;
self.ticks.this_run = this_run;
}
}

impl<'w, T: ?Sized> From<Mut<'w, T>> for Ref<'w, T> {
Expand Down