Zeenobit / moonshine_save

A save/load framework for Bevy game engine.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Save / Load on Events

data-niklas opened this issue · comments

Hi! Thanks for the awesome crate.

The plugins currently support loading and saving the game state dynamically using run_if and custom resources implementing *FileRequest.

I propose to use Bevy's event system, to send custom load / save events. The load / save plugins could then register event readers and load / save when they receive a new event.

https://bevy-cheatbook.github.io/programming/events.html

E.g.: repurpose *FileRequest to something similar to

pub struct SaveIntoFileRequest(PathBuf);
pub struct LoadFromFileRequest(PathBuf);

App::new()
        .add_event::<SaveIntoFileRequest>()
        .add_event::<LoadFromFileRequest>()
        .add_system(process_save_events)
        .add_system(process_load_events);

That makes sense to me. I'll look into implementing save_into_file_on_event<E> and load_from_file_on_event<E>.

Added in 0.2.2