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