|
|
|
@ -104,31 +104,30 @@ void GUI::handle_world_events() { |
|
|
|
|
auto player = $world.get_the<Player>(); |
|
|
|
|
|
|
|
|
|
while($world.has_event<eGUI>()) { |
|
|
|
|
auto [evt, entity] = $world.recv<eGUI>(); |
|
|
|
|
auto [evt, entity, data] = $world.recv<eGUI>(); |
|
|
|
|
|
|
|
|
|
switch(evt) { |
|
|
|
|
case eGUI::HIT: { |
|
|
|
|
auto combat = $world.get<Combat>(entity); |
|
|
|
|
case eGUI::COMBAT: { |
|
|
|
|
auto &damage = std::any_cast<Events::Combat&>(data); |
|
|
|
|
auto enemy_combat = $world.get<Combat>(entity); |
|
|
|
|
|
|
|
|
|
if(entity == player.entity) { |
|
|
|
|
$log.log(format("Enemy HIT YOU, you have {} HP!", combat.hp)); |
|
|
|
|
if(damage.enemy_did > 0) { |
|
|
|
|
$log.log(format("Enemy HIT YOU for {} damage!", damage.enemy_did)); |
|
|
|
|
$log.log(format("-- Enemy has {} HP left.", enemy_combat.hp)); |
|
|
|
|
$sounds.play("hit"); |
|
|
|
|
} else { |
|
|
|
|
$log.log(format("You HIT enemy, they have {} HP!", combat.hp)); |
|
|
|
|
$log.log("Enemy MISSED YOU."); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(damage.player_did > 0) { |
|
|
|
|
$log.log(format("You HIT enemy for {} damage!", damage.player_did)); |
|
|
|
|
$sounds.play("hit"); |
|
|
|
|
} else { |
|
|
|
|
$log.log("You MISSED the enemy."); |
|
|
|
|
} |
|
|
|
|
} break; |
|
|
|
|
case eGUI::MISS: |
|
|
|
|
if(entity == player.entity) { |
|
|
|
|
$log.log("You MISSED the enemy."); |
|
|
|
|
} else { |
|
|
|
|
$log.log("Enemy MISSED YOU."); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case eGUI::DEAD: |
|
|
|
|
$log.log("--- ENEMY DEAD!"); |
|
|
|
|
break; |
|
|
|
|
case eGUI::LOOT: { |
|
|
|
|
auto loot = $world.get<Loot>(entity); |
|
|
|
|
auto &loot = std::any_cast<Loot&>(data); |
|
|
|
|
auto inventory = $world.get<Inventory>(player.entity); |
|
|
|
|
$log.log(format("You found {} gold. You have {} now.", |
|
|
|
|
loot.amount, inventory.gold)); |
|
|
|
@ -182,7 +181,7 @@ void GUI::run_systems() { |
|
|
|
|
auto player = $world.get_the<Player>(); |
|
|
|
|
System::enemy_pathing($world, $game_map, player); |
|
|
|
|
System::motion($world, $game_map); |
|
|
|
|
System::combat($world, player); |
|
|
|
|
System::collision($world, player); |
|
|
|
|
System::death($world); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|