diff --git a/src/client/graphics/layers/DynamicUILayer.ts b/src/client/graphics/layers/DynamicUILayer.ts index affd9f0f4..b151a1b83 100644 --- a/src/client/graphics/layers/DynamicUILayer.ts +++ b/src/client/graphics/layers/DynamicUILayer.ts @@ -116,14 +116,25 @@ export class DynamicUILayer implements Layer { } onBombEvent(unit: UnitView) { - if (this.createdThisTick(unit) && this.isOwnedByPlayer(unit)) { + const myPlayer = this.game.myPlayer(); + if (!myPlayer) { + return; + } + if ( + this.createdThisTick(unit) && + (unit.owner() === myPlayer || unit.owner().isOnSameTeam(myPlayer)) + ) { const target = new NukeTelegraph(this.transformHandler, this.game, unit); this.uiElements.push(target); } } onTransportShipEvent(unit: UnitView) { - if (this.createdThisTick(unit) && this.isOwnedByPlayer(unit)) { + const myPlayer = this.game.myPlayer(); + if (!myPlayer) { + return; + } + if (this.createdThisTick(unit) && unit.owner() === myPlayer) { const target = new NavalTarget(this.transformHandler, this.game, unit); this.uiElements.push(target); } @@ -146,11 +157,6 @@ export class DynamicUILayer implements Layer { } } - private isOwnedByPlayer(unit: UnitView): boolean { - const my = this.game.myPlayer(); - return my !== null && unit.owner() === my; - } - private createdThisTick(unit: UnitView): boolean { return unit.createdAt() === this.game.ticks(); }