mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 08:20:50 +00:00
Sam/factory radius ghost upgrade fix (#4104)
> **Before opening a PR:** discuss new features on [Discord](https://discord.gg/K9zernJB5z) first, and file bugs or small improvements as [issues](https://github.com/openfrontio/OpenFrontIO/issues/new/choose). You must be assigned to an `approved` issue — unsolicited PRs will be auto-closed. **Add approved & assigned issue number here:** Resolves #4059 ## Description: Makes ghost radius centred on building being upgrading (if upgrading building) <img width="1920" height="1080" alt="Screenshot from 2026-06-01 15-45-37" src="https://github.com/user-attachments/assets/9cf19e59-0e20-4b43-b65f-35eebb37fa8e" /> <img width="1920" height="1080" alt="Screenshot from 2026-06-01 15-45-24" src="https://github.com/user-attachments/assets/1953238f-5156-4bf7-aa18-8278c27d1a68" /> ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory ## Please put your Discord username so you can be contacted if a bug or regression is found: tktk123456
This commit is contained in:
@@ -335,12 +335,24 @@ export class BuildPreviewController implements Controller {
|
||||
rangeRadius = this.game.config().defensePostRange();
|
||||
break;
|
||||
}
|
||||
let radiusTileX = this.game.x(tileRef);
|
||||
let radiusTileY = this.game.y(tileRef);
|
||||
if (
|
||||
rangeRadius > 0 &&
|
||||
u.canUpgrade !== false &&
|
||||
upgradeTargetTile !== null
|
||||
) {
|
||||
radiusTileX = this.game.x(upgradeTargetTile);
|
||||
radiusTileY = this.game.y(upgradeTargetTile);
|
||||
}
|
||||
|
||||
const cost = u.cost;
|
||||
return {
|
||||
ghostType: u.type,
|
||||
tileX: this.game.x(tileRef),
|
||||
tileY: this.game.y(tileRef),
|
||||
radiusTileX,
|
||||
radiusTileY,
|
||||
canBuild: u.canBuild !== false,
|
||||
canUpgrade: u.canUpgrade !== false,
|
||||
cost: Number(cost),
|
||||
|
||||
@@ -54,8 +54,8 @@ export class RangeCirclePass {
|
||||
|
||||
updateGhostPreview(data: GhostPreviewData | null): void {
|
||||
if (data && data.rangeRadius > 0) {
|
||||
this.centerX = data.tileX;
|
||||
this.centerY = data.tileY;
|
||||
this.centerX = data.radiusTileX;
|
||||
this.centerY = data.radiusTileY;
|
||||
this.radius = data.rangeRadius;
|
||||
this.warning = data.rangeWarning;
|
||||
} else {
|
||||
|
||||
@@ -152,6 +152,8 @@ export interface GhostPreviewData {
|
||||
ghostType: string; // UnitType string ("City", "Port", etc.)
|
||||
tileX: number; // Hover tile X
|
||||
tileY: number; // Hover tile Y
|
||||
radiusTileX: number;
|
||||
radiusTileY: number;
|
||||
canBuild: boolean; // Valid placement?
|
||||
canUpgrade: boolean; // Upgrading existing structure?
|
||||
cost: number; // Gold cost
|
||||
|
||||
Reference in New Issue
Block a user