oil oil baby

This commit is contained in:
Restart2008
2026-02-20 15:55:44 -08:00
parent 90204f6628
commit db4a815390
40 changed files with 442 additions and 105 deletions
+48
View File
@@ -0,0 +1,48 @@
import { Execution, Game, Unit, UnitType } from "../game/Game";
import { TrainStationExecution } from "./TrainStationExecution";
export class OilRigExecution implements Execution {
private active: boolean = true;
private game: Game;
private stationCreated = false;
constructor(private oilRig: Unit) {}
init(mg: Game, ticks: number): void {
this.game = mg;
}
tick(ticks: number): void {
if (!this.stationCreated) {
this.createStation();
this.stationCreated = true;
}
if (!this.oilRig.isActive()) {
this.active = false;
return;
}
}
isActive(): boolean {
return this.active;
}
activeDuringSpawnPhase(): boolean {
return false;
}
private createStation(): void {
const structures = this.game.nearbyUnits(
this.oilRig.tile()!,
this.game.config().trainStationMaxRange(),
[UnitType.City, UnitType.Port, UnitType.OilRig],
);
this.game.addExecution(new TrainStationExecution(this.oilRig, true));
for (const { unit } of structures) {
if (!unit.hasTrainStation()) {
this.game.addExecution(new TrainStationExecution(unit));
}
}
}
}