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
30
systems.cpp
30
systems.cpp
|
|
@ -17,7 +17,7 @@
|
|||
#include "shaders.hpp"
|
||||
#include "inventory.hpp"
|
||||
#include "game_level.hpp"
|
||||
#include "gui/fsm_events.hpp"
|
||||
#include "events.hpp"
|
||||
#include "animation.hpp"
|
||||
|
||||
using std::string;
|
||||
|
|
@ -180,7 +180,7 @@ void System::distribute_loot(Position target_pos) {
|
|||
}
|
||||
|
||||
set_position(world, *level.collision, loot_entity, target_pos);
|
||||
level.world->send<Events::GUI>(Events::GUI::ENTITY_SPAWN, loot_entity, {});
|
||||
level.world->send<game::Event>(game::Event::ENTITY_SPAWN, loot_entity, {});
|
||||
}
|
||||
|
||||
void System::death() {
|
||||
|
|
@ -198,7 +198,7 @@ void System::death() {
|
|||
dead_things.push_back(ent);
|
||||
}
|
||||
// we need to send this event for everything that dies
|
||||
world.send<Events::GUI>(Events::GUI::DEATH, ent, {});
|
||||
world.send<game::Event>(game::Event::DEATH, ent, {});
|
||||
} else if(float(combat.hp) / float(combat.max_hp) < 0.5f) {
|
||||
// if enemies are below 50% health they are marked with bad health
|
||||
if(world.has<ai::EntityAI>(ent)) {
|
||||
|
|
@ -262,7 +262,7 @@ void System::combat(int attack_id) {
|
|||
while(auto act = battle.next()) {
|
||||
auto [enemy, enemy_action, cost, host_state] = *act;
|
||||
|
||||
Events::Combat result {
|
||||
components::CombatResult result {
|
||||
player_combat.attack(*enemy.combat), 0
|
||||
};
|
||||
|
||||
|
|
@ -275,7 +275,7 @@ void System::combat(int attack_id) {
|
|||
animation::animate_entity(world, enemy.entity);
|
||||
}
|
||||
|
||||
world.send<Events::GUI>(Events::GUI::COMBAT, enemy.entity, result);
|
||||
world.send<game::Event>(game::Event::COMBAT, enemy.entity, result);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -296,7 +296,7 @@ void System::collision() {
|
|||
auto combat = world.get<Combat>(entity);
|
||||
if(!combat.dead) {
|
||||
combat_count++;
|
||||
world.send<Events::GUI>(Events::GUI::COMBAT_START, entity, entity);
|
||||
world.send<game::Event>(game::Event::COMBAT_START, entity, entity);
|
||||
}
|
||||
} else {
|
||||
dbc::log(fmt::format("UNKNOWN COLLISION TYPE {}", entity));
|
||||
|
|
@ -305,7 +305,7 @@ void System::collision() {
|
|||
|
||||
if(combat_count == 0) {
|
||||
// BUG: this is probably how we get stuck in combat
|
||||
world.send<Events::GUI>(Events::GUI::NO_NEIGHBORS, level.player, level.player);
|
||||
world.send<game::Event>(game::Event::NO_NEIGHBORS, level.player, level.player);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -357,7 +357,7 @@ void System::pickup() {
|
|||
// 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
|
||||
// and move it or show the loot container UI
|
||||
world.send<Events::GUI>(Events::GUI::LOOT_ITEM, entity, entity);
|
||||
world.send<game::Event>(game::Event::LOOT_ITEM, entity, entity);
|
||||
}
|
||||
} else if(world.has<Device>(entity)) {
|
||||
System::device(world, level.player, entity);
|
||||
|
|
@ -372,13 +372,13 @@ void System::device(World &world, Entity actor, Entity item) {
|
|||
|
||||
for(auto event : device.events) {
|
||||
if(event == "STAIRS_DOWN") {
|
||||
world.send<Events::GUI>(Events::GUI::STAIRS_DOWN, actor, device);
|
||||
world.send<game::Event>(game::Event::STAIRS_DOWN, actor, device);
|
||||
} else if(event == "STAIRS_UP") {
|
||||
world.send<Events::GUI>(Events::GUI::STAIRS_UP, actor, device);
|
||||
world.send<game::Event>(game::Event::STAIRS_UP, actor, device);
|
||||
} else if(event == "TRAP") {
|
||||
world.send<Events::GUI>(Events::GUI::TRAP, actor, device);
|
||||
world.send<game::Event>(game::Event::TRAP, actor, device);
|
||||
} else if(event == "LOOT_CONTAINER") {
|
||||
world.send<Events::GUI>(Events::GUI::LOOT_CONTAINER, actor, device);
|
||||
world.send<game::Event>(game::Event::LOOT_CONTAINER, actor, device);
|
||||
} else {
|
||||
dbc::log(fmt::format(
|
||||
"INVALID EVENT {} for device {}",
|
||||
|
|
@ -457,7 +457,7 @@ void System::drop_item(Entity item) {
|
|||
set_position(world, *level.collision, item, drop_spot);
|
||||
|
||||
level.world->not_constant(item);
|
||||
level.world->send<Events::GUI>(Events::GUI::ENTITY_SPAWN, item, {});
|
||||
level.world->send<game::Event>(game::Event::ENTITY_SPAWN, item, {});
|
||||
}
|
||||
|
||||
// NOTE: I think pickup and this need to be different
|
||||
|
|
@ -628,7 +628,7 @@ bool System::use_item(const string& slot_name) {
|
|||
}
|
||||
}
|
||||
|
||||
gui::Event System::shortest_rotate(Point player_at, Point aiming_at, Point target) {
|
||||
game::Event System::shortest_rotate(Point player_at, Point aiming_at, Point target) {
|
||||
dbc::check(aiming_at != target, "you're already pointing there.");
|
||||
dbc::check(player_at != target, "you can't turn on yourself");
|
||||
|
||||
|
|
@ -643,7 +643,7 @@ gui::Event System::shortest_rotate(Point player_at, Point aiming_at, Point targe
|
|||
float diff = target_angle - aiming_angle;
|
||||
double normalized = fmod(diff + 360.0, 360.0);
|
||||
|
||||
return normalized < 180.0 ? gui::Event::ROTATE_LEFT : gui::Event::ROTATE_RIGHT;
|
||||
return normalized < 180.0 ? game::Event::ROTATE_LEFT : game::Event::ROTATE_RIGHT;
|
||||
}
|
||||
|
||||
void System::clear_attack() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue