diff options
author | nil <niljo@airmail.cc> | 2024-12-18 16:14:54 +0100 |
---|---|---|
committer | nil <niljo@airmail.cc> | 2024-12-18 16:14:54 +0100 |
commit | 7b005bc02b1e73c71f8cb8f4e03b6fe6ff420c67 (patch) | |
tree | 92dd185788f0c9d7868e935649a676f13ca9bbf7 /src/engine/vector2.js | |
parent | 827d1d8e533e45360ead5cbb5cab5547d2252282 (diff) |
order liberties
Diffstat (limited to 'src/engine/vector2.js')
-rw-r--r-- | src/engine/vector2.js | 16 |
1 files changed, 16 insertions, 0 deletions
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) + } + } } |