A* Pathfinding Project  3.8.12
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)
 Main Post-Processing function.
 
override void OnDestroy ()
 
- Public Member Functions inherited from MonoModifier
void Awake ()
 Alerts the Seeker that this modifier exists.
 
void OnDisable ()
 
void OnEnable ()
 
virtual void PreProcess (Path p)
 
- Public Member Functions inherited from IPathModifier
void Apply (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
Seeker seeker
 

Properties

override int Order [get]
 
- Properties inherited from MonoModifier
abstract int Order [get]
 Modifiers will be executed from lower order to higher order.
 
- Properties inherited from IPathModifier
int Order [get]
 

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)
virtual

Main Post-Processing function.

Implements MonoModifier.

void ApplyNow ( Path  somePath)
private
void ClearOnDestroy ( Path  p)
private
void InversePrevious ( )
private
override void OnDestroy ( )
virtual

Reimplemented from MonoModifier.

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 int Order
get

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