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

Implement Reflect for State<S> and NextState<S> #9742

Merged
merged 3 commits into from
Sep 11, 2023

Conversation

johanhelsing
Copy link
Contributor

Objective

  • Make it possible to snapshot/save states
  • Useful for re-using parts of the state system for rollback safe states
  • Or to save states with scenes/savegames

Solution

  • Conditionally add the derive if the bevy_reflect is enabled

Changelog

  • NextState<S> and State<S> now implement Reflect as long as S does.

@alice-i-cecile alice-i-cecile added this to the 0.12 milestone Sep 10, 2023
@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Usability A simple quality-of-life change that makes Bevy easier to use A-Reflection Runtime information about types labels Sep 10, 2023
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Sep 10, 2023
@alice-i-cecile
Copy link
Member

LGTM. Should we register these types when App::add_state is called too?

@MrGVSV
Copy link
Member

MrGVSV commented Sep 11, 2023

LGTM. Should we register these types when App::add_state is called too?

This would be great, but unfortunately I don't think we can do that without requiring all state types (i.e. S) implement Reflect

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Sep 11, 2023
Merged via the queue into bevyengine:main with commit 4fe2b12 Sep 11, 2023
25 checks passed
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this pull request Jan 9, 2024
# Objective

- Make it possible to snapshot/save states
- Useful for re-using parts of the state system for rollback safe states
- Or to save states with scenes/savegames

## Solution

- Conditionally add the derive if the `bevy_reflect` is enabled

---

## Changelog

- `NextState<S>` and `State<S>` now implement `Reflect` as long as `S`
does.
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 A-Reflection Runtime information about types C-Usability A simple quality-of-life change that makes Bevy easier to use 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