Skip to content

Commit 16b1f70

Browse files
committed
feat: added auto GoToPlayerEvent on random spawn
1 parent 7eb62af commit 16b1f70

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/client/ClientGameRunner.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import {
4747
} from "./Transport";
4848
import { createCanvas } from "./Utils";
4949
import { createRenderer, GameRenderer } from "./graphics/GameRenderer";
50+
import { GoToPlayerEvent } from "./graphics/layers/Leaderboard";
5051
import SoundManager from "./sound/SoundManager";
5152

5253
export interface LobbyConfig {
@@ -314,6 +315,19 @@ export class ClientGameRunner {
314315
if (message.type === "start") {
315316
this.hasJoined = true;
316317
console.log("starting game!");
318+
319+
if (this.gameView.isRandomSpawn()) {
320+
setTimeout(() => {
321+
const myPlayer = this.gameView.myPlayer();
322+
323+
if (!myPlayer) {
324+
return;
325+
}
326+
327+
this.eventBus.emit(new GoToPlayerEvent(myPlayer));
328+
}, 1000);
329+
}
330+
317331
for (const turn of message.turns) {
318332
if (turn.turnNumber < this.turnsSeen) {
319333
continue;

0 commit comments

Comments
 (0)