rust/lib-hwengine-future/src/ai/ammo.rs
author unC0Rr
Fri, 10 Jan 2025 17:37:34 +0100
changeset 16055 2d65bd46c92f
parent 16053 85d7d6b71087
permissions -rw-r--r--
Start work on hedgehog tracer

#[repr(usize)]
pub enum AmmoType {
    Nothing,
    Grenade,
    ClusterBomb,
    Bazooka,
    Bee,
    Shotgun,
    PickHammer, // 6
    Skip,
    Rope,
    Mine,
    DEagle,
    Dynamite,
    FirePunch,
    Whip, // 13
    BaseballBat,
    Parachute,
    AirAttack,
    MineStrike,
    BlowTorch, // 18
    Girder,
    Teleport,
    Switch,
    Mortar,
    Kamikaze,
    Cake, // 24
    Seduction,
    Watermelon,
    HellishBomb,
    Napalm,
    Drill,
    Ballgun, // 30
    RCPlane,
    LowGravity,
    ExtraDamage,
    Invulnerable,
    ExtraTime, // 35
    LaserSight,
    Vampiric,
    SniperRifle,
    Jetpack,
    Molotov,
    Birdy,
    PortalGun, // 42
    Piano,
    GasBomb,
    SineGun,
    Flamethrower,
    SMine,
    Hammer, // 48
    Resurrector,
    DrillStrike,
    Snowball,
    Tardis,
    LandGun, // 53
    IceGun,
    Knife,
    Rubber,
    AirMine,
    Creeper,
    Minigun,
    Sentry, // 60
    Count,
}

impl TryFrom<usize> for AmmoType {
    type Error = &'static str;

    fn try_from(value: usize) -> Result<Self, Self::Error> {
        if value < Self::Count as usize {
            Ok(unsafe { std::mem::transmute(value) })
        } else {
            Err("Invalid ammo type")
        }
    }
}