change away to availability status
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { SignalData } from "simple-peer";
|
||||
import type { RoomConnection } from "./RoomConnection";
|
||||
import type { BodyResourceDescriptionInterface } from "../Phaser/Entity/PlayerTextures";
|
||||
import { AvailabilityStatus } from "../Messages/ts-proto-generated/protos/messages";
|
||||
|
||||
export interface PointInterface {
|
||||
x: number;
|
||||
@@ -14,7 +15,7 @@ export interface MessageUserPositionInterface {
|
||||
name: string;
|
||||
characterLayers: BodyResourceDescriptionInterface[];
|
||||
position: PointInterface;
|
||||
away: boolean;
|
||||
status: AvailabilityStatus;
|
||||
visitCardUrl: string | null;
|
||||
companion: string | null;
|
||||
userUuid: string;
|
||||
@@ -30,7 +31,7 @@ export interface MessageUserJoined {
|
||||
name: string;
|
||||
characterLayers: BodyResourceDescriptionInterface[];
|
||||
position: PointInterface;
|
||||
away: boolean;
|
||||
status: AvailabilityStatus;
|
||||
visitCardUrl: string | null;
|
||||
companion: string | null;
|
||||
userUuid: string;
|
||||
|
||||
@@ -41,6 +41,7 @@ import {
|
||||
SetPlayerDetailsMessage as SetPlayerDetailsMessageTsProto,
|
||||
PingMessage as PingMessageTsProto,
|
||||
CharacterLayerMessage,
|
||||
AvailabilityStatus,
|
||||
} from "../Messages/ts-proto-generated/protos/messages";
|
||||
import { Subject } from "rxjs";
|
||||
import { selectCharacterSceneVisibleStore } from "../Stores/SelectCharacterStore";
|
||||
@@ -520,9 +521,9 @@ export class RoomConnection implements RoomConnection {
|
||||
this.socket.send(bytes);
|
||||
}
|
||||
|
||||
public emitPlayerAway(away: boolean): void {
|
||||
public emitPlayerStatusChange(status: AvailabilityStatus): void {
|
||||
const message = SetPlayerDetailsMessageTsProto.fromPartial({
|
||||
away,
|
||||
status,
|
||||
});
|
||||
const bytes = ClientToServerMessageTsProto.encode({
|
||||
message: {
|
||||
@@ -670,7 +671,7 @@ export class RoomConnection implements RoomConnection {
|
||||
characterLayers,
|
||||
visitCardUrl: message.visitCardUrl,
|
||||
position: ProtobufClientUtils.toPointInterface(position),
|
||||
away: message.away,
|
||||
status: message.status,
|
||||
companion: companion ? companion.name : null,
|
||||
userUuid: message.userUuid,
|
||||
outlineColor: message.hasOutline ? message.outlineColor : undefined,
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
import { AvailabilityStatus } from "../../Messages/ts-proto-generated/protos/messages";
|
||||
import { Easing } from "../../types";
|
||||
|
||||
export enum PlayerStatus {
|
||||
Online = "Online",
|
||||
Silenced = "Silenced",
|
||||
Away = "Away",
|
||||
}
|
||||
|
||||
export class PlayerStatusDot extends Phaser.GameObjects.Container {
|
||||
private statusImage: Phaser.GameObjects.Image;
|
||||
private statusImageOutline: Phaser.GameObjects.Image;
|
||||
|
||||
private status: PlayerStatus;
|
||||
private status: AvailabilityStatus;
|
||||
|
||||
private readonly COLORS = {
|
||||
online: 0x8cc43f,
|
||||
@@ -19,12 +14,13 @@ export class PlayerStatusDot extends Phaser.GameObjects.Container {
|
||||
awayOutline: 0x875d13,
|
||||
silenced: 0xe74c3c,
|
||||
silencedOutline: 0xc0392b,
|
||||
never: 0xff00ff,
|
||||
};
|
||||
|
||||
constructor(scene: Phaser.Scene, x: number, y: number) {
|
||||
super(scene, x, y);
|
||||
|
||||
this.status = PlayerStatus.Online;
|
||||
this.status = AvailabilityStatus.ONLINE;
|
||||
|
||||
this.statusImage = this.scene.add.image(0, 0, "iconStatusIndicatorInside");
|
||||
this.statusImageOutline = this.scene.add.image(0, 0, "iconStatusIndicatorOutline");
|
||||
@@ -36,7 +32,7 @@ export class PlayerStatusDot extends Phaser.GameObjects.Container {
|
||||
this.scene.add.existing(this);
|
||||
}
|
||||
|
||||
public setStatus(status: PlayerStatus, instant: boolean = false): void {
|
||||
public setStatus(status: AvailabilityStatus, instant: boolean = false): void {
|
||||
if (this.status === status) {
|
||||
return;
|
||||
}
|
||||
@@ -73,12 +69,14 @@ export class PlayerStatusDot extends Phaser.GameObjects.Container {
|
||||
|
||||
private getColors(): { filling: number; outline: number } {
|
||||
switch (this.status) {
|
||||
case PlayerStatus.Online:
|
||||
case AvailabilityStatus.ONLINE:
|
||||
return { filling: this.COLORS.online, outline: this.COLORS.onlineOutline };
|
||||
case PlayerStatus.Away:
|
||||
case AvailabilityStatus.AWAY:
|
||||
return { filling: this.COLORS.away, outline: this.COLORS.awayOutline };
|
||||
case PlayerStatus.Silenced:
|
||||
case AvailabilityStatus.SILENCED:
|
||||
return { filling: this.COLORS.silenced, outline: this.COLORS.silencedOutline };
|
||||
default:
|
||||
return { filling: this.COLORS.never, outline: this.COLORS.never };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,9 +100,8 @@ import type { CoWebsite } from "../../WebRtc/CoWebsite/CoWesbite";
|
||||
import CancelablePromise from "cancelable-promise";
|
||||
import { Deferred } from "ts-deferred";
|
||||
import { SuperLoaderPlugin } from "../Services/SuperLoaderPlugin";
|
||||
import { PlayerDetailsUpdatedMessage } from "../../Messages/ts-proto-generated/protos/messages";
|
||||
import { AvailabilityStatus, PlayerDetailsUpdatedMessage } from "../../Messages/ts-proto-generated/protos/messages";
|
||||
import { privacyShutdownStore } from "../../Stores/PrivacyShutdownStore";
|
||||
import { PlayerStatus } from "../Components/PlayerStatusDot";
|
||||
export interface GameSceneInitInterface {
|
||||
initPosition: PointInterface | null;
|
||||
reconnecting: boolean;
|
||||
@@ -710,7 +709,8 @@ export class GameScene extends DirtyScene {
|
||||
});
|
||||
|
||||
this.privacyShutdownStoreUnsubscribe = privacyShutdownStore.subscribe((away) => {
|
||||
this.connection?.emitPlayerAway(away);
|
||||
// TODO: Might be a problem with SILENCED here
|
||||
this.connection?.emitPlayerStatusChange(away ? AvailabilityStatus.AWAY : AvailabilityStatus.ONLINE);
|
||||
});
|
||||
|
||||
Promise.all([
|
||||
@@ -771,7 +771,7 @@ export class GameScene extends DirtyScene {
|
||||
characterLayers: message.characterLayers,
|
||||
name: message.name,
|
||||
position: message.position,
|
||||
away: message.away,
|
||||
status: message.status,
|
||||
visitCardUrl: message.visitCardUrl,
|
||||
companion: message.companion,
|
||||
userUuid: message.userUuid,
|
||||
@@ -1956,8 +1956,8 @@ ${escapedMessage}
|
||||
if (addPlayerData.outlineColor !== undefined) {
|
||||
player.setApiOutlineColor(addPlayerData.outlineColor);
|
||||
}
|
||||
if (addPlayerData.away !== undefined) {
|
||||
player.setStatus(addPlayerData.away ? PlayerStatus.Away : PlayerStatus.Online, true);
|
||||
if (addPlayerData.status !== undefined) {
|
||||
player.setStatus(addPlayerData.status, true);
|
||||
}
|
||||
this.MapPlayers.add(player);
|
||||
this.MapPlayersByKey.set(player.userId, player);
|
||||
@@ -2108,8 +2108,8 @@ ${escapedMessage}
|
||||
if (message.details?.showVoiceIndicator !== undefined) {
|
||||
character.showTalkIcon(message.details?.showVoiceIndicator);
|
||||
}
|
||||
if (message.details?.away !== undefined) {
|
||||
character.setStatus(message.details?.away ? PlayerStatus.Away : PlayerStatus.Online);
|
||||
if (message.details?.status !== undefined) {
|
||||
character.setStatus(message.details?.status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { AvailabilityStatus } from "../../Messages/ts-proto-generated/protos/messages";
|
||||
import type { BodyResourceDescriptionInterface } from "../Entity/PlayerTextures";
|
||||
|
||||
export interface PlayerInterface {
|
||||
@@ -7,7 +8,7 @@ export interface PlayerInterface {
|
||||
visitCardUrl: string | null;
|
||||
companion: string | null;
|
||||
userUuid: string;
|
||||
away: boolean;
|
||||
status: AvailabilityStatus;
|
||||
color?: string;
|
||||
outlineColor?: number;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { writable } from "svelte/store";
|
||||
import type { PlayerInterface } from "../Phaser/Game/PlayerInterface";
|
||||
import type { RoomConnection } from "../Connexion/RoomConnection";
|
||||
import { getRandomColor } from "../WebRtc/ColorGenerator";
|
||||
import { AvailabilityStatus } from "../Messages/ts-proto-generated/protos/messages";
|
||||
|
||||
let idCount = 0;
|
||||
|
||||
@@ -28,7 +29,7 @@ function createPlayersStore() {
|
||||
visitCardUrl: message.visitCardUrl,
|
||||
companion: message.companion,
|
||||
userUuid: message.userUuid,
|
||||
away: message.away,
|
||||
status: message.status,
|
||||
color: getRandomColor(),
|
||||
});
|
||||
return users;
|
||||
@@ -58,7 +59,7 @@ function createPlayersStore() {
|
||||
characterLayers: [],
|
||||
visitCardUrl: null,
|
||||
companion: null,
|
||||
away: false,
|
||||
status: AvailabilityStatus.ONLINE,
|
||||
userUuid: "dummy",
|
||||
color: getRandomColor(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user