Finally unified all of my events into one place.
This commit is contained in:
parent
6c34fea64a
commit
c618a4828f
30 changed files with 215 additions and 216 deletions
|
|
@ -18,7 +18,7 @@ namespace boss {
|
|||
$ui.init();
|
||||
}
|
||||
|
||||
bool Fight::event(gui::Event ev, std::any data) {
|
||||
bool Fight::event(game::Event ev, std::any data) {
|
||||
// if the mouse event is handled the done, this may be wrong later
|
||||
if(handle_mouse(ev)) return in_state(State::END);
|
||||
|
||||
|
|
@ -35,8 +35,8 @@ namespace boss {
|
|||
return in_state(State::END);
|
||||
}
|
||||
|
||||
void Fight::START(gui::Event ev, std::any) {
|
||||
using enum gui::Event;
|
||||
void Fight::START(game::Event ev, std::any) {
|
||||
using enum game::Event;
|
||||
|
||||
switch(ev) {
|
||||
// this is only if using the debug X key to skip it
|
||||
|
|
@ -53,15 +53,15 @@ namespace boss {
|
|||
}
|
||||
}
|
||||
|
||||
void Fight::PLAYER_REQUESTS(gui::Event ev, std::any data) {
|
||||
using enum gui::Event;
|
||||
void Fight::PLAYER_REQUESTS(game::Event ev, std::any data) {
|
||||
using enum game::Event;
|
||||
|
||||
switch(ev) {
|
||||
// this is only if using the debug X key to skip it
|
||||
case BOSS_START:
|
||||
state(State::END);
|
||||
break;
|
||||
case START_COMBAT:
|
||||
case COMBAT_START:
|
||||
System::plan_battle($battle, $world, $boss_id);
|
||||
$ui.status(L"PLANNING BATTLE");
|
||||
state(State::PLAN_BATTLE);
|
||||
|
|
@ -81,15 +81,15 @@ namespace boss {
|
|||
}
|
||||
}
|
||||
|
||||
void Fight::PLAN_BATTLE(gui::Event ev, std::any data) {
|
||||
using enum gui::Event;
|
||||
void Fight::PLAN_BATTLE(game::Event ev, std::any data) {
|
||||
using enum game::Event;
|
||||
|
||||
switch(ev) {
|
||||
// this is only if using the debug X key to skip it
|
||||
case BOSS_START:
|
||||
state(State::END);
|
||||
break;
|
||||
case START_COMBAT:
|
||||
case COMBAT_START:
|
||||
$ui.status(L"EXEC PLAN");
|
||||
state(State::EXEC_PLAN);
|
||||
break;
|
||||
|
|
@ -114,12 +114,12 @@ namespace boss {
|
|||
}
|
||||
|
||||
void Fight::do_combat(std::any data) {
|
||||
if(data.type() != typeid(Events::Combat)) {
|
||||
if(data.type() != typeid(components::CombatResult)) {
|
||||
std::cout << "!!!!!! INVALID thing do_combat received: {}" << data.type().name() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
auto result = std::any_cast<Events::Combat>(data);
|
||||
auto result = std::any_cast<components::CombatResult>(data);
|
||||
|
||||
if(result.enemy_did > 0) {
|
||||
// make boss move
|
||||
|
|
@ -134,15 +134,15 @@ namespace boss {
|
|||
|
||||
}
|
||||
|
||||
void Fight::EXEC_PLAN(gui::Event ev, std::any data) {
|
||||
using enum gui::Event;
|
||||
void Fight::EXEC_PLAN(game::Event ev, std::any data) {
|
||||
using enum game::Event;
|
||||
|
||||
switch(ev) {
|
||||
// this is only if using the debug X key to skip it
|
||||
case BOSS_START:
|
||||
state(State::END);
|
||||
break;
|
||||
case START_COMBAT:
|
||||
case COMBAT_START:
|
||||
next_combat_dumb_name();
|
||||
break;
|
||||
case COMBAT:
|
||||
|
|
@ -154,7 +154,7 @@ namespace boss {
|
|||
}
|
||||
}
|
||||
|
||||
void Fight::END(gui::Event ev, std::any) {
|
||||
void Fight::END(game::Event ev, std::any) {
|
||||
fmt::println("BOSS_FIGHT:END event {}", (int)ev);
|
||||
}
|
||||
|
||||
|
|
@ -171,8 +171,8 @@ namespace boss {
|
|||
$ui.render(window);
|
||||
}
|
||||
|
||||
bool Fight::handle_mouse(gui::Event ev) {
|
||||
using enum gui::Event;
|
||||
bool Fight::handle_mouse(game::Event ev) {
|
||||
using enum game::Event;
|
||||
|
||||
switch(ev) {
|
||||
case MOUSE_CLICK: {
|
||||
|
|
@ -209,30 +209,31 @@ namespace boss {
|
|||
|
||||
void Fight::handle_world_events() {
|
||||
fmt::println(">>>>>>>>>>>>>>>>> BOSS FIGHT EVENTS");
|
||||
dbc::check($world->has_event<Events::GUI>(), "World doesn't have GUI events.");
|
||||
dbc::check($world->has_event<game::Event>(), "World doesn't have GUI events.");
|
||||
|
||||
while($world->has_event<Events::GUI>()) {
|
||||
auto [evt, entity, data] = $world->recv<Events::GUI>();
|
||||
while($world->has_event<game::Event>()) {
|
||||
auto [evt, entity, data] = $world->recv<game::Event>();
|
||||
fmt::println("boss fight received event", int(evt));
|
||||
|
||||
switch(evt) {
|
||||
case Events::GUI::ATTACK:
|
||||
case game::Event::ATTACK:
|
||||
fmt::println("sending attack");
|
||||
event(gui::Event::ATTACK, data);
|
||||
event(game::Event::ATTACK, data);
|
||||
break;
|
||||
case Events::GUI::COMBAT_START:
|
||||
case game::Event::COMBAT_START:
|
||||
fmt::println("sending combat start {}", data.type().name());
|
||||
event(gui::Event::START_COMBAT, data);
|
||||
event(game::Event::COMBAT_START, data);
|
||||
break;
|
||||
case Events::GUI::COMBAT:
|
||||
case game::Event::COMBAT:
|
||||
fmt::println("sending combat {}", data.type().name());
|
||||
event(gui::Event::COMBAT, data);
|
||||
event(game::Event::COMBAT, data);
|
||||
break;
|
||||
default:
|
||||
fmt::println("GUI EVENT: {} entity={}", int(evt), entity);
|
||||
}
|
||||
}
|
||||
dbc::check(!$world->has_event<Events::GUI>(), "World still has events!");
|
||||
|
||||
dbc::check(!$world->has_event<game::Event>(), "World still has events!");
|
||||
fmt::println("<<<<<<<<<<<<<<<< BOSS FIGHT EVENTS");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue