From e9633766c96f0c412e786eacfd24eab967bd317b Mon Sep 17 00:00:00 2001 From: "Z. Cliffe Schreuders" Date: Sat, 21 Feb 2026 00:20:59 +0000 Subject: [PATCH] fix: update player module version and enhance teleportation cooldown to prevent rapid back-and-forth movement --- public/break_escape/js/core/game.js | 2 +- public/break_escape/js/core/player.js | 12 ++++++++++++ public/break_escape/js/systems/collision.js | 8 +++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/public/break_escape/js/core/game.js b/public/break_escape/js/core/game.js index 98e21a3..abe7a55 100644 --- a/public/break_escape/js/core/game.js +++ b/public/break_escape/js/core/game.js @@ -1,5 +1,5 @@ import { initializeRooms, calculateWorldBounds, calculateRoomPositions, createRoom, revealRoom, updatePlayerRoom, rooms } from './rooms.js?v=17'; -import { createPlayer, updatePlayerMovement, movePlayerToPoint, facePlayerToward, player } from './player.js?v=17'; +import { createPlayer, updatePlayerMovement, movePlayerToPoint, facePlayerToward, player } from './player.js?v=18'; import { initializePathfinder } from './pathfinding.js?v=7'; import { initializeInventory, processInitialInventoryItems } from '../systems/inventory.js?v=9'; import { checkObjectInteractions, setGameInstance, isObjectInInteractionRange } from '../systems/interactions.js?v=31'; diff --git a/public/break_escape/js/core/player.js b/public/break_escape/js/core/player.js index 35373f4..cb5bca9 100644 --- a/public/break_escape/js/core/player.js +++ b/public/break_escape/js/core/player.js @@ -915,6 +915,18 @@ export function movePlayerToPoint(x, y) { } } +// Exposed globally so teleport handlers (collision.js) can cancel in-flight paths +// without creating a circular import. +window.cancelClickToMove = () => { + playerPath = []; + playerPathIndex = 0; + playerFollowingPath = false; + playerFinalGoal = null; + ++playerPathRequestId; // invalidate any pending EasyStar callbacks + isMoving = false; + targetPoint = null; +}; + /** * Turn the player to face a world position, updating direction and idle animation. * Call this before triggering a click-based interaction so the player visually diff --git a/public/break_escape/js/systems/collision.js b/public/break_escape/js/systems/collision.js index 4136ba4..494c8a2 100644 --- a/public/break_escape/js/systems/collision.js +++ b/public/break_escape/js/systems/collision.js @@ -14,7 +14,7 @@ let rooms = null; // Teleportation cooldown system to prevent rapid back-and-forth let lastTeleportTime = 0; -const TELEPORT_COOLDOWN = 500; // 500ms cooldown between teleports +const TELEPORT_COOLDOWN = 1500; // 1.5s — long enough that a path cannot loop back // Initialize collision system export function initializeCollision(gameInstance, roomsRef) { @@ -361,6 +361,9 @@ export function removeTilesUnderDoor(wallLayer, roomId, position) { player.x = doorX - offset; } lastTeleportTime = currentTime; + // Cancel any active click-to-move path — prevents it + // from immediately re-crossing the door on the way back. + window.cancelClickToMove?.(); console.log(`Teleported player through door void (from ${roomId}) to x=${player.x}`); } } @@ -666,6 +669,9 @@ export function removeWallTilesForDoorInRoom(roomId, fromRoomId, direction, door player.x = doorX + offset; } lastTeleportTime = currentTime; + // Cancel any active click-to-move path — prevents it + // from immediately re-crossing the door on the way back. + window.cancelClickToMove?.(); console.log(`Teleported player through door void to x=${player.x}`); } }