dreamwell-engine 1.0.0

Dreamwell pure-logic engine library — transforms, hierarchy, canon pipeline, spatial math, hashing, tile rules, validation, waymark schema, material/lighting descriptors. No SpacetimeDB dependency.
Documentation
use serde::{Deserialize, Serialize};

/// Behavior block — steering/simulation behavior applied to particles.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum BehaviorBlock {
    Seek,
    Flee,
    Orbit,
    AlignToVelocity,
    AlignToSurfaceNormal,
    Drift,
    Wobble,
    Settle,
    Hover,
    Tether,
    Fuse,
    Split,
    ParticleLite,
}

impl BehaviorBlock {
    pub const ALL: &[BehaviorBlock] = &[
        Self::Seek,
        Self::Flee,
        Self::Orbit,
        Self::AlignToVelocity,
        Self::AlignToSurfaceNormal,
        Self::Drift,
        Self::Wobble,
        Self::Settle,
        Self::Hover,
        Self::Tether,
        Self::Fuse,
        Self::Split,
        Self::ParticleLite,
    ];

    pub fn name(&self) -> &'static str {
        match self {
            Self::Seek => "Seek",
            Self::Flee => "Flee",
            Self::Orbit => "Orbit",
            Self::AlignToVelocity => "Align to Velocity",
            Self::AlignToSurfaceNormal => "Align to Surface Normal",
            Self::Drift => "Drift",
            Self::Wobble => "Wobble",
            Self::Settle => "Settle",
            Self::Hover => "Hover",
            Self::Tether => "Tether",
            Self::Fuse => "Fuse",
            Self::Split => "Split",
            Self::ParticleLite => "Particle Lite",
        }
    }

    /// GPU compute weight (relative cost, 1.0 = baseline).
    pub fn compute_weight(&self) -> f32 {
        match self {
            Self::Seek | Self::Flee | Self::Drift => 1.0,
            Self::Orbit | Self::Hover | Self::Wobble => 1.2,
            Self::AlignToVelocity | Self::AlignToSurfaceNormal => 1.5,
            Self::Settle | Self::Tether => 1.0,
            Self::Fuse | Self::Split => 2.0,
            Self::ParticleLite => 3.0,
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn behavior_block_all() {
        assert_eq!(BehaviorBlock::ALL.len(), 13);
    }

    #[test]
    fn behavior_serde_roundtrip() {
        for &b in BehaviorBlock::ALL {
            let json = serde_json::to_string(&b).unwrap();
            let restored: BehaviorBlock = serde_json::from_str(&json).unwrap();
            assert_eq!(b, restored);
        }
    }
}