From bd1cd53332e2cca094e4779bfb6f092bb170af3c Mon Sep 17 00:00:00 2001 From: Admin Date: Fri, 18 Sep 2026 00:56:25 +0000 Subject: [PATCH] Trace player state through first hit frame --- src/game-v4.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/game-v4.js b/src/game-v4.js index bf17f2e..9303196 100644 --- a/src/game-v4.js +++ b/src/game-v4.js @@ -342,6 +342,7 @@ class GameScene extends Phaser.Scene { update(_time, deltaMs) { const dt = Math.min(deltaMs / 1000, 0.05); + const hadQueuedPlayerHit = this.pendingPlayerHits.length > 0; if (this.gameState !== 'playing') { if (Phaser.Input.Keyboard.JustDown(this.keys.restart)) this.scene.restart(); @@ -375,6 +376,19 @@ class GameScene extends Phaser.Scene { this.drawWeaponArcs(); this.drawHud(); this.checkGameState(); + + if (hadQueuedPlayerHit) { + airshipLog('combat:post-hit-frame-complete', { + gameState: this.gameState, + hull: this.playerHull, + playerActive: this.player?.active ?? null, + playerVisible: this.player?.visible ?? null, + bodyEnabled: this.player?.body?.enable ?? null, + velocityX: this.player?.body?.velocity?.x ?? null, + velocityY: this.player?.body?.velocity?.y ?? null, + now: this.time.now, + }); + } } updatePlayer(dt, deltaMs) { @@ -536,6 +550,15 @@ class GameScene extends Phaser.Scene { this.pendingPlayerHits = []; const beforeHull = this.playerHull; + const playerStateBefore = { + active: this.player?.active ?? null, + visible: this.player?.visible ?? null, + bodyEnabled: this.player?.body?.enable ?? null, + velocityX: this.player?.body?.velocity?.x ?? null, + velocityY: this.player?.body?.velocity?.y ?? null, + gameState: this.gameState, + }; + const result = processQueuedPlayerHits({ hull: this.playerHull, lastHitAt: this.lastPlayerHitAt, @@ -557,6 +580,15 @@ class GameScene extends Phaser.Scene { hullAfter: this.playerHull, gameOver: result.gameOver, now: this.time.now, + playerStateBefore, + playerStateAfter: { + active: this.player?.active ?? null, + visible: this.player?.visible ?? null, + bodyEnabled: this.player?.body?.enable ?? null, + velocityX: this.player?.body?.velocity?.x ?? null, + velocityY: this.player?.body?.velocity?.y ?? null, + gameState: this.gameState, + }, }, result.gameOver ? 'warn' : 'info'); if (result.gameOver) this.finishGame();