Skip to content

Commit

Permalink
Merge pull request #468 from Annoraaq/bugfix/#467-fix-jps
Browse files Browse the repository at this point in the history
Bugfix/#467 fix jps
  • Loading branch information
Annoraaq authored Feb 27, 2024
2 parents f02ee20 + 56bcf18 commit a1f6366
Show file tree
Hide file tree
Showing 29 changed files with 470 additions and 321 deletions.
2 changes: 1 addition & 1 deletion src/Direction/Direction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Position } from "../GridEngine.js";
import { Position } from "../Position.js";
import { Vector2 } from "../Utils/Vector2/Vector2.js";
export enum Direction {
NONE = "none",
Expand Down
6 changes: 4 additions & 2 deletions src/GridCharacter/GridCharacter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { LayerPositionUtils } from "./../Utils/LayerPositionUtils/LayerPositionUtils.js";
import { LayerVecPos } from "./../Pathfinding/ShortestPathAlgorithm.js";
import {
LayerPositionUtils,
LayerVecPos,
} from "./../Utils/LayerPositionUtils/LayerPositionUtils.js";
import {
directionVector,
NumberOfDirections,
Expand Down
2 changes: 1 addition & 1 deletion src/GridCharacter/GridCharacterState.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Direction } from "../Direction/Direction";
import { CollisionConfig } from "../GridEngineHeadless";
import { LayerPosition } from "../IGridEngine";
import { LayerPosition } from "../Position.js";
import { CharId } from "./GridCharacter";

export interface GridCharacterState {
Expand Down
12 changes: 5 additions & 7 deletions src/GridEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ import {
import { CharacterFilteringOptions } from "./GridCharacter/CharacterFilter/CharacterFilter.js";

import { version as VERSION } from "../package.json";
import {
IsPositionAllowedFn,
PathfindingOptions,
} from "./Pathfinding/Pathfinding.js";
import { ShortestPathAlgorithmType } from "./Pathfinding/ShortestPathAlgorithm.js";
import {
GridEngineHeadless,
Expand Down Expand Up @@ -58,12 +54,9 @@ import {
import {
CharacterShift,
CharacterShiftAction,
CharLayer,
FollowOptions,
IGridEngine,
LayerPosition,
PathfindingResult,
Position,
} from "./IGridEngine.js";
import {
ArrayTilemap,
Expand All @@ -75,6 +68,11 @@ import { TiledTile } from "./GridTilemap/TiledTilemap/TiledTile.js";
import { GridEngineState } from "./GridEngineState.js";
import { GridCharacterState } from "./GridCharacter/GridCharacterState.js";
import { GridEngineStatePhaser } from "./GridEnginePhaser/GridEngineStatePhaser.js";
import {
IsPositionAllowedFn,
PathfindingOptions,
} from "./Pathfinding/PathfindingOptions.js";
import { CharLayer, LayerPosition, Position } from "./Position.js";

export {
ArrayTilemap,
Expand Down
2 changes: 1 addition & 1 deletion src/GridEngineHeadless.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { take } from "rxjs/operators";
import { PathfindingOptions } from "./Pathfinding/Pathfinding.js";
import { Direction, NumberOfDirections } from "./Direction/Direction.js";
import { GridCharacter } from "./GridCharacter/GridCharacter.js";
import {
Expand All @@ -8,6 +7,7 @@ import {
} from "./Movement/QueueMovement/QueueMovement.js";
import { Vector2 } from "./Utils/Vector2/Vector2.js";
import { ShortestPathAlgorithmType } from "./Pathfinding/ShortestPathAlgorithm.js";
import { PathfindingOptions } from "./Pathfinding/PathfindingOptions.js";

expect.extend({
toBeCharacter(receivedChar: GridCharacter, expectedCharId: string) {
Expand Down
14 changes: 6 additions & 8 deletions src/GridEngineHeadless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,17 @@ import {
} from "./GridCharacter/CharacterFilter/CharacterFilter.js";

import { version as VERSION } from "../package.json";
import {
IsPositionAllowedFn,
Pathfinding,
PathfindingOptions,
} from "./Pathfinding/Pathfinding.js";
import { Pathfinding } from "./Pathfinding/Pathfinding.js";
import { LayerPositionUtils } from "./Utils/LayerPositionUtils/LayerPositionUtils.js";
import { ShortestPathAlgorithmType } from "./Pathfinding/ShortestPathAlgorithm.js";
import { GridTilemap } from "./GridTilemap/GridTilemap.js";
import { Tilemap } from "./GridTilemap/Tilemap.js";
import {
CharacterShift,
CharacterShiftAction,
CharLayer,
FollowOptions,
IGridEngine,
LayerPosition,
PathfindingResult,
Position,
} from "./IGridEngine.js";
import { Rect } from "./Utils/Rect/Rect.js";
import {
Expand All @@ -59,6 +52,11 @@ import {
} from "./Movement/QueueMovement/QueueMovement.js";
import { GridCharacterState } from "./GridCharacter/GridCharacterState.js";
import { GridEngineState } from "./GridEngineState.js";
import {
IsPositionAllowedFn,
PathfindingOptions,
} from "./Pathfinding/PathfindingOptions.js";
import { CharLayer, LayerPosition, Position } from "./Position.js";

export {
CollisionStrategy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import {
} from "../../GridEngine.js";
import { Vector2 } from "../../Utils/Vector2/Vector2.js";
import { CharacterAnimation } from "../../GridCharacter/CharacterAnimation/CharacterAnimation.js";
import { LayerVecPos } from "../../Pathfinding/ShortestPathAlgorithm.js";
import { Utils } from "../../Utils/Utils/Utils.js";
import { Subject } from "rxjs";
import { filter, takeUntil } from "rxjs/operators";
import { Direction, directionVector } from "../../Direction/Direction.js";
import { GridTilemapPhaser } from "../GridTilemapPhaser/GridTilemapPhaser.js";
import { LayerVecPos } from "../../Utils/LayerPositionUtils/LayerPositionUtils.js";

export class GridCharacterPhaser {
private customOffset = new Vector2(0, 0);
Expand Down
2 changes: 1 addition & 1 deletion src/GridTilemap/CharBlockCache/CharBlockCache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { Vector2 } from "../../Utils/Vector2/Vector2.js";
import { CharBlockCache } from "./CharBlockCache.js";
import { GridTilemap } from "../GridTilemap.js";
import { mockLayeredBlockMap } from "../../Utils/MockFactory/MockFactory.js";
import { LayerVecPos } from "../../Pathfinding/ShortestPathAlgorithm.js";
import { Tilemap } from "../Tilemap.js";
import { LayerVecPos } from "../../Utils/LayerPositionUtils/LayerPositionUtils.js";

describe("CharBlockCache", () => {
let charBlockCache: CharBlockCache;
Expand Down
2 changes: 1 addition & 1 deletion src/GridTilemap/CharBlockCache/CharBlockCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { CharLayer, Position } from "../../GridEngine.js";
import { Vector2 } from "../../Utils/Vector2/Vector2.js";
import { CollisionStrategy } from "../../Collisions/CollisionStrategy.js";
import { LayerVecPos } from "../../Pathfinding/ShortestPathAlgorithm.js";
import { LayerVecPos } from "../../Utils/LayerPositionUtils/LayerPositionUtils.js";

export class CharBlockCache {
private tilePosToCharacters: Map<string, Set<GridCharacter>> = new Map();
Expand Down
2 changes: 1 addition & 1 deletion src/GridTilemap/GridTilemap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { GridCharacter } from "./../GridCharacter/GridCharacter.js";
import { Vector2 } from "../Utils/Vector2/Vector2.js";
import { Direction, NumberOfDirections } from "./../Direction/Direction.js";
import { GridTilemap } from "./GridTilemap.js";
import { LayerVecPos } from "../Pathfinding/ShortestPathAlgorithm.js";
import {
mockLayeredBlockMap,
updateLayer,
} from "../Utils/MockFactory/MockFactory.js";
import { MockTilemap } from "../Utils/MockFactory/MockTilemap.js";
import { Tilemap } from "./Tilemap.js";
import { Rect } from "../Utils/Rect/Rect.js";
import { LayerVecPos } from "../Utils/LayerPositionUtils/LayerPositionUtils.js";

describe("GridTilemap", () => {
let gridTilemap: GridTilemap;
Expand Down
2 changes: 1 addition & 1 deletion src/GridTilemap/TileCollisionCache/TileCollisionCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Vector2 } from "../../Utils/Vector2/Vector2.js";
import { GridTilemap } from "../GridTilemap.js";
import { Tilemap } from "../Tilemap.js";
import { Rect } from "../../Utils/Rect/Rect.js";
import { CharLayer } from "../../IGridEngine.js";
import { CharLayer } from "../../Position.js";

const BITMAP_POS_HAS_TILE = 0;
const BITMAP_POS_NO_DIRECTION = 1;
Expand Down
18 changes: 2 additions & 16 deletions src/IGridEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,10 @@ import {
} from "./Movement/QueueMovement/QueueMovement.js";
import { Observable } from "rxjs";
import { CharacterFilteringOptions } from "./GridCharacter/CharacterFilter/CharacterFilter.js";
import { PathfindingOptions } from "./Pathfinding/Pathfinding.js";
import { PositionChange } from "./GridCharacter/GridCharacter.js";
import { ShortestPathAlgorithmType } from "./Pathfinding/ShortestPathAlgorithm.js";

export type CharLayer = string | undefined;

/**
* Specifies a tile position along with a character layer.
*/
export interface LayerPosition {
position: Position;
charLayer: CharLayer;
}

export interface Position {
x: number;
y: number;
}
import { PathfindingOptions } from "./Pathfinding/PathfindingOptions.js";
import { CharLayer, LayerPosition, Position } from "./Position.js";

/**
* Result of a pathfinding algorithm run.
Expand Down
6 changes: 2 additions & 4 deletions src/Movement/FollowMovement/FollowMovement.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
LayerVecPos,
ShortestPathAlgorithmType,
} from "./../../Pathfinding/ShortestPathAlgorithm.js";
import { ShortestPathAlgorithmType } from "./../../Pathfinding/ShortestPathAlgorithm.js";
import { Direction, NumberOfDirections } from "./../../Direction/Direction.js";
import { FollowMovement } from "./FollowMovement.js";
import { TargetMovement } from "../TargetMovement/TargetMovement.js";
Expand All @@ -11,6 +8,7 @@ import { GridTilemap } from "../../GridTilemap/GridTilemap.js";
import { mockBlockMap } from "../../Utils/MockFactory/MockFactory.js";
import { CollisionStrategy } from "../../Collisions/CollisionStrategy.js";
import { GridCharacter } from "../../GridCharacter/GridCharacter.js";
import { LayerVecPos } from "../../Utils/LayerPositionUtils/LayerPositionUtils.js";

const mockTargetMovement = {
setCharacter: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion src/Movement/QueueMovement/QueueMovement.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
QueueMovementConfig,
QueuedPathBlockedStrategy,
} from "./QueueMovement.js";
import { LayerVecPos } from "../../Pathfinding/ShortestPathAlgorithm.js";
import {
CharConfig,
GridCharacter,
Expand All @@ -17,6 +16,7 @@ import {
import { Tilemap } from "../../GridTilemap/Tilemap.js";
import { GridTilemap } from "../../GridTilemap/GridTilemap.js";
import { CollisionStrategy } from "../../Collisions/CollisionStrategy.js";
import { LayerVecPos } from "../../Utils/LayerPositionUtils/LayerPositionUtils.js";

const CHUNKS_PER_SECOND = 2;

Expand Down
4 changes: 2 additions & 2 deletions src/Movement/QueueMovement/QueueMovement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import {
} from "../../Direction/Direction.js";
import { GridCharacter } from "../../GridCharacter/GridCharacter.js";
import { GridTilemap } from "../../GridTilemap/GridTilemap.js";
import { LayerVecPos } from "../../Pathfinding/ShortestPathAlgorithm.js";
import { Vector2 } from "../../Utils/Vector2/Vector2.js";
import { Movement, MovementInfo } from "../Movement.js";
import { Subject } from "rxjs";
import { filter, take } from "rxjs/operators";
import { CharLayer, LayerPosition, Position } from "../../IGridEngine.js";
import { DistanceUtilsFactory } from "../../Utils/DistanceUtilsFactory/DistanceUtilsFactory.js";
import { DistanceUtils } from "../../Utils/DistanceUtils.js";
import { Concrete } from "../../Utils/TypeUtils.js";
import { LayerVecPos } from "../../Utils/LayerPositionUtils/LayerPositionUtils.js";
import { CharLayer, LayerPosition, Position } from "../../Position.js";

/**
* @category Queue Movement
Expand Down
10 changes: 5 additions & 5 deletions src/Movement/TargetMovement/TargetMovement.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
LayerVecPos,
ShortestPathAlgorithmType,
} from "./../../Pathfinding/ShortestPathAlgorithm.js";
import { ShortestPathAlgorithmType } from "./../../Pathfinding/ShortestPathAlgorithm.js";
import { Direction, NumberOfDirections } from "../../Direction/Direction.js";
import {
MoveToConfig,
Expand All @@ -24,7 +21,10 @@ import {
mockCharMap,
updateLayer,
} from "../../Utils/MockFactory/MockFactory.js";
import { LayerPositionUtils } from "../../Utils/LayerPositionUtils/LayerPositionUtils.js";
import {
LayerPositionUtils,
LayerVecPos,
} from "../../Utils/LayerPositionUtils/LayerPositionUtils.js";

const TEST_CHAR_CONFIG = {
speed: 1,
Expand Down
16 changes: 9 additions & 7 deletions src/Movement/TargetMovement/TargetMovement.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { NoPathFoundStrategy } from "./../../Pathfinding/NoPathFoundStrategy.js";
import { DistanceUtilsFactory } from "./../../Utils/DistanceUtilsFactory/DistanceUtilsFactory.js";
import {
LayerVecPos,
PathfindingOptions,
IsPositionAllowedFn,
} from "./../../Pathfinding/PathfindingOptions.js";
import {
ShortestPath,
ShortestPathAlgorithmType,
} from "./../../Pathfinding/ShortestPathAlgorithm.js";
Expand All @@ -15,14 +18,13 @@ import { Retryable } from "./Retryable/Retryable.js";
import { PathBlockedStrategy } from "../../Pathfinding/PathBlockedStrategy.js";
import { CharLayer, LayerPosition, Position } from "../../GridEngine.js";
import { filter, Subject, take } from "rxjs";
import {
IsPositionAllowedFn,
Pathfinding,
PathfindingOptions,
} from "../../Pathfinding/Pathfinding.js";
import { Pathfinding } from "../../Pathfinding/Pathfinding.js";
import { Concrete } from "../../Utils/TypeUtils.js";
import { Bfs } from "../../Pathfinding/Bfs/Bfs.js";
import { LayerPositionUtils } from "../../Utils/LayerPositionUtils/LayerPositionUtils.js";
import {
LayerPositionUtils,
LayerVecPos,
} from "../../Utils/LayerPositionUtils/LayerPositionUtils.js";

/**
* @category Pathfinding
Expand Down
6 changes: 4 additions & 2 deletions src/Pathfinding/AStar/AStar.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import {
LayerVecPos,
ShortestPathAlgorithm,
ShortestPathResult,
} from "../ShortestPathAlgorithm.js";
import { VectorUtils } from "../../Utils/VectorUtils.js";
import { MinFibonacciHeap } from "mnemonist/fibonacci-heap";
import { LayerPositionUtils } from "../../Utils/LayerPositionUtils/LayerPositionUtils.js";
import {
LayerPositionUtils,
LayerVecPos,
} from "../../Utils/LayerPositionUtils/LayerPositionUtils.js";

interface ShortestPathTuple {
previous: Map<string, LayerVecPos>;
Expand Down
6 changes: 4 additions & 2 deletions src/Pathfinding/Bfs/Bfs.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import {
LayerVecPos,
ShortestPathAlgorithm,
ShortestPathResult,
} from "./../ShortestPathAlgorithm.js";
import { VectorUtils } from "../../Utils/VectorUtils.js";
import { Queue } from "../../Datastructures/Queue/Queue.js";
import { LayerPositionUtils } from "../../Utils/LayerPositionUtils/LayerPositionUtils.js";
import {
LayerPositionUtils,
LayerVecPos,
} from "../../Utils/LayerPositionUtils/LayerPositionUtils.js";

interface ShortestPathTuple {
previous: Map<string, LayerVecPos>;
Expand Down
Loading

0 comments on commit a1f6366

Please sign in to comment.