From 56ecf8834768fa61c299c07094c8760209f5bb45 Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 31 Dec 2022 16:35:42 +0100 Subject: Keep at range distance is now updated according to optimal range of turrets --- sim/src/BaseBattle.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'sim/src') diff --git a/sim/src/BaseBattle.cpp b/sim/src/BaseBattle.cpp index 5f72483..1b27c2e 100644 --- a/sim/src/BaseBattle.cpp +++ b/sim/src/BaseBattle.cpp @@ -1,5 +1,7 @@ #include "BaseBattle.h" +#include + #include #include @@ -30,8 +32,12 @@ BaseBattle::BaseBattle(const campaign::Scenario& scenario) : for (const auto& ship : scenario.ships) { const auto entity = build(repo->ship_type(ship.type), ship.team); _registry.emplace(entity, ship.identifier); - for (const auto& turret_type : ship.turrets) - build(repo->turret_type(turret_type), entity); + auto& state = _registry.get(entity); + for (const auto& turret_type : ship.turrets) { + auto def = repo->turret_type(turret_type); + build(def, entity); + state.keep_at_range = std::min(state.keep_at_range, def.optimal_range); + } manager.add(ship.team, entity); // registry supports on construction events } } -- cgit v1.1