veloren/common/src/comp/body/object.rs

19 lines
413 B
Rust
Raw Normal View History

2019-07-21 12:42:45 +00:00
use rand::{seq::SliceRandom, thread_rng};
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Body {
Bomb,
Scarecrow,
Chest,
Pumpkin,
}
impl Body {
pub fn random() -> Self {
let mut rng = thread_rng();
*(&ALL_OBJECTS).choose(&mut rng).unwrap()
}
}
const ALL_OBJECTS: [Body; 4] = [Body::Bomb, Body::Scarecrow, Body::Chest, Body::Pumpkin];