From 01c430dfdbe85df759119381f1ad12f569cce249 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Fri, 18 Dec 2020 12:45:50 +0100 Subject: [PATCH 01/10] Start layer TCM --- maps/Floor0/floor0.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maps/Floor0/floor0.json b/maps/Floor0/floor0.json index be78195b..6a88f78d 100644 --- a/maps/Floor0/floor0.json +++ b/maps/Floor0/floor0.json @@ -140,7 +140,7 @@ { "data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "height":51, - "id":29, + "id":30, "name":"start-tcm", "opacity":1, "properties":[ @@ -429,7 +429,7 @@ "x":0, "y":0 }], - "nextlayerid":30, + "nextlayerid":31, "nextobjectid":2, "orientation":"orthogonal", "renderorder":"right-down", From f5dd5efc0ea92c6a2e261c890581919d2e214caf Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Fri, 18 Dec 2020 13:56:25 +0100 Subject: [PATCH 02/10] Manage Local Storage customers player error --- front/src/Phaser/Entity/Character.ts | 8 ++++++-- front/src/Phaser/Game/GameScene.ts | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/front/src/Phaser/Entity/Character.ts b/front/src/Phaser/Entity/Character.ts index a1ed30d5..13d0b637 100644 --- a/front/src/Phaser/Entity/Character.ts +++ b/front/src/Phaser/Entity/Character.ts @@ -106,7 +106,9 @@ export abstract class Character extends Container { }); }) // Needed, otherwise, animations are not handled correctly. - this.scene.sys.updateList.add(sprite); + if(this.scene) { + this.scene.sys.updateList.add(sprite); + } this.sprites.set(texture, sprite); } } @@ -229,7 +231,9 @@ export abstract class Character extends Container { this.scene.events.removeListener('postupdate', this.postupdate.bind(this)); } for (const sprite of this.sprites.values()) { - this.scene.sys.updateList.remove(sprite); + if(this.scene) { + this.scene.sys.updateList.remove(sprite); + } } super.destroy(fromScene); this.playerName.destroy(); diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index a5248ff7..8ac7ef85 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -63,6 +63,7 @@ import {urlManager} from "../../Url/UrlManager"; import {PresentationModeIcon} from "../Components/PresentationModeIcon"; import {ChatModeIcon} from "../Components/ChatModeIcon"; import {OpenChatIcon, openChatIconName} from "../Components/OpenChatIcon"; +import {SelectCharacterScene, SelectCharacterSceneName} from "../Login/SelectCharacterScene"; export interface GameSceneInitInterface { initPosition: PointInterface|null, @@ -375,7 +376,13 @@ export class GameScene extends ResizableScene implements CenterListener { mediaManager.setUserInputManager(this.userInputManager); //notify game manager can to create currentUser in map - this.createCurrentPlayer(); + try { + this.createCurrentPlayer(); + }catch (err){ + //permit to return on character custom if any there any changes frame in the new version + gameManager.leaveGame(this, SelectCharacterSceneName, new SelectCharacterScene()); + throw 'characterLayers are not invalid'; + } //initialise camera this.initCamera(); @@ -670,8 +677,12 @@ export class GameScene extends ResizableScene implements CenterListener { public cleanupClosingScene(): void { // We are completely destroying the current scene to avoid using a half-backed instance when coming back to the same map. - this.connection.closeConnection(); - this.simplePeer.unregister(); + if(this.connection) { + this.connection.closeConnection(); + } + if(this.simplePeer) { + this.simplePeer.unregister(); + } } private switchLayoutMode(): void { From 323fa6abba3f98afc94112d6776409994f26290e Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Fri, 18 Dec 2020 14:30:46 +0100 Subject: [PATCH 03/10] Create exception error --- front/src/Exception/TextureError.ts | 1 + front/src/Phaser/Entity/Character.ts | 9 +++---- front/src/Phaser/Game/GameScene.ts | 36 +++++++++++++++------------- 3 files changed, 25 insertions(+), 21 deletions(-) create mode 100644 front/src/Exception/TextureError.ts diff --git a/front/src/Exception/TextureError.ts b/front/src/Exception/TextureError.ts new file mode 100644 index 00000000..39a339f6 --- /dev/null +++ b/front/src/Exception/TextureError.ts @@ -0,0 +1 @@ +export class TextureError extends Error{} \ No newline at end of file diff --git a/front/src/Phaser/Entity/Character.ts b/front/src/Phaser/Entity/Character.ts index 13d0b637..5c89447e 100644 --- a/front/src/Phaser/Entity/Character.ts +++ b/front/src/Phaser/Entity/Character.ts @@ -3,6 +3,7 @@ import {SpeechBubble} from "./SpeechBubble"; import BitmapText = Phaser.GameObjects.BitmapText; import Container = Phaser.GameObjects.Container; import Sprite = Phaser.GameObjects.Sprite; +import {TextureError} from "../../Exception/TextureError"; export interface PlayerResourceDescriptionInterface { name: string, @@ -94,6 +95,9 @@ export abstract class Character extends Container { public addTextures(textures: string[], frame?: string | number): void { for (const texture of textures) { + if(!this.scene.textures.exists(texture)){ + throw new TextureError('texture not found'); + } const sprite = new Sprite(this.scene, 0, 0, texture, frame); sprite.setInteractive({useHandCursor: true}); this.add(sprite); @@ -154,10 +158,7 @@ export abstract class Character extends Container { if (moving && (!sprite.anims.currentAnim || sprite.anims.currentAnim.key !== direction)) { sprite.play(texture+'-'+direction, true); } else if (!moving) { - /*if (this.anims.currentAnim) { - this.anims.stop(); - }*/ - sprite.play(texture+'-'+direction, true); + sprite.anims.play(texture + '-' + direction, true); sprite.anims.stop(); } } diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 8ac7ef85..8dbbea8c 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -64,6 +64,7 @@ import {PresentationModeIcon} from "../Components/PresentationModeIcon"; import {ChatModeIcon} from "../Components/ChatModeIcon"; import {OpenChatIcon, openChatIconName} from "../Components/OpenChatIcon"; import {SelectCharacterScene, SelectCharacterSceneName} from "../Login/SelectCharacterScene"; +import {TextureError} from "../../Exception/TextureError"; export interface GameSceneInitInterface { initPosition: PointInterface|null, @@ -376,13 +377,7 @@ export class GameScene extends ResizableScene implements CenterListener { mediaManager.setUserInputManager(this.userInputManager); //notify game manager can to create currentUser in map - try { - this.createCurrentPlayer(); - }catch (err){ - //permit to return on character custom if any there any changes frame in the new version - gameManager.leaveGame(this, SelectCharacterSceneName, new SelectCharacterScene()); - throw 'characterLayers are not invalid'; - } + this.createCurrentPlayer(); //initialise camera this.initCamera(); @@ -829,16 +824,23 @@ export class GameScene extends ResizableScene implements CenterListener { createCurrentPlayer(){ //initialise player //TODO create animation moving between exit and start - this.CurrentPlayer = new Player( - this, - this.startX, - this.startY, - this.playerName, - this.characterLayers, - PlayerAnimationNames.WalkDown, - false, - this.userInputManager - ); + try { + this.CurrentPlayer = new Player( + this, + this.startX, + this.startY, + this.playerName, + this.characterLayers, + PlayerAnimationNames.WalkDown, + false, + this.userInputManager + ); + }catch (err){ + if(err instanceof TextureError) { + gameManager.leaveGame(this, SelectCharacterSceneName, new SelectCharacterScene()); + throw err; + } + } //create collision this.createCollisionWithPlayer(); From df114bc1ce02a997879a218bd01c8476cc9caa2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 18 Dec 2020 15:58:49 +0100 Subject: [PATCH 04/10] Fixing broken reconnection --- front/src/Phaser/Game/GameScene.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index a5248ff7..734e0f96 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -155,14 +155,14 @@ export class GameScene extends ResizableScene implements CenterListener { private playerName!: string; private characterLayers!: string[]; - constructor(private room: Room, MapUrlFile: string) { + constructor(private room: Room, MapUrlFile: string, customKey?: string|undefined) { super({ - key: room.id + key: customKey ?? room.id }); this.Terrains = []; this.groups = new Map(); this.instance = room.getInstance(); - + this.MapUrlFile = MapUrlFile; this.RoomId = room.id; @@ -517,7 +517,7 @@ export class GameScene extends ResizableScene implements CenterListener { this.simplePeer.unregister(); const gameSceneKey = 'somekey' + Math.round(Math.random() * 10000); - const game: Phaser.Scene = new GameScene(this.room, this.MapUrlFile); + const game: Phaser.Scene = new GameScene(this.room, this.MapUrlFile, gameSceneKey); this.scene.add(gameSceneKey, game, true, { initPosition: { @@ -1220,6 +1220,6 @@ export class GameScene extends ResizableScene implements CenterListener { }); })) } - + } From 36f886aed6fef8b92ab5091f294dda1bd4525225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 18 Dec 2020 16:08:04 +0100 Subject: [PATCH 05/10] Fixing cat running too fast on reconnect scene because animations were duplicated --- front/src/Phaser/Game/GameScene.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 734e0f96..2a331069 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -579,8 +579,8 @@ export class GameScene extends ResizableScene implements CenterListener { this.ConsoleGlobalMessageManager = new ConsoleGlobalMessageManager(this.connection, this.userInputManager, this.connection.isAdmin()); - this.scene.wake(); - this.scene.sleep(ReconnectingSceneName); + this.scene.wake(); + this.scene.stop(ReconnectingSceneName); //init user position and play trigger to check layers properties this.gameMap.setPosition(this.CurrentPlayer.x, this.CurrentPlayer.y); From a1fd209578344e11c58cfa40b44c8f616378f0e0 Mon Sep 17 00:00:00 2001 From: Gregoire Parant Date: Fri, 18 Dec 2020 16:30:22 +0100 Subject: [PATCH 06/10] Fix catch error --- front/src/Phaser/Game/GameScene.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 8dbbea8c..89fb03bd 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -838,8 +838,8 @@ export class GameScene extends ResizableScene implements CenterListener { }catch (err){ if(err instanceof TextureError) { gameManager.leaveGame(this, SelectCharacterSceneName, new SelectCharacterScene()); - throw err; } + throw err; } //create collision From a5b5007908bff3f40d01fef7980e7b46f136ddd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 18 Dec 2020 17:04:31 +0100 Subject: [PATCH 07/10] Switching to deeployer-action to speed up CD --- .github/workflows/build-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index f103945c..a57b53fa 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -167,7 +167,7 @@ jobs: - uses: rlespinasse/github-slug-action@3.1.0 - name: Deploy - uses: thecodingmachine/deeployer@master + uses: thecodingmachine/deeployer-action@master env: KUBE_CONFIG_FILE: ${{ secrets.KUBE_CONFIG_FILE }} ADMIN_API_TOKEN: ${{ secrets.ADMIN_API_TOKEN }} From 76dee71a5f55a07aaa4a724dd3f465e525a4ce3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Sun, 20 Dec 2020 22:31:06 +0100 Subject: [PATCH 08/10] Improving doc: the tile layer format must be CSV --- website/dist/create-map.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/website/dist/create-map.html b/website/dist/create-map.html index 9548aac6..7d952c93 100644 --- a/website/dist/create-map.html +++ b/website/dist/create-map.html @@ -109,6 +109,9 @@
  • set a start position for the players
  • configure the "floor layer" (so that WorkAdventure can correctly display characters above the floor, but under the ceiling)
  • eventually, you can place exits that link to other maps
  • +
  • the "Tile Layer Format" must be set to CSV. If you started from the map starter kit as explained above, + you have nothing to do. However, if you start from scratch, please be sure to select "CSV" for the tile layer format + when creating the map. You can change this setting later in the map properties.
  • WorkAdventure Map Rules

    From c9250c08f3381a57409665d8b7f2a6d8afe67151 Mon Sep 17 00:00:00 2001 From: Dariusz Niemczyk <3636685+Palid@users.noreply.github.com> Date: Sun, 27 Dec 2020 10:47:56 +0100 Subject: [PATCH 09/10] Fix CustomizeScene killing CPU Fixes #518 --- front/src/Phaser/Login/CustomizeScene.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/front/src/Phaser/Login/CustomizeScene.ts b/front/src/Phaser/Login/CustomizeScene.ts index 9a8776a2..016afac4 100644 --- a/front/src/Phaser/Login/CustomizeScene.ts +++ b/front/src/Phaser/Login/CustomizeScene.ts @@ -148,7 +148,6 @@ export class CustomizeScene extends ResizableScene { this.selectedLayers[this.activeRow] = this.layers[this.activeRow].length - 1 } this.moveLayers(); - this.updateSelectedLayer(); this.saveInLocalStorage(); } From 640d994ddabef583821798991fcee5d0f838b707 Mon Sep 17 00:00:00 2001 From: Dariusz Niemczyk <3636685+Palid@users.noreply.github.com> Date: Sun, 27 Dec 2020 11:00:23 +0100 Subject: [PATCH 10/10] Properly fix the CustomizeScene by limiting input When left/right arrow is being held on chrome the Phaser gets into infinite rendering loop that doesn't crash the browser but makes it slow to a crawl. --- front/src/Phaser/Login/CustomizeScene.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/front/src/Phaser/Login/CustomizeScene.ts b/front/src/Phaser/Login/CustomizeScene.ts index 016afac4..944b57f9 100644 --- a/front/src/Phaser/Login/CustomizeScene.ts +++ b/front/src/Phaser/Login/CustomizeScene.ts @@ -126,10 +126,10 @@ export class CustomizeScene extends ResizableScene { gameManager.tryResumingGame(this, EnableCameraSceneName); }); - this.input.keyboard.on('keydown-RIGHT', () => this.moveCursorHorizontally(1)); - this.input.keyboard.on('keydown-LEFT', () => this.moveCursorHorizontally(-1)); - this.input.keyboard.on('keydown-DOWN', () => this.moveCursorVertically(1)); - this.input.keyboard.on('keydown-UP', () => this.moveCursorVertically(-1)); + this.input.keyboard.on('keyup-RIGHT', () => this.moveCursorHorizontally(1)); + this.input.keyboard.on('keyup-LEFT', () => this.moveCursorHorizontally(-1)); + this.input.keyboard.on('keyup-DOWN', () => this.moveCursorVertically(1)); + this.input.keyboard.on('keyup-UP', () => this.moveCursorVertically(-1)); const customCursorPosition = localUserStore.getCustomCursorPosition(); if (customCursorPosition) { @@ -148,6 +148,7 @@ export class CustomizeScene extends ResizableScene { this.selectedLayers[this.activeRow] = this.layers[this.activeRow].length - 1 } this.moveLayers(); + this.updateSelectedLayer(); this.saveInLocalStorage(); }