mirror of
https://github.com/cliffe/BreakEscape.git
synced 2026-02-20 13:50:46 +00:00
Improve door and unlock interaction handling: deactivate door sprites immediately upon opening, clean up interaction indicators, and ensure proper checks for inactive or destroyed doors.
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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', {
|
||||
|
||||
Reference in New Issue
Block a user