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    /// The initial position.
31    pub position: Vec3<f32>,
32
33    /// The id of the character template.
34    pub item_id: Uuid,
35}
36
37impl Default for Item {
38    fn default() -> Self {
39        Self::new()
40    }
41}
42
43impl Item {
44    pub fn new() -> Self {
45        Self {
46            id: Uuid::new_v4(),
47            name: "NewItem".to_string(),
48
49            module: Module::as_type(codegridfx::ModuleType::ItemTemplate),
50            map: Map::default(),
51            source: String::new(),
52            source_debug: String::new(),
53            data: String::new(),
54            position: zero(),
55
56            item_id: Uuid::new_v4(),
57        }
58    }
59}