Table of Contents

Class AIBehaviorNode

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Abstract base class for all behavior tree nodes. Nodes are ScriptableObject assets so designers can build trees entirely in the Unity inspector without code.

Behavior trees sit above the state machine layer and decide which BaseAIState the NPC should transition to. The state machine then handles the actual movement, combat, and animation logic.

Node types:

public abstract class AIBehaviorNode : ScriptableObject
Inheritance
Object
ScriptableObject
AIBehaviorNode
Derived
Inherited Members
ScriptableObject.SetDirty()
ScriptableObject.CreateInstance<T>()
Object.GetEntityId()
Object.GetInstanceID()
Object.GetHashCode()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Scene)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.Instantiate(Object, Transform)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Destroy(Object)
Object.DestroyImmediate(Object)
Object.DontDestroyOnLoad(Object)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Object.FindObjectsByType<T>()
Object.FindObjectsByType<T>(FindObjectsInactive)
Object.ToString()
Object.name
Object.hideFlags

Fields

EditorComment

[TextArea(1, 3)]
[Tooltip("Designer note — has no runtime effect.")]
public string EditorComment

Field Value

string

EditorPosition

[HideInInspector]
public Vector2 EditorPosition

Field Value

Vector2

MAX_EVALUATION_DEPTH

Maximum node depth a tree may descend to in one evaluation.

public const int MAX_EVALUATION_DEPTH = 64

Field Value

int

Remarks

Generous enough that no sane hand-authored tree reaches it, small enough that hitting it costs nothing. A tree deeper than this is a cycle, not a design.

Properties

DepthExceeded

True when the evaluation in progress has descended past MAX_EVALUATION_DEPTH, which means the tree contains a cycle.

public static bool DepthExceeded { get; }

Property Value

bool

Methods

Ascend()

Leaves a child node.

protected static void Ascend()

BeginEvaluation()

Resets the depth counter at the start of a tree evaluation.

public static void BeginEvaluation()

EndEvaluation()

Clears evaluation state once a tree evaluation finishes.

public static void EndEvaluation()

Evaluate(AIController)

Evaluate this node for the given NPC. Called once per behavior tree tick (not every frame).

public abstract AINodeResult Evaluate(AIController controller)

Parameters

controller AIController

The AI controller of the evaluating NPC.

Returns

AINodeResult

The result of this node's evaluation.

EvaluateChild(AIBehaviorNode, AIController)

Evaluates a child node with depth accounting.

protected static AINodeResult EvaluateChild(AIBehaviorNode child, AIController controller)

Parameters

child AIBehaviorNode

The child to evaluate. Null returns Failure.

controller AIController

The AI controller of the evaluating NPC.

Returns

AINodeResult

The child's result, or Failure when the depth limit was hit.

TryDescend()

Enters a child node, refusing to descend when the depth limit has been reached.

protected static bool TryDescend()

Returns

bool

True when it is safe to descend.

Remarks

Composite and decorator nodes call this before evaluating a child. Returning false turns a cyclic tree into a failed evaluation — the NPC falls back to its state machine — instead of a stack overflow that takes the server process down with it.