import type { Game } from './Game';
import { Ghost } from './Ghost';

const ACTIVATE_RADIUS = 8;

// Labyrinth-Wächter: steht still am Wegpunkt und greift erst an,
// wenn der Spieler in die Nähe kommt.
export class MazeGuard extends Ghost {
  private activated = false;

  protected chase(dt: number, game: Game) {
    if (!this.activated) {
      const dx = game.player.body.position.x - this.body.position.x;
      const dz = game.player.body.position.z - this.body.position.z;
      if (Math.hypot(dx, dz) < ACTIVATE_RADIUS) {
        this.activated = true;
      }
      return;
    }
    super.chase(dt, game);
  }
}
