Trace player state through first hit frame
This commit is contained in:
parent
3414b2458a
commit
bd1cd53332
@ -342,6 +342,7 @@ class GameScene extends Phaser.Scene {
|
|||||||
|
|
||||||
update(_time, deltaMs) {
|
update(_time, deltaMs) {
|
||||||
const dt = Math.min(deltaMs / 1000, 0.05);
|
const dt = Math.min(deltaMs / 1000, 0.05);
|
||||||
|
const hadQueuedPlayerHit = this.pendingPlayerHits.length > 0;
|
||||||
|
|
||||||
if (this.gameState !== 'playing') {
|
if (this.gameState !== 'playing') {
|
||||||
if (Phaser.Input.Keyboard.JustDown(this.keys.restart)) this.scene.restart();
|
if (Phaser.Input.Keyboard.JustDown(this.keys.restart)) this.scene.restart();
|
||||||
@ -375,6 +376,19 @@ class GameScene extends Phaser.Scene {
|
|||||||
this.drawWeaponArcs();
|
this.drawWeaponArcs();
|
||||||
this.drawHud();
|
this.drawHud();
|
||||||
this.checkGameState();
|
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) {
|
updatePlayer(dt, deltaMs) {
|
||||||
@ -536,6 +550,15 @@ class GameScene extends Phaser.Scene {
|
|||||||
this.pendingPlayerHits = [];
|
this.pendingPlayerHits = [];
|
||||||
|
|
||||||
const beforeHull = this.playerHull;
|
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({
|
const result = processQueuedPlayerHits({
|
||||||
hull: this.playerHull,
|
hull: this.playerHull,
|
||||||
lastHitAt: this.lastPlayerHitAt,
|
lastHitAt: this.lastPlayerHitAt,
|
||||||
@ -557,6 +580,15 @@ class GameScene extends Phaser.Scene {
|
|||||||
hullAfter: this.playerHull,
|
hullAfter: this.playerHull,
|
||||||
gameOver: result.gameOver,
|
gameOver: result.gameOver,
|
||||||
now: this.time.now,
|
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');
|
}, result.gameOver ? 'warn' : 'info');
|
||||||
|
|
||||||
if (result.gameOver) this.finishGame();
|
if (result.gameOver) this.finishGame();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user