diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-08-13 17:09:12 -0600 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-08-13 17:09:12 -0600 |
commit | 2dc3120831fbcd03b635bbad59213ff0bf1f8879 (patch) | |
tree | df1b6e88e8f0a9370e2cd321f52725524cc4d06d /engine/systems/FacingDirection.ts | |
parent | 98e795029bcc404463ed151ff5255a72498bc641 (diff) | |
download | jumpstorm-2dc3120831fbcd03b635bbad59213ff0bf1f8879.tar.gz jumpstorm-2dc3120831fbcd03b635bbad59213ff0bf1f8879.zip |
refactor velocity a bit for no real reason besides verbosity
Diffstat (limited to 'engine/systems/FacingDirection.ts')
-rw-r--r-- | engine/systems/FacingDirection.ts | 15 |
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); } }, |