Browse Source

item helper methods

pbs
jake 4 years ago
parent
commit
15b4732981
  1. 17
      src/ship/items/inventory.rs

17
src/ship/items/inventory.rs

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

Loading…
Cancel
Save