fix(render): turn nuke range circle red when launch would break alliance

Wire targetingAlly through GhostPreviewData.rangeWarning so RangeCirclePass
can color the blast-radius circle red instead of white when the ghosted nuke
would trigger a traitor penalty. Restores behavior lost in the canvas→WebGL
migration.
This commit is contained in:
evanpelle
2026-05-27 16:25:34 -07:00
parent 21e42ce461
commit a5e28d81d2
4 changed files with 27 additions and 13 deletions
@@ -163,18 +163,13 @@ export class BuildPreviewController implements Controller {
}
}
// targetingAlly is computed above for state purposes; the renderer's
// ghost passes derive their own "warning" visual from canBuild/canUpgrade
// if needed. (Leave the variable here so its eslint-no-unused doesn't trip.)
void targetingAlly;
this.game
?.myPlayer()
?.buildables(tileRef, [this.ghostUnit?.buildableUnit.type])
.then((buildables) => {
if (!this.ghostUnit) {
this.pendingConfirm = null;
this.emitGhostPreview(tileRef);
this.emitGhostPreview(tileRef, targetingAlly);
return;
}
@@ -187,7 +182,7 @@ export class BuildPreviewController implements Controller {
canUpgrade: false,
});
this.pendingConfirm = null;
this.emitGhostPreview(tileRef);
this.emitGhostPreview(tileRef, targetingAlly);
return;
}
@@ -201,7 +196,7 @@ export class BuildPreviewController implements Controller {
}
}
this.emitGhostPreview(tileRef);
this.emitGhostPreview(tileRef, targetingAlly);
});
}
@@ -211,8 +206,11 @@ export class BuildPreviewController implements Controller {
* the ghost can't be placed. smoothLoop interpolates displayed position
* toward the target tile each frame.
*/
private emitGhostPreview(tileRef: TileRef | undefined): void {
const data = this.buildGhostPreviewData(tileRef);
private emitGhostPreview(
tileRef: TileRef | undefined,
targetingAlly: boolean,
): void {
const data = this.buildGhostPreviewData(tileRef, targetingAlly);
if (data === null) {
this.lastGhostData = null;
this.view.updateGhostPreview(null);
@@ -302,6 +300,7 @@ export class BuildPreviewController implements Controller {
private buildGhostPreviewData(
tileRef: TileRef | undefined,
targetingAlly: boolean,
): GhostPreviewData | null {
if (!this.ghostUnit) return null;
if (tileRef === undefined) return null;
@@ -352,6 +351,7 @@ export class BuildPreviewController implements Controller {
ownerID: myPlayer.smallID(),
upgradeTargetTile,
rangeRadius,
rangeWarning: targetingAlly,
};
}