Observable that, whenever a specified position is entered on optionally provided layers, will notify with the target characters position change
Turns the character towards the given direction without moving it.
true if the character is able to collide with the tilemap. Don't confuse this with an actual collision check. You should use isBlocked or isTileBlocked for this.
Observable that will notify about every change of direction that is not part of a movement. This is the case if the character tries to walk towards a blocked tile. The character will turn but not move. It also emits when you call GridEngine.turnTowards.
This obsersable never emits more than one time in a row for the same direction. So for instance, if GridEngine.turnTowards is called multiple times in a row (without any facing direction change occurring inbetween) with the same direction, this observable would only emit once.
Returns the character layer of the given character. You can read more about character layers and transitions here
Returns all collision groups of the given character. Collision Groups Example
All collision groups of the given character.
Information about the current automatic movement (including random movement, follow movement and target movement)
Observable that will notify about every change of tile position. It will notify at the end of the movement.
Observable that will notify about every change of tile position. It will notify at the beginning of the movement.
Refresh the tile collision cache. For performance reasons, you should provide an area that needs to be rebuilt, if possible. You need to have GridEngineConfigHeadless.cacheTileCollisions enabled.
For more information on pathfinding performance check out pathfinding performance.
Places the character with the given id to the provided tile position. If that character is moving, the movement is stopped. The positionChangeStarted and positionChangeFinished observables will emit. If the character was moving, the movementStopped observable will also emit.
Optional
layer: stringStops any automated movement such as random movement (moveRandomly), following (follow), moving to a specified position (moveTo) or queued movements (addQueueMovements).
Adds a character after calling create.
Initializes GridEngine. Must be called before any other methods of GridEngine are called.
Optional
options: CharacterFilteringOptionsAll character IDs that are registered in the plugin, satisfying the provided filtering options.
Observable that emits when a new character is added or an existing is removed.
Beta
Returns the current state of Grid Engine. This is useful for persiting or sharing the state.
Beta
Sets the given state for Grid Engine. Be aware that it will not remove any characters from Grid Engine. If you want to completely reset the state, you should call GridEngineHeadless.create or remove all characters via GridEngineHeadless.removeAllCharacters.
Alpha
Returns the shortest path from source to destination.
Source position
Destination position
Pathfinding options
Shortest path. In case that no path could be found,
closestToTarget
is a position with a minimum distance to the target.
Character charId
will start to walk towards charIdToFollow
on a
shortest path until it reaches the specified distance
.
ID of character that should follow
ID of character that should be followed
Optional
options: FollowOptionsID of character that should follow
ID of character that should be followed
Optional
distance: numberMinimum distance to keep to charIdToFollow
in
manhattan distance
in case of 4 direction mode and with and
Chebyshev distance
in case of 8 direction mode.
Optional
closestPointIfBlocked: booleancharId
will move to the closest point
(manhattan distance
in case of 4 direction mode and with and
Chebyshev distance
in case of 8 direction mode)
to charIdToFollow
that is reachable from charId
in case that there
does not exist a path between charId
and charIdToFollow
.
Use follow(charId: string, charIdToFollow: string, options: FollowOptions): void; instead.
Character charId
will start to walk towards charIdToFollow
on a
shortest path until it reaches the specified distance
.
Returns the tile cost for a position.
Initiates movement toward the specified targetPos
. The movement will
happen along one shortest path. Check out MoveToConfig for
pathfinding configurations.
Optional
config: MoveToConfigan observable that will fire whenever the moveTo movement is finished or aborted. It will provide a result code as well as a description and a character layer.
Adds new positions to the movement queue. Any other automatic movement of the character will be stopped.
Positions to enqueue
Optional
options: QueueMovementConfigOptions for the queue movement. These options take effect immediately (also for previously enqueued but not yet executed movements).
Clears the complete movement queue for the character, that was filled by using IGridEngine.addQueueMovements.
Returns all enqueued movements for the given character.
Emits whenever queued movements for a character finish (with success or failure).
Initiates random movement of the character with the given id. The
character will randomly pick one of the non-blocking directions.
Optionally a delay
in milliseconds can be provided. This represents the
waiting time after a finished movement, before the next is being initiated.
If a radius
other than -1 is provided, the character will not move
further than that radius from its initial position (the position it has
been, when moveRandomly
was called). The distance is calculated with the
manhattan distance
in case of 4 direction mode and with and
Chebyshev distance
in case of 8 direction mode. Additionally, if a radius
other than -1 was
given, the character might move more than one tile into a random direction
in one run (as long as the route is neither blocked nor outside of the
radius).
Finds the identifiers of all characters at the provided tile position.
Optional
layer: stringThe identifiers of all characters on this tile.
Gets the tile position and character layer adjacent to the given position in the given direction.
The character layer that the transition on the given position and character layer leads to.
Checks whether the given position is blocked by either the tilemap or a blocking character. If you provide no layer, be sure not to use character layers in your tilemap.
Optional
layer: stringTrue if position on given layer is blocked by the tilemap or a character
Checks whether the given position is blocked by the tilemap. If you provide no layer, be sure not to use character layers in your tilemap.
Optional
layer: stringTrue if position on given layer is blocked by the tilemap.
Sets the character layer toLayer
that the transition on position
position
from character layer fromLayer
should lead to.
You can read more about character layers and transitions
here
Position of the new transition
Character layer the new transition should start at
Character layer the new transition should lead to
Initiates movement of the character with the given id. If the character is already moving nothing happens. If the movement direction is currently blocked, the character will only turn towards that direction. Movement commands are not queued.