From 58ef5cb59f8da8695651238751b696cac795f023 Mon Sep 17 00:00:00 2001 From: Renge Date: Sun, 24 Apr 2022 20:49:57 -0400 Subject: [PATCH] feat: add distance limitation to isPlayerVisible --- src/shattered_sword/AI/EnemyAI.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/shattered_sword/AI/EnemyAI.ts b/src/shattered_sword/AI/EnemyAI.ts index 1afad16..9758c9e 100644 --- a/src/shattered_sword/AI/EnemyAI.ts +++ b/src/shattered_sword/AI/EnemyAI.ts @@ -143,6 +143,10 @@ export default class EnemyAI extends StateMachineAI implements BattlerAI { let start = this.owner.position.clone(); let delta = pos.clone().sub(start); + if (delta.mag() >= 640) { + return null; + } + // Iterate through the tilemap region until we find a collision let minX = Math.min(start.x, pos.x); let maxX = Math.max(start.x, pos.x);