summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2023-02-12 14:03:45 +0100
committerAki <please@ignore.pl>2023-02-12 14:03:45 +0100
commit4f2f2d329aeee7e45198cfc6e46f7648cedf1707 (patch)
treefaf394fa693b443170644cc7de6dfb7a03e5af37
parentd85120a0255d3b37b57323a7a18f87a1dd0ab62a (diff)
downloadkurator-4f2f2d329aeee7e45198cfc6e46f7648cedf1707.zip
kurator-4f2f2d329aeee7e45198cfc6e46f7648cedf1707.tar.gz
kurator-4f2f2d329aeee7e45198cfc6e46f7648cedf1707.tar.bz2
Extracted marker setup from Battle scene constructor
-rw-r--r--kurator/src/Battle.cpp21
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);
}