Fixing suspend/resume
In case we suspend a laptop and resume it, the RECONNECT event is called by socket.io without any error being thrown (so without us being redirected to the Reconnect Scene). This fix makes sure we go to the reconnect scene before going back to the main scene.
This commit is contained in:
parent
80fddb3c69
commit
ce7b4092a6
@ -168,7 +168,7 @@ export class GameManager {
|
|||||||
private oldMapUrlFile : string;
|
private oldMapUrlFile : string;
|
||||||
private oldInstance : string;
|
private oldInstance : string;
|
||||||
private scenePlugin: ScenePlugin;
|
private scenePlugin: ScenePlugin;
|
||||||
private reconnectScene: Scene;
|
private reconnectScene: Scene|null;
|
||||||
switchToDisconnectedScene(): void {
|
switchToDisconnectedScene(): void {
|
||||||
if (this.currentGameScene === null) {
|
if (this.currentGameScene === null) {
|
||||||
return;
|
return;
|
||||||
@ -186,8 +186,12 @@ export class GameManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
reconnectToGameScene(lastPositionShared: PointInterface) {
|
reconnectToGameScene(lastPositionShared: PointInterface) {
|
||||||
|
if (this.reconnectScene === null && this.currentGameScene) {
|
||||||
|
// In case we are asked to reconnect even if switchToDisconnectedScene was not triggered (can happen when a laptop goes to sleep)
|
||||||
|
this.switchToDisconnectedScene();
|
||||||
|
}
|
||||||
const game : Phaser.Scene = GameScene.createFromUrl(this.oldMapUrlFile, this.oldInstance);
|
const game : Phaser.Scene = GameScene.createFromUrl(this.oldMapUrlFile, this.oldInstance);
|
||||||
this.reconnectScene.scene.add(this.oldSceneKey, game, true, { initPosition: lastPositionShared });
|
this.reconnectScene?.scene.add(this.oldSceneKey, game, true, { initPosition: lastPositionShared });
|
||||||
}
|
}
|
||||||
|
|
||||||
private getCurrentGameScene(): GameScene {
|
private getCurrentGameScene(): GameScene {
|
||||||
|
Loading…
Reference in New Issue
Block a user