implemented feedback
This commit is contained in:
parent
7c6b73efdb
commit
e5a196a42b
@ -4,7 +4,7 @@ import {Zone} from "_Model/Zone";
|
||||
import {Movable} from "_Model/Movable";
|
||||
import {PositionNotifier} from "_Model/PositionNotifier";
|
||||
import {ServerDuplexStream} from "grpc";
|
||||
import {BatchMessage, Companion, PusherToBackMessage, ServerToClientMessage, SubMessage} from "../Messages/generated/messages_pb";
|
||||
import {BatchMessage, CompanionMessage, PusherToBackMessage, ServerToClientMessage, SubMessage} from "../Messages/generated/messages_pb";
|
||||
import {CharacterLayer} from "_Model/Websocket/CharacterLayer";
|
||||
|
||||
export type UserSocket = ServerDuplexStream<PusherToBackMessage, ServerToClientMessage>;
|
||||
@ -24,7 +24,7 @@ export class User implements Movable {
|
||||
public readonly tags: string[],
|
||||
public readonly name: string,
|
||||
public readonly characterLayers: CharacterLayer[],
|
||||
public readonly companion?: Companion
|
||||
public readonly companion?: CompanionMessage
|
||||
) {
|
||||
this.listenedZones = new Set<Zone>();
|
||||
|
||||
|
@ -52,7 +52,13 @@ class LocalUserStore {
|
||||
return localStorage.setItem(companionKey, JSON.stringify(companion));
|
||||
}
|
||||
getCompanion(): string|null {
|
||||
return JSON.parse(localStorage.getItem(companionKey) || "null");
|
||||
const companion = JSON.parse(localStorage.getItem(companionKey) || "null");
|
||||
|
||||
if (typeof companion !== "string" || companion === "") {
|
||||
return null;
|
||||
}
|
||||
|
||||
return companion;
|
||||
}
|
||||
wasCompanionSet(): boolean {
|
||||
return localStorage.getItem(companionKey) ? true : false;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import Sprite = Phaser.GameObjects.Sprite;
|
||||
import Container = Phaser.GameObjects.Container;
|
||||
import { lazyLoadResource } from "./CompanionTexturesLoadingManager";
|
||||
import { lazyLoadCompanionResource } from "./CompanionTexturesLoadingManager";
|
||||
import { PlayerAnimationDirections, PlayerAnimationTypes } from "../Player/Animation";
|
||||
|
||||
export interface CompanionStatus {
|
||||
@ -37,7 +37,7 @@ export class Companion extends Container {
|
||||
|
||||
this.companionName = name;
|
||||
|
||||
lazyLoadResource(this.scene.load, this.companionName)
|
||||
lazyLoadCompanionResource(this.scene.load, this.companionName)
|
||||
.then(resource => {
|
||||
this.addResource(resource);
|
||||
this.invisible = false;
|
||||
|
@ -1,23 +1,15 @@
|
||||
import LoaderPlugin = Phaser.Loader.LoaderPlugin;
|
||||
import { COMPANION_RESOURCES, CompanionResourceDescriptionInterface } from "./CompanionTextures";
|
||||
|
||||
export const getAllResources = (): CompanionResourceDescriptionInterface[] => {
|
||||
export const getAllCompanionResources = (loader: LoaderPlugin): CompanionResourceDescriptionInterface[] => {
|
||||
COMPANION_RESOURCES.forEach((resource: CompanionResourceDescriptionInterface) => {
|
||||
lazyLoadCompanionResource(loader, resource.name);
|
||||
});
|
||||
|
||||
return COMPANION_RESOURCES;
|
||||
}
|
||||
|
||||
export const lazyLoadAllResources = (loader: LoaderPlugin): Promise<CompanionResourceDescriptionInterface[]> => {
|
||||
const promises: Promise<string>[] = [];
|
||||
|
||||
COMPANION_RESOURCES.forEach((resource: CompanionResourceDescriptionInterface) => {
|
||||
promises.push(lazyLoadResource(loader, resource.name));
|
||||
});
|
||||
|
||||
return Promise.all(promises).then(() => {
|
||||
return COMPANION_RESOURCES;
|
||||
});
|
||||
}
|
||||
|
||||
export const lazyLoadResource = (loader: LoaderPlugin, name: string): Promise<string> => {
|
||||
export const lazyLoadCompanionResource = (loader: LoaderPlugin, name: string): Promise<string> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const resource = COMPANION_RESOURCES.find(item => item.name === name);
|
||||
|
||||
|
@ -7,7 +7,7 @@ import { TextField } from "../Components/TextField";
|
||||
import { EnableCameraSceneName } from "./EnableCameraScene";
|
||||
import { localUserStore } from "../../Connexion/LocalUserStore";
|
||||
import { CompanionResourceDescriptionInterface } from "../Companion/CompanionTextures";
|
||||
import { getAllResources, lazyLoadAllResources } from "../Companion/CompanionTexturesLoadingManager";
|
||||
import { getAllCompanionResources } from "../Companion/CompanionTexturesLoadingManager";
|
||||
|
||||
export const SelectCompanionSceneName = "SelectCompanionScene";
|
||||
|
||||
@ -38,11 +38,9 @@ export class SelectCompanionScene extends ResizableScene {
|
||||
}
|
||||
|
||||
preload() {
|
||||
lazyLoadAllResources(this.load).then(() => {
|
||||
console.log("Loaded all companion textures.");
|
||||
});
|
||||
addLoader(this);
|
||||
|
||||
getAllResources().forEach(model => {
|
||||
getAllCompanionResources(this.load).forEach(model => {
|
||||
this.companionModels.push(model);
|
||||
});
|
||||
|
||||
|
@ -36,7 +36,7 @@ message CharacterLayerMessage {
|
||||
string name = 2;
|
||||
}
|
||||
|
||||
message Companion {
|
||||
message CompanionMessage {
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ message UserJoinedMessage {
|
||||
string name = 2;
|
||||
repeated CharacterLayerMessage characterLayers = 3;
|
||||
PositionMessage position = 4;
|
||||
Companion companion = 5;
|
||||
CompanionMessage companion = 5;
|
||||
}
|
||||
|
||||
message UserLeftMessage {
|
||||
@ -256,7 +256,7 @@ message JoinRoomMessage {
|
||||
string roomId = 5;
|
||||
repeated string tag = 6;
|
||||
string IPAddress = 7;
|
||||
Companion companion = 8;
|
||||
CompanionMessage companion = 8;
|
||||
}
|
||||
|
||||
message UserJoinedZoneMessage {
|
||||
@ -265,7 +265,7 @@ message UserJoinedZoneMessage {
|
||||
repeated CharacterLayerMessage characterLayers = 3;
|
||||
PositionMessage position = 4;
|
||||
Zone fromZone = 5;
|
||||
Companion companion = 6;
|
||||
CompanionMessage companion = 6;
|
||||
}
|
||||
|
||||
message UserLeftZoneMessage {
|
||||
|
@ -12,7 +12,7 @@ import {
|
||||
WebRtcSignalToServerMessage,
|
||||
PlayGlobalMessage,
|
||||
ReportPlayerMessage,
|
||||
QueryJitsiJwtMessage, SendUserMessage, ServerToClientMessage, Companion
|
||||
QueryJitsiJwtMessage, SendUserMessage, ServerToClientMessage, CompanionMessage
|
||||
} from "../Messages/generated/messages_pb";
|
||||
import {UserMovesMessage} from "../Messages/generated/messages_pb";
|
||||
import {TemplatedApp} from "uWebSockets.js"
|
||||
@ -139,10 +139,10 @@ export class IoSocketController {
|
||||
const right = Number(query.right);
|
||||
const name = query.name;
|
||||
|
||||
let companion: Companion|undefined = undefined;
|
||||
let companion: CompanionMessage|undefined = undefined;
|
||||
|
||||
if (typeof query.companion === 'string') {
|
||||
companion = new Companion();
|
||||
companion = new CompanionMessage();
|
||||
companion.setName(query.companion);
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ import {Identificable} from "./Identificable";
|
||||
import {ViewportInterface} from "_Model/Websocket/ViewportMessage";
|
||||
import {
|
||||
BatchMessage,
|
||||
Companion,
|
||||
CompanionMessage,
|
||||
PusherToBackMessage,
|
||||
ServerToClientMessage,
|
||||
SubMessage
|
||||
@ -30,7 +30,7 @@ export interface ExSocketInterface extends WebSocket, Identificable {
|
||||
characterLayers: CharacterLayer[];
|
||||
position: PointInterface;
|
||||
viewport: ViewportInterface;
|
||||
companion?: Companion;
|
||||
companion?: CompanionMessage;
|
||||
/**
|
||||
* Pushes an event that will be sent in the next batch of events
|
||||
*/
|
||||
|
@ -6,7 +6,7 @@ import {
|
||||
PointMessage, PositionMessage, UserJoinedMessage,
|
||||
UserJoinedZoneMessage, UserLeftZoneMessage, UserMovedMessage,
|
||||
ZoneMessage,
|
||||
Companion
|
||||
CompanionMessage
|
||||
} from "../Messages/generated/messages_pb";
|
||||
import * as messages_pb from "../Messages/generated/messages_pb";
|
||||
import {ClientReadableStream} from "grpc";
|
||||
@ -31,7 +31,7 @@ export type MovesCallback = (thing: Movable, position: PositionInterface, listen
|
||||
export type LeavesCallback = (thing: Movable, listener: User) => void;*/
|
||||
|
||||
export class UserDescriptor {
|
||||
private constructor(public readonly userId: number, private name: string, private characterLayers: CharacterLayerMessage[], private position: PositionMessage, private companion?: Companion) {
|
||||
private constructor(public readonly userId: number, private name: string, private characterLayers: CharacterLayerMessage[], private position: PositionMessage, private companion?: CompanionMessage) {
|
||||
if (!Number.isInteger(this.userId)) {
|
||||
throw new Error('UserDescriptor.userId is not an integer: '+this.userId);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user