A little bit nicer but ultimately the way the system talks to the GUI needs a redesign to be more 'coarse grain'
This commit is contained in:
parent
0a268591c2
commit
011fee4872
4 changed files with 37 additions and 31 deletions
16
gui.cpp
16
gui.cpp
|
@ -97,12 +97,13 @@ void GUI::create_renderer() {
|
|||
}
|
||||
|
||||
void GUI::handle_world_events() {
|
||||
using eGUI = Events::GUI;
|
||||
auto player = $world.get_the<Player>();
|
||||
|
||||
while($world.has_event<Events::GUI>()) {
|
||||
auto [evt, entity] = $world.recv<Events::GUI>();
|
||||
while($world.has_event<eGUI>()) {
|
||||
auto [evt, entity] = $world.recv<eGUI>();
|
||||
switch(evt) {
|
||||
case Events::GUI::HIT: {
|
||||
case eGUI::HIT: {
|
||||
auto combat = $world.get<Combat>(entity);
|
||||
|
||||
if(entity == player.entity) {
|
||||
|
@ -113,16 +114,21 @@ void GUI::handle_world_events() {
|
|||
$sounds.play("hit");
|
||||
}
|
||||
} break;
|
||||
case Events::GUI::MISS:
|
||||
case eGUI::MISS:
|
||||
if(entity == player.entity) {
|
||||
$log.log("You MISSED the enemy.");
|
||||
} else {
|
||||
$log.log("Enemy MISSED YOU.");
|
||||
}
|
||||
break;
|
||||
case Events::GUI::DEAD:
|
||||
case eGUI::DEAD:
|
||||
$log.log("--- ENEMY DEAD!");
|
||||
break;
|
||||
case eGUI::LOOT: {
|
||||
auto loot = $world.get<Loot>(entity);
|
||||
$log.log(format("You found {} gold.", loot.amount));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$log.log(format("INVALID EVENT! {},{}", evt, entity));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue