A* Pathfinding Project  4.3.7
The A* Pathfinding Project for Unity 3D
GridGraphRule Class Reference

Custom rule for a grid graph. More...

Detailed Description

Custom rule for a grid graph.

See also
Pathfinding.GridGraphRules
Grid Graph Rules

Classes

interface  IConnectionFilter
 
interface  INodeModifier
 
struct  JobConnectionFilter
 
struct  JobNodeModifier
 

Public Types

enum  Pass { BeforeCollision, BeforeConnections, AfterConnections, PostProcess }
 Where in the scanning process a rule will be executed. More...
 

Public Member Functions

virtual void DisposeUnmanagedData ()
 Called when the rule is removed or the graph is destroyed. More...
 
virtual void Register (GridGraphRules rules)
 Does preprocessing and adds callbacks to the #GridGraphRules object. More...
 
virtual void SetDirty ()
 Call if you have changed any setting of the rule. More...
 

Static Public Member Functions

static void FilterNodeConnections< T > (IntRect bounds, NativeArray< int > nodeConnections, ref T filter)
 
static void ForEachNode< T > (IntRect bounds, ref T callback)
 

Public Attributes

bool enabled = true
 Only enabled rules are executed. More...
 
virtual int Hash => dirty
 Hash of the settings for this rule. More...
 

Private Attributes

int dirty
 

Member Enumeration Documentation

◆ Pass

enum Pass
strong

Where in the scanning process a rule will be executed.

Enumerator
BeforeCollision 

Before the collision testing phase but after height testing.

This is very early. Most data is not valid by this point.

You can use this if you want to modify the node positions and still have it picked up by the collision testing code.

BeforeConnections 

Before connections are calculated.

At this point height testing, collision testing has been done (if they are enabled).

This is the most common pass to use. If you are modifying walkability here then connections and erosion will be calculated properly.

AfterConnections 

After connections are calculated.

If you are modifying connections directly you should that in this pass.

Note
If erosion is used then this pass will be executed twice. One time before erosion and one time after erosion when the connections are calculated again.
PostProcess 

After everything else.

This pass is executed after everything else is done. You should not modify walkability in this pass because then the node connections will not be up to date.

Member Function Documentation

◆ DisposeUnmanagedData()

virtual void DisposeUnmanagedData ( )
virtual

Called when the rule is removed or the graph is destroyed.

Use this to e.g. clean up any NativeArrays that the rule uses.

Note
The rule should remain valid after this method has been called. However the Register method is guaranteed to be called before the rule is executed again.

Reimplemented in RuleTexture, RuleElevationPenalty, and RuleAnglePenalty.

◆ FilterNodeConnections< T >()

static void FilterNodeConnections< T > ( IntRect  bounds,
NativeArray< int >  nodeConnections,
ref T  filter 
)
static
Type Constraints
T :struct 
T :IConnectionFilter 

◆ ForEachNode< T >()

static void ForEachNode< T > ( IntRect  bounds,
ref T  callback 
)
static
Type Constraints
T :struct 
T :INodeModifier 

◆ Register()

virtual void Register ( GridGraphRules  rules)
virtual

Does preprocessing and adds callbacks to the #GridGraphRules object.

Reimplemented in RuleTexture, RulePerLayerModifications, RuleElevationPenalty, and RuleAnglePenalty.

◆ SetDirty()

virtual void SetDirty ( )
virtual

Call if you have changed any setting of the rule.

This will ensure that any cached data the rule uses is rebuilt. If you do not do this then any settings changes may not affect the graph when it is rescanned or updated.

Member Data Documentation

◆ dirty

int dirty
private

◆ enabled

bool enabled = true

Only enabled rules are executed.

◆ Hash

virtual int Hash => dirty

Hash of the settings for this rule.

The Register method will be called again whenever the hash changes. If the hash does not change it is assumed that the Register method does not need to be called again.


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