C# Class Pathfinding.MultiTargetPath

Inheritance: ABPath
Show file Open project: TruckDefenseInstitute/Convoy Class Usage Examples

Public Properties

Property Type Description
callbacks OnPathDelegate[]
chosenTarget int
heuristicMode HeuristicMode
nodePaths List[]
originalTargetPoints Vector3[]
pathsForAll bool
targetNodes GraphNode[]
targetPoints Vector3[]
targetsFound bool[]
vectorPaths List[]

Protected Properties

Property Type Description
targetNodeCount int

Public Methods

Method Description
ChooseShortestPath ( ) : void

Set chosenTarget to the index of the shortest path

Construct ( Array startPoints, Vector3 target, Array callbackDelegates, OnPathDelegate callback = null ) : MultiTargetPath
Construct ( Vector3 start, Array targets, Array callbackDelegates, OnPathDelegate callback = null ) : MultiTargetPath
MultiTargetPath ( ) : UnityEngine

Default constructor. Do not use this. Instead use the static Construct method which can handle path pooling.

RecalculateHTarget ( bool firstTime ) : void
ResetFlags ( ) : void

Reset flag1 on all nodes after the pathfinding has completed (no matter if an error occurs or if the path is canceled)

SetPathParametersForReturn ( int target ) : void

Protected Methods

Method Description
CalculateStep ( long targetTick ) : void
Cleanup ( ) : void
FoundTarget ( PathNode nodeR, int i ) : void
Initialize ( ) : void
OnEnterPool ( ) : void
Prepare ( ) : void
RebuildOpenList ( ) : void
Reset ( ) : void
ReturnPath ( ) : void
Setup ( Vector3 start, Array targets, Array callbackDelegates, OnPathDelegate callback ) : void
Trace ( PathNode node ) : void

Private Methods

Method Description
DebugString ( PathLog logMode ) : string

Method Details

CalculateStep() protected method

protected CalculateStep ( long targetTick ) : void
targetTick long
return void

ChooseShortestPath() public method

Set chosenTarget to the index of the shortest path
public ChooseShortestPath ( ) : void
return void

Cleanup() protected method

protected Cleanup ( ) : void
return void

Construct() public static method

public static Construct ( Array startPoints, Vector3 target, Array callbackDelegates, OnPathDelegate callback = null ) : MultiTargetPath
startPoints Array
target Vector3
callbackDelegates Array
callback OnPathDelegate
return MultiTargetPath

Construct() public static method

public static Construct ( Vector3 start, Array targets, Array callbackDelegates, OnPathDelegate callback = null ) : MultiTargetPath
start Vector3
targets Array
callbackDelegates Array
callback OnPathDelegate
return MultiTargetPath

FoundTarget() protected method

protected FoundTarget ( PathNode nodeR, int i ) : void
nodeR PathNode
i int
return void

Initialize() protected method

protected Initialize ( ) : void
return void

MultiTargetPath() public method

Default constructor. Do not use this. Instead use the static Construct method which can handle path pooling.
public MultiTargetPath ( ) : UnityEngine
return UnityEngine

OnEnterPool() protected method

protected OnEnterPool ( ) : void
return void

Prepare() protected method

protected Prepare ( ) : void
return void

RebuildOpenList() protected method

protected RebuildOpenList ( ) : void
return void

RecalculateHTarget() public method

public RecalculateHTarget ( bool firstTime ) : void
firstTime bool
return void

Reset() protected method

protected Reset ( ) : void
return void

ResetFlags() public method

Reset flag1 on all nodes after the pathfinding has completed (no matter if an error occurs or if the path is canceled)
public ResetFlags ( ) : void
return void

ReturnPath() protected method

protected ReturnPath ( ) : void
return void

SetPathParametersForReturn() public method

public SetPathParametersForReturn ( int target ) : void
target int
return void

Setup() protected method

protected Setup ( Vector3 start, Array targets, Array callbackDelegates, OnPathDelegate callback ) : void
start Vector3
targets Array
callbackDelegates Array
callback OnPathDelegate
return void

Trace() protected method

protected Trace ( PathNode node ) : void
node PathNode
return void

Property Details

callbacks public property

Callbacks to call for each individual path
public OnPathDelegate[] callbacks
return OnPathDelegate[]

chosenTarget public property

The closest target index (if any target was found)
public int chosenTarget
return int

heuristicMode public property

How to calculate the heuristic. The \link hTarget heuristic target point \endlink can be calculated in different ways, by taking the Average position of all targets, or taking the mid point of them (i.e center of the AABB encapsulating all targets). The one which works best seems to be Sequential, it sets hTarget to the target furthest away, and when that target is found, it moves on to the next one.\n Some modes have the option to be 'moving' (e.g 'MovingAverage'), that means that it is updated every time a target is found.\n The H score is calculated according to AstarPath.heuristic Note: If pathsForAll is false then this option is ignored and it is always treated as being set to None
public HeuristicMode heuristicMode
return HeuristicMode

nodePaths public property

Stores all paths to the targets. Elements are null if no path was found
public List[] nodePaths
return List[]

originalTargetPoints public property

Target points specified when creating the path. These are not snapped to the nearest nodes
public Vector3[] originalTargetPoints
return Vector3[]

pathsForAll public property

If true, a path to all targets will be returned, otherwise just the one to the closest one.
public bool pathsForAll
return bool

targetNodeCount protected property

Number of target nodes left to find
protected int targetNodeCount
return int

targetNodes public property

Nearest nodes to the targetPoints
public GraphNode[] targetNodes
return GraphNode[]

targetPoints public property

Target points specified when creating the path. These are snapped to the nearest nodes
public Vector3[] targetPoints
return Vector3[]

targetsFound public property

Indicates if the target has been found. Also true if the target cannot be reached (is in another area)
public bool[] targetsFound
return bool[]

vectorPaths public property

Stores all vector paths to the targets. Elements are null if no path was found
public List[] vectorPaths
return List[]