Class BaseAgent<TAgent, TObject, TStateKey, TStateData, TStateDataContext, TActionScheduler, THeuristic, TTerminationEvaluator, TStateManager, TActionKey>
A sample (abstract) agent script for GameObjects; Allows specifying a plan/agent definition and for initializing an instance of a planner and controller; Provides default implementations that can be overridden
Inheritance
Namespace: UnityEngine.AI.Planner.DomainLanguage.TraitBased
Syntax
public abstract class BaseAgent<TAgent, TObject, TStateKey, TStateData, TStateDataContext, TActionScheduler, THeuristic, TTerminationEvaluator, TStateManager, TActionKey> : MonoBehaviour where TAgent : class where TObject : struct, IDomainObject where TStateKey : struct, IEquatable<TStateKey>, IStateKey where TStateData : struct, ITraitBasedStateData<TObject> where TStateDataContext : struct, ITraitBasedStateDataContext<TObject, TStateKey, TStateData> where TActionScheduler : ITraitBasedActionScheduler<TObject, TStateKey, TStateData, TStateDataContext, TStateManager, TActionKey, ActionResult>, IGetActionName, new()
where THeuristic : struct, IHeuristic<TStateData> where TTerminationEvaluator : struct, ITerminationEvaluator<TStateData> where TStateManager : JobComponentSystem, ITraitBasedStateManager<TObject, TStateKey, TStateData, TStateDataContext> where TActionKey : struct, IEquatable<TActionKey>, IActionKeyWithGuid
Type Parameters
Name | Description |
---|---|
TAgent | Agent type (i.e. inheriting class) |
TObject | Object type (usually domain generated code) |
TStateKey | StateKey type (usually domain generated code) |
TStateData | StateData type (usually domain generated code) |
TStateDataContext | StateDataContext type (usually domain generated code) |
TActionScheduler | ActionScheduler type (usually domain generated code) |
THeuristic | Heuristic type (usually domain generated code, but can be custom) |
TTerminationEvaluator | Termination evaluator type (usually domain generated code, but can be custom) |
TStateManager | StateManager type (usually domain generated code) |
TActionKey | ActionKey type (usually just ActionKey) |
Fields
m_StateManager
Instance of the state manager
Declaration
protected TStateManager m_StateManager
Field Value
Type | Description |
---|---|
TStateManager |
Properties
CurrentOperationalAction
Current operational action that the controller is executing
Declaration
public IOperationalAction<TAgent, TStateData, TActionKey> CurrentOperationalAction { get; }
Property Value
Type | Description |
---|---|
IOperationalAction<TAgent, TStateData, TActionKey> |
Methods
CompleteAction()
Signal completion of the current operational action
Declaration
public void CompleteAction()
GetCurrentState(Boolean)
Get the controller's current state (useful in operational actions)
Declaration
public TStateData GetCurrentState(bool readWrite = false)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | readWrite | Whether the state needs to be capable of writing back to |
Returns
Type | Description |
---|---|
TStateData | Current state data |
InitializeController()
Initialize the controller
Declaration
protected virtual void InitializeController()
ReadyToAct()
Override to provide to the planner when a plan can be executed by the controller
Declaration
protected virtual bool ReadyToAct()
Returns
Type | Description |
---|---|
System.Boolean | Whether the plan is ready to be acted upon |
Start()
Start is called on the frame when a script is enabled just before any Update methods are called the first time (See Unity docs)
Declaration
protected virtual void Start()
Update()
Update is called every frame, if the MonoBehaviour is enabled (see Unity docs)
Declaration
protected virtual void Update()