refactor(pathfinding): remove unused PathStatus.PENDING

Drop PENDING from PathStatus/PathResult and remove dead PENDING branches from
TradeShipExecution, TransportShipExecution, and WarshipExecution.
This commit is contained in:
scamiv
2026-02-25 22:36:06 +01:00
parent 0a5e427925
commit 04d8998744
4 changed files with 3 additions and 33 deletions
-20
View File
@@ -110,26 +110,6 @@ export class TradeShipExecution implements Execution {
const result = this.pathFinder.next(curTile, dst);
switch (result.status) {
case PathStatus.PENDING:
if (dst !== this.motionPlanDst) {
this.motionPlanId++;
const from = curTile;
const path = this.pathFinder.findPath(from, dst) ?? [from];
if (path.length === 0 || path[0] !== from) {
path.unshift(from);
}
this.mg.recordMotionPlan({
kind: "grid",
unitId: this.tradeShip.id(),
planId: this.motionPlanId,
startTick: ticks + 1,
ticksPerStep: 1,
path,
});
this.motionPlanDst = dst;
}
break;
case PathStatus.NEXT:
if (dst !== this.motionPlanDst) {
this.motionPlanId++;
@@ -248,8 +248,6 @@ export class TransportShipExecution implements Execution {
case PathStatus.NEXT:
this.boat.move(result.node);
break;
case PathStatus.PENDING:
break;
case PathStatus.NOT_FOUND: {
// TODO: add to poisoned port list
const map = this.mg.map();
-6
View File
@@ -190,9 +190,6 @@ export class WarshipExecution implements Execution {
case PathStatus.NEXT:
this.warship.move(result.node);
break;
case PathStatus.PENDING:
this.warship.touch();
break;
case PathStatus.NOT_FOUND: {
console.log(`path not found to target`);
break;
@@ -221,9 +218,6 @@ export class WarshipExecution implements Execution {
case PathStatus.NEXT:
this.warship.move(result.node);
break;
case PathStatus.PENDING:
this.warship.touch();
return;
case PathStatus.NOT_FOUND: {
console.log(`path not found to target`);
break;
+3 -5
View File
@@ -4,14 +4,12 @@
*/
export enum PathStatus {
NEXT,
PENDING,
COMPLETE,
NOT_FOUND,
NEXT = 0,
COMPLETE = 2,
NOT_FOUND = 3,
}
export type PathResult<T> =
| { status: PathStatus.PENDING }
| { status: PathStatus.NEXT; node: T }
| { status: PathStatus.COMPLETE; node: T }
| { status: PathStatus.NOT_FOUND };