mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-30 06:12:29 +00:00
Redraw stacked buildings sprites (#1170)
## Description: When buildings are stacked on each other, the buildings under are not redrawn when the stacked building is destroyed. A simple outer range + sprite radius check triggers a touch which redraws the buildings. Sprite radius is set to 16 (dont forget to change it if it ever changes) ### Before:  ### After:  ## 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 - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: Vivacious Box
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
Execution,
|
||||
Game,
|
||||
isStructureType,
|
||||
MessageType,
|
||||
Player,
|
||||
TerraNullius,
|
||||
@@ -12,6 +13,8 @@ import { ParabolaPathFinder } from "../pathfinding/PathFinding";
|
||||
import { PseudoRandom } from "../PseudoRandom";
|
||||
import { NukeType } from "../StatsSchemas";
|
||||
|
||||
const SPRITE_RADIUS = 16;
|
||||
|
||||
export class NukeExecution implements Execution {
|
||||
private active = true;
|
||||
private mg: Game;
|
||||
@@ -221,6 +224,8 @@ export class NukeExecution implements Execution {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.redrawBuildings(magnitude.outer + SPRITE_RADIUS);
|
||||
this.active = false;
|
||||
this.nuke.setReachedTarget();
|
||||
this.nuke.delete(false);
|
||||
@@ -231,6 +236,19 @@ export class NukeExecution implements Execution {
|
||||
.bombLand(this.player, this.target(), this.nuke.type() as NukeType);
|
||||
}
|
||||
|
||||
private redrawBuildings(range: number) {
|
||||
const rangeSquared = range * range;
|
||||
for (const unit of this.mg.units()) {
|
||||
if (isStructureType(unit.type())) {
|
||||
if (
|
||||
this.mg.euclideanDistSquared(this.dst, unit.tile()) < rangeSquared
|
||||
) {
|
||||
unit.touch();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
owner(): Player {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@@ -151,6 +151,19 @@ export enum UnitType {
|
||||
Construction = "Construction",
|
||||
}
|
||||
|
||||
const _structureTypes: ReadonlySet<UnitType> = new Set([
|
||||
UnitType.City,
|
||||
UnitType.Construction,
|
||||
UnitType.DefensePost,
|
||||
UnitType.SAMLauncher,
|
||||
UnitType.MissileSilo,
|
||||
UnitType.Port,
|
||||
]);
|
||||
|
||||
export function isStructureType(type: UnitType): boolean {
|
||||
return _structureTypes.has(type);
|
||||
}
|
||||
|
||||
export interface OwnerComp {
|
||||
owner: Player;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user