Restore stable player hit collision path

This commit is contained in:
Admin 2026-09-18 00:05:07 +00:00
parent 36823472ed
commit 7dc08d851f

View File

@ -435,20 +435,11 @@ class GameScene extends Phaser.Scene {
const damage = clamp(Number.isFinite(rawDamage) ? rawDamage : PIRATE_SHOT_DAMAGE, 1, 25);
const { x, y } = shot;
// Do not destroy an Arcade body from inside the overlap callback. Disable
// it immediately, then clean it up and render impact FX on the next tick.
if (shot.body) shot.disableBody(true, true);
else shot.setActive(false).setVisible(false);
this.time.delayedCall(0, () => {
if (shot?.scene) shot.destroy();
try {
this.spawnExplosion(x, y, 0.32);
this.flashShip(this.player, 0xffcccc);
} catch (error) {
console.warn('Player impact FX failed', error);
}
});
// Mirror the proven player-shot collision path: remove the projectile
// immediately, render impact feedback, then rate-limit hull damage only.
shot.destroy();
this.spawnExplosion(x, y, 0.32);
this.flashShip(this.player, 0xffcccc);
if (this.time.now - this.lastPlayerHitAt < PLAYER_HIT_COOLDOWN_MS) return;
this.lastPlayerHitAt = this.time.now;