ran prettier
This commit is contained in:
parent
0eaeaf7cfb
commit
45a7e9331b
13 changed files with 62 additions and 77 deletions
|
@ -15,7 +15,7 @@ import { TexturesHelper } from "../Helpers/TexturesHelper";
|
|||
import type { PictureStore } from "../../Stores/PictureStore";
|
||||
import { Unsubscriber, Writable, writable } from "svelte/store";
|
||||
import { createColorStore } from "../../Stores/OutlineColorStore";
|
||||
import type { OutlineableInterface } from '../Game/OutlineableInterface';
|
||||
import type { OutlineableInterface } from "../Game/OutlineableInterface";
|
||||
import type CancelablePromise from "cancelable-promise";
|
||||
|
||||
const playerNameY = -25;
|
||||
|
@ -155,7 +155,7 @@ export abstract class Character extends Container implements OutlineableInterfac
|
|||
return this.clickable;
|
||||
}
|
||||
|
||||
public getPosition(): { x: number, y: number } {
|
||||
public getPosition(): { x: number; y: number } {
|
||||
return { x: this.x, y: this.y };
|
||||
}
|
||||
|
||||
|
|
|
@ -1,23 +1,21 @@
|
|||
|
||||
import { requestVisitCardsStore } from "../../Stores/GameStore";
|
||||
import { ActionsMenuData, actionsMenuStore } from '../../Stores/ActionsMenuStore';
|
||||
import { ActionsMenuData, actionsMenuStore } from "../../Stores/ActionsMenuStore";
|
||||
import { Character } from "../Entity/Character";
|
||||
import type { GameScene } from "../Game/GameScene";
|
||||
import type { PointInterface } from "../../Connexion/ConnexionModels";
|
||||
import type { PlayerAnimationDirections } from "../Player/Animation";
|
||||
import type { Unsubscriber } from 'svelte/store';
|
||||
import type { ActivatableInterface } from '../Game/ActivatableInterface';
|
||||
import type { Unsubscriber } from "svelte/store";
|
||||
import type { ActivatableInterface } from "../Game/ActivatableInterface";
|
||||
import type CancelablePromise from "cancelable-promise";
|
||||
|
||||
/**
|
||||
* Class representing the sprite of a remote player (a player that plays on another computer)
|
||||
*/
|
||||
export class RemotePlayer extends Character implements ActivatableInterface {
|
||||
|
||||
public userId: number;
|
||||
public readonly activationRadius: number;
|
||||
|
||||
private registeredActions: { actionName: string, callback: Function }[];
|
||||
|
||||
private registeredActions: { actionName: string; callback: Function }[];
|
||||
private visitCardUrl: string | null;
|
||||
private isActionsMenuInitialized: boolean = false;
|
||||
private actionsMenuStoreUnsubscriber: Unsubscriber;
|
||||
|
@ -34,21 +32,9 @@ export class RemotePlayer extends Character implements ActivatableInterface {
|
|||
visitCardUrl: string | null,
|
||||
companion: string | null,
|
||||
companionTexturePromise?: Promise<string>,
|
||||
activationRadius?: number,
|
||||
activationRadius?: number
|
||||
) {
|
||||
super(
|
||||
Scene,
|
||||
x,
|
||||
y,
|
||||
texturesPromise,
|
||||
name,
|
||||
direction,
|
||||
moving,
|
||||
1,
|
||||
true,
|
||||
companion,
|
||||
companionTexturePromise
|
||||
);
|
||||
super(Scene, x, y, texturesPromise, name, direction, moving, 1, true, companion, companionTexturePromise);
|
||||
|
||||
//set data
|
||||
this.userId = userId;
|
||||
|
@ -76,13 +62,13 @@ export class RemotePlayer extends Character implements ActivatableInterface {
|
|||
}
|
||||
}
|
||||
|
||||
public registerActionsMenuAction(action: { actionName: string, callback: Function }): void {
|
||||
public registerActionsMenuAction(action: { actionName: string; callback: Function }): void {
|
||||
this.registeredActions.push(action);
|
||||
this.updateIsClickable();
|
||||
}
|
||||
|
||||
public unregisterActionsMenuAction(actionName: string) {
|
||||
const index = this.registeredActions.findIndex(action => action.actionName === actionName);
|
||||
const index = this.registeredActions.findIndex((action) => action.actionName === actionName);
|
||||
if (index !== -1) {
|
||||
this.registeredActions.splice(index, 1);
|
||||
}
|
||||
|
@ -125,7 +111,7 @@ export class RemotePlayer extends Character implements ActivatableInterface {
|
|||
callback: () => {
|
||||
requestVisitCardsStore.set(this.visitCardUrl);
|
||||
actionsMenuStore.clear();
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
|
||||
export interface ActivatableInterface {
|
||||
readonly activationRadius: number;
|
||||
isActivatable: () => boolean;
|
||||
activate: () => void;
|
||||
getPosition: () => { x: number, y: number };
|
||||
getPosition: () => { x: number; y: number };
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
import Sprite = Phaser.GameObjects.Sprite;
|
||||
import type { GameScene } from "../Game/GameScene";
|
||||
import type OutlinePipelinePlugin from "phaser3-rex-plugins/plugins/outlinepipeline-plugin.js";
|
||||
import type { ActivatableInterface } from '../Game/ActivatableInterface';
|
||||
import type { ActivatableInterface } from "../Game/ActivatableInterface";
|
||||
|
||||
type EventCallback = (state: unknown, parameters: unknown) => void;
|
||||
|
||||
export class ActionableItem implements ActivatableInterface{
|
||||
export class ActionableItem implements ActivatableInterface {
|
||||
private readonly activationRadiusSquared: number;
|
||||
private isSelectable: boolean = false;
|
||||
private callbacks: Map<string, Array<EventCallback>> = new Map<string, Array<EventCallback>>();
|
||||
|
@ -41,7 +41,7 @@ export class ActionableItem implements ActivatableInterface{
|
|||
}
|
||||
}
|
||||
|
||||
public getPosition(): { x: number, y: number } {
|
||||
public getPosition(): { x: number; y: number } {
|
||||
return { x: this.sprite.x, y: this.sprite.y };
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Player } from '../Player/Player';
|
||||
import { RemotePlayer } from '../Entity/RemotePlayer';
|
||||
import { Player } from "../Player/Player";
|
||||
import { RemotePlayer } from "../Entity/RemotePlayer";
|
||||
|
||||
import type { UserInputHandlerInterface } from "../../Interfaces/UserInputHandlerInterface";
|
||||
import type { GameScene } from "../Game/GameScene";
|
||||
|
@ -55,7 +55,7 @@ export class GameSceneUserInputHandler implements UserInputHandlerInterface {
|
|||
public handleSpaceKeyUpEvent(event: Event): Event {
|
||||
const activatable = this.gameScene.getActivatablesManager().getSelectedActivatableObject();
|
||||
if (activatable && activatable.isActivatable()) {
|
||||
activatable.activate();
|
||||
activatable.activate();
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue