Now when you loot an item the loot UI works.

This commit is contained in:
Zed A. Shaw 2025-06-11 23:49:37 -04:00
parent 38159a5f84
commit 86eabed3db
8 changed files with 66 additions and 119 deletions

View file

@ -296,25 +296,13 @@ namespace gui {
sound::stop("ambient");
state(State::NEXT_LEVEL);
break;
case LOOT_OPEN: {
Config items("assets/items.json");
auto& data = items["TORCH_BAD"];
for(int i = 0; $loot_ui.contents.size() < 10; i++) {
auto gui_id = $loot_ui.$gui.entity("item_", i);
if(!$loot_ui.contents.contains(gui_id)) {
auto torch = $level.world->entity();
components::configure_entity(*$level.world, torch, data["components"]);
$loot_ui.contents.try_emplace(gui_id, torch);
}
}
$loot_ui.update();
case LOOT_OPEN:
$loot_ui.active = true;
state(State::LOOTING);
} break;
break;
case INV_SELECT:
state(State::INV_GRAB);
dbc::log("Dropping/grabbing items not yet supported.");
state(State::IDLE);
break;
case MOUSE_CLICK:
mouse_action(false);
@ -580,8 +568,12 @@ namespace gui {
event(Event::INV_SELECT, data);
break;
case eGUI::LOOT: {
$map_ui.log(L"You picked up an item.");
} break;
dbc::check(world.has<components::Sprite>(entity), "inventory doesn't have a sprite");
auto gui_id = $loot_ui.$gui.entity("item_0");
$loot_ui.contents.insert_or_assign(gui_id, entity);
$loot_ui.update();
event(Event::LOOT_OPEN);
} break;
case eGUI::HP_STATUS:
System::player_status($level);
break;