A* Pathfinding Project  4.1.9
The A* Pathfinding Project for Unity 3D
CooperativeContext.Agent Class Reference

Public Member Functions

 Agent (CooperativeContext context, GraphNode initialNode, int id)
 
uint ApproximateDistanceToTarget (GraphNode node)
 
void DiscardRemainingPath ()
 
CooperativeABPath GetNewPath (Vector3 target)
 
GraphNode GetNode (int tick)
 
float MeasureDistance (float startTime, float endTime)
 
void OnPostTick ()
 
Vector3 SamplePath (float time)
 Determine where this agent should be at the specified tick. More...
 
Vector3 SampleSmoothPath (float startTime, float endTime)
 Determine where this agent should be at the specified tick. More...
 

Public Attributes

readonly CooperativePathData path
 
readonly CooperativePathData threadsafePath
 
bool wantToOptimizePath
 

Package Attributes

int moved
 
GraphNode node
 

Properties

MonoBehaviour component [get, set]
 
bool enabled [get, set]
 
float endOfPathTime [get]
 
bool wantsToRecalculatePath [get]
 
- Properties inherited from CooperativeContext.IAgent
MonoBehaviour component [get, set]
 
bool enabled [get, set]
 
float endOfPathTime [get]
 
bool wantsToRecalculatePath [get]
 

Private Member Functions

CooperativeABPath.LatePathData GetLatestPathData ()
 Retrieves the latest info on where the path should start. More...
 
void OnImmediatePathComplete (Path _path)
 Called right after the path has been calculated. More...
 

Static Private Member Functions

static Vector3 SamplePath (List< GraphNode > path, float relativeTick, Vector3 defaultValue)
 Sample where the specified path expects an agent to be at the specified tick. More...
 
static Vector3 SamplePath (List< GraphNode > path, float relativeTick, Vector3 defaultValue, out GraphNode secondNode)
 Sample where the specified path expects an agent to be at the specified tick. More...
 

Private Attributes

CooperativeContext cooperativeContext
 
System.Func< CooperativeABPath.LatePathDatagetLatestPathData
 
CooperativeABPath lastPath
 
bool mEnabled = true
 
OnPathDelegate onImmediatePathComplete
 

Constructor & Destructor Documentation

◆ Agent()

Agent ( CooperativeContext  context,
GraphNode  initialNode,
int  id 
)

Member Function Documentation

◆ ApproximateDistanceToTarget()

uint ApproximateDistanceToTarget ( GraphNode  node)

◆ DiscardRemainingPath()

void DiscardRemainingPath ( )

◆ GetLatestPathData()

CooperativeABPath.LatePathData GetLatestPathData ( )
private

Retrieves the latest info on where the path should start.

Called right before a path starts to be calculated.

Warning
If multithreading is used, this may be called from a separate thread. Do not use any part of the Unity API (except basic stuff like math) from this method.

◆ GetNewPath()

CooperativeABPath GetNewPath ( Vector3  target)

◆ GetNode()

GraphNode GetNode ( int  tick)

◆ MeasureDistance()

float MeasureDistance ( float  startTime,
float  endTime 
)

◆ OnImmediatePathComplete()

void OnImmediatePathComplete ( Path  _path)
private

Called right after the path has been calculated.

This happens before it has been post-processed by the Seeker component. We need to reserve all the (time,node) pairs for the path before the next path calculation starts. So it must happen on the pathfinding thread.

Warning
If multithreading is used, this will be called from a separate thread. Do not use any part of the Unity API (except basic stuff like math) from this method.

◆ OnPostTick()

void OnPostTick ( )

◆ SamplePath() [1/3]

Vector3 SamplePath ( float  time)

Determine where this agent should be at the specified tick.

Will correctly handle transitions when a new path has been calculated.

Implements CooperativeContext.IAgent.

◆ SamplePath() [2/3]

static Vector3 SamplePath ( List< GraphNode path,
float  relativeTick,
Vector3  defaultValue 
)
staticprivate

Sample where the specified path expects an agent to be at the specified tick.

Returns default value if the path is null or has no points.

◆ SamplePath() [3/3]

static Vector3 SamplePath ( List< GraphNode path,
float  relativeTick,
Vector3  defaultValue,
out GraphNode  secondNode 
)
staticprivate

Sample where the specified path expects an agent to be at the specified tick.

Returns default value if the path is null or has no points.

◆ SampleSmoothPath()

Vector3 SampleSmoothPath ( float  startTime,
float  endTime 
)

Determine where this agent should be at the specified tick.

Will correctly handle transitions when a new path has been calculated.

Applies some basic smoothing to the path.

Implements CooperativeContext.IAgent.

Member Data Documentation

◆ cooperativeContext

CooperativeContext cooperativeContext
private

◆ getLatestPathData

System.Func<CooperativeABPath.LatePathData> getLatestPathData
private

◆ lastPath

CooperativeABPath lastPath
private

◆ mEnabled

bool mEnabled = true
private

◆ moved

int moved
package

◆ node

GraphNode node
package

◆ onImmediatePathComplete

OnPathDelegate onImmediatePathComplete
private

◆ path

readonly CooperativePathData path

◆ threadsafePath

readonly CooperativePathData threadsafePath

◆ wantToOptimizePath

bool wantToOptimizePath

Property Documentation

◆ component

MonoBehaviour component
getset

◆ enabled

bool enabled
getset

◆ endOfPathTime

float endOfPathTime
get

◆ wantsToRecalculatePath

bool wantsToRecalculatePath
get

The documentation for this class was generated from the following file: