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-06-14 15:27:05 +00:00
|
|
|
Pos(comp::Pos),
|
|
|
|
Vel(comp::Vel),
|
|
|
|
Ori(comp::Ori),
|
2019-06-30 11:48:28 +00:00
|
|
|
Body(comp::Body),
|
2019-04-10 17:23:27 +00:00
|
|
|
Player(comp::Player),
|
2019-07-02 18:52:44 +00:00
|
|
|
CanBuild(comp::CanBuild),
|
2019-05-13 13:58:01 +00:00
|
|
|
Stats(comp::Stats),
|
2019-07-21 16:50:13 +00:00
|
|
|
LightEmitter(comp::LightEmitter),
|
2019-07-26 21:01:41 +00:00
|
|
|
Item(comp::Item),
|
2019-08-02 18:56:37 +00:00
|
|
|
Scale(comp::Scale),
|
2019-09-09 19:11:40 +00:00
|
|
|
MountState(comp::MountState),
|
|
|
|
Mounting(comp::Mounting),
|
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-06-14 15:27:05 +00:00
|
|
|
Pos(PhantomData<comp::Pos>),
|
|
|
|
Vel(PhantomData<comp::Vel>),
|
|
|
|
Ori(PhantomData<comp::Ori>),
|
2019-06-30 11:48:28 +00:00
|
|
|
Body(PhantomData<comp::Body>),
|
2019-04-10 17:23:27 +00:00
|
|
|
Player(PhantomData<comp::Player>),
|
2019-07-02 18:52:44 +00:00
|
|
|
CanBuild(PhantomData<comp::CanBuild>),
|
2019-05-13 13:58:01 +00:00
|
|
|
Stats(PhantomData<comp::Stats>),
|
2019-07-21 16:50:13 +00:00
|
|
|
LightEmitter(PhantomData<comp::LightEmitter>),
|
2019-07-26 21:01:41 +00:00
|
|
|
Item(PhantomData<comp::Item>),
|
2019-08-02 18:56:37 +00:00
|
|
|
Scale(PhantomData<comp::Scale>),
|
2019-09-09 19:11:40 +00:00
|
|
|
MountState(PhantomData<comp::MountState>),
|
|
|
|
Mounting(PhantomData<comp::Mounting>),
|
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
|
|
|
}
|