mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 13:10:42 +00:00
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:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user