updated using Unit.pathRemaining()

This commit is contained in:
Rj Manhas
2025-11-11 17:28:58 -07:00
parent 5850174832
commit 3c76aef369
7 changed files with 50 additions and 2 deletions
+4
View File
@@ -495,6 +495,10 @@ export interface Unit {
setSafeFromPirates(): void; // Only for trade ships
isSafeFromPirates(): boolean; // Only for trade ships
// Transport Ships
setPathRemaining(tiles: number | undefined): void; // Only for transport ships
pathRemaining(): number | undefined; // Only for transport ships
// Construction
constructionType(): UnitType | null;
setConstructionType(type: UnitType): void;
+1
View File
@@ -134,6 +134,7 @@ export interface UnitUpdate {
hasTrainStation: boolean;
trainType?: TrainType; // Only for trains
loaded?: boolean; // Only for trains
pathRemaining?: number; // Only for transport ships
}
export interface AttackUpdate {
+6
View File
@@ -103,6 +103,12 @@ export class UnitView {
}
return this.data.retreating;
}
pathRemaining(): number | undefined {
if (this.type() !== UnitType.TransportShip) {
return undefined;
}
return this.data.pathRemaining;
}
tile(): TileRef {
return this.data.pos;
}
+13
View File
@@ -40,6 +40,7 @@ export class UnitImpl implements Unit {
private _trajectoryIndex: number = 0;
private _trajectory: TrajectoryTile[];
private _deletionAt: number | null = null;
private _pathRemaining: number | undefined; // Only for transport ships
constructor(
private _type: UnitType,
@@ -139,6 +140,7 @@ export class UnitImpl implements Unit {
hasTrainStation: this._hasTrainStation,
trainType: this._trainType,
loaded: this._loaded,
pathRemaining: this._pathRemaining,
};
}
@@ -464,4 +466,15 @@ export class UnitImpl implements Unit {
this.mg.addUpdate(this.toUpdate());
}
}
setPathRemaining(tiles: number | undefined): void {
if (this._pathRemaining !== tiles) {
this._pathRemaining = tiles;
this.mg.addUpdate(this.toUpdate());
}
}
pathRemaining(): number | undefined {
return this._pathRemaining;
}
}