|
|
@@ -8,13 +8,13 @@ use crate::{ |
|
|
|
Error, |
|
|
|
}; |
|
|
|
|
|
|
|
pub struct StateUpdate { |
|
|
|
pub struct InputStateUpdate { |
|
|
|
mouse_event_id: ReaderId<MouseEvent>, |
|
|
|
window_events_id: ReaderId<WindowEvent>, |
|
|
|
keyboard_events_id: ReaderId<KeyboardEvent>, |
|
|
|
} |
|
|
|
|
|
|
|
impl StateUpdate { |
|
|
|
impl InputStateUpdate { |
|
|
|
pub fn new(world: &mut World) -> Result<Self, Error> { |
|
|
|
let mouse_event_id = world.register_event_reader::<MouseEvent>()?; |
|
|
|
let window_events_id = world.register_event_reader::<WindowEvent>()?; |
|
|
@@ -29,18 +29,18 @@ impl StateUpdate { |
|
|
|
} |
|
|
|
|
|
|
|
#[derive(SystemData)] |
|
|
|
pub struct StateUpdateData<'a> { |
|
|
|
pub struct InputStateUpdateData<'a> { |
|
|
|
input_state: Write<'a, InputState>, |
|
|
|
mouse_events: ReadExpect<'a, EventChannel<MouseEvent>>, |
|
|
|
window_events: ReadExpect<'a, EventChannel<WindowEvent>>, |
|
|
|
keyboard_events: ReadExpect<'a, EventChannel<KeyboardEvent>>, |
|
|
|
} |
|
|
|
|
|
|
|
impl<'a> System<'a> for StateUpdate { |
|
|
|
type SystemData = StateUpdateData<'a>; |
|
|
|
impl<'a> System<'a> for InputStateUpdate { |
|
|
|
type SystemData = InputStateUpdateData<'a>; |
|
|
|
|
|
|
|
fn run(&mut self, data: Self::SystemData) { |
|
|
|
let StateUpdateData { |
|
|
|
let InputStateUpdateData { |
|
|
|
mut input_state, |
|
|
|
mouse_events, |
|
|
|
window_events, |