Skip to main content

dreamwell_engine/physics/
classes.rs

1use serde::{Deserialize, Serialize};
2
3/// Particle class — determines behavior and promotion eligibility.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
5pub enum ParticleClass {
6    VisualOnly,
7    Debris,
8    Hazard,
9    PickupCandidate,
10    PersistentRubble,
11    FluidLike,
12    ParticleMicroAgent,
13    SignalCarrier,
14    ResourceShard,
15    DreamwellSpecial,
16}
17
18/// Replication class — determines network synchronization behavior.
19#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
20pub enum ReplicationClass {
21    None,
22    EventOnly,
23    SeedReconstructable,
24    PromotionOnly,
25    NearbyImportant,
26    FullyReplicated,
27}
28
29/// Simulation precision mode.
30#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
31pub enum SimulationMode {
32    Full,
33    Simplified,
34    VisualApproximation,
35    Frozen,
36    Culled,
37}
38
39impl ParticleClass {
40    pub const ALL: &[ParticleClass] = &[
41        Self::VisualOnly,
42        Self::Debris,
43        Self::Hazard,
44        Self::PickupCandidate,
45        Self::PersistentRubble,
46        Self::FluidLike,
47        Self::ParticleMicroAgent,
48        Self::SignalCarrier,
49        Self::ResourceShard,
50        Self::DreamwellSpecial,
51    ];
52}
53
54impl ReplicationClass {
55    pub const ALL: &[ReplicationClass] = &[
56        Self::None,
57        Self::EventOnly,
58        Self::SeedReconstructable,
59        Self::PromotionOnly,
60        Self::NearbyImportant,
61        Self::FullyReplicated,
62    ];
63}
64
65impl SimulationMode {
66    pub const ALL: &[SimulationMode] = &[
67        Self::Full,
68        Self::Simplified,
69        Self::VisualApproximation,
70        Self::Frozen,
71        Self::Culled,
72    ];
73}
74
75#[cfg(test)]
76mod tests {
77    use super::*;
78
79    #[test]
80    fn particle_class_all() {
81        assert_eq!(ParticleClass::ALL.len(), 10);
82    }
83
84    #[test]
85    fn replication_class_all() {
86        assert_eq!(ReplicationClass::ALL.len(), 6);
87    }
88
89    #[test]
90    fn simulation_mode_all() {
91        assert_eq!(SimulationMode::ALL.len(), 5);
92    }
93
94    #[test]
95    fn serde_roundtrip() {
96        for &pc in ParticleClass::ALL {
97            let json = serde_json::to_string(&pc).unwrap();
98            let restored: ParticleClass = serde_json::from_str(&json).unwrap();
99            assert_eq!(pc, restored);
100        }
101    }
102}