From f8e47626f556ed70d719dc50b33d063864ad49c5 Mon Sep 17 00:00:00 2001 From: Alex Ilchenko Date: Wed, 6 Mar 2024 16:33:23 +0100 Subject: [PATCH] feat(engine): added getIsMoving function --- src/features/engine/utils/get-is-moving/get-is-moving.ts | 6 ++++++ src/features/engine/utils/get-is-moving/index.ts | 1 + 2 files changed, 7 insertions(+) create mode 100644 src/features/engine/utils/get-is-moving/get-is-moving.ts create mode 100644 src/features/engine/utils/get-is-moving/index.ts diff --git a/src/features/engine/utils/get-is-moving/get-is-moving.ts b/src/features/engine/utils/get-is-moving/get-is-moving.ts new file mode 100644 index 0000000..83e85e8 --- /dev/null +++ b/src/features/engine/utils/get-is-moving/get-is-moving.ts @@ -0,0 +1,6 @@ +import { VECTOR_ZERO } from '../../constants'; +import { Entity, isMovable } from '../../types/entities'; +import { getIsSameVector } from '../get-is-same-vector'; + +export const getIsMoving = (entity: Entity) => + isMovable(entity) && !getIsSameVector(entity.velocity, VECTOR_ZERO); diff --git a/src/features/engine/utils/get-is-moving/index.ts b/src/features/engine/utils/get-is-moving/index.ts new file mode 100644 index 0000000..6fd219d --- /dev/null +++ b/src/features/engine/utils/get-is-moving/index.ts @@ -0,0 +1 @@ +export * from './get-is-moving';