From 632c367ae6885657e6c99b96b8bf7a96b61a2bb9 Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 14 Feb 2023 00:13:02 +0100 Subject: Extracted basic simulation behaviour and that part of state to own class --- sim/src/BaseBattle.cpp | 34 ++++------------------------------ 1 file changed, 4 insertions(+), 30 deletions(-) (limited to 'sim/src/BaseBattle.cpp') diff --git a/sim/src/BaseBattle.cpp b/sim/src/BaseBattle.cpp index 916a9f8..ee09740 100644 --- a/sim/src/BaseBattle.cpp +++ b/sim/src/BaseBattle.cpp @@ -1,21 +1,11 @@ #include "BaseBattle.h" -#include - #include #include #include #include #include -#include -#include -#include -#include -#include - -#include "Builder.h" -#include "RandomSpawner.h" namespace kurator @@ -24,10 +14,10 @@ namespace sim { -BaseBattle::BaseBattle(const campaign::Scenario& scenario) +BaseBattle::BaseBattle(const campaign::Scenario& scenario) : + state {load_scenario(scenario)}, + base {base_simulation_systems(state)} { - load_scenario(state, scenario); - manager.extend(state.registry); } @@ -48,23 +38,7 @@ BaseBattle::const_context() const void BaseBattle::update(engine::Context& ctx) { - pick_random_targets(); - keep_at_range(ctx); - FloatingMovement::update(ctx); - TurretControl::update(ctx); - kill_off_dead(ctx); - manager.update(ctx); -} - - -void -BaseBattle::pick_random_targets() -{ - auto view = state.registry.view(); - for (auto&& [entity, team, ai] : view.each()) { - if (!state.registry.valid(ai.target)) - ai.target = manager.random(team.id); - } + base(ctx); } -- cgit v1.1