Browse Source

split this into individual/individual_mut

pbs
jake 4 years ago
parent
commit
c437c3da5b
  1. 9
      src/ship/items/inventory.rs
  2. 2
      src/ship/items/manager.rs
  3. 2
      src/ship/items/use_tool.rs

9
src/ship/items/inventory.rs

@ -198,7 +198,14 @@ impl InventoryItem {
Ok(()) Ok(())
} }
pub fn individual(&mut self) -> Option<&mut IndividualInventoryItem> {
pub fn individual(&self) -> Option<&IndividualInventoryItem> {
match self {
InventoryItem::Individual(ref individual_inventory_item) => Some(individual_inventory_item),
_ => None
}
}
pub fn individual_mut(&mut self) -> Option<&mut IndividualInventoryItem> {
match self { match self {
InventoryItem::Individual(ref mut individual_inventory_item) => Some(individual_inventory_item), InventoryItem::Individual(ref mut individual_inventory_item) => Some(individual_inventory_item),
_ => None _ => None

2
src/ship/items/manager.rs

@ -611,7 +611,7 @@ impl ItemManager {
let individual_item = mag_handle.item_mut() let individual_item = mag_handle.item_mut()
.ok_or(ItemManagerError::NoSuchItemId(mag_id))? .ok_or(ItemManagerError::NoSuchItemId(mag_id))?
.individual()
.individual_mut()
.ok_or(ItemManagerError::WrongItemType(mag_id))?; .ok_or(ItemManagerError::WrongItemType(mag_id))?;
let mag = individual_item let mag = individual_item
.mag_mut() .mag_mut()

2
src/ship/items/use_tool.rs

@ -52,7 +52,7 @@ async fn mag_cell<EG: EntityGateway>(entity_gateway: &mut EG, used_cell: &Consum
let mag_item = mag_handle.item_mut() let mag_item = mag_handle.item_mut()
.ok_or(UseItemError::InvalidItem)?; .ok_or(UseItemError::InvalidItem)?;
let actual_mag = mag_item let actual_mag = mag_item
.individual()
.individual_mut()
.ok_or(UseItemError::InvalidItem)? .ok_or(UseItemError::InvalidItem)?
.mag_mut() .mag_mut()
.ok_or(UseItemError::InvalidItem)?; .ok_or(UseItemError::InvalidItem)?;

Loading…
Cancel
Save