Refactored the animation so I can normalize it to one api. Next is to create the concept of a temporary entity that represents a transitive effect.

This commit is contained in:
Zed A. Shaw 2025-09-11 14:18:52 -04:00
parent 0afaa20c1d
commit 8384b11993
10 changed files with 123 additions and 23 deletions

View file

@ -18,6 +18,7 @@
#include "inventory.hpp"
#include "game_level.hpp"
#include "gui/fsm_events.hpp"
#include "animation.hpp"
using std::string;
using namespace fmt;
@ -232,16 +233,6 @@ void System::death() {
}
}
inline void animate_entity(World &world, Entity entity) {
if(world.has<Animation>(entity)) {
auto& animation = world.get<Animation>(entity);
animation.play();
}
if(auto snd = world.get_if<Sound>(entity)) {
sound::play(snd->attack);
}
}
void System::combat(int attack_id) {
auto& level = GameDB::current_level();
@ -292,7 +283,7 @@ void System::combat(int attack_id) {
if(enemy_action == combat::BattleAction::ATTACK) {
result.enemy_did = enemy.combat.attack(player_combat);
animate_entity(world, enemy.entity);
animation::animate_entity(world, enemy.entity);
}
world.send<Events::GUI>(Events::GUI::COMBAT, enemy.entity, result);