Refactor before working on animations sending events.

This commit is contained in:
Zed A. Shaw 2026-01-06 23:50:03 -05:00
parent 8b1f288fce
commit 63260f01b9
7 changed files with 10 additions and 42 deletions

View file

@ -89,7 +89,7 @@ namespace boss {
break;
case COMBAT_START:
$ui.status(L"X TURN", L"STEP");
next_combat_dumb_name();
next_combat();
break;
case COMBAT:
do_combat(data);
@ -99,7 +99,11 @@ namespace boss {
}
}
void Fight::next_combat_dumb_name() {
void Fight::END(game::Event ev, std::any) {
fmt::println("BOSS_FIGHT:END event {}", (int)ev);
}
void Fight::next_combat() {
if(auto action = $battle.next()) {
System::combat(*action, $world, $boss_id, 0);
} else if(player_dead()) {
@ -143,10 +147,6 @@ namespace boss {
}
void Fight::END(game::Event ev, std::any) {
fmt::println("BOSS_FIGHT:END event {}", (int)ev);
}
void Fight::run_systems() {
$ui.update_stats();
$battle.set($host, "tough_personality", false);
@ -155,7 +155,6 @@ namespace boss {
}
void Fight::render(sf::RenderWindow& window) {
$ui.play_animations();
$ui.render();
}

View file

@ -51,7 +51,7 @@ namespace boss {
void init_fight();
void do_combat(std::any data);
void next_combat_dumb_name();
void next_combat();
sf::Vector2f mouse_position();
bool handle_keyboard_mouse();
};

View file

@ -87,7 +87,7 @@ namespace boss {
}
void System::plan_battle(BattleEngine& battle, std::shared_ptr<DinkyECS::World> world, DinkyECS::Entity boss_id) {
// REFACTOR: make this loop the list of entities in the battle then
// BUG: make this loop the list of entities in the battle then
// use their world state to configure the plan
battle.plan();
}

View file

@ -78,7 +78,9 @@ namespace boss {
$actions.render(*$window);
$combat_ui.render(*$window);
$arena.play_animations();
$arena.render($view_texture);
$view_texture.display();
$window->draw($view_sprite);
}
@ -102,10 +104,6 @@ namespace boss {
$arena.animate_actor(actor);
}
void UI::play_animations() {
$arena.play_animations();
}
void UI::damage(const string& actor, const std::string& target, int amount) {
if(amount > 0) {
$arena.attach_text(target, fmt::format("{}", amount));

View file

@ -37,7 +37,6 @@ namespace boss {
void move_actor(const std::string& actor, const std::string& cell_name);
void animate_actor(const std::string& actor);
void update_stats();
void play_animations();
void damage(const std::string& actor, const std::string& target, int amount);
void reset_camera();
};

View file

@ -101,10 +101,6 @@ namespace scene {
}
for(auto& actor : $actors) {
if(actor.effect != nullptr) {
dbc::log(fmt::format("ACTOR {} SHADER {}", actor.name, (void*)actor.effect.get()));
}
view.draw(*actor.st.sprite, actor.effect.get());
if(actor.anim.playing) view.draw(actor.text);
}
@ -172,29 +168,6 @@ namespace scene {
$camera.play();
}
std::pair<Element&, Element&> Engine::left_right(const std::string &actor, const std::string &target) {
auto& first = actor_config(actor);
auto& second = actor_config(target);
if(first.pos.x < second.pos.x) {
// first is left
return {first, second};
} else if(first.pos.x == second.pos.x) {
auto fb = first.st.sprite->getGlobalBounds();
auto sb = second.st.sprite->getGlobalBounds();
// use the widest one as right
if(fb.size.x >= sb.size.x) {
return {first, second};
} else {
return {second, first};
}
} else {
// second is left
return {second, first};
}
}
void Engine::zoom(const std::string &actor, const std::string& style, float scale) {
auto& config = actor_config(actor);
auto bounds = config.st.sprite->getGlobalBounds();

View file

@ -56,6 +56,5 @@ namespace scene {
void zoom(const std::string& actor, const std::string& style, float scale=0.9f);
void zoom(float mid_x, float mid_y, const std::string& style, float scale);
void reset(sf::RenderTexture& view);
std::pair<Element&, Element&> left_right(const std::string &actor, const std::string &target);
};
}