pub struct Inventory { /* private fields */ }Implementations§
Source§impl Inventory
impl Inventory
pub fn new(capacity: usize, max_weight: f32) -> Self
pub fn add_item(&mut self, item: Item) -> bool
pub fn remove_item(&mut self, slot_idx: usize) -> Option<Item>
pub fn remove_count(&mut self, slot_idx: usize, count: u32) -> u32
pub fn get(&self, slot_idx: usize) -> Option<&ItemStack>
pub fn get_mut(&mut self, slot_idx: usize) -> Option<&mut ItemStack>
pub fn find_item_by_id(&self, id: u64) -> Option<usize>
pub fn find_items_by_category(&self, cat: ItemCategory) -> Vec<usize>
pub fn used_slots(&self) -> usize
pub fn free_slots(&self) -> usize
pub fn is_full(&self) -> bool
pub fn total_value(&self) -> u64
pub fn add_gold(&mut self, amount: u64)
pub fn remove_gold(&mut self, amount: u64) -> bool
pub fn gold(&self) -> u64
pub fn weight(&self) -> f32
pub fn max_weight(&self) -> f32
pub fn capacity(&self) -> usize
Sourcepub fn transfer(&mut self, slot_idx: usize, target: &mut Inventory) -> bool
pub fn transfer(&mut self, slot_idx: usize, target: &mut Inventory) -> bool
Transfer item from this inventory to another.
pub fn iter(&self) -> impl Iterator<Item = (usize, &ItemStack)>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Inventory
impl RefUnwindSafe for Inventory
impl Send for Inventory
impl Sync for Inventory
impl Unpin for Inventory
impl UnsafeUnpin for Inventory
impl UnwindSafe for Inventory
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
Mutably borrows from an owned value. Read more
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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.