Class GridEngineHeadless

Implements

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

Character

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

    Parameters

    • charId: string

    Returns undefined | string

  • 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

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

  • 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

Grid Engine

  • 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

GridEngine

Other

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.

  • 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: (LayerPosition | Direction)[]

      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 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 = 0
    • radius: number = -1

    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.

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

  • 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