Save / Load on Events
data-niklas opened this issue · 2 comments
data-niklas commented
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);
Zeenobit commented
That makes sense to me. I'll look into implementing save_into_file_on_event<E>
and load_from_file_on_event<E>
.