diff --git a/src/core/execution/ShellExecution.ts b/src/core/execution/ShellExecution.ts index 4f0d306f7..0fc149e11 100644 --- a/src/core/execution/ShellExecution.ts +++ b/src/core/execution/ShellExecution.ts @@ -1,12 +1,11 @@ -import { consolex } from "../Consolex"; import { Execution, Game, Player, Unit, UnitType } from "../game/Game"; import { TileRef } from "../game/GameMap"; -import { PathFindResultType } from "../pathfinding/AStar"; -import { PathFinder } from "../pathfinding/PathFinding"; +import { AirPathFinder } from "../pathfinding/PathFinding"; +import { PseudoRandom } from "../PseudoRandom"; export class ShellExecution implements Execution { private active = true; - private pathFinder: PathFinder; + private pathFinder: AirPathFinder; private shell: Unit; private mg: Game; private destroyAtTick: number = -1; @@ -19,7 +18,7 @@ export class ShellExecution implements Execution { ) {} init(mg: Game, ticks: number): void { - this.pathFinder = PathFinder.Mini(mg, 2000, 10); + this.pathFinder = new AirPathFinder(mg, new PseudoRandom(mg.ticks())); this.mg = mg; } @@ -49,24 +48,14 @@ export class ShellExecution implements Execution { const result = this.pathFinder.nextTile( this.shell.tile(), this.target.tile(), - 3, ); - switch (result.type) { - case PathFindResultType.Completed: - this.active = false; - this.target.modifyHealth(-this.effectOnTarget()); - this.shell.delete(false); - return; - case PathFindResultType.NextTile: - this.shell.move(result.tile); - break; - case PathFindResultType.Pending: - return; - case PathFindResultType.PathNotFound: - consolex.log(`Shell ${this.shell} could not find target`); - this.active = false; - this.shell.delete(false); - return; + if (result === true) { + this.active = false; + this.target.modifyHealth(-this.effectOnTarget()); + this.shell.delete(false); + return; + } else { + this.shell.move(result); } } }