Files
OpenFrontIO/src/core/execution/MoveWarshipExecution.ts
T
Readixyee 665a8c3823 Executions dont switch owner (#326)
when an building is taken over by another player the execution for it
doesnt change its owner this makes it so when a sam is captured it tries
to intercept your own nukes and doesnt intercept the ones by the
previous player

this change makes executions of buildings automaticly switch their owner
2025-03-27 16:03:15 -07:00

36 lines
751 B
TypeScript

import { Execution, Game, Player, PlayerID } from "../game/Game";
const cancelDelay = 2;
export class MoveWarshipExecution implements Execution {
private active = true;
private mg: Game;
constructor(
public readonly unitId: number,
public readonly position: number,
) {}
init(mg: Game, ticks: number): void {
this.mg = mg;
}
tick(ticks: number): void {
const warship = this.mg.units().find((u) => u.id() == this.unitId);
if (!warship) {
console.log("MoveWarshipExecution: warship is already dead");
return;
}
warship.setMoveTarget(this.position);
this.active = false;
}
isActive(): boolean {
return this.active;
}
activeDuringSpawnPhase(): boolean {
return false;
}
}