rust/lib-hwengine-future/src/ai/ammo.rs
branchtransitional_engine
changeset 16053 85d7d6b71087
parent 16049 db18f1a30b0c
equal deleted inserted replaced
16052:6633961698ad 16053:85d7d6b71087
    61     Creeper,
    61     Creeper,
    62     Minigun,
    62     Minigun,
    63     Sentry, // 60
    63     Sentry, // 60
    64     Count,
    64     Count,
    65 }
    65 }
       
    66 
       
    67 impl TryFrom<usize> for AmmoType {
       
    68     type Error = &'static str;
       
    69 
       
    70     fn try_from(value: usize) -> Result<Self, Self::Error> {
       
    71         if value < Self::Count as usize {
       
    72             Ok(unsafe { std::mem::transmute(value) })
       
    73         } else {
       
    74             Err("Invalid ammo type")
       
    75         }
       
    76     }
       
    77 }