A* Pathfinding Project  3.6.1
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
AlternativePath Class Reference

Applies penalty to the paths it processes telling other units to avoid choosing the same path. More...

Detailed Description

Applies penalty to the paths it processes telling other units to avoid choosing the same path.

Note that this might not work properly if penalties are modified by other actions as well (e.g graph update objects which reset the penalty to zero). It will only work when all penalty modifications are relative, i.e adding or subtracting penalties, but not when setting penalties to specific values.

When destroyed, it will correctly remove any added penalty. However it will only be done before the next path request is calculated, so if this was the last path requesting unit to be destroyed, the penalty will stay in the graph until the next path request is made.

Public Member Functions

override void Apply (Path p, ModifierData source)
 Main Post-Processing function.
 
new void OnDestroy ()
 
- Public Member Functions inherited from MonoModifier
virtual Vector3[] Apply (GraphNode[] path, Vector3 start, Vector3 end, int startIndex, int endIndex, NavGraph graph)
 
virtual Vector3[] Apply (Vector3[] path, Vector3 start, Vector3 end)
 
virtual void ApplyOriginal (Path p)
 
void Awake ()
 Alerts the Seeker that this modifier exists.
 
void OnDestroy ()
 
void OnDisable ()
 
void OnEnable ()
 
virtual void PreProcess (Path p)
 
- Public Member Functions inherited from IPathModifier
void Apply (Path p, ModifierData source)
 
void ApplyOriginal (Path p)
 
void PreProcess (Path p)
 

Public Attributes

int penalty = 1000
 How much penalty (weight) to apply to nodes.
 
int randomStep = 10
 Max number of nodes to skip in a row.
 
- Public Attributes inherited from MonoModifier
int priority = 0
 Higher priority modifiers are executed first.
 
Seeker seeker
 

Properties

override ModifierData input [get]
 
override ModifierData output [get]
 
- Properties inherited from MonoModifier
abstract ModifierData input [get]
 
abstract ModifierData output [get]
 
int Priority [get, set]
 
- Properties inherited from IPathModifier
ModifierData input [get]
 
ModifierData output [get]
 
int Priority [get, set]
 

Private Member Functions

void ApplyNow (Path somePath)
 
void ClearOnDestroy (Path p)
 
void InversePrevious ()
 

Private Attributes

bool destroyed = false
 
System.Object lockObject = new System.Object ()
 
GraphNode[] prevNodes
 The previous path.
 
int prevPenalty = 0
 The previous penalty used.
 
int prevSeed
 Previous seed.
 
System.Random rnd = new System.Random ()
 A random object.
 
System.Random seedGenerator = new System.Random ()
 A random object generating random seeds for other random objects.
 
GraphNode[] toBeApplied
 The nodes waiting to have their penalty changed.
 
bool waitingForApply = false
 

Member Function Documentation

override void Apply ( Path  p,
ModifierData  source 
)
virtual

Main Post-Processing function.

Implements MonoModifier.

void ApplyNow ( Path  somePath)
private
void ClearOnDestroy ( Path  p)
private
void InversePrevious ( )
private
new void OnDestroy ( )

Member Data Documentation

bool destroyed = false
private
System.Object lockObject = new System.Object ()
private
int penalty = 1000

How much penalty (weight) to apply to nodes.

GraphNode [] prevNodes
private

The previous path.

int prevPenalty = 0
private

The previous penalty used.

Stored just in case it changes during operation

int prevSeed
private

Previous seed.

Used to figure out which nodes to revert penalty on without storing them in an array

int randomStep = 10

Max number of nodes to skip in a row.

System.Random rnd = new System.Random ()
private

A random object.

System.Random seedGenerator = new System.Random ()
private

A random object generating random seeds for other random objects.

GraphNode [] toBeApplied
private

The nodes waiting to have their penalty changed.

bool waitingForApply = false
private

Property Documentation

override ModifierData input
get
override ModifierData output
get

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