static keys - items in inventory will save their assigned key

precursor to cleaning up/modularising inventory display, instead of needing to iterate through every item held to find unique copies, we can just check if the button pressed corresponds to any entity's Key {} index
This commit is contained in:
Llywelwyn 2023-10-05 00:52:34 +01:00
parent a7b4f621fb
commit d11971126c
19 changed files with 445 additions and 122 deletions

View file

@ -30,6 +30,7 @@ use super::{
Viewshed,
WantsToMelee,
WantsToPickupItem,
WantsToAssignKey,
get_dest,
Destination,
DamageType,
@ -640,7 +641,9 @@ fn get_item(ecs: &mut World) -> RunState {
return RunState::AwaitingInput;
}
Some(item) => {
let mut assignkey = ecs.write_storage::<WantsToAssignKey>();
let mut pickup = ecs.write_storage::<WantsToPickupItem>();
assignkey.insert(item, WantsToAssignKey {}).expect("Unable to insert WantsToAssignKey");
pickup
.insert(*player_entity, WantsToPickupItem { collected_by: *player_entity, item })
.expect("Unable to insert want to pickup item.");