PathwaySingleton
TODO:
- Test on server
- Make debugging class
Static Member Summary
Static Private Members | ||
private static |
The base FPS to base calculations from. |
|
private static |
The minimum distance away from a node before this system determines it has made it to that node. |
|
private static |
The default mode this pathway system uses. |
|
private static |
The default amount of pixels per second to move the instance when using |
|
private static |
The default step pixels per second to use. |
|
private static |
The default step size for this instance to use on the path. |
|
private static |
The tile size to use if no tile size has been assigned. |
|
private static |
A static weight to be applied when a tile should be not be traveled to at all. |
|
private static |
The max amount of delta time between ticks. |
|
private static |
The maximum amount of ticks an instance can be in the same position before the pathfinder deems it "stuck". |
|
private static |
The weight that indicates that this tile is walkable. |
|
private static |
An object that stores the map tiles in normal format and in 2D format. |
Constructor Summary
Private Constructor | ||
private |
|
Member Summary
Public Members | ||
public |
version: * The version of the module. |
Private Members | ||
private |
An array of active instances that are currently pathfinding. |
|
private |
The delta time between the current and last tick. |
|
private |
The time in ms between the current and last tick. |
|
private |
A weakmap storing the data of instances used in this pathfinder. |
|
private |
The last tracked time in the ticker. |
|
private |
The logger module this module uses to log errors / logs |
|
private |
The tile size to use for this system. |
Method Summary
Public Methods | ||
public |
Ends the current pathfinding for pInstance. |
|
public |
setTileSize(pTileSize: number) Sets the tilesize of this system. |
|
public |
Moves pInstance to the destination position with pOptions in mind. |
Private Methods | ||
private |
getIndexOf2DArray(pArray: Array, pValue: any): Array<number> Finds the index of a value in a 2D array. |
|
private |
Generates a path from the origin point to the end point with obstacles in mind. |
|
private |
getPositionFromInstance(pInstance: Object): Object Gets the position from the instance based on the pathfinding info. |
|
private |
isTileAccessible(pTile: Object, pExclusionList: Array): boolean Checks to see if pTile is accessible for movement. |
|
private |
mapTilesToGrid(pMapName: string, pExclusionList: Array): Object | undefined Converts map tiles to grids. |
|
private |
moveInstance(pInstance: Object, pInstanceData: Object, pInstancePosition: Object) Moves the specified instance to the next node. |
|
private |
nodeToTile(pMapName: string, pNode: Object): Object Converts a node to a tile. |
|
private |
tileToNode(pTile: Object}): Object Converts a tile to a node position. |
|
private |
toTwoDimensionalArray(pArray: Array, pLengthOfSubArray: number): Array Converts an array to an 2D array. |
|
private |
Tracks this instance as active. |
|
private |
Untracks this instance. |
|
private |
update() Updates active instances on the pathfinder. |
Static Private Members
private static DEFAULT_MINIMUM_DISTANCE: number source
The minimum distance away from a node before this system determines it has made it to that node.
private static DEFAULT_PIXELS_PER_SECOND: number source
The default amount of pixels per second to move the instance when using position
mode.
private static DEFAULT_STEP_PIXELS_PER_SECOND: number source
The default step pixels per second to use.
private static DEFAULT_STEP_SIZE: number source
The default step size for this instance to use on the path.
private static DEFAULT_TILE_SIZE: number source
The tile size to use if no tile size has been assigned.
private static IMPASSABLE_WEIGHT: number source
A static weight to be applied when a tile should be not be traveled to at all.
private static MAX_DELTA_TIME: number source
The max amount of delta time between ticks. If this limit is passed, it will be clamped.
private static MAX_STUCK_COUNTER: number source
The maximum amount of ticks an instance can be in the same position before the pathfinder deems it "stuck". The user will be able to tweak values up to this max value.
Private Constructors
private constructor() source
Public Members
Private Members
Public Methods
public end(pInstance: Object) source
Ends the current pathfinding for pInstance.
Params:
Name | Type | Attribute | Description |
pInstance | Object | The instance to terminate pathfinding on. |
public setTileSize(pTileSize: number) source
Sets the tilesize of this system.
Params:
Name | Type | Attribute | Description |
pTileSize | number | The tilesize of the game. |
public to(pInstance: Object, pDestination: Object, pOptions: Object) source
Moves pInstance to the destination position with pOptions in mind.
Private Methods
private getIndexOf2DArray(pArray: Array, pValue: any): Array<number> source
Finds the index of a value in a 2D array.
Params:
Name | Type | Attribute | Description |
pArray | Array | The 2D array to search in. |
|
pValue | any | The value to find in the 2D array. |
private getPath(pInstance: Object, pOrigin: Object, pDestination: Object) source
Generates a path from the origin point to the end point with obstacles in mind.
private getPositionFromInstance(pInstance: Object): Object source
Gets the position from the instance based on the pathfinding info. Centered position from the geometrical.
Params:
Name | Type | Attribute | Description |
pInstance | Object | The instance to get the position from. |
private isTileAccessible(pTile: Object, pExclusionList: Array): boolean source
Checks to see if pTile is accessible for movement.
private mapTilesToGrid(pMapName: string, pExclusionList: Array): Object | undefined source
Converts map tiles to grids.
private moveInstance(pInstance: Object, pInstanceData: Object, pInstancePosition: Object) source
Moves the specified instance to the next node.
private tileToNode(pTile: Object}): Object source
Converts a tile to a node position.
Params:
Name | Type | Attribute | Description |
pTile | Object} | The tile to convert into a node position. |
private toTwoDimensionalArray(pArray: Array, pLengthOfSubArray: number): Array source
Converts an array to an 2D array.
private track(pInstance: Object) source
Tracks this instance as active.
Params:
Name | Type | Attribute | Description |
pInstance | Object | The instance to track. |