Skip to content

System: pathfinding

Pathfinding systems.

Provides pathfinding logic for entities with the Pathfinding property. Entities can use either A* pathfinding or a simple straight-line approach to move toward their targets.

entity_pathfinding(state, usage_limit, entity_id)

Apply pathfinding for a single entity (straight-line or A*).

get_astar_next_position(state, entity_id, target_id)

Compute next step toward target using A* with Manhattan distance heuristic.

Parameters:

Name Type Description Default
state State

Current world state.

required
entity_id EntityID

ID of the entity to move.

required
target_id EntityID

ID of the target entity.

required

Returns:

Name Type Description
Position Position

Next position toward the target, or current position if no path found.

get_straight_line_next_position(state, entity_id, target_id)

Compute next step toward target using straight-line heuristic.

Parameters:

Name Type Description Default
state State

Current world state.

required
entity_id EntityID

ID of the entity to move.

required
target_id EntityID

ID of the target entity.

required

Returns:

Name Type Description
Position Position

Next position toward the target.

pathfinding_system(state)

Advance all pathfinding-enabled entities by one tile if possible.