pub struct Item {
pub id: u32,
pub position: Vec3<f32>,
pub creator_id: Uuid,
pub item_type: String,
pub max_capacity: u32,
pub container: Option<Vec<Item>>,
pub attributes: ValueContainer,
pub dirty_flags: u8,
pub dirty_attributes: FxHashSet<String>,
}Fields§
§id: u32The unique ID of the item
position: Vec3<f32>The position in the map (if not on an entity).
creator_id: UuidMaps the item to a creator ID
item_type: StringThe item’s type or identifier (e.g., “Potion”, “Sword”)
max_capacity: u32Maximum capacity of this container/stack (e.g., max stack size for stackable items)
container: Option<Vec<Item>>Container: Holds nested items if this item can act as a container
attributes: ValueContainerAttributes: Dynamic properties of the item
dirty_flags: u8Dirty flags for static attributes
dirty_attributes: FxHashSet<String>Dirty dynamic attributes
Implementations§
Source§impl Item
impl Item
pub fn new() -> Self
Sourcepub fn get_pos_xz(&self) -> Vec2<f32>
pub fn get_pos_xz(&self) -> Vec2<f32>
Get the XZ position.
Sourcepub fn set_position(&mut self, new_position: Vec3<f32>)
pub fn set_position(&mut self, new_position: Vec3<f32>)
Set the position and mark it as dirty
Sourcepub fn set_max_capacity(&mut self, new_max_capacity: u32)
pub fn set_max_capacity(&mut self, new_max_capacity: u32)
Set the position and mark it as dirty
Sourcepub fn is_container(&self) -> bool
pub fn is_container(&self) -> bool
Check if the item is a container or stackable
Sourcepub fn add_to_container(&mut self, item: Item) -> Result<(), String>
pub fn add_to_container(&mut self, item: Item) -> Result<(), String>
Add an item to the container
Sourcepub fn remove_from_container(&mut self, item_id: u32) -> Result<Item, String>
pub fn remove_from_container(&mut self, item_id: u32) -> Result<Item, String>
Remove an item from the container by ID
Sourcepub fn set_attribute(&mut self, key: &str, value: Value)
pub fn set_attribute(&mut self, key: &str, value: Value)
Set a dynamic attribute and mark it as dirty
Sourcepub fn get_attribute(&self, key: &str) -> Option<&Value>
pub fn get_attribute(&self, key: &str) -> Option<&Value>
Get a dynamic attribute
Sourcepub fn get_attr_string(&self, key: &str) -> Option<String>
pub fn get_attr_string(&self, key: &str) -> Option<String>
Get the given String
Sourcepub fn get_attr_uuid(&self, key: &str) -> Option<Uuid>
pub fn get_attr_uuid(&self, key: &str) -> Option<Uuid>
Get the given Uuid
Sourcepub fn mark_dirty_attribute(&mut self, key: &str)
pub fn mark_dirty_attribute(&mut self, key: &str)
Mark a dynamic attribute as dirty
Sourcepub fn mark_all_dirty(&mut self)
pub fn mark_all_dirty(&mut self)
Mark all fields and attributes as dirty
Sourcepub fn clear_dirty(&mut self)
pub fn clear_dirty(&mut self)
Clear all dirty flags and attributes
Sourcepub fn get_update(&self) -> ItemUpdate
pub fn get_update(&self) -> ItemUpdate
Generate an ItemUpdate containing only dirty fields and attributes
Sourcepub fn apply_update(&mut self, update: ItemUpdate)
pub fn apply_update(&mut self, update: ItemUpdate)
Apply an ItemUpdate to this item
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Item
impl<'de> Deserialize<'de> for Item
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Item
impl RefUnwindSafe for Item
impl Send for Item
impl Sync for Item
impl Unpin for Item
impl UnsafeUnpin for Item
impl UnwindSafe for Item
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<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.