Have a separate container vs. item loot for the different situations where you're pick items out of a container vs. an item on the ground.

master
Zed A. Shaw 6 days ago
parent 7db64b73c5
commit af933c827a
  1. 4
      assets/devices.json
  2. 22
      events.hpp
  3. 15
      gui/fsm.cpp
  4. 6
      systems.cpp

@ -57,7 +57,7 @@
"foreground": [150, 100, 189],
"background": [150, 100, 189]
},
{"_type": "Device", "config": {}, "events": ["LOOT_OPEN"]},
{"_type": "Device", "config": {}, "events": ["LOOT_CONTAINER"]},
{"_type": "Sprite", "name": "barrel_small", "width": 256, "height": 256, "scale": 1.0},
{"_type": "Sound", "attack": "pickup", "death": "blank"}
],
@ -73,7 +73,7 @@
"foreground": [32, 123, 164],
"background": [24, 205, 189]
},
{"_type": "Device", "config": {}, "events": ["LOOT_OPEN"]},
{"_type": "Device", "config": {}, "events": ["LOOT_CONTAINER"]},
{"_type": "Sprite", "name": "grave_stone", "width": 256, "height": 256, "scale": 1.0},
{"_type": "Sound", "attack": "pickup", "death": "blank"}
]

@ -2,10 +2,11 @@
namespace Events {
enum GUI {
START, COMBAT, LOOT, DEATH, STAIRS_UP, STAIRS_DOWN, TRAP,
START, COMBAT, DEATH, STAIRS_UP, STAIRS_DOWN, TRAP,
COMBAT_START, NO_NEIGHBORS, HP_STATUS,
ATTACK, BLOCK, EVADE, NEW_RITUAL,
UPDATE_SPRITE, ENEMY_SPAWN, NOOP,
LOOT_ITEM, LOOT_CONTAINER,
LOOT_CLOSE, LOOT_SELECT, INV_SELECT, AIM_CLICK
};
@ -32,14 +33,15 @@ namespace gui {
STOP_COMBAT = 12,
STAIRS_DOWN = 13,
LOOT_OPEN=14,
LOOT_SELECT=15,
INV_SELECT=16,
QUIT = 17,
MOUSE_CLICK=18,
MOUSE_MOVE=19,
MOUSE_DRAG=20,
MOUSE_DRAG_START=21,
MOUSE_DROP=22,
KEY_PRESS=23
LOOT_ITEM=15,
LOOT_SELECT=16,
INV_SELECT=17,
QUIT = 18,
MOUSE_CLICK=19,
MOUSE_MOVE=20,
MOUSE_DRAG=21,
MOUSE_DRAG_START=22,
MOUSE_DROP=23,
KEY_PRESS=24
};
}

@ -575,14 +575,19 @@ namespace gui {
dbc::log("there's no thing there!");
}
break;
case eGUI::LOOT: {
if(world.has<components::InventoryItem>(entity)) {
case eGUI::LOOT_ITEM: {
dbc::check(world.has<components::InventoryItem>(entity),
"INVALID LOOT_ITEM, that entity has no InventoryItem");
auto gui_id = $loot_ui.$gui.entity("item_0");
$loot_ui.contents.insert_or_assign(gui_id, entity);
$loot_ui.update();
} else {
dbc::log("unhandled loot event.");
}
event(Event::LOOT_OPEN);
} break;
case eGUI::LOOT_CONTAINER: {
dbc::check(world.has<components::InventoryItem>(entity),
"INVALID LOOT_ITEM, that entity has no InventoryItem");
dbc::log("everything is empty for now");
event(Event::LOOT_OPEN);
} break;
case eGUI::HP_STATUS:

@ -335,7 +335,7 @@ void System::pickup(GameLevel &level, DinkyECS::Entity entity) {
// 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, entity, item);
world.send<Events::GUI>(Events::GUI::LOOT_ITEM, entity, item);
}
} else if(world.has<Device>(entity)) {
System::device(world, player.entity, entity);
@ -354,8 +354,8 @@ void System::device(DinkyECS::World &world, DinkyECS::Entity actor, DinkyECS::En
world.send<Events::GUI>(Events::GUI::STAIRS_UP, actor, device);
} else if(event == "TRAP") {
world.send<Events::GUI>(Events::GUI::TRAP, actor, device);
} else if(event == "LOOT_OPEN") {
world.send<Events::GUI>(Events::GUI::LOOT, actor, device);
} else if(event == "LOOT_CONTAINER") {
world.send<Events::GUI>(Events::GUI::LOOT_CONTAINER, actor, device);
} else {
dbc::log(fmt::format(
"INVALID EVENT {} for device {}",

Loading…
Cancel
Save