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 preview_rigging: String,
33
34 pub position: Vec3<f32>,
36
37 #[serde(default = "default_orientation")]
39 pub orientation: Vec2<f32>,
40
41 pub character_id: Uuid,
43}
44
45impl Default for Character {
46 fn default() -> Self {
47 Self::new()
48 }
49}
50
51impl Character {
52 pub fn new() -> Self {
53 Self {
54 id: Uuid::new_v4(),
55 name: "NewCharacter".to_string(),
56
57 module: Module::as_type(codegridfx::ModuleType::CharacterTemplate),
58
59 map: Map::default(),
60 source: String::new(),
61 source_debug: String::new(),
62 data: String::new(),
63 preview_rigging: String::new(),
64 position: zero(),
65 orientation: default_orientation(),
66
67 character_id: Uuid::new_v4(),
68 }
69 }
70}
71
72fn default_orientation() -> Vec2<f32> {
73 Vec2::new(1.0, 0.0)
74}