summaryrefslogtreecommitdiff
path: root/sim/src
diff options
context:
space:
mode:
Diffstat (limited to 'sim/src')
-rw-r--r--sim/src/BaseBattle.cpp10
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
}
}