From 94d6d863e1b78766cdb5f286e3d9f374c02c5d33 Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 24 Apr 2023 23:55:02 +0200 Subject: Fixed Turrets percepting time too fast --- sim/include/kurator/sim/weapons.h | 1 + sim/src/weapons.cpp | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'sim') diff --git a/sim/include/kurator/sim/weapons.h b/sim/include/kurator/sim/weapons.h index 7dd5b3b..4c87b34 100644 --- a/sim/include/kurator/sim/weapons.h +++ b/sim/include/kurator/sim/weapons.h @@ -19,6 +19,7 @@ struct Turret universe::TurretType type; double delay = 0.0; double reload = 0.0; + float action = 0.0; int rounds = type.rounds; void shoot_at(State& ctx, const entt::entity& target, double distance); }; diff --git a/sim/src/weapons.cpp b/sim/src/weapons.cpp index bd130dc..28fc6fa 100644 --- a/sim/src/weapons.cpp +++ b/sim/src/weapons.cpp @@ -22,8 +22,7 @@ static bool reload_(float& dt, Turret& turret); void Turret::shoot_at(State& ctx, const entt::entity& target, const double distance) { - float remaining_dt = ctx.clock.dt; - while (reload_(remaining_dt, *this)) { + while (reload_(action, *this)) { auto& target_points = ctx.registry.get(target); const auto& movement = ctx.registry.get(target); auto damage = type.effective_damage(distance, movement.speed.magnitude()); @@ -47,11 +46,11 @@ update_turrets(State& ctx) ctx.registry.destroy(entity); continue; } - float remaining_dt = ctx.clock.dt; - while (remaining_dt > 0.0) { - if (reload_(remaining_dt, turret)) + while (turret.action > 0.0) { + if (reload_(turret.action, turret)) break; } + turret.action = ctx.clock.dt; } } -- cgit v1.1