pub struct ItemDefinition<K, S, D>where
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, S, D> Clone for ItemDefinition<K, S, D>
impl<K, S, D> 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 moreSource§impl<K, S, D> Debug for ItemDefinition<K, S, D>
impl<K, S, D> Debug for ItemDefinition<K, S, D>
Source§impl<'de, K, S, D> Deserialize<'de> for ItemDefinition<K, S, D>
impl<'de, K, S, D> Deserialize<'de> for ItemDefinition<K, S, D>
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ItemDefinition<K, S, D>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ItemDefinition<K, S, D>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl<K, S, D> Serialize for ItemDefinition<K, S, D>
impl<K, S, D> Serialize for ItemDefinition<K, S, D>
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl<K, S, D> Freeze for ItemDefinition<K, S, D>
impl<K, S, D> RefUnwindSafe for ItemDefinition<K, S, D>
impl<K, S, D> Send for ItemDefinition<K, S, D>
impl<K, S, D> Sync for ItemDefinition<K, S, D>
impl<K, S, D> Unpin for ItemDefinition<K, S, D>
impl<K, S, D> UnwindSafe for ItemDefinition<K, S, D>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more