use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ParticleClass {
VisualOnly,
Debris,
Hazard,
PickupCandidate,
PersistentRubble,
FluidLike,
ParticleMicroAgent,
SignalCarrier,
ResourceShard,
DreamwellSpecial,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ReplicationClass {
None,
EventOnly,
SeedReconstructable,
PromotionOnly,
NearbyImportant,
FullyReplicated,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum SimulationMode {
Full,
Simplified,
VisualApproximation,
Frozen,
Culled,
}
impl ParticleClass {
pub const ALL: &[ParticleClass] = &[
Self::VisualOnly,
Self::Debris,
Self::Hazard,
Self::PickupCandidate,
Self::PersistentRubble,
Self::FluidLike,
Self::ParticleMicroAgent,
Self::SignalCarrier,
Self::ResourceShard,
Self::DreamwellSpecial,
];
}
impl ReplicationClass {
pub const ALL: &[ReplicationClass] = &[
Self::None,
Self::EventOnly,
Self::SeedReconstructable,
Self::PromotionOnly,
Self::NearbyImportant,
Self::FullyReplicated,
];
}
impl SimulationMode {
pub const ALL: &[SimulationMode] = &[
Self::Full,
Self::Simplified,
Self::VisualApproximation,
Self::Frozen,
Self::Culled,
];
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn particle_class_all() {
assert_eq!(ParticleClass::ALL.len(), 10);
}
#[test]
fn replication_class_all() {
assert_eq!(ReplicationClass::ALL.len(), 6);
}
#[test]
fn simulation_mode_all() {
assert_eq!(SimulationMode::ALL.len(), 5);
}
#[test]
fn serde_roundtrip() {
for &pc in ParticleClass::ALL {
let json = serde_json::to_string(&pc).unwrap();
let restored: ParticleClass = serde_json::from_str(&json).unwrap();
assert_eq!(pc, restored);
}
}
}