mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-13 08:04:46 +00:00
Set a targetable status for nukes (#1174)
## Description: Set a targetable status for units (specifically atom bomb and hydro) A nuke is targetable near launch and target but is untargetable mid air. An untargetable unit is half transparent to show that it cannot be destroyed.  ## 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:
@@ -383,6 +383,8 @@ export interface Unit {
|
||||
targetedBySAM(): boolean;
|
||||
setReachedTarget(): void;
|
||||
reachedTarget(): boolean;
|
||||
isTargetable(): boolean;
|
||||
setTargetable(targetable: boolean): void;
|
||||
|
||||
// Health
|
||||
hasHealth(): boolean;
|
||||
|
||||
@@ -76,6 +76,7 @@ export interface UnitUpdate {
|
||||
isActive: boolean;
|
||||
reachedTarget: boolean;
|
||||
retreating: boolean;
|
||||
targetable: boolean;
|
||||
targetUnitId?: number; // Only for trade ships
|
||||
targetTile?: TileRef; // Only for nukes
|
||||
health?: number;
|
||||
|
||||
@@ -72,6 +72,10 @@ export class UnitView {
|
||||
return this.data.id;
|
||||
}
|
||||
|
||||
targetable(): boolean {
|
||||
return this.data.targetable;
|
||||
}
|
||||
|
||||
type(): UnitType {
|
||||
return this.data.unitType;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ export class UnitImpl implements Unit {
|
||||
private _readyMissileCount: number = 1;
|
||||
private _patrolTile: TileRef | undefined;
|
||||
private _level: number = 1;
|
||||
private _targetable: boolean = true;
|
||||
|
||||
constructor(
|
||||
private _type: UnitType,
|
||||
private mg: GameImpl,
|
||||
@@ -63,6 +65,17 @@ export class UnitImpl implements Unit {
|
||||
}
|
||||
}
|
||||
|
||||
setTargetable(targetable: boolean): void {
|
||||
if (this._targetable !== targetable) {
|
||||
this._targetable = targetable;
|
||||
this.mg.addUpdate(this.toUpdate());
|
||||
}
|
||||
}
|
||||
|
||||
isTargetable(): boolean {
|
||||
return this._targetable;
|
||||
}
|
||||
|
||||
setPatrolTile(tile: TileRef): void {
|
||||
this._patrolTile = tile;
|
||||
}
|
||||
@@ -101,6 +114,7 @@ export class UnitImpl implements Unit {
|
||||
reachedTarget: this._reachedTarget,
|
||||
retreating: this._retreating,
|
||||
pos: this._tile,
|
||||
targetable: this._targetable,
|
||||
lastPos: this._lastTile,
|
||||
health: this.hasHealth() ? Number(this._health) : undefined,
|
||||
constructionType: this._constructionType,
|
||||
|
||||
Reference in New Issue
Block a user