|
@ -14,6 +14,7 @@ use crate::entity::item::mag::Mag; |
|
|
use crate::entity::item::{Meseta, NewItemEntity};
|
|
|
use crate::entity::item::{Meseta, NewItemEntity};
|
|
|
use crate::ship::map::MapArea;
|
|
|
use crate::ship::map::MapArea;
|
|
|
use crate::ship::drops::{ItemDrop, ItemDropType};
|
|
|
use crate::ship::drops::{ItemDrop, ItemDropType};
|
|
|
|
|
|
use crate::ship::ship::ShipError;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
#[derive(Debug)]
|
|
@ -182,8 +183,7 @@ impl ActiveItemDatabase { |
|
|
ActiveInventory(activated.take(30).collect())
|
|
|
ActiveInventory(activated.take(30).collect())
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
// TODO: Result
|
|
|
|
|
|
pub fn activate_item_drop<EG: EntityGateway>(&mut self, entity_gateway: &mut EG, item_drop: ItemDrop) -> ActiveItemOnFloor {
|
|
|
|
|
|
|
|
|
pub fn activate_item_drop<EG: EntityGateway>(&mut self, entity_gateway: &mut EG, item_drop: ItemDrop) -> Result<ActiveItemOnFloor, ShipError> {
|
|
|
let item_detail = match item_drop.item {
|
|
|
let item_detail = match item_drop.item {
|
|
|
ItemDropType::Weapon(w) => Some(ItemDetail::Weapon(w)),
|
|
|
ItemDropType::Weapon(w) => Some(ItemDetail::Weapon(w)),
|
|
|
ItemDropType::Armor(w) => Some(ItemDetail::Armor(w)),
|
|
|
ItemDropType::Armor(w) => Some(ItemDetail::Armor(w)),
|
|
@ -205,7 +205,7 @@ impl ActiveItemDatabase { |
|
|
z: item_drop.z,
|
|
|
z: item_drop.z,
|
|
|
}
|
|
|
}
|
|
|
}).unwrap();
|
|
|
}).unwrap();
|
|
|
stack_items(vec![item_entity]).pop().unwrap()
|
|
|
|
|
|
|
|
|
stack_items(vec![item_entity]).pop().ok_or(ShipError::ItemError)?
|
|
|
},
|
|
|
},
|
|
|
None => {
|
|
|
None => {
|
|
|
let meseta = match item_drop.item {
|
|
|
let meseta = match item_drop.item {
|
|
@ -217,13 +217,13 @@ impl ActiveItemDatabase { |
|
|
};
|
|
|
};
|
|
|
let active_item = self.activate_item(item_instance);
|
|
|
let active_item = self.activate_item(item_instance);
|
|
|
|
|
|
|
|
|
ActiveItemOnFloor {
|
|
|
|
|
|
|
|
|
Ok(ActiveItemOnFloor {
|
|
|
map_area: item_drop.map_area,
|
|
|
map_area: item_drop.map_area,
|
|
|
x: item_drop.x,
|
|
|
x: item_drop.x,
|
|
|
y: item_drop.y,
|
|
|
y: item_drop.y,
|
|
|
z: item_drop.z,
|
|
|
z: item_drop.z,
|
|
|
item: active_item,
|
|
|
item: active_item,
|
|
|
}
|
|
|
|
|
|
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|