Updated code to be more consistent with codebase

This commit is contained in:
Brad 2020-10-25 15:54:08 -04:00
parent 11f747cc5f
commit cfbdbf14aa

View File

@ -66,14 +66,15 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
return;
};
// Grab the stats from the player and check if the player is dead.
let stats = state.ecs().read_storage::<comp::Stats>();
match stats.get(entity){
Some(x) => if x.is_dead {
if let Some(entity_stats) = stats.get(entity){
if entity_stats.is_dead {
debug!("Failed to pick up item as the player is dead");
return;
},
None => debug!("Stats wasn't found"),
return; // If dead, don't continue
}
}else{
debug!("Entity stats component wasn't found")
}
// Attempt to add the item to the player's inventory