mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
3fa21b3dc7
Is also able to refactor some of the uglier code and introduces a framework that (suitably extended) could be useful in removing boilerplate elsewhere.
31 lines
747 B
Rust
31 lines
747 B
Rust
use rand::{seq::SliceRandom, thread_rng};
|
|
|
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
pub struct Body {
|
|
pub torso: Torso,
|
|
pub tail: Tail,
|
|
}
|
|
impl Body {
|
|
pub fn random() -> Self {
|
|
let mut rng = thread_rng();
|
|
Self {
|
|
torso: *(&ALL_TORSOS).choose(&mut rng).unwrap(),
|
|
tail: *(&ALL_TAILS).choose(&mut rng).unwrap(),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
#[repr(u32)]
|
|
pub enum Torso {
|
|
Default,
|
|
}
|
|
const ALL_TORSOS: [Torso; 1] = [Torso::Default];
|
|
|
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
#[repr(u32)]
|
|
pub enum Tail {
|
|
Default,
|
|
}
|
|
const ALL_TAILS: [Tail; 1] = [Tail::Default];
|