Skip to content

Saving and loading game state #23

@idanarye

Description

@idanarye

The common conception about saving and loading game state in Bevy (or ECS in general) is that you just have to do serialize all the components of all the entities into a file, and when loading just rebuild the scene from that component data. That, however, is very similar to the common conception about editors for Bevy - the very conception that Yoleck is trying to be an alternative to. So I figure Yoleck can offer a similar alternative to. Since Yoleck already has a concise representation of the level, one that does not have to store every single component because it can build them from YoleckEntityTypes and YoleckComponents, it shouldn't be that much more work to save just the changed data.

Advantages over entire-scene save:

  1. Smaller files - has less data so save.
  2. Saves have a much better chance to survive changes to the levels and the game code. Of course, this is not something that can be guaranteed, and I'll need to come up with guidelines to which changes break the saves and which doesn't.
  3. During playtests in the editor, we will be able to save the state, modify the level, and then resume it from the same state.

Yoleck itself is not going to handle the storage medium for the saved files. Doing that will lock users to a specific persistence solution. Instead, when initiating a save Yoleck will send an event with a serde_json::Value that represents the state, and when loading the user will have to provide that serde_json::Value. Note that serde_json::Value is not an actual JSON - it's just an in-memory data type with JSON semantics. It can be stored as a more compact and less human-readable format.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions