mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-23 12:55:17 +00:00
updated using Unit.pathRemaining()
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user