Skip to content

Expose the added tick for change detection, both getting and setting. #18746

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

Conversation

moonheart08
Copy link
Contributor

Objective

  • Allow viewing and setting the added tick for change detection aware data, to allow operations like checking if the value has been modified since first being added, and spoofing that state (i.e. returning the value to default in place without a remove/insert dance)

Solution

  • Added corresponding functions matching the existing changed API:
    • fn added(&self) -> Tick
    • fn set_added(&mut self)
    • fn set_last_added(&mut self, last_added: Tick)

Discussed on discord @ https://canary.discord.com/channels/691052431525675048/749335865876021248/1358718892465193060

Testing

  • Running the bevy test suite by.. making a PR, heck.
  • No new tests were introduced due to triviality (i.e. I don't know what to test about this API, and the corresponding API for changed is similarly lacking tests.)

@SpecificProtagonist SpecificProtagonist added C-Feature A new feature, making something new possible D-Trivial Nice and easy! A great choice to get started with Bevy A-ECS Entities, components, systems, and events S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 7, 2025
@moonheart08 moonheart08 force-pushed the 2025-07-04-change-detection-added-helpers branch from d7f221e to 2e1e65c Compare April 8, 2025 00:12
@moonheart08
Copy link
Contributor Author

Should be good to go now.

moonheart08 and others added 5 commits April 8, 2025 06:56
Co-authored-by: SpecificProtagonist <vincentjunge@posteo.net>
Co-authored-by: Chris Russell <8494645+chescock@users.noreply.github.com>
@moonheart08 moonheart08 force-pushed the 2025-07-04-change-detection-added-helpers branch from 2e1e65c to 5afe74b Compare April 8, 2025 11:56
@alice-i-cecile alice-i-cecile added this to the 0.16 milestone Apr 8, 2025
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 8, 2025
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Apr 8, 2025
Merged via the queue into bevyengine:main with commit 0410212 Apr 8, 2025
34 checks passed
mockersf pushed a commit that referenced this pull request Apr 8, 2025
…#18746)

# Objective

- Allow viewing and setting the added tick for change detection aware
data, to allow operations like checking if the value has been modified
since first being added, and spoofing that state (i.e. returning the
value to default in place without a remove/insert dance)

## Solution

- Added corresponding functions matching the existing `changed` API:
  - `fn added(&self) -> Tick`
  - `fn set_added(&mut self)`
  - `fn set_last_added(&mut self, last_added: Tick)`

Discussed on discord @
https://canary.discord.com/channels/691052431525675048/749335865876021248/1358718892465193060

## Testing

- Running the bevy test suite by.. making a PR, heck.
- No new tests were introduced due to triviality (i.e. I don't know what
to test about this API, and the corresponding API for `changed` is
similarly lacking tests.)

---------

Co-authored-by: moonheart08 <moonheart08@users.noreply.github.com>
Co-authored-by: SpecificProtagonist <vincentjunge@posteo.net>
Co-authored-by: Chris Russell <8494645+chescock@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Feature A new feature, making something new possible D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants