disable activation by distance if in JITSI
This commit is contained in:
parent
bf0d2eb412
commit
aec7790875
@ -11,6 +11,8 @@ export class ActivatablesManager {
|
||||
|
||||
private currentPlayer: Player;
|
||||
|
||||
private canSelectByDistance: boolean = true;
|
||||
|
||||
private readonly outlineColor = 0xffff00;
|
||||
private readonly directionalActivationPositionShift = 50;
|
||||
|
||||
@ -49,6 +51,9 @@ export class ActivatablesManager {
|
||||
}
|
||||
|
||||
public deduceSelectedActivatableObjectByDistance(): void {
|
||||
if (!this.canSelectByDistance) {
|
||||
return;
|
||||
}
|
||||
const newNearestObject = this.findNearestActivatableObject();
|
||||
if (this.selectedActivatableObjectByDistance === newNearestObject) {
|
||||
return;
|
||||
@ -67,18 +72,6 @@ export class ActivatablesManager {
|
||||
}
|
||||
}
|
||||
|
||||
private findNearestActivatableObject(): ActivatableInterface | undefined {
|
||||
let shortestDistance: number = Infinity;
|
||||
let closestObject: ActivatableInterface | undefined = undefined;
|
||||
|
||||
for (const [object, distance] of this.activatableObjectsDistances.entries()) {
|
||||
if (object.isActivatable() && object.activationRadius > distance && shortestDistance > distance) {
|
||||
shortestDistance = distance;
|
||||
closestObject = object;
|
||||
}
|
||||
}
|
||||
return closestObject;
|
||||
}
|
||||
public updateActivatableObjectsDistances(objects: ActivatableInterface[]): void {
|
||||
const currentPlayerPos = this.currentPlayer.getDirectionalActivationPosition(this.directionalActivationPositionShift);
|
||||
for (const object of objects) {
|
||||
@ -96,4 +89,33 @@ export class ActivatablesManager {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public disableSelectingByDistance(): void {
|
||||
this.canSelectByDistance = false;
|
||||
if (isOutlineable(this.selectedActivatableObjectByDistance)) {
|
||||
this.selectedActivatableObjectByDistance?.characterFarAwayOutline();
|
||||
}
|
||||
this.selectedActivatableObjectByDistance = undefined;
|
||||
}
|
||||
|
||||
public enableSelectingByDistance(): void {
|
||||
this.canSelectByDistance = true;
|
||||
}
|
||||
|
||||
private findNearestActivatableObject(): ActivatableInterface | undefined {
|
||||
let shortestDistance: number = Infinity;
|
||||
let closestObject: ActivatableInterface | undefined = undefined;
|
||||
|
||||
for (const [object, distance] of this.activatableObjectsDistances.entries()) {
|
||||
if (object.isActivatable() && object.activationRadius > distance && shortestDistance > distance) {
|
||||
shortestDistance = distance;
|
||||
closestObject = object;
|
||||
}
|
||||
}
|
||||
return closestObject;
|
||||
}
|
||||
|
||||
public isSelectingByDistanceEnabled(): boolean {
|
||||
return this.canSelectByDistance;
|
||||
}
|
||||
}
|
||||
|
@ -957,9 +957,11 @@ 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;
|
||||
|
@ -53,8 +53,9 @@ export class GameSceneUserInputHandler implements UserInputHandlerInterface {
|
||||
public handlePointerDownEvent(pointer: Phaser.Input.Pointer, gameObjects: Phaser.GameObjects.GameObject[]): void {}
|
||||
|
||||
public handleSpaceKeyUpEvent(event: Event): Event {
|
||||
const activatable = this.gameScene.getActivatablesManager().getSelectedActivatableObject();
|
||||
if (activatable && activatable.isActivatable()) {
|
||||
const activatableManager = this.gameScene.getActivatablesManager();
|
||||
const activatable = activatableManager.getSelectedActivatableObject();
|
||||
if (activatable && activatable.isActivatable() && activatableManager.isSelectingByDistanceEnabled()) {
|
||||
activatable.activate();
|
||||
}
|
||||
return event;
|
||||
|
@ -10,8 +10,6 @@ export function createColorStore() {
|
||||
|
||||
|
||||
const updateColor = () => {
|
||||
console.log('update color');
|
||||
console.log(pointedByPointer, pointedByCharacter, followColor, apiColor);
|
||||
set(pointedByPointer ?? pointedByCharacter ?? followColor ?? apiColor);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user