cleaner approach to disable activatablesManager distance check if space-event

This commit is contained in:
Hanusiak Piotr 2022-02-07 14:22:43 +01:00
parent 81272fbb3c
commit d480150728
5 changed files with 15 additions and 5 deletions

View file

@ -9,4 +9,7 @@ export interface UserInputHandlerInterface {
handlePointerUpEvent: (pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[]) => void;
handlePointerDownEvent: (pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[]) => void;
handleSpaceKeyUpEvent: (event: Event) => Event;
addSpaceEventListener: (callback: Function) => void;
removeSpaceEventListner: (callback: Function) => void;
}

View file

@ -957,11 +957,9 @@ export class GameScene extends DirtyScene {
this.gameMap.onPropertyChange(GameMapProperties.JITSI_ROOM, (newValue, oldValue, allProps) => {
if (newValue === undefined) {
this.activatablesManager.enableSelectingByDistance();
layoutManagerActionStore.removeAction("jitsi");
this.stopJitsi();
} else {
this.activatablesManager.disableSelectingByDistance();
const openJitsiRoomFunction = () => {
const roomName = jitsiFactory.getRoomName(newValue.toString(), this.instance);
const jitsiUrl = allProps.get(GameMapProperties.JITSI_URL) as string | undefined;
@ -972,7 +970,6 @@ export class GameScene extends DirtyScene {
} else {
this.startJitsi(roomName, undefined);
}
this.activatablesManager.enableSelectingByDistance();
layoutManagerActionStore.removeAction("jitsi");
};

View file

@ -60,4 +60,13 @@ export class GameSceneUserInputHandler implements UserInputHandlerInterface {
}
return event;
}
public addSpaceEventListener(callback: Function): void {
this.gameScene.input.keyboard.addListener("keyup-SPACE", callback);
this.gameScene.getActivatablesManager().disableSelectingByDistance();
}
public removeSpaceEventListner(callback: Function): void {
this.gameScene.input.keyboard.removeListener("keyup-SPACE", callback);
this.gameScene.getActivatablesManager().enableSelectingByDistance();
}
}

View file

@ -223,10 +223,10 @@ export class UserInputManager {
}
addSpaceEventListner(callback: Function) {
this.scene.input.keyboard.addListener("keyup-SPACE", callback);
this.userInputHandler.addSpaceEventListener(callback);
}
removeSpaceEventListner(callback: Function) {
this.scene.input.keyboard.removeListener("keyup-SPACE", callback);
this.userInputHandler.removeSpaceEventListner(callback);
}
destroy(): void {

View file

@ -1,4 +1,5 @@
import { derived, writable } from "svelte/store";
import type { ActivatablesManager } from "../Phaser/Game/ActivatablesManager";
import type { UserInputManager } from "../Phaser/UserInput/UserInputManager";
export interface LayoutManagerAction {