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