summaryrefslogtreecommitdiff
path: root/kurator
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2023-02-11 00:54:15 +0100
committerAki <please@ignore.pl>2023-02-11 00:54:15 +0100
commitf9269a45b82f637173e30760e1f4febc7ccb2b3e (patch)
tree8077af07826bedf693aac744de15b6b5b4c87ab3 /kurator
parent29e18d3d2918f7b1668c2bfb7d708c60aceea4bf (diff)
downloadkurator-f9269a45b82f637173e30760e1f4febc7ccb2b3e.zip
kurator-f9269a45b82f637173e30760e1f4febc7ccb2b3e.tar.gz
kurator-f9269a45b82f637173e30760e1f4febc7ccb2b3e.tar.bz2
Clock now tracks seconds since creation
Diffstat (limited to 'kurator')
-rw-r--r--kurator/src/Battle.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/kurator/src/Battle.cpp b/kurator/src/Battle.cpp
index da4cbde..7363661 100644
--- a/kurator/src/Battle.cpp
+++ b/kurator/src/Battle.cpp
@@ -43,7 +43,6 @@ Battle::Battle(std::shared_ptr<Session> _session) :
Battle::Battle(std::shared_ptr<Session> _session, campaign::Scenario scenario, Battle::Callback _report) :
session {std::move(_session)},
battle {sim::prepare(scenario)},
- clock {},
report {std::move(_report)}
{
battle->dispatcher().sink<sim::End>().connect<&Battle::on_end>(*this);
@@ -103,8 +102,9 @@ Battle::update()
if (IsWindowResized())
camera.scale = std::min(GetScreenWidth()/30000.0, GetScreenHeight()/30000.0); // won't work in frame
auto& registry = battle->registry();
+ clock.update();
engine::Context ctx {registry, battle->dispatcher(), clock};
- battle->update(clock.dt());
+ battle->update(clock.dt);
progress_timers(ctx);
move_ui_pops(ctx);
blink_crosses(ctx);
@@ -123,7 +123,7 @@ progress_timers(engine::Context& ctx)
{
auto timers = ctx.registry.view<Timed>();
for (auto&& [entity, timer] : timers.each()) {
- timer.left -= timer.scaled ? ctx.clock.dt() : ctx.clock.ui();
+ timer.left -= timer.scaled ? ctx.clock.dt : ctx.clock.ui;
if (timer.left < 0.0)
ctx.registry.destroy(entity);
}
@@ -135,10 +135,10 @@ move_ui_pops(engine::Context& ctx)
{
auto pops = ctx.registry.view<PopMove, UIOffset>();
for (auto&& [entity, pop, offset] : pops.each()) {
- const auto speed = pop.speed.scale(ctx.clock.ui());
+ const auto speed = pop.speed.scale(ctx.clock.ui);
offset.x += speed.x;
offset.y += speed.y;
- const auto damp = pop.speed.scale(pop.damp).scale(ctx.clock.ui());
+ const auto damp = pop.speed.scale(pop.damp).scale(ctx.clock.ui);
pop.speed.x -= damp.x;
pop.speed.y -= damp.y;
}
@@ -150,7 +150,7 @@ blink_crosses(engine::Context& ctx)
{
auto crosses = ctx.registry.view<Cross>();
for (auto&& [entity, cross] : crosses.each()) {
- cross.timer += ctx.clock.ui();
+ cross.timer += ctx.clock.ui;
const auto dphase = cross.phase * 2;
if (cross.timer > dphase)
cross.timer -= dphase;
@@ -163,7 +163,7 @@ animate_lines(engine::Context& ctx)
{
auto lines = ctx.registry.view<Line>();
for (auto&& [entity, line] : lines.each())
- line.position += (1.0 + line.hlength) / line.duration * ctx.clock.dt();
+ line.position += (1.0 + line.hlength) / line.duration * ctx.clock.dt;
}