diff options
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) + } + } } |