eldiron_shared/
character.rs1use codegridfx::Module;
2use num_traits::zero;
3use rusterix::Map;
4use theframework::prelude::*;
5
6#[derive(Serialize, Deserialize, Clone, Debug)]
8pub struct Character {
9 pub id: Uuid,
10 pub name: String,
11
12 pub map: Map,
14
15 #[serde(default)]
17 pub module: Module,
18
19 pub source: String,
21
22 #[serde(default)]
24 pub source_debug: String,
25
26 #[serde(default)]
28 pub data: String,
29
30 #[serde(default)]
32 pub authoring: String,
33
34 #[serde(default)]
36 pub preview_rigging: String,
37
38 pub position: Vec3<f32>,
40
41 #[serde(default = "default_orientation")]
43 pub orientation: Vec2<f32>,
44
45 pub character_id: Uuid,
47}
48
49impl Default for Character {
50 fn default() -> Self {
51 Self::new()
52 }
53}
54
55impl Character {
56 pub fn new() -> Self {
57 Self {
58 id: Uuid::new_v4(),
59 name: "NewCharacter".to_string(),
60
61 module: Module::as_type(codegridfx::ModuleType::CharacterTemplate),
62
63 map: Map::default(),
64 source: String::new(),
65 source_debug: String::new(),
66 data: String::new(),
67 authoring: String::new(),
68 preview_rigging: String::new(),
69 position: zero(),
70 orientation: default_orientation(),
71
72 character_id: Uuid::new_v4(),
73 }
74 }
75}
76
77fn default_orientation() -> Vec2<f32> {
78 Vec2::new(1.0, 0.0)
79}