Add event handling to systems
This commit is contained in:
parent
c32a452f17
commit
948a929040
5 changed files with 30 additions and 23 deletions
|
|
@ -56,6 +56,18 @@ impl EngineTrait for Engine {
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_event(&mut self, platform_context: PlatformContext) {
|
||||
let mut ctx = SystemContext {
|
||||
scene: self.scene_manager.current_mut(),
|
||||
platform_context,
|
||||
debug_ui_buffer: self.debug_ui_buffer.clone(),
|
||||
};
|
||||
|
||||
for system in self.system_manager.systems.values_mut() {
|
||||
system.handle_event(&mut ctx);
|
||||
}
|
||||
}
|
||||
|
||||
// pub fn build_system_context(&mut self) -> SystemContext {
|
||||
// SystemContext {
|
||||
// scene: self.scene_manager.current_mut(),
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ pub trait System {
|
|||
fn initialize(&mut self) {}
|
||||
/// Spawn the first entities of the world.
|
||||
fn load_world(&mut self, _ctx: &mut SystemContext) {}
|
||||
/// Handle events sent from the platform.
|
||||
fn handle_event(&mut self, _ctx: &mut SystemContext) {}
|
||||
fn update(&mut self, _ctx: &mut SystemContext) {}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue