veloren/common/src/msg/ecs_packet.rs

64 lines
2.0 KiB
Rust
Raw Normal View History

use crate::{comp, state};
use serde_derive::{Deserialize, Serialize};
use std::marker::PhantomData;
// Automatically derive From<T> for EcsResPacket
// for each variant EcsResPacket::T(T).
sphynx::sum_type! {
#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum EcsResPacket {
Time(state::Time),
TimeOfDay(state::TimeOfDay),
}
}
impl sphynx::ResPacket for EcsResPacket {}
// Automatically derive From<T> for EcsCompPacket
// for each variant EcsCompPacket::T(T.)
sphynx::sum_type! {
#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum EcsCompPacket {
Pos(comp::Pos),
Vel(comp::Vel),
Ori(comp::Ori),
2019-06-30 11:48:28 +00:00
Body(comp::Body),
Player(comp::Player),
CanBuild(comp::CanBuild),
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),
Scale(comp::Scale),
MountState(comp::MountState),
Mounting(comp::Mounting),
2019-09-25 20:22:39 +00:00
Mass(comp::Mass),
2019-09-28 18:31:35 +00:00
Projectile(comp::Projectile),
Gravity(comp::Gravity),
Sticky(comp::Sticky),
}
}
// Automatically derive From<T> for EcsCompPhantom
// for each variant EcsCompPhantom::T(PhantomData<T>).
sphynx::sum_type! {
#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum EcsCompPhantom {
Pos(PhantomData<comp::Pos>),
Vel(PhantomData<comp::Vel>),
Ori(PhantomData<comp::Ori>),
2019-06-30 11:48:28 +00:00
Body(PhantomData<comp::Body>),
Player(PhantomData<comp::Player>),
CanBuild(PhantomData<comp::CanBuild>),
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>),
Scale(PhantomData<comp::Scale>),
MountState(PhantomData<comp::MountState>),
Mounting(PhantomData<comp::Mounting>),
2019-09-25 20:22:39 +00:00
Mass(PhantomData<comp::Mass>),
2019-09-28 18:31:35 +00:00
Projectile(PhantomData<comp::Projectile>),
Gravity(PhantomData<comp::Gravity>),
Sticky(PhantomData<comp::Sticky>),
}
}
impl sphynx::CompPacket for EcsCompPacket {
type Phantom = EcsCompPhantom;
}