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.
This commit is contained in:
parent
7db64b73c5
commit
af933c827a
4 changed files with 30 additions and 23 deletions
|
@ -57,7 +57,7 @@
|
||||||
"foreground": [150, 100, 189],
|
"foreground": [150, 100, 189],
|
||||||
"background": [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": "Sprite", "name": "barrel_small", "width": 256, "height": 256, "scale": 1.0},
|
||||||
{"_type": "Sound", "attack": "pickup", "death": "blank"}
|
{"_type": "Sound", "attack": "pickup", "death": "blank"}
|
||||||
],
|
],
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
"foreground": [32, 123, 164],
|
"foreground": [32, 123, 164],
|
||||||
"background": [24, 205, 189]
|
"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": "Sprite", "name": "grave_stone", "width": 256, "height": 256, "scale": 1.0},
|
||||||
{"_type": "Sound", "attack": "pickup", "death": "blank"}
|
{"_type": "Sound", "attack": "pickup", "death": "blank"}
|
||||||
]
|
]
|
||||||
|
|
22
events.hpp
22
events.hpp
|
@ -2,10 +2,11 @@
|
||||||
|
|
||||||
namespace Events {
|
namespace Events {
|
||||||
enum GUI {
|
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,
|
COMBAT_START, NO_NEIGHBORS, HP_STATUS,
|
||||||
ATTACK, BLOCK, EVADE, NEW_RITUAL,
|
ATTACK, BLOCK, EVADE, NEW_RITUAL,
|
||||||
UPDATE_SPRITE, ENEMY_SPAWN, NOOP,
|
UPDATE_SPRITE, ENEMY_SPAWN, NOOP,
|
||||||
|
LOOT_ITEM, LOOT_CONTAINER,
|
||||||
LOOT_CLOSE, LOOT_SELECT, INV_SELECT, AIM_CLICK
|
LOOT_CLOSE, LOOT_SELECT, INV_SELECT, AIM_CLICK
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,14 +33,15 @@ namespace gui {
|
||||||
STOP_COMBAT = 12,
|
STOP_COMBAT = 12,
|
||||||
STAIRS_DOWN = 13,
|
STAIRS_DOWN = 13,
|
||||||
LOOT_OPEN=14,
|
LOOT_OPEN=14,
|
||||||
LOOT_SELECT=15,
|
LOOT_ITEM=15,
|
||||||
INV_SELECT=16,
|
LOOT_SELECT=16,
|
||||||
QUIT = 17,
|
INV_SELECT=17,
|
||||||
MOUSE_CLICK=18,
|
QUIT = 18,
|
||||||
MOUSE_MOVE=19,
|
MOUSE_CLICK=19,
|
||||||
MOUSE_DRAG=20,
|
MOUSE_MOVE=20,
|
||||||
MOUSE_DRAG_START=21,
|
MOUSE_DRAG=21,
|
||||||
MOUSE_DROP=22,
|
MOUSE_DRAG_START=22,
|
||||||
KEY_PRESS=23
|
MOUSE_DROP=23,
|
||||||
|
KEY_PRESS=24
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
21
gui/fsm.cpp
21
gui/fsm.cpp
|
@ -575,14 +575,19 @@ namespace gui {
|
||||||
dbc::log("there's no thing there!");
|
dbc::log("there's no thing there!");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case eGUI::LOOT: {
|
case eGUI::LOOT_ITEM: {
|
||||||
if(world.has<components::InventoryItem>(entity)) {
|
dbc::check(world.has<components::InventoryItem>(entity),
|
||||||
auto gui_id = $loot_ui.$gui.entity("item_0");
|
"INVALID LOOT_ITEM, that entity has no InventoryItem");
|
||||||
$loot_ui.contents.insert_or_assign(gui_id, entity);
|
auto gui_id = $loot_ui.$gui.entity("item_0");
|
||||||
$loot_ui.update();
|
$loot_ui.contents.insert_or_assign(gui_id, entity);
|
||||||
} else {
|
$loot_ui.update();
|
||||||
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);
|
event(Event::LOOT_OPEN);
|
||||||
} break;
|
} break;
|
||||||
case eGUI::HP_STATUS:
|
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
|
// 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
|
// GUI figures out which it is, then when you click either pick it up
|
||||||
// and move it or show the loot container UI
|
// 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)) {
|
} else if(world.has<Device>(entity)) {
|
||||||
System::device(world, player.entity, 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);
|
world.send<Events::GUI>(Events::GUI::STAIRS_UP, actor, device);
|
||||||
} else if(event == "TRAP") {
|
} else if(event == "TRAP") {
|
||||||
world.send<Events::GUI>(Events::GUI::TRAP, actor, device);
|
world.send<Events::GUI>(Events::GUI::TRAP, actor, device);
|
||||||
} else if(event == "LOOT_OPEN") {
|
} else if(event == "LOOT_CONTAINER") {
|
||||||
world.send<Events::GUI>(Events::GUI::LOOT, actor, device);
|
world.send<Events::GUI>(Events::GUI::LOOT_CONTAINER, actor, device);
|
||||||
} else {
|
} else {
|
||||||
dbc::log(fmt::format(
|
dbc::log(fmt::format(
|
||||||
"INVALID EVENT {} for device {}",
|
"INVALID EVENT {} for device {}",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue