A* Pathfinding Project
3.8
The A* Pathfinding Project for Unity 3D
|
Applies penalty to the paths it processes telling other units to avoid choosing the same path. More...
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. | |
new void | OnDestroy () |
Public Member Functions inherited from MonoModifier | |
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) |
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 |
|
virtual |
Main Post-Processing function.
Implements MonoModifier.
|
private |
|
private |
|
private |
new void OnDestroy | ( | ) |
|
private |
|
private |
int penalty = 1000 |
How much penalty (weight) to apply to nodes.
|
private |
The previous path.
|
private |
The previous penalty used.
Stored just in case it changes during operation
|
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.
|
private |
A random object.
|
private |
A random object generating random seeds for other random objects.
|
private |
The nodes waiting to have their penalty changed.
|
private |
|
get |