diff options
author | Aki <please@ignore.pl> | 2022-12-31 16:35:42 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-12-31 16:35:42 +0100 |
commit | 56ecf8834768fa61c299c07094c8760209f5bb45 (patch) | |
tree | 33d5fa15ad1606976d786a01a88646cc07d115d6 | |
parent | b8d3a357428d3af09031d2ae8925e1c2e93810ba (diff) | |
download | kurator-56ecf8834768fa61c299c07094c8760209f5bb45.zip kurator-56ecf8834768fa61c299c07094c8760209f5bb45.tar.gz kurator-56ecf8834768fa61c299c07094c8760209f5bb45.tar.bz2 |
Keep at range distance is now updated according to optimal range of turrets
-rw-r--r-- | sim/src/BaseBattle.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
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 <algorithm> + #include <entt/entity/registry.hpp> #include <entt/signal/dispatcher.hpp> @@ -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<campaign::UniqueIdentifier>(entity, ship.identifier); - for (const auto& turret_type : ship.turrets) - build(repo->turret_type(turret_type), entity); + auto& state = _registry.get<AIState>(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 } } |