2019-07-29 19:54:48 +00:00
|
|
|
use specs::{Component, FlaggedStorage};
|
|
|
|
use specs_idvs::IDVStorage;
|
2019-09-09 19:11:40 +00:00
|
|
|
use sphynx::Uid;
|
2019-07-29 19:54:58 +00:00
|
|
|
use vek::*;
|
2019-06-09 14:20:20 +00:00
|
|
|
|
2019-09-09 19:11:40 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
|
|
|
pub enum ControlEvent {
|
|
|
|
Mount(Uid),
|
|
|
|
Unmount,
|
|
|
|
}
|
|
|
|
|
2019-06-09 14:20:20 +00:00
|
|
|
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
|
|
|
pub struct Controller {
|
2019-08-30 22:13:45 +00:00
|
|
|
pub primary: bool,
|
|
|
|
pub secondary: bool,
|
2019-06-09 14:20:20 +00:00
|
|
|
pub move_dir: Vec2<f32>,
|
2019-08-24 17:58:28 +00:00
|
|
|
pub look_dir: Vec3<f32>,
|
2019-09-09 19:11:40 +00:00
|
|
|
pub sit: bool,
|
2019-06-09 14:20:20 +00:00
|
|
|
pub jump: bool,
|
2019-06-11 04:08:55 +00:00
|
|
|
pub roll: bool,
|
|
|
|
pub glide: bool,
|
2019-09-09 19:11:40 +00:00
|
|
|
pub climb: bool,
|
|
|
|
pub climb_down: bool,
|
|
|
|
pub wall_leap: bool,
|
2019-06-09 14:20:20 +00:00
|
|
|
pub respawn: bool,
|
2019-09-09 19:11:40 +00:00
|
|
|
pub events: Vec<ControlEvent>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Controller {
|
|
|
|
pub fn reset(&mut self) {
|
|
|
|
*self = Self::default();
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn clear_events(&mut self) {
|
|
|
|
self.events.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn push_event(&mut self, event: ControlEvent) {
|
|
|
|
self.events.push(event);
|
|
|
|
}
|
2019-06-09 14:20:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Component for Controller {
|
2019-07-29 19:54:48 +00:00
|
|
|
type Storage = FlaggedStorage<Self, IDVStorage<Self>>;
|
2019-06-09 14:20:20 +00:00
|
|
|
}
|
2019-09-09 19:11:40 +00:00
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
|
|
|
pub enum MountState {
|
|
|
|
Unmounted,
|
|
|
|
MountedBy(Uid),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Component for MountState {
|
|
|
|
type Storage = FlaggedStorage<Self, IDVStorage<Self>>;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
|
|
|
pub struct Mounting(pub Uid);
|
|
|
|
|
|
|
|
impl Component for Mounting {
|
|
|
|
type Storage = FlaggedStorage<Self, IDVStorage<Self>>;
|
|
|
|
}
|