From d666a398ecc528f2c214e37245ac6a148dff4c91 Mon Sep 17 00:00:00 2001 From: Evan Date: Sun, 3 Nov 2024 20:29:53 -0800 Subject: [PATCH] control panel dissappears when player dies --- src/client/graphics/layers/ControlPanel.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/client/graphics/layers/ControlPanel.ts b/src/client/graphics/layers/ControlPanel.ts index 4e2955700..855c33669 100644 --- a/src/client/graphics/layers/ControlPanel.ts +++ b/src/client/graphics/layers/ControlPanel.ts @@ -58,12 +58,12 @@ export class ControlPanel extends LitElement implements Layer { tick() { // Update game state based on numTroops value if needed if (!this._isVisible && !this.game.inSpawnPhase()) { - this.toggleVisibility(); + this.setVisibile(true) } const player = this.game.playerByClientID(this.clientID) - if (player == null) { - this._isVisible = false + if (player == null || !player.isAlive()) { + this.setVisibile(false) return } this._population = player.population() @@ -87,11 +87,12 @@ export class ControlPanel extends LitElement implements Layer { return false; } - toggleVisibility() { - this._isVisible = !this._isVisible; + setVisibile(visible: boolean) { + this._isVisible = visible this.requestUpdate(); } + targetTroops(): number { return this._manpower * this.targetTroopRatio }