ran prettier

This commit is contained in:
Hanusiak Piotr 2022-02-02 13:30:49 +01:00
parent 0eaeaf7cfb
commit 45a7e9331b
13 changed files with 62 additions and 77 deletions

View file

@ -1,7 +1,6 @@
export interface ActivatableInterface {
readonly activationRadius: number;
isActivatable: () => boolean;
activate: () => void;
getPosition: () => { x: number, y: number };
getPosition: () => { x: number; y: number };
}

View file

@ -1,17 +1,16 @@
import { isOutlineable } from '../../Utils/CustomTypeGuards';
import { MathUtils } from '../../Utils/MathUtils';
import type { Player } from '../Player/Player';
import type { ActivatableInterface } from './ActivatableInterface';
import { isOutlineable } from "../../Utils/CustomTypeGuards";
import { MathUtils } from "../../Utils/MathUtils";
import type { Player } from "../Player/Player";
import type { ActivatableInterface } from "./ActivatableInterface";
export class ActivatablesManager {
// The item that can be selected by pressing the space key.
private selectedActivatableObjectByDistance?: ActivatableInterface;
private selectedActivatableObjectByPointer?: ActivatableInterface;
private activatableObjectsDistances: Map<ActivatableInterface, number> = new Map<ActivatableInterface, number>();
private currentPlayer: Player;
constructor(currentPlayer: Player) {
this.currentPlayer = currentPlayer;
}
@ -54,7 +53,7 @@ export class ActivatablesManager {
// update value but do not change the outline
if (this.selectedActivatableObjectByPointer) {
this.selectedActivatableObjectByDistance = newNearestObject;
return;
return;
}
if (isOutlineable(this.selectedActivatableObjectByDistance)) {
this.selectedActivatableObjectByDistance?.characterFarAwayOutline();
@ -88,7 +87,7 @@ export class ActivatablesManager {
public updateDistanceForSingleActivatableObject(object: ActivatableInterface): void {
this.activatableObjectsDistances.set(
object,
MathUtils.distanceBetween(this.currentPlayer.getPosition(), object.getPosition()),
MathUtils.distanceBetween(this.currentPlayer.getPosition(), object.getPosition())
);
}
}

View file

@ -49,7 +49,7 @@ import { GameMapPropertiesListener } from "./GameMapPropertiesListener";
import { analyticsClient } from "../../Administration/AnalyticsClient";
import { GameMapProperties } from "./GameMapProperties";
import { PathfindingManager } from "../../Utils/PathfindingManager";
import { ActivatablesManager } from './ActivatablesManager';
import { ActivatablesManager } from "./ActivatablesManager";
import type {
GroupCreatedUpdatedMessageInterface,
MessageUserMovedInterface,
@ -805,10 +805,9 @@ export class GameScene extends DirtyScene {
this.simplePeer = new SimplePeer(this.connection);
userMessageManager.setReceiveBanListener(this.bannedUser.bind(this));
this.CurrentPlayer.on(
hasMovedEventName,
(event: HasPlayerMovedEvent) => { this.handleCurrentPlayerHasMovedEvent(event); },
);
this.CurrentPlayer.on(hasMovedEventName, (event: HasPlayerMovedEvent) => {
this.handleCurrentPlayerHasMovedEvent(event);
});
// Set up variables manager
this.sharedVariablesManager = new SharedVariablesManager(
@ -1685,7 +1684,10 @@ ${escapedMessage}
//listen event to share position of user
this.pushPlayerPosition(event);
this.gameMap.setPosition(event.x, event.y);
this.activatablesManager.updateActivatableObjectsDistances([...Array.from(this.MapPlayersByKey.values()), ...this.actionableItems.values()]);
this.activatablesManager.updateActivatableObjectsDistances([
...Array.from(this.MapPlayersByKey.values()),
...this.actionableItems.values(),
]);
this.activatablesManager.deduceSelectedActivatableObjectByDistance();
}

View file

@ -1,11 +1,10 @@
export interface OutlineableInterface {
setFollowOutlineColor(color: number): void
removeFollowOutlineColor(): void
setApiOutlineColor(color: number): void
removeApiOutlineColor(): void
pointerOverOutline(): void
pointerOutOutline(): void
characterCloseByOutline(): void
characterFarAwayOutline(): void
setFollowOutlineColor(color: number): void;
removeFollowOutlineColor(): void;
setApiOutlineColor(color: number): void;
removeApiOutlineColor(): void;
pointerOverOutline(): void;
pointerOutOutline(): void;
characterCloseByOutline(): void;
characterFarAwayOutline(): void;
}