Add event handler methods to the engine structure
This commit is contained in:
parent
c32a452f17
commit
9905ffd26b
5 changed files with 29 additions and 25 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,7 @@ pub trait System {
|
|||
fn initialize(&mut self) {}
|
||||
/// Spawn the first entities of the world.
|
||||
fn load_world(&mut self, _ctx: &mut SystemContext) {}
|
||||
fn handle_event(&mut self, _ctx: &mut SystemContext) {}
|
||||
fn update(&mut self, _ctx: &mut SystemContext) {}
|
||||
}
|
||||
|
||||
|
|
@ -40,4 +41,4 @@ impl SystemManager {
|
|||
pub fn remove<S: 'static>(&mut self) {
|
||||
self.systems.shift_remove(&TypeId::of::<S>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue