summaryrefslogtreecommitdiff
path: root/sim/src/FloatingMovement.cpp
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2023-02-11 17:26:49 +0100
committerAki <please@ignore.pl>2023-02-11 17:26:49 +0100
commita5266d3e5da1d9ee9f873124674c68843a407ac0 (patch)
tree18a91419c4bdf37e7333a17bfb804e53fb92764a /sim/src/FloatingMovement.cpp
parente66011756340e03fe941723f762119ed78ec2402 (diff)
downloadkurator-a5266d3e5da1d9ee9f873124674c68843a407ac0.zip
kurator-a5266d3e5da1d9ee9f873124674c68843a407ac0.tar.gz
kurator-a5266d3e5da1d9ee9f873124674c68843a407ac0.tar.bz2
Context is now used in sim systems
Diffstat (limited to 'sim/src/FloatingMovement.cpp')
-rw-r--r--sim/src/FloatingMovement.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/sim/src/FloatingMovement.cpp b/sim/src/FloatingMovement.cpp
index e1794d5..da6cd20 100644
--- a/sim/src/FloatingMovement.cpp
+++ b/sim/src/FloatingMovement.cpp
@@ -1,8 +1,6 @@
#include <kurator/sim/FloatingMovement.h>
-#include <entt/entity/registry.hpp>
-#include <entt/signal/dispatcher.hpp>
-
+#include <kurator/engine/Context.h>
#include <kurator/sim/components.h>
@@ -13,21 +11,21 @@ namespace sim
void
-FloatingMovement::update(entt::registry& registry, entt::dispatcher&, const float dt)
+FloatingMovement::update(engine::Context& ctx)
{
- auto view = registry.view<Transform, FloatingMovement, AIState>();
+ auto view = ctx.registry.view<Transform, FloatingMovement, AIState>();
for (auto&& [entity, transform, movement, ai] : view.each()) {
const auto offset = ai.destination - transform.position;
const auto at_destination = offset.magnitude() > movement.destination_boundary;
const auto acceleration =
at_destination ?
- offset.normalized().scale(movement.acceleration * dt) :
- offset.normalized().scale(-1 * movement.deceleration * dt);
+ offset.normalized().scale(movement.acceleration * ctx.clock.dt) :
+ offset.normalized().scale(-1 * movement.deceleration * ctx.clock.dt);
movement.speed.x += acceleration.x;
movement.speed.y += acceleration.y;
if (movement.speed.magnitude() > movement.max_speed)
movement.speed = movement.speed.normalized().scale(movement.max_speed);
- const auto speed = movement.speed.scale(dt);
+ const auto speed = movement.speed.scale(ctx.clock.dt);
transform.position.x += speed.x;
transform.position.y += speed.y;
transform.angle = speed.angle();