-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(types): add internal annotations
- Loading branch information
Showing
22 changed files
with
60 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1 @@ | ||
import type { PathfindingEventPayload, PathfindingEventsParent } from './types'; | ||
export declare class PathfindingEvents { | ||
private listeners; | ||
private parent; | ||
constructor(parent: PathfindingEventsParent); | ||
on<K extends keyof PathfindingEventPayload>(event: K, callback: (payload: PathfindingEventPayload[K]) => void): void; | ||
send<K extends keyof PathfindingEventPayload>(event: K, payload: PathfindingEventPayload[K]): void; | ||
} | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1 @@ | ||
import type { PathfindingTaskResult } from '../task/types'; | ||
import type { PathfindingGrid, PathfindingPosition } from '../types'; | ||
export declare enum PathfindingEvent { | ||
CreateTask = "CreateTask", | ||
CompleteTask = "CompleteTask", | ||
CancelTask = "CancelTask", | ||
AddLayer = "AddLayer", | ||
RemoveLayer = "RemoveLayer", | ||
SetWalkable = "SetWalkable", | ||
SetWeight = "SetWeight" | ||
} | ||
export type PathfindingEventPayload = { | ||
[PathfindingEvent.CreateTask]: { | ||
idLayer: string; | ||
idTask: number; | ||
from: PathfindingPosition; | ||
to: PathfindingPosition; | ||
}; | ||
[PathfindingEvent.CancelTask]: { | ||
idLayer: string; | ||
idTask: number; | ||
}; | ||
[PathfindingEvent.SetWeight]: { | ||
idLayer: string; | ||
position: PathfindingPosition; | ||
value: number | null; | ||
}; | ||
[PathfindingEvent.SetWalkable]: { | ||
idLayer: string; | ||
position: PathfindingPosition; | ||
state: boolean; | ||
}; | ||
[PathfindingEvent.CompleteTask]: { | ||
idLayer: string; | ||
idTask: number; | ||
result: PathfindingTaskResult; | ||
}; | ||
[PathfindingEvent.AddLayer]: { | ||
idLayer: string; | ||
grid: PathfindingGrid; | ||
}; | ||
[PathfindingEvent.RemoveLayer]: { | ||
idLayer: string; | ||
}; | ||
}; | ||
export interface PathfindingEventsParent { | ||
on(event: 'message', callback: (body: PathfindingEventsBody) => void): void; | ||
postMessage(payload: Record<string, any>): void; | ||
} | ||
export type PathfindingEventsBody = { | ||
event: string; | ||
payload: Record<string, any>; | ||
}; | ||
export {}; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1 @@ | ||
import type { PathfindingNodeConfig } from './types'; | ||
import type { PathfindingTaskResult } from '../task/types'; | ||
import type { PathfindingPosition } from '../types'; | ||
export declare class PathfindingNode { | ||
readonly position: PathfindingPosition; | ||
readonly distance: number; | ||
private parent; | ||
private weight; | ||
constructor({ position, distance, weight, }: PathfindingNodeConfig); | ||
getBetterGuessDistance(): number; | ||
getWeight(): number; | ||
setWeight(weight: number): void; | ||
getParent(): PathfindingNode | null; | ||
setParent(parent: PathfindingNode): void; | ||
compute(): PathfindingTaskResult; | ||
getNextWeight(shift: PathfindingPosition, weights: number[][]): number; | ||
} | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1 @@ | ||
import type { PathfindingPosition } from '../types'; | ||
export type PathfindingNodeConfig = { | ||
position: PathfindingPosition; | ||
distance: number; | ||
weight?: number; | ||
}; | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1 @@ | ||
export declare const PATHFINDING_PROCESS_LOOP_RATE = 200; | ||
export declare const PATHFINDING_PROCESS_NEXT_DIRECTIINS_STRAIGHT: { | ||
R: { | ||
x: number; | ||
y: number; | ||
}; | ||
L: { | ||
x: number; | ||
y: number; | ||
}; | ||
D: { | ||
x: number; | ||
y: number; | ||
}; | ||
U: { | ||
x: number; | ||
y: number; | ||
}; | ||
}; | ||
export declare const PATHFINDING_PROCESS_NEXT_DIRECTIINS_DIAGONAL: { | ||
RD: { | ||
x: number; | ||
y: number; | ||
}; | ||
RU: { | ||
x: number; | ||
y: number; | ||
}; | ||
LU: { | ||
x: number; | ||
y: number; | ||
}; | ||
LD: { | ||
x: number; | ||
y: number; | ||
}; | ||
}; | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1 @@ | ||
import type { PathfindingTask } from '../task'; | ||
import type { PathfindingGrid, PathfindingPosition } from '../types'; | ||
export declare class PathfindingProcess { | ||
private readonly grids; | ||
private readonly weights; | ||
private queue; | ||
private timer; | ||
constructor(loopRate?: number); | ||
destroy(): void; | ||
createTask(task: PathfindingTask): void; | ||
cancelTask(idLayer: string, idTask: number): void; | ||
addLayer(idLayer: string, grid: PathfindingGrid): void; | ||
removeLayer(idLayer: string): void; | ||
setWeight(idLayer: string, position: PathfindingPosition, value: number | null): void; | ||
setWalkable(idLayer: string, position: PathfindingPosition, state: boolean): void; | ||
private next; | ||
private getNextDirections; | ||
private isWalkable; | ||
} | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1 @@ | ||
import { PathfindingNode } from '../node'; | ||
import type { PathfindingTaskConfig, PathfindingTaskResult } from './types'; | ||
import type { PathfindingPosition } from '../types'; | ||
export declare class PathfindingTask { | ||
readonly from: PathfindingPosition; | ||
readonly to: PathfindingPosition; | ||
readonly id: number; | ||
readonly diagonals: boolean; | ||
readonly idLayer: string; | ||
private tree; | ||
private nodes; | ||
readonly complete: (result: PathfindingTaskResult) => void; | ||
constructor({ idTask, from, to, idLayer, diagonals }: PathfindingTaskConfig, onComplete: (result: PathfindingTaskResult) => void); | ||
private getDistanceFrom; | ||
addNode(parent: PathfindingNode, position: PathfindingPosition, weight: number): void; | ||
private pushNode; | ||
pickNode(position: PathfindingPosition): PathfindingNode; | ||
takeLastNode(): PathfindingNode | null; | ||
useNode(current: PathfindingNode, next: PathfindingNode, weight: number): void; | ||
getNextWeight(currentNode: PathfindingNode, shift: PathfindingPosition, weights: number[][]): number; | ||
} | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1 @@ | ||
import type { PathfindingPosition } from '../types'; | ||
export type PathfindingTaskConfig = { | ||
idTask: number; | ||
idLayer: string; | ||
from: PathfindingPosition; | ||
to: PathfindingPosition; | ||
diagonals?: boolean; | ||
}; | ||
export type PathfindingTaskResult = { | ||
path: PathfindingPosition[] | null; | ||
weight: number; | ||
}; | ||
export type PathfindingTaskCallback = (result: PathfindingTaskResult) => void; | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters