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

Add last_changed_tick and added_tick to ComponentTicks #8803

Merged
merged 2 commits into from Jun 12, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions crates/bevy_ecs/src/component.rs
Expand Up @@ -686,18 +686,24 @@ pub struct ComponentTicks {
}

impl ComponentTicks {
#[inline]
/// Returns `true` if the component was added after the system last ran.
#[inline]
pub fn is_added(&self, last_run: Tick, this_run: Tick) -> bool {
self.added.is_newer_than(last_run, this_run)
}

#[inline]
/// Returns `true` if the component was added or mutably dereferenced after the system last ran.
#[inline]
pub fn is_changed(&self, last_run: Tick, this_run: Tick) -> bool {
self.changed.is_newer_than(last_run, this_run)
}

/// Returns the change tick recording the time this data was most recently changed.
#[inline]
pub fn last_changed(&self) -> u32 {
self.changed.get()
}
nicopap marked this conversation as resolved.
Show resolved Hide resolved

pub(crate) fn new(change_tick: Tick) -> Self {
Self {
added: change_tick,
Expand Down