Best practices for snapshot+restore? #1322
Replies: 2 comments
-
I know this is an old question so you've likely already solved your problem, but I recently implemented save and load for my app and it induced quite a bit of a rewrite for me. I used moonshine_save for saving files, but tweaked it a bit so that it saves to .bincode instead of .ron. You do have to be extra careful with making sure that each Not sure how to fix this, but the annotations, type registrations, and various impls end up being scattered around your code base. I'm not 100% on this, but if something is off and not fully implemented, you may not get a type error or even a panic!() during app load. You may get the wrong stuff loading so have to be extra careful. The biggest time sink was implementing a series of systems to have "Aesthetic" entities that follow along the "Save/Load" entities. You can't, and you likely don't want to, save the meshes etc. in your save file. So in my app I have a few systems that monitor the "Save/Load" entities and update the "Aesthetic" entities when needed. For undo/redo, I saved the Having said all that I'm quite happy with it now, as I have save/load and also snapshotting which allows me to undo/redo. Putting this out here, hopefully it helps somebody else. Not sure which way the engine is going in this department but I need these features now so am happy to report that something can certainly be pieced together. |
Beta Was this translation helpful? Give feedback.
-
Generic time machine. Undo/redo. Lots of different options, what works for bevy though? I'm working on chess, to start with, and I've wanted to attach a move list to each piece. It seems like with the ECS I could just do |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there! 👋
I have a use case that looks roughly like this:
So I need to serialize or otherwise snapshot either the entire world, or some subset of it, so that I can restore it later.
I started out looking at
DynamicScene::from_world
, but it tries to serialize internal things in the rendering pipeline that aren't actually serializable. Even if that approach could be made to work, that made me realize that I probably don't actually want to snapshot literally everything in the World, anyway.So, I'm now thinking of an approach that looks something like this:
When entering "play" mode:
When exiting "play" mode:
Does that sound reasonable? Is there a more structured de facto standard way of doing this sort of thing in Bevy already? Am I missing some way that I should be using scenes or something to help me with this -- e.g. somehow spawning all of my entities that I want to persist under a single parent, and then using that to serialize a subset of the world?
Beta Was this translation helpful? Give feedback.
All reactions