|
|
|
@ -320,10 +320,7 @@ void System::pickup(GameLevel &level) { |
|
|
|
|
auto &collision = *level.collision; |
|
|
|
|
auto pos = player_position(level); |
|
|
|
|
|
|
|
|
|
if(!collision.something_there(pos.aiming_at)) { |
|
|
|
|
dbc::log("nothing there"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if(!collision.something_there(pos.aiming_at)) return; |
|
|
|
|
|
|
|
|
|
auto entity = level.collision->find(pos.aiming_at, [&](auto data) -> bool { |
|
|
|
|
return (world.has<InventoryItem>(data.entity) || |
|
|
|
@ -336,7 +333,7 @@ void System::pickup(GameLevel &level) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// use spatial find to find an item with inventory...
|
|
|
|
|
if(auto item = world.get_if<InventoryItem>(entity)) { |
|
|
|
|
if(world.has<InventoryItem>(entity)) { |
|
|
|
|
// NOTE: this might need to be a separate system so that people can leave stuff alone
|
|
|
|
|
remove_from_world(level, entity); |
|
|
|
|
|
|
|
|
@ -352,7 +349,7 @@ void System::pickup(GameLevel &level) { |
|
|
|
|
// NOTE: chests are different from say a torch, maybe 2 events or the
|
|
|
|
|
// GUI figures out which it is, then when you click either pick it up
|
|
|
|
|
// and move it or show the loot container UI
|
|
|
|
|
world.send<Events::GUI>(Events::GUI::LOOT_ITEM, entity, *item); |
|
|
|
|
world.send<Events::GUI>(Events::GUI::LOOT_ITEM, entity, entity); |
|
|
|
|
} |
|
|
|
|
} else if(world.has<Device>(entity)) { |
|
|
|
|
System::device(world, level.player, entity); |
|
|
|
@ -591,13 +588,15 @@ void System::render_map(Matrix& tiles, EntityGrid& entity_map, sf::RenderTexture |
|
|
|
|
render.display(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool System::use_item(GameLevel& level, Entity what) { |
|
|
|
|
bool System::use_item(GameLevel& level, const string& slot_name) { |
|
|
|
|
auto& world = *level.world; |
|
|
|
|
auto& inventory = world.get<inventory::Model>(level.player); |
|
|
|
|
auto& player_combat = world.get<Combat>(level.player); |
|
|
|
|
|
|
|
|
|
if(player_combat.hp >= player_combat.max_hp) return false; |
|
|
|
|
|
|
|
|
|
auto what = inventory.get(slot_name); |
|
|
|
|
|
|
|
|
|
if(auto curative = world.get_if<Curative>(what)) { |
|
|
|
|
inventory.remove(what); |
|
|
|
|
|
|
|
|
|