Sending color outline on connect
This commit is contained in:
parent
482ba9690a
commit
35463930a0
@ -322,6 +322,12 @@ export class SocketManager {
|
||||
userJoinedZoneMessage.setVisitcardurl(thing.visitCardUrl);
|
||||
}
|
||||
userJoinedZoneMessage.setCompanion(thing.companion);
|
||||
if (thing.outlineColor === undefined) {
|
||||
userJoinedZoneMessage.setHasoutline(false);
|
||||
} else {
|
||||
userJoinedZoneMessage.setHasoutline(true);
|
||||
userJoinedZoneMessage.setOutlinecolor(thing.outlineColor);
|
||||
}
|
||||
|
||||
const subMessage = new SubToPusherMessage();
|
||||
subMessage.setUserjoinedzonemessage(userJoinedZoneMessage);
|
||||
|
@ -65,6 +65,7 @@ export interface MessageUserJoined {
|
||||
visitCardUrl: string | null;
|
||||
companion: string | null;
|
||||
userUuid: string;
|
||||
outlineColor: number | undefined;
|
||||
}
|
||||
|
||||
export interface PositionInterface {
|
||||
|
@ -423,6 +423,7 @@ export class RoomConnection implements RoomConnection {
|
||||
position: ProtobufClientUtils.toPointInterface(position),
|
||||
companion: companion ? companion.getName() : null,
|
||||
userUuid: message.getUseruuid(),
|
||||
outlineColor: message.getHasoutline() ? message.getOutlinecolor() : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -683,6 +683,7 @@ export class GameScene extends DirtyScene {
|
||||
visitCardUrl: message.visitCardUrl,
|
||||
companion: message.companion,
|
||||
userUuid: message.userUuid,
|
||||
outlineColor: message.outlineColor,
|
||||
};
|
||||
this.addPlayer(userMessage);
|
||||
});
|
||||
@ -1703,8 +1704,9 @@ ${escapedMessage}
|
||||
case "PlayerDetailsUpdated":
|
||||
this.doUpdatePlayerDetails(event.details);
|
||||
break;
|
||||
default:
|
||||
default: {
|
||||
const tmp: never = event;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Let's move all users
|
||||
@ -1778,6 +1780,9 @@ ${escapedMessage}
|
||||
addPlayerData.companion,
|
||||
addPlayerData.companion !== null ? lazyLoadCompanionResource(this.load, addPlayerData.companion) : undefined
|
||||
);
|
||||
if (addPlayerData.outlineColor !== undefined) {
|
||||
player.setOutlineColor(addPlayerData.outlineColor);
|
||||
}
|
||||
this.MapPlayers.add(player);
|
||||
this.MapPlayersByKey.set(player.userId, player);
|
||||
player.updatePosition(addPlayerData.position);
|
||||
|
@ -8,4 +8,5 @@ export interface PlayerInterface {
|
||||
companion: string | null;
|
||||
userUuid: string;
|
||||
color?: string;
|
||||
outlineColor?: number;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ message SetPlayerDetailsMessage {
|
||||
//repeated string characterLayers = 2;
|
||||
|
||||
// TODO: switch to google.protobuf.Int32Value when we migrate to ts-proto
|
||||
int32 outlineColor = 3;
|
||||
uint32 outlineColor = 3;
|
||||
bool removeOutlineColor = 4;
|
||||
}
|
||||
|
||||
@ -181,6 +181,8 @@ message UserJoinedMessage {
|
||||
CompanionMessage companion = 5;
|
||||
string visitCardUrl = 6;
|
||||
string userUuid = 7;
|
||||
uint32 outlineColor = 8;
|
||||
bool hasOutline = 9;
|
||||
}
|
||||
|
||||
message UserLeftMessage {
|
||||
@ -318,6 +320,8 @@ message UserJoinedZoneMessage {
|
||||
CompanionMessage companion = 6;
|
||||
string visitCardUrl = 7;
|
||||
string userUuid = 8;
|
||||
uint32 outlineColor = 9;
|
||||
bool hasOutline = 10;
|
||||
}
|
||||
|
||||
message UserLeftZoneMessage {
|
||||
|
@ -17,6 +17,7 @@ import {
|
||||
CompanionMessage,
|
||||
ErrorMessage,
|
||||
PlayerDetailsUpdatedMessage,
|
||||
SetPlayerDetailsMessage,
|
||||
} from "../Messages/generated/messages_pb";
|
||||
import { ClientReadableStream } from "grpc";
|
||||
import { PositionDispatcher } from "_Model/PositionDispatcher";
|
||||
@ -48,7 +49,8 @@ export class UserDescriptor {
|
||||
private characterLayers: CharacterLayerMessage[],
|
||||
private position: PositionMessage,
|
||||
private visitCardUrl: string | null,
|
||||
private companion?: CompanionMessage
|
||||
private companion?: CompanionMessage,
|
||||
private outlineColor?: number
|
||||
) {
|
||||
if (!Number.isInteger(this.userId)) {
|
||||
throw new Error("UserDescriptor.userId is not an integer: " + this.userId);
|
||||
@ -67,7 +69,8 @@ export class UserDescriptor {
|
||||
message.getCharacterlayersList(),
|
||||
position,
|
||||
message.getVisitcardurl(),
|
||||
message.getCompanion()
|
||||
message.getCompanion(),
|
||||
message.getHasoutline() ? message.getOutlinecolor() : undefined
|
||||
);
|
||||
}
|
||||
|
||||
@ -79,6 +82,14 @@ export class UserDescriptor {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public updateDetails(playerDetails: SetPlayerDetailsMessage) {
|
||||
if (playerDetails.getRemoveoutlinecolor()) {
|
||||
this.outlineColor = undefined;
|
||||
} else {
|
||||
this.outlineColor = playerDetails.getOutlinecolor();
|
||||
}
|
||||
}
|
||||
|
||||
public toUserJoinedMessage(): UserJoinedMessage {
|
||||
const userJoinedMessage = new UserJoinedMessage();
|
||||
|
||||
@ -91,6 +102,12 @@ export class UserDescriptor {
|
||||
}
|
||||
userJoinedMessage.setCompanion(this.companion);
|
||||
userJoinedMessage.setUseruuid(this.userUuid);
|
||||
if (this.outlineColor !== undefined) {
|
||||
userJoinedMessage.setOutlinecolor(this.outlineColor);
|
||||
userJoinedMessage.setHasoutline(true);
|
||||
} else {
|
||||
userJoinedMessage.setHasoutline(false);
|
||||
}
|
||||
|
||||
return userJoinedMessage;
|
||||
}
|
||||
@ -211,7 +228,7 @@ export class Zone {
|
||||
const userDescriptor = this.users.get(userId);
|
||||
|
||||
if (userDescriptor === undefined) {
|
||||
console.error('Unexpected move message received for user "' + userId + '"');
|
||||
console.error('Unexpected move message received for unknown user "' + userId + '"');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -224,6 +241,23 @@ export class Zone {
|
||||
} else if (message.hasPlayerdetailsupdatedmessage()) {
|
||||
const playerDetailsUpdatedMessage =
|
||||
message.getPlayerdetailsupdatedmessage() as PlayerDetailsUpdatedMessage;
|
||||
|
||||
const userId = playerDetailsUpdatedMessage.getUserid();
|
||||
const userDescriptor = this.users.get(userId);
|
||||
|
||||
if (userDescriptor === undefined) {
|
||||
console.error('Unexpected details message received for unknown user "' + userId + '"');
|
||||
return;
|
||||
}
|
||||
|
||||
const details = playerDetailsUpdatedMessage.getDetails();
|
||||
if (details === undefined) {
|
||||
console.error('Unexpected details message without details received for user "' + userId + '"');
|
||||
return;
|
||||
}
|
||||
|
||||
userDescriptor.updateDetails(details);
|
||||
|
||||
this.notifyPlayerDetailsUpdated(playerDetailsUpdatedMessage);
|
||||
} else if (message.hasErrormessage()) {
|
||||
const errorMessage = message.getErrormessage() as ErrorMessage;
|
||||
|
Loading…
Reference in New Issue
Block a user