A* Pathfinding Project  3.7.3
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
void Awake ()
 Alerts the Seeker that this modifier exists.
 
void OnDestroy ()
 
void OnDisable ()
 
void OnEnable ()
 
void PreProcess (Path p)
 
- Public Member Functions inherited from IPathModifier
void Apply (Path p, ModifierData source)
 
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
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]
 Higher priority modifiers are executed first.
 
- 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
 
readonly System.Object lockObject = new System.Object ()
 
GraphNode[] prevNodes
 The previous path.
 
int prevPenalty
 The previous penalty used.
 
int prevSeed
 Previous seed.
 
System.Random rnd = new System.Random ()
 A random object.
 
readonly 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
 

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
private
readonly 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
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.

readonly 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
private

Property Documentation

override ModifierData input
get
override ModifierData output
get

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