assembly_xml/obj/
inv.rs

1//! ## Data for the [`Inventory` component](https://docs.lu-dev.net/en/latest/components/017-inventory.html)
2
3use serde::{Deserialize, Serialize};
4
5/// Data for the [`Inventory` component](https://docs.lu-dev.net/en/latest/components/017-inventory.html)
6#[derive(Default, Debug, PartialEq, Deserialize, Serialize)]
7pub struct Inventory {
8    /// LOT of the item in the consumable slot
9    #[serde(rename = "csl")]
10    pub consumable_slot_lot: i32,
11    /// Inventory 'Bags'
12    pub bag: Bags,
13    /// Groups
14    #[serde(default)]
15    pub grps: Vec<Group>,
16    /// Items
17    pub items: Items,
18}
19
20#[derive(Default, Debug, PartialEq, Deserialize, Serialize)]
21/// A list of bags
22pub struct Bags {
23    #[serde(rename = "b")]
24    /// List of bags
25    children: Vec<Bag>,
26}
27
28/// A storage container
29///
30/// (e.g Items, Models, Vault Items, Behaviors)
31#[derive(Default, Debug, PartialEq, Deserialize, Serialize)]
32pub struct Bag {
33    /// Type of the bag. See `InventoryType` enum for values.
34    #[serde(rename = "t")]
35    pub ty: u32,
36    /// Size of the bag i.e. Amount of slots
37    #[serde(rename = "m")]
38    pub max: u32,
39}
40
41/// One group
42#[derive(Default, Debug, PartialEq, Deserialize, Serialize)]
43pub struct Group {
44    /// `user_group XXX`
45    pub attr_id: String,
46    /// Space-separated LOTs
47    pub attr_l: String,
48    /// Name
49    pub attr_n: String,
50    /// Type of the group
51    pub attr_t: u32,
52    /// Unknown
53    pub attr_u: String,
54}
55
56/// All items
57#[derive(Default, Debug, PartialEq, Deserialize, Serialize)]
58pub struct Items {
59    /// ??
60    #[serde(rename = "nn")]
61    pub attr_nn: Option<String>,
62
63    /// Items in the storage container
64    #[serde(rename = "in")]
65    pub children: Vec<ItemBag>,
66}
67
68/// A list of items for a storage container
69#[derive(Default, Debug, PartialEq, Deserialize, Serialize)]
70pub struct ItemBag {
71    /// Type of the bag. See `InventoryType` enum for values.
72    #[serde(rename = "t")]
73    pub ty: u32,
74    /// Items in the bag
75    #[serde(default, rename = "i")]
76    pub children: Vec<Item>,
77}
78
79/// An item in an inventory
80#[derive(Default, Debug, PartialEq, Deserialize, Serialize)]
81pub struct Item {
82    /// Whether the item is bound
83    #[serde(rename = "b")]
84    pub bound: bool,
85    /// Amount of items for stackable items.
86    #[serde(rename = "c")]
87    pub count: u32,
88    /// Boolean whether the item is equipped.
89    ///
90    /// If it isn’t, this attribute isn’t there at all, if it is, it’s set to 1.
91    #[serde(default, rename = "eq")]
92    pub equipped: bool,
93    /// Object ID
94    #[serde(rename = "id")]
95    pub id: u64,
96    /// LOT
97    #[serde(rename = "l")]
98    pub template: u32,
99    /// Slot
100    #[serde(rename = "s")]
101    pub slot: u32,
102    /// Some kind of ID for models. Investigate. Referred to by client strings as “subkey”?
103    #[serde(rename = "sk")]
104    pub subkey: u64,
105    /// Extra Info
106    #[serde(rename = "x")]
107    pub x: Option<ItemExtra>,
108}
109
110/// Extra item information
111#[derive(Default, Debug, PartialEq, Deserialize, Serialize)]
112#[allow(missing_docs)]
113pub struct ItemExtra {
114    #[serde(rename = "b")]
115    pub attr_b: Option<String>,
116    /// Module Assembly
117    #[serde(rename = "ma")]
118    pub module_assembly: String,
119    #[serde(rename = "ub")]
120    pub attr_ub: Option<String>,
121    #[serde(rename = "ud")]
122    pub attr_ud: Option<String>,
123    #[serde(rename = "ui")]
124    pub attr_ui: Option<String>,
125    #[serde(rename = "um")]
126    pub attr_um: Option<String>,
127    /// UGC name?
128    #[serde(rename = "un")]
129    pub attr_un: Option<String>,
130    #[serde(rename = "uo")]
131    pub attr_uo: Option<String>,
132    #[serde(rename = "up")]
133    pub attr_up: Option<String>,
134}