First class save / load support
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
**What problem does this solve or what need does it fill?**
Saving and loading game state is a core functionality that will be reused across almost every game made in Bevy, but implementing this functionality requires advanced Bevy knowledge and there isn't consensus on how you might effectively accomplish it.
**What solution would you like?**
A pair of `Commands` to save and load a game state, probably in combination with some Resources to set global config of this functionality.
@TheRawMeatball whipped up the following prototype:
```rust
struct SaveCommand;
struct LastSaveData(Option)
trait SaveCommandExt {
fn save(&mut self);
}
impl Command for SaveCommand {
fn write(self: Box, world: &mut World, resources: &mut Resources){
let data = /*serialize stuff*/;
resources.get_mut::().unwrap().0 = Some(data);
}
}
impl SaveCommandExt for Commands {
fn save(&mut self) {
self.add_command(SaveCommand)
}
}
```
Usage:
```rust
fn regular_system(commands: &mut Commands) {
commands.save();
}
```
**What alternative(s) have you considered?**
Clearly document an idiomatic way to do this.
**Additional context**
Here's an [example](https://discord.com/channels/691052431525675048/692648082499829760/810224027732934697) of a new user trying to implement this on their own and stumbling.
This issue relates directly to #255.
Contributor guide
Assessment
This issue has not been assessed yet.