use crate::{comp, state}; use serde_derive::{Deserialize, Serialize}; use std::marker::PhantomData; // Automatically derive From 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 for EcsCompPacket // for each variant EcsCompPacket::T(T.) sphynx::sum_type! { #[derive(Clone, Debug, Serialize, Deserialize)] pub enum EcsCompPacket { Pos(comp::phys::Pos), Vel(comp::phys::Vel), Ori(comp::phys::Ori), Actor(comp::Actor), Player(comp::Player), Stats(comp::Stats), Attacking(comp::Attacking), Rolling(comp::Rolling), } } // Automatically derive From for EcsCompPhantom // for each variant EcsCompPhantom::T(PhantomData). sphynx::sum_type! { #[derive(Clone, Debug, Serialize, Deserialize)] pub enum EcsCompPhantom { Pos(PhantomData), Vel(PhantomData), Ori(PhantomData), Actor(PhantomData), Player(PhantomData), Stats(PhantomData), Attacking(PhantomData), Rolling(PhantomData), } } impl sphynx::CompPacket for EcsCompPacket { type Phantom = EcsCompPhantom; }