FEATURE: clicking on another player show a contact card when possible
This commit is contained in:
parent
fffd36267d
commit
c5f3cfe87c
14 changed files with 183 additions and 9 deletions
|
@ -3,6 +3,8 @@ import type {PointInterface} from "../../Connexion/ConnexionModels";
|
|||
import {Character} from "../Entity/Character";
|
||||
import type {PlayerAnimationDirections} from "../Player/Animation";
|
||||
|
||||
export const playerClickedEvent = 'playerClickedEvent';
|
||||
|
||||
/**
|
||||
* Class representing the sprite of a remote player (a player that plays on another computer)
|
||||
*/
|
||||
|
@ -25,6 +27,10 @@ export class RemotePlayer extends Character {
|
|||
|
||||
//set data
|
||||
this.userId = userId;
|
||||
|
||||
this.on('pointerdown', () => {
|
||||
this.emit(playerClickedEvent, this.userId);
|
||||
})
|
||||
}
|
||||
|
||||
updatePosition(position: PointInterface): void {
|
||||
|
@ -40,6 +46,6 @@ export class RemotePlayer extends Character {
|
|||
}
|
||||
|
||||
isClickable(): boolean {
|
||||
return false; //todo: make remote players clickable if they are logged in.
|
||||
return true; //todo: make remote players clickable if they are logged in.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import type {AddPlayerInterface} from "./AddPlayerInterface";
|
|||
import {PlayerAnimationDirections} from "../Player/Animation";
|
||||
import {PlayerMovement} from "./PlayerMovement";
|
||||
import {PlayersPositionInterpolator} from "./PlayersPositionInterpolator";
|
||||
import {RemotePlayer} from "../Entity/RemotePlayer";
|
||||
import {playerClickedEvent, RemotePlayer} from "../Entity/RemotePlayer";
|
||||
import {Queue} from 'queue-typescript';
|
||||
import {SimplePeer, UserSimplePeerInterface} from "../../WebRtc/SimplePeer";
|
||||
import {ReconnectingSceneName} from "../Reconnecting/ReconnectingScene";
|
||||
|
@ -1379,6 +1379,9 @@ ${escapedMessage}
|
|||
addPlayerData.companion,
|
||||
addPlayerData.companion !== null ? lazyLoadCompanionResource(this.load, addPlayerData.companion) : undefined
|
||||
);
|
||||
player.on(playerClickedEvent, (userID:number) => {
|
||||
this.connection?.requestVisitCardUrl(userID);
|
||||
})
|
||||
this.MapPlayers.add(player);
|
||||
this.MapPlayersByKey.set(player.userId, player);
|
||||
player.updatePosition(addPlayerData.position);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue