pub struct ItemDefinition<K, S, D: Default> {
pub key: K,
pub slot_type: S,
pub name: String,
pub friendly_name: String,
pub description: String,
pub maximum_stack: Option<usize>,
pub maximum_durability: Option<usize>,
pub user_data: D,
}Expand description
An ItemDefinition stores the different properties of a type of item.
It is a schema that contains the data which isn’t changing between different item instances.
Generic Types:
- K: Type of the key. Usually an enum or a number (ie u32).
- T: Type of the different item types. For example, an armor-type item can not be placed into a
weapon-type inventory slot. If you don’t need to make the distinction between different item
types, use the
()type. - D: The type of the custom user data. If you don’t have any, use the
()type. It can (and probably should) be different than the custom user data used onItemInstances
Fields§
§key: KThe key identifying this item definition.
slot_type: SThe type / item group that this item definition is part of.
name: StringThe display name of this item definition.
friendly_name: StringThe friendly name of this item definition. Mostly used to find items by name instead of by key.
description: StringThe display description of this item definition.
maximum_stack: Option<usize>The maximum number of elements that can be in an item stack. Setting this value to 1 disables the ability to stack this type of item.
maximum_durability: Option<usize>The default maximum durability of this item. Setting this to None means that this item type doesn’t use the concept of durability and is unbreakable.
user_data: DCustom user data. For example: rarity, weight, list of allowed upgrades, etc…
Implementations§
Trait Implementations§
Source§impl<K: Clone, S: Clone, D: Clone + Default> Clone for ItemDefinition<K, S, D>
impl<K: Clone, S: Clone, D: Clone + Default> Clone for ItemDefinition<K, S, D>
Source§fn clone(&self) -> ItemDefinition<K, S, D>
fn clone(&self) -> ItemDefinition<K, S, D>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more