Skip to main content

eldiron_shared/
item.rs

1use codegridfx::Module;
2use num_traits::zero;
3use rusterix::Map;
4use theframework::prelude::*;
5
6/// An item instance.
7#[derive(Serialize, Deserialize, Clone, Debug)]
8pub struct Item {
9    pub id: Uuid,
10    pub name: String,
11
12    /// The item map model.
13    pub map: Map,
14
15    /// The module source
16    #[serde(default)]
17    pub module: Module,
18
19    /// The instance initialization or template code.
20    pub source: String,
21
22    /// The instance initialization or template debug code.
23    #[serde(default)]
24    pub source_debug: String,
25
26    /// The attributes toml data.
27    #[serde(default)]
28    pub data: String,
29
30    /// Authoring metadata used for look/description style presentation.
31    #[serde(default)]
32    pub authoring: String,
33
34    /// The initial position.
35    pub position: Vec3<f32>,
36
37    /// The id of the character template.
38    pub item_id: Uuid,
39}
40
41impl Default for Item {
42    fn default() -> Self {
43        Self::new()
44    }
45}
46
47impl Item {
48    pub fn new() -> Self {
49        Self {
50            id: Uuid::new_v4(),
51            name: "NewItem".to_string(),
52
53            module: Module::as_type(codegridfx::ModuleType::ItemTemplate),
54            map: Map::default(),
55            source: String::new(),
56            source_debug: String::new(),
57            data: String::new(),
58            authoring: String::new(),
59            position: zero(),
60
61            item_id: Uuid::new_v4(),
62        }
63    }
64}