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

45 lines
991 B
Rust
Raw Normal View History

use crate::{make_case_elim, make_proj_elim};
2019-10-24 23:42:33 +00:00
use rand::{seq::SliceRandom, thread_rng};
use serde::{Deserialize, Serialize};
2019-10-24 23:42:33 +00:00
make_proj_elim!(
body,
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Body {
pub torso: Torso,
pub tail: Tail,
}
);
2019-10-24 23:42:33 +00:00
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(),
}
}
}
make_case_elim!(
torso,
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[repr(u32)]
pub enum Torso {
Default = 0,
}
);
2019-10-24 23:42:33 +00:00
const ALL_TORSOS: [Torso; 1] = [Torso::Default];
make_case_elim!(
tail,
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[repr(u32)]
pub enum Tail {
Default = 0,
}
);
const ALL_TAILS: [Tail; 1] = [Tail::Default];