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

Automatic resource tracking #42

Open
wainwrightmark opened this issue Jul 14, 2023 · 3 comments
Open

Automatic resource tracking #42

wainwrightmark opened this issue Jul 14, 2023 · 3 comments

Comments

@wainwrightmark
Copy link

Hi.
Thanks for making this plugin - it's unbelievably useful.

For my game I've built quite an ergonomic wrapper around it and I think might be worth adding something like it to this crate.
Basically, you call app.init_tracked_resource<T>() for some Resource, and then that resource gets initialized with the value in the PkvStore and every time the resource changes, the store updates. You never need to use the PkvStore directly.

Happy to contribute code / examples / documentation if this is considered worth adding.

@JeanMertz
Copy link

@wainwrightmark any chance of sharing (part of) your implementation here for others to use, even if it isn't upstreamed into bevy_pkv?

@johanhelsing
Copy link
Owner

Yes sounds very useful. Happy to accept a pr if the implementation is clean. Sorry i forgot to respond to this

@wainwrightmark
Copy link
Author

Hi. I'm afraid I don't have a ton of time this week to write a PR but I might be able to soon.

If you want to use the code, I believe its all in these two files:

https://github.com/wainwrightmark/nice_bevy_utils/blob/main/src/lib.rs
https://github.com/wainwrightmark/nice_bevy_utils/blob/main/src/tracked_resource.rs

Just looking at it now, it might also be worth adding:

  • A way to control which schedule the changes are tracked in (currently PostUpdate)
  • A way to handle store errors more gracefully
  • A derive macro for TrackableResource

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants