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.ts27
1 files changed, 15 insertions, 12 deletions
diff --git a/engine/systems/FacingDirection.ts b/engine/systems/FacingDirection.ts
index 4426ab6..01f32cf 100644
--- a/engine/systems/FacingDirection.ts
+++ b/engine/systems/FacingDirection.ts
@@ -2,10 +2,10 @@ import {
ComponentNames,
Velocity,
FacingDirection as FacingDirectionComponent,
- Control,
-} from "../components";
-import { Game } from "../Game";
-import { System, SystemNames } from "./";
+ Control
+} from '../components';
+import { Game } from '../Game';
+import { System, SystemNames } from './';
export class FacingDirection extends System {
constructor() {
@@ -20,24 +20,27 @@ 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,
+ 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);
}
- },
+ }
);
}
}