diff options
-rw-r--r-- | engine/CMakeLists.txt | 1 | ||||
-rw-r--r-- | engine/include/kurator/engine/Context.h | 46 | ||||
-rw-r--r-- | engine/src/Context.cpp | 45 | ||||
-rw-r--r-- | kurator/src/Battle.cpp | 79 | ||||
-rw-r--r-- | kurator/src/Battle.h | 7 | ||||
-rw-r--r-- | sim/CMakeLists.txt | 3 | ||||
-rw-r--r-- | sim/include/kurator/sim/Battle.h | 29 | ||||
-rw-r--r-- | sim/include/kurator/sim/FloatingMovement.h | 5 | ||||
-rw-r--r-- | sim/include/kurator/sim/State.h | 3 | ||||
-rw-r--r-- | sim/include/kurator/sim/System.h | 4 | ||||
-rw-r--r-- | sim/include/kurator/sim/TurretControl.h | 4 | ||||
-rw-r--r-- | sim/src/BaseBattle.cpp | 46 | ||||
-rw-r--r-- | sim/src/BaseBattle.h | 32 | ||||
-rw-r--r-- | sim/src/BaseSimulation.cpp | 5 | ||||
-rw-r--r-- | sim/src/BaseSimulation.h | 3 | ||||
-rw-r--r-- | sim/src/Battle.cpp | 24 | ||||
-rw-r--r-- | sim/src/FloatingMovement.cpp | 4 | ||||
-rw-r--r-- | sim/src/State.cpp | 25 | ||||
-rw-r--r-- | sim/src/TeamManager.cpp | 8 | ||||
-rw-r--r-- | sim/src/TeamManager.h | 6 | ||||
-rw-r--r-- | sim/src/TurretControl.cpp | 4 | ||||
-rw-r--r-- | sim/src/systems.cpp | 8 | ||||
-rw-r--r-- | sim/src/systems.h | 8 |
23 files changed, 70 insertions, 329 deletions
diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt index 43c09a5..7cb7f20 100644 --- a/engine/CMakeLists.txt +++ b/engine/CMakeLists.txt @@ -3,7 +3,6 @@ add_library( ${PROJECT_NAME} STATIC src/Camera.cpp src/Clock.cpp - src/Context.cpp src/Point.cpp ) target_include_directories( diff --git a/engine/include/kurator/engine/Context.h b/engine/include/kurator/engine/Context.h deleted file mode 100644 index 093285e..0000000 --- a/engine/include/kurator/engine/Context.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once - -#include <entt/entity/registry.hpp> -#include <entt/signal/dispatcher.hpp> - -#include "Camera.h" -#include "Clock.h" - - -namespace kurator -{ -namespace engine -{ - - -struct Context; -struct ConstContext; - - -struct Context -{ - Context(entt::registry& registry_, entt::dispatcher& dispatcher_, Clock& clock_, Camera& camera_); - entt::registry& registry; - entt::dispatcher& dispatcher; - Clock& clock; - Camera& camera; - operator ConstContext() const; -}; - - -struct ConstContext -{ - ConstContext( - const entt::registry& registry_, - const entt::dispatcher& dispatcher_, - const Clock& clock_, - const Camera& camera_); - const entt::registry& registry; - const entt::dispatcher& dispatcher; - const Clock& clock; - const Camera& camera; -}; - - -} // namespace engine -} // namespace kurator diff --git a/engine/src/Context.cpp b/engine/src/Context.cpp deleted file mode 100644 index 8c81c89..0000000 --- a/engine/src/Context.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include <kurator/engine/Context.h> - -#include <entt/entity/registry.hpp> -#include <entt/signal/dispatcher.hpp> - -#include <kurator/engine/Camera.h> -#include <kurator/engine/Clock.h> - - -namespace kurator -{ -namespace engine -{ - - -Context::Context(entt::registry& registry_, entt::dispatcher& dispatcher_, Clock& clock_, Camera& camera_) : - registry {registry_}, - dispatcher {dispatcher_}, - clock {clock_}, - camera {camera_} -{ -} - - -Context::operator ConstContext() const -{ - return ConstContext{registry, dispatcher, clock, camera}; -} - - -ConstContext::ConstContext( - const entt::registry& registry_, - const entt::dispatcher& dispatcher_, - const Clock& clock_, - const Camera& camera_) : - registry {registry_}, - dispatcher {dispatcher_}, - clock {clock_}, - camera {camera_} -{ -} - - -} // namespace engine -} // namespace kurator diff --git a/kurator/src/Battle.cpp b/kurator/src/Battle.cpp index 3eadc28..73a0136 100644 --- a/kurator/src/Battle.cpp +++ b/kurator/src/Battle.cpp @@ -10,13 +10,13 @@ #include <raylib.h> #include <imgui.h> -#include <kurator/engine/Context.h> #include <kurator/engine/Point.h> #include <kurator/campaign/scenarios.h> -#include <kurator/sim/Battle.h> +#include <kurator/sim.h> #include <kurator/sim/components.h> #include <kurator/sim/events.h> #include <kurator/sim/FloatingMovement.h> +#include <kurator/sim/State.h> #include <kurator/stats/events.h> #include <kurator/universe/ShipType.h> #include <kurator/universe/UniqueIdentifier.h> @@ -40,15 +40,15 @@ Battle::Battle(std::shared_ptr<Session> _session) : } -static void attach_markers(engine::Context& ctx); +static void attach_markers(sim::State& ctx); Battle::Battle(std::shared_ptr<Session> _session, campaign::Scenario scenario, Battle::Callback _report) : session {std::move(_session)}, - battle {sim::prepare(scenario)}, + ctx {sim::load_scenario(scenario)}, + simulation_base {sim::base_simulation_systems(ctx)}, report {std::move(_report)} { - auto ctx = battle->context(); ctx.dispatcher.sink<sim::End>().connect<&Battle::on_end>(*this); ctx.dispatcher.sink<sim::Hit>().connect<&Battle::on_hit>(*this); ctx.dispatcher.sink<sim::Destroyed>().connect<&Battle::on_destroyed>(*this); @@ -60,7 +60,7 @@ Battle::Battle(std::shared_ptr<Session> _session, campaign::Scenario scenario, B void -attach_markers(engine::Context& ctx) +attach_markers(sim::State& ctx) { auto ships = ctx.registry.view<sim::Team, universe::ShipType, universe::UniqueIdentifier>(); for (const auto& [entity, team, type, identifier] : ships.each()) { @@ -73,7 +73,6 @@ attach_markers(engine::Context& ctx) Battle::~Battle() { - auto ctx = battle->context(); ctx.dispatcher.sink<sim::End>().disconnect(*this); ctx.dispatcher.sink<sim::Hit>().disconnect(*this); ctx.dispatcher.sink<sim::Destroyed>().disconnect(*this); @@ -95,16 +94,15 @@ time_controls(const char* id, float& time_factor) } -static void progress_timers(engine::Context& ctx); -static void move_ui_pops(engine::Context& ctx); -static void blink_crosses(engine::Context& ctx); -static void animate_lines(engine::Context& ctx); +static void progress_timers(sim::State& ctx); +static void move_ui_pops(sim::State& ctx); +static void blink_crosses(sim::State& ctx); +static void animate_lines(sim::State& ctx); void Battle::update() { - auto ctx = battle->context(); if (IsKeyPressed(KEY_ESCAPE)) return session->set(std::make_shared<Pause>(session, session->current())); if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) { @@ -115,7 +113,7 @@ Battle::update() if (IsWindowResized()) ctx.camera.scale = std::min(GetScreenWidth()/30000.0, GetScreenHeight()/30000.0); ctx.clock.update(); - battle->update(ctx); + simulation_base(ctx); progress_timers(ctx); move_ui_pops(ctx); blink_crosses(ctx); @@ -130,7 +128,7 @@ Battle::update() void -progress_timers(engine::Context& ctx) +progress_timers(sim::State& ctx) { auto timers = ctx.registry.view<Timed>(); for (auto&& [entity, timer] : timers.each()) { @@ -142,7 +140,7 @@ progress_timers(engine::Context& ctx) void -move_ui_pops(engine::Context& ctx) +move_ui_pops(sim::State& ctx) { auto pops = ctx.registry.view<PopMove, UIOffset>(); for (auto&& [entity, pop, offset] : pops.each()) { @@ -157,7 +155,7 @@ move_ui_pops(engine::Context& ctx) void -blink_crosses(engine::Context& ctx) +blink_crosses(sim::State& ctx) { auto crosses = ctx.registry.view<Cross>(); for (auto&& [entity, cross] : crosses.each()) { @@ -170,7 +168,7 @@ blink_crosses(engine::Context& ctx) void -animate_lines(engine::Context& ctx) +animate_lines(sim::State& ctx) { auto lines = ctx.registry.view<Line>(); for (auto&& [entity, line] : lines.each()) @@ -178,16 +176,15 @@ animate_lines(engine::Context& ctx) } -static void draw_crosses(engine::ConstContext& ctx); -static void draw_lines(engine::ConstContext& ctx); -static void draw_markers(engine::ConstContext& ctx); -static void draw_pops(engine::ConstContext& ctx); +static void draw_crosses(const sim::State& ctx); +static void draw_lines(const sim::State& ctx); +static void draw_markers(const sim::State& ctx); +static void draw_pops(const sim::State& ctx); void Battle::draw() const { - auto ctx = battle->const_context(); ClearBackground(BLACK); Grid().draw(ctx.camera); draw_crosses(ctx); @@ -199,7 +196,7 @@ Battle::draw() const void -draw_crosses(engine::ConstContext& ctx) +draw_crosses(const sim::State& ctx) { auto crosses = ctx.registry.view<sim::Transform, Cross>(); for (const auto& [entity, transform, cross] : crosses.each()) { @@ -223,7 +220,7 @@ draw_crosses(engine::ConstContext& ctx) void -draw_lines(engine::ConstContext& ctx) +draw_lines(const sim::State& ctx) { auto lines = ctx.registry.view<Line>(); for (const auto& [entity, line] : lines.each()) { @@ -238,7 +235,7 @@ draw_lines(engine::ConstContext& ctx) void -draw_markers(engine::ConstContext& ctx) +draw_markers(const sim::State& ctx) { auto view = ctx.registry.view<const Marker, const sim::Transform>(); for (auto [entity, marker, transform] : view.each()) { @@ -260,7 +257,7 @@ draw_markers(engine::ConstContext& ctx) void -draw_pops(engine::ConstContext& ctx) +draw_pops(const sim::State& ctx) { auto pops = ctx.registry.view<CenteredText, sim::Transform, UIOffset>(); for (const auto& [entity, text, transform, offset] : pops.each()) { @@ -283,16 +280,15 @@ Battle::on_end(const sim::End&) void Battle::on_hit(const sim::Hit& hit) { - auto& registry = battle->context().registry; - if (!registry.valid(hit.victim)) + if (!ctx.registry.valid(hit.victim)) return; - const auto& source = registry.get<sim::Transform>(hit.source); - const auto& victim = registry.get<sim::Transform>(hit.victim); - auto& popup = registry.get<PopupEmitter>(hit.victim); - popup.emit(registry, victim, hit.damage); - const auto line = registry.create(); - registry.emplace<Timed>(line, 0.2, true); - registry.emplace<Line>( + const auto& source = ctx.registry.get<sim::Transform>(hit.source); + const auto& victim = ctx.registry.get<sim::Transform>(hit.victim); + auto& popup = ctx.registry.get<PopupEmitter>(hit.victim); + popup.emit(ctx.registry, victim, hit.damage); + const auto line = ctx.registry.create(); + ctx.registry.emplace<Timed>(line, 0.2, true); + ctx.registry.emplace<Line>( line, RED, source.position, @@ -305,14 +301,13 @@ Battle::on_hit(const sim::Hit& hit) void Battle::on_destroyed(const sim::Destroyed& event) { - auto& registry = battle->context().registry; - if (!registry.valid(event.victim)) + if (!ctx.registry.valid(event.victim)) return; - const auto& victim = registry.get<sim::Transform>(event.victim); - const auto cross = registry.create(); - registry.emplace<Timed>(cross, 1.6); - registry.emplace<Cross>(cross, 0.2, 6.0); - registry.emplace<sim::Transform>(cross, victim.position, 0.0); + const auto& victim = ctx.registry.get<sim::Transform>(event.victim); + const auto cross = ctx.registry.create(); + ctx.registry.emplace<Timed>(cross, 1.6); + ctx.registry.emplace<Cross>(cross, 0.2, 6.0); + ctx.registry.emplace<sim::Transform>(cross, victim.position, 0.0); } diff --git a/kurator/src/Battle.h b/kurator/src/Battle.h index c02717d..f6ec8d6 100644 --- a/kurator/src/Battle.h +++ b/kurator/src/Battle.h @@ -4,9 +4,9 @@ #include <memory> #include <kurator/campaign/Scenario.h> -#include <kurator/engine/Context.h> -#include <kurator/sim/Battle.h> #include <kurator/sim/events.h> +#include <kurator/sim/State.h> +#include <kurator/sim/System.h> #include <kurator/stats/EventLog.h> #include <kurator/stats/events.h> @@ -34,7 +34,8 @@ public: void on_ship_left(const stats::ShipLeft& event); // duplicated? private: std::shared_ptr<Session> session; - std::unique_ptr<sim::Battle> battle; + sim::State ctx; + sim::System simulation_base; ForceBalance balance; stats::EventLog log; Callback report; diff --git a/sim/CMakeLists.txt b/sim/CMakeLists.txt index a221d2f..a0a4d00 100644 --- a/sim/CMakeLists.txt +++ b/sim/CMakeLists.txt @@ -1,15 +1,12 @@ project(sim) add_library( ${PROJECT_NAME} STATIC - src/BaseBattle.cpp src/BaseSimulation.cpp - src/Battle.cpp src/Builder.cpp src/FloatingMovement.cpp src/HitPoints.cpp src/RandomSpawner.cpp src/sim.cpp - src/State.cpp src/systems.cpp src/TeamManager.cpp src/TurretControl.cpp diff --git a/sim/include/kurator/sim/Battle.h b/sim/include/kurator/sim/Battle.h deleted file mode 100644 index 1692c0c..0000000 --- a/sim/include/kurator/sim/Battle.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include <memory> - -#include <kurator/engine/Context.h> -#include <kurator/campaign/Scenario.h> - - -namespace kurator -{ -namespace sim -{ - - -class Battle -{ -public: - virtual ~Battle() = default; - virtual engine::Context context() = 0; - virtual engine::ConstContext const_context() const = 0; - virtual void update(engine::Context& ctx) = 0; -}; - - -auto prepare(const campaign::Scenario& scenario) -> std::unique_ptr<Battle>; - - -} // namespace sim -} // namespace kurator diff --git a/sim/include/kurator/sim/FloatingMovement.h b/sim/include/kurator/sim/FloatingMovement.h index 4239d99..ff40e23 100644 --- a/sim/include/kurator/sim/FloatingMovement.h +++ b/sim/include/kurator/sim/FloatingMovement.h @@ -1,8 +1,9 @@ #pragma once -#include <kurator/engine/Context.h> #include <kurator/engine/Point.h> +#include "State.h" + namespace kurator { @@ -17,7 +18,7 @@ struct FloatingMovement double deceleration; double destination_boundary = 100.0; engine::Point speed = {0.0, 0.0}; - static void update(engine::Context& ctx); + static void update(State& ctx); }; diff --git a/sim/include/kurator/sim/State.h b/sim/include/kurator/sim/State.h index 8449ad2..fc7c54a 100644 --- a/sim/include/kurator/sim/State.h +++ b/sim/include/kurator/sim/State.h @@ -5,7 +5,6 @@ #include <kurator/engine/Camera.h> #include <kurator/engine/Clock.h> -#include <kurator/engine/Context.h> namespace kurator @@ -20,8 +19,6 @@ struct State entt::dispatcher dispatcher; engine::Clock clock; engine::Camera camera; // does not fit in here really - operator engine::Context(); - operator engine::ConstContext() const; }; diff --git a/sim/include/kurator/sim/System.h b/sim/include/kurator/sim/System.h index 101812a..d4b744c 100644 --- a/sim/include/kurator/sim/System.h +++ b/sim/include/kurator/sim/System.h @@ -2,7 +2,7 @@ #include <functional> -#include <kurator/engine/Context.h> +#include "State.h" namespace kurator @@ -11,7 +11,7 @@ namespace sim { -using System = std::function<void(engine::Context&)>; +using System = std::function<void(State&)>; } // namespace sim diff --git a/sim/include/kurator/sim/TurretControl.h b/sim/include/kurator/sim/TurretControl.h index 323b54b..731f30e 100644 --- a/sim/include/kurator/sim/TurretControl.h +++ b/sim/include/kurator/sim/TurretControl.h @@ -2,7 +2,7 @@ #include <entt/entity/entity.hpp> -#include <kurator/engine/Context.h> +#include "State.h" namespace kurator @@ -17,7 +17,7 @@ struct TurretControl double reload; int rounds; entt::entity owner; - static void update(engine::Context& ctx); + static void update(State& ctx); }; diff --git a/sim/src/BaseBattle.cpp b/sim/src/BaseBattle.cpp deleted file mode 100644 index ee09740..0000000 --- a/sim/src/BaseBattle.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "BaseBattle.h" - -#include <entt/entity/registry.hpp> -#include <entt/signal/dispatcher.hpp> - -#include <kurator/engine/Context.h> -#include <kurator/campaign/Scenario.h> -#include <kurator/sim.h> - - -namespace kurator -{ -namespace sim -{ - - -BaseBattle::BaseBattle(const campaign::Scenario& scenario) : - state {load_scenario(scenario)}, - base {base_simulation_systems(state)} -{ -} - - -engine::Context -BaseBattle::context() -{ - return state; -} - - -engine::ConstContext -BaseBattle::const_context() const -{ - return state; -} - - -void -BaseBattle::update(engine::Context& ctx) -{ - base(ctx); -} - - -} // namespace sim -} // namespace kurator diff --git a/sim/src/BaseBattle.h b/sim/src/BaseBattle.h deleted file mode 100644 index 3e98658..0000000 --- a/sim/src/BaseBattle.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#include <kurator/engine/Context.h> -#include <kurator/campaign/Scenario.h> -#include <kurator/sim/Battle.h> -#include <kurator/sim/State.h> -#include <kurator/sim/System.h> - -#include "TeamManager.h" - - -namespace kurator -{ -namespace sim -{ - - -class BaseBattle : public Battle -{ -public: - explicit BaseBattle(const campaign::Scenario& scenario); - engine::Context context() override; - engine::ConstContext const_context() const override; - void update(engine::Context& ctx) override; -private: - State state; - System base; -}; - - -} // namespace sim -} // namespace kurator diff --git a/sim/src/BaseSimulation.cpp b/sim/src/BaseSimulation.cpp index 05b224d..545e9ce 100644 --- a/sim/src/BaseSimulation.cpp +++ b/sim/src/BaseSimulation.cpp @@ -1,6 +1,5 @@ #include "BaseSimulation.h" -#include <kurator/engine/Context.h> #include <kurator/sim/State.h> #include <kurator/sim/FloatingMovement.h> #include <kurator/sim/TurretControl.h> @@ -17,12 +16,12 @@ namespace sim BaseSimulation::BaseSimulation(State& ctx) { - manager.extend(ctx.registry); + manager.extend(ctx); } void -BaseSimulation::operator()(engine::Context& ctx) +BaseSimulation::operator()(State& ctx) { pick_random_targets(ctx, manager); keep_at_range(ctx); diff --git a/sim/src/BaseSimulation.h b/sim/src/BaseSimulation.h index 4d73382..bdbcd68 100644 --- a/sim/src/BaseSimulation.h +++ b/sim/src/BaseSimulation.h @@ -1,6 +1,5 @@ #pragma once -#include <kurator/engine/Context.h> #include <kurator/sim/State.h> #include "TeamManager.h" @@ -16,7 +15,7 @@ class BaseSimulation { public: explicit BaseSimulation(State& ctx); - void operator()(engine::Context& ctx); + void operator()(State& ctx); private: TeamManager manager; }; diff --git a/sim/src/Battle.cpp b/sim/src/Battle.cpp deleted file mode 100644 index 4bbfcb6..0000000 --- a/sim/src/Battle.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include <kurator/sim/Battle.h> - -#include <memory> - -#include <kurator/campaign/Scenario.h> - -#include "BaseBattle.h" - - -namespace kurator -{ -namespace sim -{ - - -std::unique_ptr<Battle> -prepare(const campaign::Scenario& scenario) -{ - return std::make_unique<BaseBattle>(scenario); -} - - -} // namespace sim -} // namespace kurator diff --git a/sim/src/FloatingMovement.cpp b/sim/src/FloatingMovement.cpp index da6cd20..39ec17c 100644 --- a/sim/src/FloatingMovement.cpp +++ b/sim/src/FloatingMovement.cpp @@ -1,7 +1,7 @@ #include <kurator/sim/FloatingMovement.h> -#include <kurator/engine/Context.h> #include <kurator/sim/components.h> +#include <kurator/sim/State.h> namespace kurator @@ -11,7 +11,7 @@ namespace sim void -FloatingMovement::update(engine::Context& ctx) +FloatingMovement::update(State& ctx) { auto view = ctx.registry.view<Transform, FloatingMovement, AIState>(); for (auto&& [entity, transform, movement, ai] : view.each()) { diff --git a/sim/src/State.cpp b/sim/src/State.cpp deleted file mode 100644 index 3c8a709..0000000 --- a/sim/src/State.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include <kurator/sim/State.h> - -#include <kurator/engine/Context.h> - - -namespace kurator -{ -namespace sim -{ - - -State::operator engine::Context() -{ - return {registry, dispatcher, clock, camera}; -} - - -State::operator engine::ConstContext() const -{ - return {registry, dispatcher, clock, camera}; -} - - -} // namespace sim -} // namespace kurator diff --git a/sim/src/TeamManager.cpp b/sim/src/TeamManager.cpp index 778cd18..7107b07 100644 --- a/sim/src/TeamManager.cpp +++ b/sim/src/TeamManager.cpp @@ -7,9 +7,9 @@ #include <entt/entity/registry.hpp> -#include <kurator/engine/Context.h> #include <kurator/sim/components.h> #include <kurator/sim/events.h> +#include <kurator/sim/State.h> #include <kurator/universe/ShipType.h> @@ -27,9 +27,9 @@ TeamManager::TeamManager() : void -TeamManager::extend(entt::registry& registry) +TeamManager::extend(State& ctx) { - auto ships = registry.view<universe::ShipType, sim::Team>(); + auto ships = ctx.registry.view<universe::ShipType, sim::Team>(); for (const auto& [entity, type, team] : ships.each()) add(team.id, entity); } @@ -62,7 +62,7 @@ TeamManager::random(const int exclude) void -TeamManager::update(engine::Context& ctx) +TeamManager::update(State& ctx) { for (auto& members : teams) { auto is_valid = [&](entt::entity entity){ return !ctx.registry.valid(entity); }; diff --git a/sim/src/TeamManager.h b/sim/src/TeamManager.h index 7f53510..d708745 100644 --- a/sim/src/TeamManager.h +++ b/sim/src/TeamManager.h @@ -5,7 +5,7 @@ #include <entt/entity/registry.hpp> -#include <kurator/engine/Context.h> +#include <kurator/sim/State.h> namespace kurator @@ -19,10 +19,10 @@ class TeamManager public: using Team = std::vector<entt::entity>; TeamManager(); - void extend(entt::registry& registry); + void extend(State& ctx); void add(int team, entt::entity entity); entt::entity random(int exclude); - void update(engine::Context& ctx); + void update(State& ctx); private: std::vector<Team> teams; std::mt19937 generator; diff --git a/sim/src/TurretControl.cpp b/sim/src/TurretControl.cpp index fa42bf5..ba54f3f 100644 --- a/sim/src/TurretControl.cpp +++ b/sim/src/TurretControl.cpp @@ -1,9 +1,9 @@ #include <kurator/sim/TurretControl.h> -#include <kurator/engine/Context.h> #include <kurator/sim/components.h> #include <kurator/sim/HitPoints.h> #include <kurator/sim/events.h> +#include <kurator/sim/State.h> #include <kurator/universe/TurretType.h> @@ -17,7 +17,7 @@ bool consume(float& dt, double& target); void -TurretControl::update(engine::Context& ctx) +TurretControl::update(State& ctx) { auto view = ctx.registry.view<TurretControl, universe::TurretType>(); for (auto&& [entity, control, def] : view.each()) { diff --git a/sim/src/systems.cpp b/sim/src/systems.cpp index 4dc1e71..c6f997a 100644 --- a/sim/src/systems.cpp +++ b/sim/src/systems.cpp @@ -1,9 +1,9 @@ #include "systems.h" -#include <kurator/engine/Context.h> #include <kurator/sim/components.h> #include <kurator/sim/events.h> #include <kurator/sim/HitPoints.h> +#include <kurator/sim/State.h> #include <kurator/stats/events.h> #include <kurator/universe/UniqueIdentifier.h> @@ -15,7 +15,7 @@ namespace sim void -pick_random_targets(engine::Context& ctx, TeamManager& manager) +pick_random_targets(State& ctx, TeamManager& manager) { auto view = ctx.registry.view<Team, AIState>(); for (auto&& [entity, team, ai] : view.each()) { @@ -26,7 +26,7 @@ pick_random_targets(engine::Context& ctx, TeamManager& manager) void -keep_at_range(engine::Context& ctx) +keep_at_range(State& ctx) { auto view = ctx.registry.view<Transform, AIState>(); for (auto&& [entity, self, ai] : view.each()) { @@ -40,7 +40,7 @@ keep_at_range(engine::Context& ctx) void -kill_off_dead(engine::Context& ctx) +kill_off_dead(State& ctx) { auto view = ctx.registry.view<HitPoints>(); for (auto&& [entity, points] : view.each()) { diff --git a/sim/src/systems.h b/sim/src/systems.h index 4c8838b..396ebb2 100644 --- a/sim/src/systems.h +++ b/sim/src/systems.h @@ -1,6 +1,6 @@ #pragma once -#include <kurator/engine/Context.h> +#include <kurator/sim/State.h> #include "TeamManager.h" @@ -11,9 +11,9 @@ namespace sim { -void pick_random_targets(engine::Context& ctx, TeamManager& manager); -void keep_at_range(engine::Context& ctx); -void kill_off_dead(engine::Context& ctx); +void pick_random_targets(State& ctx, TeamManager& manager); +void keep_at_range(State& ctx); +void kill_off_dead(State& ctx); } // namespace sim |