Avoid right-ward shift

This commit is contained in:
timokoesters 2019-08-30 21:54:33 +02:00
parent 7e66fe792d
commit 082ccd7c46
No known key found for this signature in database
GPG Key ID: CD80BE9AAEE78097
2 changed files with 13 additions and 19 deletions

View File

@ -81,7 +81,7 @@ pub enum Debug {
Boost,
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Item {
Tool {
kind: Tool,

View File

@ -713,36 +713,30 @@ impl Server {
_ => {}
},
ClientMsg::ActivateInventorySlot(x) => {
let item_opt = state
let item = state
.ecs()
.write_storage::<comp::Inventory>()
.get_mut(entity)
.and_then(|inv| inv.remove(x));
if let Some(item) = item_opt {
match item {
comp::Item::Tool { .. } | comp::Item::Debug(_) => {
if let Some(stats) = state
.ecs()
.write_storage::<comp::Stats>()
.get_mut(entity)
Some(comp::Item::Tool { .. }) | Some(comp::Item::Debug(_)) => {
if let Some(stats) =
state.ecs().write_storage::<comp::Stats>().get_mut(entity)
{
state
.ecs()
.write_storage::<comp::Inventory>()
.get_mut(entity)
.map(|inv| {
inv.insert(x, stats.equipment.main.take())
});
.map(|inv| inv.insert(x, stats.equipment.main.take()));
stats.equipment.main = Some(item);
stats.equipment.main = item;
}
}
_ => {}
}
state.write_component(entity, comp::InventoryUpdate);
}
}
ClientMsg::SwapInventorySlots(a, b) => {
state
.ecs()