diff --git a/src/ship/items/inventory.rs b/src/ship/items/inventory.rs index b0cd347..044b6e2 100644 --- a/src/ship/items/inventory.rs +++ b/src/ship/items/inventory.rs @@ -3,6 +3,7 @@ use thiserror::Error; use libpso::character::character;//::InventoryItem; use crate::entity::item::{ItemEntityId, ItemDetail, ItemType}; use crate::entity::item::tool::Tool; +use crate::entity::item::mag::Mag; use crate::ship::items::{ClientItemId, BankItem, BankItemHandle}; use crate::ship::items::floor::{IndividualFloorItem, StackedFloorItem}; @@ -20,6 +21,15 @@ pub struct IndividualInventoryItem { pub equipped: bool, } +impl IndividualInventoryItem { + pub fn mag(&mut self) -> Option<&mut Mag> { + match self.item { + ItemDetail::Mag(ref mut mag) => Some(mag), + _ => None + } + } +} + #[derive(Debug, Clone)] pub struct StackedInventoryItem { pub entity_ids: Vec, @@ -178,6 +188,13 @@ impl InventoryItem { } Ok(()) } + + pub fn individual(&mut self) -> Option<&mut IndividualInventoryItem> { + match self { + InventoryItem::Individual(ref mut individual_inventory_item) => Some(individual_inventory_item), + _ => None + } + } }