From 7b005bc02b1e73c71f8cb8f4e03b6fe6ff420c67 Mon Sep 17 00:00:00 2001 From: nil Date: Wed, 18 Dec 2024 16:14:54 +0100 Subject: order liberties --- src/engine/vector2.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/engine/vector2.js') diff --git a/src/engine/vector2.js b/src/engine/vector2.js index 0cf2217..2bd52f7 100644 --- a/src/engine/vector2.js +++ b/src/engine/vector2.js @@ -21,4 +21,20 @@ export class Vector2 { return false } + + + static removeIfInArray(value, array) { + return array.filter(x => !Vector2.equals(value, x)) + } + + static isInArray(position, array) { + return Array.from(array) + .some(p => Vector2.equals(p, position)) + } + + static pushIfNotInArray(position, array) { + if (!Vector2.isInArray(position, array)) { + array.push(position) + } + } } -- cgit v1.2.3