diff options
-rw-r--r-- | kurator/src/Battle.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/kurator/src/Battle.cpp b/kurator/src/Battle.cpp index 380cef1..683b0e6 100644 --- a/kurator/src/Battle.cpp +++ b/kurator/src/Battle.cpp @@ -40,6 +40,9 @@ Battle::Battle(std::shared_ptr<Session> _session) : } +static void attach_markers(engine::Context& ctx); + + Battle::Battle(std::shared_ptr<Session> _session, campaign::Scenario scenario, Battle::Callback _report) : session {std::move(_session)}, battle {sim::prepare(scenario)}, @@ -49,15 +52,23 @@ Battle::Battle(std::shared_ptr<Session> _session, campaign::Scenario scenario, B battle->dispatcher().sink<sim::Hit>().connect<&Battle::on_hit>(*this); battle->dispatcher().sink<sim::Destroyed>().connect<&Battle::on_destroyed>(*this); battle->dispatcher().sink<stats::ShipLeft>().connect<&Battle::on_ship_left>(*this); + camera.scale = std::min(GetScreenWidth()/30000.0, GetScreenHeight()/30000.0); auto& registry = battle->registry(); - auto ships = registry.view<sim::Team, universe::ShipType, universe::UniqueIdentifier>(); + engine::Context ctx {registry, battle->dispatcher(), clock, camera}; + attach_markers(ctx); + balance.update(registry); +} + + +void +attach_markers(engine::Context& ctx) +{ + auto ships = ctx.registry.view<sim::Team, universe::ShipType, universe::UniqueIdentifier>(); for (const auto& [entity, team, type, identifier] : ships.each()) { std::string label = TextFormat("%s (%d)", type.name.c_str(), identifier.id); - registry.emplace<Marker>(entity, 5.0, team_color(team.id), std::move(label)); - registry.emplace<PopupEmitter>(entity); + ctx.registry.emplace<Marker>(entity, 5.0, team_color(team.id), std::move(label)); + ctx.registry.emplace<PopupEmitter>(entity); } - camera.scale = std::min(GetScreenWidth()/30000.0, GetScreenHeight()/30000.0); - balance.update(registry); } |