You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Trac3r-rust/src/event_system.rs

59 lines
1.6 KiB

use std::sync::Arc;
use specs::{Component, Entities, Join, System, VecStorage, Write, WriteStorage};
use vulkano::swapchain::Surface;
use winit::window::Window;
use crate::PersistentState;
use crate::render_system::Position;
use crate::util::tr_event::{TrEvent, TrEventExtension, TrWindowEvent};
use crate::vkprocessor::VkProcessor;
use winit::event::ElementState;
#[derive(Debug, Clone)]
pub struct Evented {
pub subscribed: fn(event: TrEvent<TrEventExtension>) -> bool,
}
impl Component for Evented {
type Storage = VecStorage<Self>;
}
pub struct EventSystem;
impl<'a> System<'a> for EventSystem {
type SystemData = (
Entities<'a>,
WriteStorage<'a, Evented>,
Write<'a, PersistentState>,
Write<'a, VkProcessor>,
Write<'a, Vec<TrEvent<TrEventExtension>>>
);
fn run(&mut self, (
entity,
mut evented_list,
mut state,
mut vk_processor,
event_stack
): Self::SystemData) {
for (evented) in (&evented_list).join() {
for event in &*event_stack {
match event {
TrEvent::WindowEvent { window_id, event } => {
match event {
TrWindowEvent::MouseInput { device_id, state, button, modifiers } => {
if *state == ElementState::Pressed {
}
},
_ => {}
}
}
_ => {}
}
}
}
for (entity, evented) in (&*entity, &mut evented_list).join() {}
}
}