[][src]Struct game_features::ItemDefinition

pub struct ItemDefinition<K, T, D: Default> {
    pub key: K,
    pub item_type: T,
    pub name: String,
    pub friendly_name: String,
    pub description: String,
    pub maximum_stack: usize,
    pub maximum_durability: Option<usize>,
    pub user_data: D,
}

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 on ItemInstances

Fields

key: K

The key identifying this item definition.

item_type: T

The type / item group that this item definition is part of.

name: String

The display name of this item definition.

friendly_name: String

The friendly name of this item definition. Mostly used to find items by name instead of by key.

description: String

The display description of this item definition.

maximum_stack: 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: D

Custom user data. For example: rarity, weight, list of allowed upgrades, etc...

Methods

impl<K, T, D: Default> ItemDefinition<K, T, D>[src]

pub fn new(
    key: K,
    item_type: T,
    name: String,
    friendly_name: String,
    description: String,
    maximum_stack: usize,
    maximum_durability: Option<usize>
) -> Self
[src]

Constructs a new ItemDefinition.

Trait Implementations

impl<K: Clone, T: Clone, D: Clone + Default> Clone for ItemDefinition<K, T, D>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<K: Debug, T: Debug, D: Debug + Default> Debug for ItemDefinition<K, T, D>[src]

impl<K, T, D: Default> Serialize for ItemDefinition<K, T, D> where
    K: Serialize,
    T: Serialize,
    D: Serialize
[src]

impl<'de, K, T, D: Default> Deserialize<'de> for ItemDefinition<K, T, D> where
    K: Deserialize<'de>,
    T: Deserialize<'de>,
    D: Deserialize<'de>, 
[src]

Auto Trait Implementations

impl<K, T, D> Send for ItemDefinition<K, T, D> where
    D: Send,
    K: Send,
    T: Send

impl<K, T, D> Sync for ItemDefinition<K, T, D> where
    D: Sync,
    K: Sync,
    T: Sync

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]