Interface IGridEngine

Hierarchy

  • IGridEngine

Implemented by

Basic Movement

  • 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.

    Parameters

    Returns void

  • Parameters

    Returns Observable<{
        charId: string;
    } & PositionChange>

    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.

    Parameters

    Returns void

Character

  • Add labels to the character.

    Parameters

    • charId: string
    • labels: string[]

    Returns void

  • Removes all labels from the character.

    Parameters

    • charId: string

    Returns void

  • Parameters

    • charId: string

    Returns boolean

    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.

  • Returns Observable<{
        charId: string;
        direction: Direction;
    }>

    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 turnTowards.

    This obsersable never emits more than one time in a row for the same direction. So for instance, if 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

    Parameters

    • charId: string

    Returns undefined | string

  • Returns all collision groups of the given character. Collision Groups Example

    Parameters

    • charId: string

    Returns string[]

    All collision groups of the given character.

  • Parameters

    • charId: string

    Returns Direction

    Direction the character is currently facing. At time of creation this is down.

  • Returns all collision groups the character should ignore.

    Parameters

    • charId: string

    Returns string[]

  • Parameters

    • charId: string

    Returns string[]

    All labels, attached to the character.

  • Parameters

    • charId: string

    Returns MovementInfo

    Information about the current automatic movement (including random movement, follow movement and target movement)

  • Returns the movement progress (0-1000) of a character to the next tile. For example, if a character has movement progress 400 that means that it has moved 400/1000th of the distance to the next tile already.

    Parameters

    • charId: string

    Returns number

  • Parameters

    • charId: string

    Returns number

    Speed in tiles per second for a character.

  • Returns Observable<{
        charId: string;
        direction: Direction;
    }>

    Observable that on each start of a movement will provide the character ID and the direction.

  • Returns Observable<{
        charId: string;
        direction: Direction;
    }>

    Observable that on each stopped movement of a character will provide it’s ID and the direction of that movement.

  • Returns Observable<{
        charId: string;
    } & PositionChange>

    Observable that will notify about every change of tile position. It will notify at the end of the movement.

  • Returns Observable<{
        charId: string;
    } & PositionChange>

    Observable that will notify about every change of tile position. It will notify at the beginning of the movement.

  • Remove labels from the character.

    Parameters

    • charId: string
    • labels: string[]

    Returns void

  • Sets collision groups for the given character. Previous collision groups will be overwritten.

    Parameters

    • charId: string
    • collisionGroups: string[]

    Returns void

  • Sets collision groups for the given character. Previous collision groups will be overwritten.

    Parameters

    • charId: string
    • ignoreCollisionGroups: string[]

    Returns void

  • 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.

    Parameters

    • charId: string
    • pos: Position
    • Optional layer: string

    Returns void

  • Sets the speed in tiles per second for a character.

    Parameters

    • charId: string
    • speed: number

    Returns void

Chatacter State

  • Parameters

    • charId: string

    Returns boolean

    True if the character is currently moving.

Grid Engine

  • Checks whether a character with the given ID is registered.

    Parameters

    • charId: string

    Returns boolean

  • Refresh the tile collision cache. For performance reasons, you should provide an area that needs to be rebuilt, if possible. You need to have cacheTileCollisions enabled.

    For more information on pathfinding performance check out pathfinding performance.

    Parameters

    • x: number
    • y: number
    • width: number
    • height: number

    Returns void

  • Removes all characters from the plugin. Please note that the corresponding sprites and containers need to be removed separately.

    Returns void

  • Removes the character with the given ID from the plugin. Please note that the corresponding sprite and container need to be removed separately.

    Parameters

    • charId: string

    Returns void

  • Parameters

    • _time: number
    • delta: number

    Returns void

Other

  • Parameters

    Returns string[]

    All character IDs that are registered in the plugin, satisfying the provided filtering options.

Pathfinding

  • Character charId will start to walk towards charIdToFollow on a shortest path until it reaches the specified distance.

    Parameters

    • charId: string

      ID of character that should follow

    • charIdToFollow: string

      ID of character that should be followed

    • Optional options: FollowOptions

    Returns void

  • Parameters

    • charId: string

      ID of character that should follow

    • charIdToFollow: string

      ID of character that should be followed

    • Optional distance: number

      Minimum 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: boolean

      charId 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.

    Returns void

    Deprecated

    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.

  • Parameters

    • charId: string
    • charIdToFollow: string
    • Optional distance: number | FollowOptions
    • Optional closestPointIfBlocked: boolean

    Returns void

  • Returns the tile cost for a position.

    Parameters

    Returns number

  • Initiates movement toward the specified targetPos. The movement will happen along one shortest path. Check out MoveToConfig for pathfinding configurations.

    Parameters

    Returns Observable<{
        charId: string;
    } & Finished>

    an 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.

Queue Movement

  • Adds new positions to the movement queue. Any other automatic movement of the character will be stopped.

    Parameters

    • charId: string
    • positions: (Direction | LayerPosition)[]

      Positions to enqueue

    • Optional options: QueueMovementConfig

      Options for the queue movement. These options take effect immediately (also for previously enqueued but not yet executed movements).

    Returns any

  • Clears the complete movement queue for the character, that was filled by using addQueueMovements.

    Parameters

    • charId: string

    Returns void

Random Movement

  • 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).

    Parameters

    • charId: string
    • delay: number
    • radius: number

    Returns void

Tilemap

  • Finds the identifiers of all characters at the provided tile position.

    Parameters

    • position: Position
    • Optional layer: string

    Returns string[]

    The identifiers of all characters on this tile.

  • Beta

    Parameters

    Returns undefined | string

    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.

    Parameters

    • position: Position
    • Optional layer: string
    • Optional collisionGroups: string[]

    Returns boolean

    True 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.

    Parameters

    • position: Position
    • Optional layer: string

    Returns boolean

    True if position on given layer is blocked by the tilemap.

  • Beta

    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

    Parameters

    • position: Position

      Position of the new transition

    • fromLayer: string

      Character layer the new transition should start at

    • toLayer: string

      Character layer the new transition should lead to

    Returns void

Generated using TypeDoc