Public texture (#1093)

* Public texture

 - Front => Get texture when user connected on public method
 - Front => Anonymous login will be make every connexion to get map details
 - Pusher => `/anonymLogin` permit to get map details and public texture load in customize scene

* Improve texture local user

- Permit to keep previous texture get with 'register' link

* Texture public loading

 - Texture will be load with Room class
 - Fix issue on lazzy loading atttempt

* Remove async await useless
This commit is contained in:
grégoire parant 2021-06-03 13:07:52 +02:00 committed by GitHub
parent 9e42d9d05b
commit 2b13b764b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 75 additions and 19 deletions

View file

@ -78,11 +78,11 @@ export class GameManager {
public async loadMap(room: Room, scenePlugin: Phaser.Scenes.ScenePlugin): Promise<void> {
const roomID = room.id;
const mapUrl = await room.getMapUrl();
const mapDetail = await room.getMapDetail();
const gameIndex = scenePlugin.getIndex(roomID);
if(gameIndex === -1){
const game : Phaser.Scene = new GameScene(room, mapUrl);
const game : Phaser.Scene = new GameScene(room, mapDetail.mapUrl);
scenePlugin.add(roomID, game, false);
}
}

View file

@ -29,6 +29,8 @@ export class CustomizeScene extends AbstractCharacterScene {
public activeRow:number = 0;
private layers: BodyResourceDescriptionInterface[][] = [];
protected lazyloadingAttempt = true; //permit to update texture loaded after renderer
constructor() {
super({
key: CustomizeSceneName
@ -38,7 +40,6 @@ export class CustomizeScene extends AbstractCharacterScene {
preload() {
this.load.html(customizeSceneKey, 'resources/html/CustomCharacterScene.html');
this.layers = loadAllLayers(this.load);
this.loadCustomSceneSelectCharacters().then((bodyResourceDescriptions) => {
bodyResourceDescriptions.forEach((bodyResourceDescription) => {
if(bodyResourceDescription.level == undefined || bodyResourceDescription.level < 0 || bodyResourceDescription.level > 5 ){
@ -46,8 +47,13 @@ export class CustomizeScene extends AbstractCharacterScene {
}
this.layers[bodyResourceDescription.level].unshift(bodyResourceDescription);
});
this.lazyloadingAttempt = true;
});
this.layers = loadAllLayers(this.load);
this.lazyloadingAttempt = false;
//this function must stay at the end of preload function
addLoader(this);
}
@ -222,6 +228,14 @@ export class CustomizeScene extends AbstractCharacterScene {
}
}
update(time: number, delta: number): void {
if(this.lazyloadingAttempt){
this.moveLayers();
this.lazyloadingAttempt = false;
}
}
public onResize(): void {
this.moveLayers();

View file

@ -33,6 +33,8 @@ export class SelectCharacterScene extends AbstractCharacterScene {
protected currentSelectUser = 0;
protected pointerClicked: boolean = false;
protected lazyloadingAttempt = true; //permit to update texture loaded after renderer
constructor() {
super({
key: SelectCharacterSceneName,
@ -46,8 +48,10 @@ export class SelectCharacterScene extends AbstractCharacterScene {
bodyResourceDescriptions.forEach((bodyResourceDescription) => {
this.playerModels.push(bodyResourceDescription);
});
})
this.lazyloadingAttempt = true;
});
this.playerModels = loadAllDefaultModels(this.load);
this.lazyloadingAttempt = false;
//this function must stay at the end of preload function
addLoader(this);
@ -238,6 +242,13 @@ export class SelectCharacterScene extends AbstractCharacterScene {
localUserStore.setPlayerCharacterIndex(this.currentSelectUser);
}
update(time: number, delta: number): void {
if(this.lazyloadingAttempt){
this.createCurrentPlayer();
this.lazyloadingAttempt = false;
}
}
public onResize(): void {
//move position of user
this.moveUser();