diff --git a/public/break_escape/js/systems/doors.js b/public/break_escape/js/systems/doors.js index f1fed17..0b10fca 100644 --- a/public/break_escape/js/systems/doors.js +++ b/public/break_escape/js/systems/doors.js @@ -636,6 +636,23 @@ function openDoor(doorSprite) { // Create animated door sprite on the opposite side createAnimatedDoorOnOppositeSide(props.connectedRoom, props.roomId, props.direction, doorSprite.x, doorSprite.y); + // Mark door as inactive immediately to prevent interaction checks from processing it + doorSprite.setActive(false); + + // Clean up interaction indicator before destroying the sprite + if (doorSprite.interactionIndicator) { + // Stop any animations on the indicator first + if (doorSprite.interactionIndicator.anims && doorSprite.interactionIndicator.anims.isPlaying) { + doorSprite.interactionIndicator.anims.stop(); + } + // Stop any tweens on the indicator + if (doorSprite.scene && doorSprite.scene.tweens) { + doorSprite.scene.tweens.killTweensOf(doorSprite.interactionIndicator); + } + doorSprite.interactionIndicator.destroy(); + delete doorSprite.interactionIndicator; + } + // Remove the door sprite doorSprite.destroy(); if (doorSprite.interactionZone) { diff --git a/public/break_escape/js/systems/interactions.js b/public/break_escape/js/systems/interactions.js index 0a1fa19..7a115f3 100644 --- a/public/break_escape/js/systems/interactions.js +++ b/public/break_escape/js/systems/interactions.js @@ -192,12 +192,14 @@ export function checkObjectInteractions() { // Also check door sprites if (room.doorSprites) { Object.values(room.doorSprites).forEach(door => { - // Skip inactive or non-locked doors - if (!door.active || !door.doorProperties || !door.doorProperties.locked) { + // Skip if door is destroyed, inactive, or not a valid door sprite + if (!door || door.scene === null || !door.active || !door.doorProperties || !door.doorProperties.locked) { // Clear highlight if door was previously highlighted - if (door.isHighlighted) { + if (door && door.isHighlighted) { door.isHighlighted = false; - door.clearTint(); + if (door.clearTint && typeof door.clearTint === 'function') { + door.clearTint(); + } // Clean up interaction sprite if exists if (door.interactionIndicator) { door.interactionIndicator.destroy(); diff --git a/public/break_escape/js/systems/unlock-system.js b/public/break_escape/js/systems/unlock-system.js index f9d59a0..625e307 100644 --- a/public/break_escape/js/systems/unlock-system.js +++ b/public/break_escape/js/systems/unlock-system.js @@ -572,6 +572,16 @@ export function unlockTarget(lockable, type, layer, serverResponse) { if (lockable.scenarioData.contents) { lockable.scenarioData.isUnlockedButNotCollected = true; + // Clear the interaction indicator immediately since this is now unlocked + if (lockable.interactionIndicator) { + // Stop any tweens on the indicator first + if (lockable.scene && lockable.scene.tweens) { + lockable.scene.tweens.killTweensOf(lockable.interactionIndicator); + } + lockable.interactionIndicator.destroy(); + delete lockable.interactionIndicator; + } + // Emit item unlocked event if (window.eventDispatcher) { window.eventDispatcher.emit('item_unlocked', { @@ -596,6 +606,16 @@ export function unlockTarget(lockable, type, layer, serverResponse) { if (lockable.contents) { lockable.isUnlockedButNotCollected = true; + // Clear the interaction indicator immediately since this is now unlocked + if (lockable.interactionIndicator) { + // Stop any tweens on the indicator first + if (lockable.scene && lockable.scene.tweens) { + lockable.scene.tweens.killTweensOf(lockable.interactionIndicator); + } + lockable.interactionIndicator.destroy(); + delete lockable.interactionIndicator; + } + // Emit item unlocked event if (window.eventDispatcher) { window.eventDispatcher.emit('item_unlocked', {