WIP event delays

This commit is contained in:
2025-02-10 17:56:38 +01:00
parent 0cead14e71
commit e2ded75017
4 changed files with 33 additions and 47 deletions

View File

@ -7,8 +7,7 @@ type Position = { positionX: number; positionY: number }
export type Node = Position & { parent?: Node; g: number; h: number; f: number }
class CharacterMoveService extends BaseService {
private readonly MOVEMENT_DELAY_MS = 200
private readonly MAX_PATH_LENGTH = 20 // Limit maximum path length
private readonly MOVEMENT_DELAY_MS = 90
private readonly DIRECTIONS = [
{ x: 0, y: -1 }, // Up
@ -46,21 +45,7 @@ class CharacterMoveService extends BaseService {
return null
}
// Add maximum distance check
const directDistance = Math.sqrt(Math.pow(targetX - character.positionX, 2) + Math.pow(targetY - character.positionY, 2))
if (directDistance > this.MAX_PATH_LENGTH) {
return null
}
const path = this.findPath(start, end, grid)
// Validate path length
if (path.length > this.MAX_PATH_LENGTH) {
return path.slice(0, this.MAX_PATH_LENGTH)
}
return path
return this.findPath(start, end, grid)
}
public calculateRotation(X1: number, Y1: number, X2: number, Y2: number): number {