2019-05-16 23:05:46 +00:00
|
|
|
use crate::{comp, state};
|
2019-04-29 20:37:19 +00:00
|
|
|
use serde_derive::{Deserialize, Serialize};
|
|
|
|
use std::marker::PhantomData;
|
2019-04-10 17:23:27 +00:00
|
|
|
|
2019-05-17 09:22:32 +00:00
|
|
|
// Automatically derive From<T> for EcsResPacket
|
|
|
|
// for each variant EcsResPacket::T(T).
|
2019-04-10 17:23:27 +00:00
|
|
|
sphynx::sum_type! {
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
2019-05-16 23:05:46 +00:00
|
|
|
pub enum EcsResPacket {
|
|
|
|
Time(state::Time),
|
|
|
|
TimeOfDay(state::TimeOfDay),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl sphynx::ResPacket for EcsResPacket {}
|
2019-05-17 09:22:32 +00:00
|
|
|
// Automatically derive From<T> for EcsCompPacket
|
|
|
|
// for each variant EcsCompPacket::T(T.)
|
2019-05-16 23:05:46 +00:00
|
|
|
sphynx::sum_type! {
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
|
|
pub enum EcsCompPacket {
|
2019-04-10 17:23:27 +00:00
|
|
|
Pos(comp::phys::Pos),
|
|
|
|
Vel(comp::phys::Vel),
|
2019-05-31 18:45:16 +00:00
|
|
|
Ori(comp::phys::Ori),
|
2019-05-12 21:21:18 +00:00
|
|
|
Actor(comp::Actor),
|
2019-04-10 17:23:27 +00:00
|
|
|
Player(comp::Player),
|
2019-05-13 13:58:01 +00:00
|
|
|
Stats(comp::Stats),
|
2019-05-25 21:13:38 +00:00
|
|
|
Attacking(comp::Attacking),
|
2019-04-10 17:23:27 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-17 09:22:32 +00:00
|
|
|
// Automatically derive From<T> for EcsCompPhantom
|
|
|
|
// for each variant EcsCompPhantom::T(PhantomData<T>).
|
2019-04-10 17:23:27 +00:00
|
|
|
sphynx::sum_type! {
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
2019-05-16 23:05:46 +00:00
|
|
|
pub enum EcsCompPhantom {
|
2019-04-10 17:23:27 +00:00
|
|
|
Pos(PhantomData<comp::phys::Pos>),
|
|
|
|
Vel(PhantomData<comp::phys::Vel>),
|
2019-05-31 18:45:16 +00:00
|
|
|
Ori(PhantomData<comp::phys::Ori>),
|
2019-05-12 21:21:18 +00:00
|
|
|
Actor(PhantomData<comp::Actor>),
|
2019-04-10 17:23:27 +00:00
|
|
|
Player(PhantomData<comp::Player>),
|
2019-05-13 13:58:01 +00:00
|
|
|
Stats(PhantomData<comp::Stats>),
|
2019-05-25 21:13:38 +00:00
|
|
|
Attacking(PhantomData<comp::Attacking>),
|
2019-04-10 17:23:27 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-16 23:05:46 +00:00
|
|
|
impl sphynx::CompPacket for EcsCompPacket {
|
|
|
|
type Phantom = EcsCompPhantom;
|
2019-04-10 17:23:27 +00:00
|
|
|
}
|