summaryrefslogtreecommitdiff
path: root/engine/systems/FacingDirection.ts
diff options
context:
space:
mode:
Diffstat (limited to 'engine/systems/FacingDirection.ts')
-rw-r--r--engine/systems/FacingDirection.ts15
1 files changed, 9 insertions, 6 deletions
diff --git a/engine/systems/FacingDirection.ts b/engine/systems/FacingDirection.ts
index 4426ab6..daf639f 100644
--- a/engine/systems/FacingDirection.ts
+++ b/engine/systems/FacingDirection.ts
@@ -20,21 +20,24 @@ export class FacingDirection extends System {
return;
}
- const totalVelocity: Velocity = new Velocity();
+ const totalVelocityComponent = new Velocity();
const control = entity.getComponent<Control>(ComponentNames.Control);
- const velocity = entity.getComponent<Velocity>(ComponentNames.Velocity);
- totalVelocity.add(velocity);
+ const velocity = entity.getComponent<Velocity>(
+ ComponentNames.Velocity,
+ ).velocity;
+
+ totalVelocityComponent.add(velocity);
if (control) {
- totalVelocity.add(control.controlVelocity);
+ totalVelocityComponent.add(control.controlVelocityComponent.velocity);
}
const facingDirection = entity.getComponent<FacingDirectionComponent>(
ComponentNames.FacingDirection,
);
- if (totalVelocity.dCartesian.dx > 0) {
+ if (totalVelocityComponent.velocity.dCartesian.dx > 0) {
entity.addComponent(facingDirection.facingRightSprite);
- } else if (totalVelocity.dCartesian.dx < 0) {
+ } else if (totalVelocityComponent.velocity.dCartesian.dx < 0) {
entity.addComponent(facingDirection.facingLeftSprite);
}
},