diff --git a/src/objects/furniture/BaseFurniture.tsx b/src/objects/furniture/BaseFurniture.tsx index e34bba71..ef5707af 100644 --- a/src/objects/furniture/BaseFurniture.tsx +++ b/src/objects/furniture/BaseFurniture.tsx @@ -603,19 +603,20 @@ export class BaseFurniture implements IFurnitureEventHandlers { group: this, }); - if (layer?.ignoreMouse !== true) { - sprite.addEventListener("click", (event) => - this._clickHandler.handleClick(event) - ); + const ignoreMouse = layer?.ignoreMouse != null && layer.ignoreMouse; + sprite.ignoreMouse = ignoreMouse; - sprite.addEventListener("pointerup", (event) => { - this._clickHandler.handlePointerUp(event); - }); + sprite.addEventListener("click", (event) => { + this._clickHandler.handleClick(event); + }); - sprite.addEventListener("pointerdown", (event) => { - this._clickHandler.handlePointerDown(event); - }); - } + sprite.addEventListener("pointerup", (event) => { + this._clickHandler.handlePointerUp(event); + }); + + sprite.addEventListener("pointerdown", (event) => { + this._clickHandler.handlePointerDown(event); + }); sprite.hitTexture = texture; diff --git a/src/objects/furniture/visualization/AnimatedFurnitureVisualization.ts b/src/objects/furniture/visualization/AnimatedFurnitureVisualization.ts index 64eabdad..b85fa0a9 100644 --- a/src/objects/furniture/visualization/AnimatedFurnitureVisualization.ts +++ b/src/objects/furniture/visualization/AnimatedFurnitureVisualization.ts @@ -64,9 +64,7 @@ export class AnimatedFurnitureVisualization extends FurnitureVisualization { this._disableTransitions = this._changeAnimationCount === 0; this._changeAnimationCount++; - if (!this.isAnimated(newAnimation.toString())) { - this.updateFrame(0); - } + this._update(); } updateAnimation(animation: string): void { diff --git a/src/objects/hitdetection/ClickHandler.ts b/src/objects/hitdetection/ClickHandler.ts index 4ee20e35..40c247ef 100644 --- a/src/objects/hitdetection/ClickHandler.ts +++ b/src/objects/hitdetection/ClickHandler.ts @@ -69,7 +69,6 @@ export class ClickHandler { private _performDoubleClick(event: HitEvent) { if (this._doubleClickInfo == null) return; - if (event.target !== this._doubleClickInfo.initialEvent.target) return; this.onDoubleClick && this.onDoubleClick(this._doubleClickInfo.initialEvent); diff --git a/src/objects/hitdetection/HitSprite.ts b/src/objects/hitdetection/HitSprite.ts index 2a30771b..40e39a97 100644 --- a/src/objects/hitdetection/HitSprite.ts +++ b/src/objects/hitdetection/HitSprite.ts @@ -21,6 +21,15 @@ export class HitSprite extends PIXI.Sprite implements HitDetectionElement { private _mirrored: boolean; private _mirrorNotVisually: boolean; private _ignore = false; + private _ignoreMouse = false; + + private _getHitmap: + | (() => ( + x: number, + y: number, + transform: { x: number; y: number } + ) => boolean) + | undefined; constructor({ hitDetection, @@ -51,6 +60,14 @@ export class HitSprite extends PIXI.Sprite implements HitDetectionElement { this.mirrored = this._mirrored; } + public get ignoreMouse() { + return this._ignoreMouse; + } + + public set ignoreMouse(value) { + this._ignoreMouse = value; + } + public get group() { return this._group; } @@ -72,14 +89,6 @@ export class HitSprite extends PIXI.Sprite implements HitDetectionElement { this.scale.x = this._mirrored ? -1 : 1; } - private _getHitmap: - | (() => ( - x: number, - y: number, - transform: { x: number; y: number } - ) => boolean) - | undefined; - public get hitTexture() { return this._hitTexture; } @@ -110,6 +119,10 @@ export class HitSprite extends PIXI.Sprite implements HitDetectionElement { handlers?.forEach((handler) => handler(event)); } + removeAllEventListeners() { + this._handlers = new Map(); + } + addEventListener(type: HitEventType, handler: HitEventHandler) { const existingHandlers = this._handlers.get(type) ?? new Set(); existingHandlers.add(handler); @@ -151,6 +164,7 @@ export class HitSprite extends PIXI.Sprite implements HitDetectionElement { hits(x: number, y: number): boolean { if (this._getHitmap == null) return false; if (this.ignore) return false; + if (this.ignoreMouse) return false; const hitBox = this.getHitBox(); diff --git a/storybook/stories/Furniture.stories.ts b/storybook/stories/Furniture.stories.ts index 71b9b58d..a4614130 100644 --- a/storybook/stories/Furniture.stories.ts +++ b/storybook/stories/Furniture.stories.ts @@ -472,6 +472,7 @@ export function GldGate() { floorFurniture3.onClick = () => { b = !b; + console.log("CHANGE"); if (b) { floorFurniture3.animation = "1";