raycaster/boss/fight.cpp

55 lines
1.2 KiB
C++

#include "boss/fight.hpp"
namespace boss {
Fight::Fight(shared_ptr<World> world, Entity boss_id) :
$world(world),
$boss_id(boss_id),
$ui(world, boss_id)
{
$ui.init();
}
bool Fight::event(gui::Event ev, std::any data) {
switch($state) {
FSM_STATE(State, START, ev, data);
FSM_STATE(State, END, ev, data);
}
return in_state(State::END);
}
void Fight::START(gui::Event ev, std::any data) {
using enum gui::Event;
switch(ev) {
// this is only if using the debug X key to skip it
case BOSS_START:
state(State::END);
break;
case MOUSE_CLICK: {
$ui.mouse(mouse_pos.x, mouse_pos.y, guecs::NO_MODS);
if($ui.boss_dead()) {
state(State::END);
}
} break;
case ATTACK: {
int attack_id = std::any_cast<int>(data);
$ui.attack(attack_id);
} break;
case MOUSE_MOVE: {
$ui.mouse(mouse_pos.x, mouse_pos.y, {1 << guecs::ModBit::hover});
} break;
case TICK:
$ui.run_systems();
break;
default:
fmt::println("BOSS_FIGHT unknown event {}", (int)ev);
}
}
void Fight::END(gui::Event ev, std::any data) {
(void)ev;
(void)data;
}
}