Corgi Engine  v9.2
MoreMountains.Tools.AIBrain Class Reference

the AI brain is responsible from going from one state to the other based on the defined transitions. It's basically just a collection of states, and it's where you'll link all the actions, decisions, states and transitions together. More...

Inheritance diagram for MoreMountains.Tools.AIBrain:

Public Member Functions

virtual AIAction[] GetAttachedActions ()
 
virtual AIDecision[] GetAttachedDecisions ()
 
virtual void TransitionToState (string newStateName)
 Transitions to the specified state, trigger exit and enter states events More...
 
virtual void ResetBrain ()
 Resets the brain, forcing it to enter its first state More...
 
virtual void DeleteUnusedActionsAndDecisions ()
 Triggered via the context menu in its inspector (or if you call it directly), this will remove any unused actions and decisions from the brain More...
 

Public Attributes

GameObject Owner
 the owner of that AI Brain, usually the associated character More...
 
List< AIStateStates
 the collection of states More...
 
float TimeInThisState
 the time we've spent in the current state More...
 
Transform Target
 the current target More...
 
Vector3 _lastKnownTargetPosition = Vector3.zero
 the last known world position of the target More...
 
bool BrainActive = true
 whether or not this brain is active More...
 
bool ResetBrainOnStart = true
 
bool ResetBrainOnEnable = false
 
float ActionsFrequency = 0f
 the frequency (in seconds) at which to perform actions (lower values : higher frequency, high values : lower frequency but better performance) More...
 
float DecisionFrequency = 0f
 the frequency (in seconds) at which to evaluate decisions More...
 
bool RandomizeFrequencies = false
 whether or not to randomize the action and decision frequencies More...
 
Vector2 RandomActionFrequency = new Vector2(0.5f, 1f)
 the min and max values between which to randomize the action frequency More...
 
Vector2 RandomDecisionFrequency = new Vector2(0.5f, 1f)
 the min and max values between which to randomize the decision frequency More...
 

Protected Member Functions

virtual void OnEnable ()
 
virtual void Awake ()
 On awake we set our brain for all states More...
 
virtual void Start ()
 On Start we set our first state More...
 
virtual void Update ()
 Every frame we update our current state More...
 
virtual void OnExitState ()
 When exiting a state we reset our time counter More...
 
virtual void InitializeDecisions ()
 Initializes all decisions More...
 
virtual void InitializeActions ()
 Initializes all actions More...
 
AIState FindState (string stateName)
 Returns a state based on the specified state name More...
 
virtual void StoreLastKnownPosition ()
 Stores the last known position of the target More...
 

Protected Attributes

AIDecision[] _decisions
 
AIAction[] _actions
 
float _lastActionsUpdate = 0f
 
float _lastDecisionsUpdate = 0f
 
AIState _initialState
 
AIState _newState
 

Properties

virtual AIState CurrentState [get, protected set]
 this brain's current state More...
 

Detailed Description

the AI brain is responsible from going from one state to the other based on the defined transitions. It's basically just a collection of states, and it's where you'll link all the actions, decisions, states and transitions together.

Member Function Documentation

◆ Awake()

virtual void MoreMountains.Tools.AIBrain.Awake ( )
protectedvirtual

On awake we set our brain for all states

◆ DeleteUnusedActionsAndDecisions()

virtual void MoreMountains.Tools.AIBrain.DeleteUnusedActionsAndDecisions ( )
virtual

Triggered via the context menu in its inspector (or if you call it directly), this will remove any unused actions and decisions from the brain

◆ FindState()

AIState MoreMountains.Tools.AIBrain.FindState ( string  stateName)
protected

Returns a state based on the specified state name

Parameters
stateName
Returns

◆ GetAttachedActions()

virtual AIAction [] MoreMountains.Tools.AIBrain.GetAttachedActions ( )
virtual

◆ GetAttachedDecisions()

virtual AIDecision [] MoreMountains.Tools.AIBrain.GetAttachedDecisions ( )
virtual

◆ InitializeActions()

virtual void MoreMountains.Tools.AIBrain.InitializeActions ( )
protectedvirtual

Initializes all actions

◆ InitializeDecisions()

virtual void MoreMountains.Tools.AIBrain.InitializeDecisions ( )
protectedvirtual

Initializes all decisions

◆ OnEnable()

virtual void MoreMountains.Tools.AIBrain.OnEnable ( )
protectedvirtual

◆ OnExitState()

virtual void MoreMountains.Tools.AIBrain.OnExitState ( )
protectedvirtual

When exiting a state we reset our time counter

◆ ResetBrain()

virtual void MoreMountains.Tools.AIBrain.ResetBrain ( )
virtual

Resets the brain, forcing it to enter its first state

◆ Start()

virtual void MoreMountains.Tools.AIBrain.Start ( )
protectedvirtual

On Start we set our first state

◆ StoreLastKnownPosition()

virtual void MoreMountains.Tools.AIBrain.StoreLastKnownPosition ( )
protectedvirtual

Stores the last known position of the target

◆ TransitionToState()

virtual void MoreMountains.Tools.AIBrain.TransitionToState ( string  newStateName)
virtual

Transitions to the specified state, trigger exit and enter states events

Parameters
newStateName

◆ Update()

virtual void MoreMountains.Tools.AIBrain.Update ( )
protectedvirtual

Every frame we update our current state

Member Data Documentation

◆ _actions

AIAction [] MoreMountains.Tools.AIBrain._actions
protected

◆ _decisions

AIDecision [] MoreMountains.Tools.AIBrain._decisions
protected

◆ _initialState

AIState MoreMountains.Tools.AIBrain._initialState
protected

◆ _lastActionsUpdate

float MoreMountains.Tools.AIBrain._lastActionsUpdate = 0f
protected

◆ _lastDecisionsUpdate

float MoreMountains.Tools.AIBrain._lastDecisionsUpdate = 0f
protected

◆ _lastKnownTargetPosition

Vector3 MoreMountains.Tools.AIBrain._lastKnownTargetPosition = Vector3.zero

the last known world position of the target

◆ _newState

AIState MoreMountains.Tools.AIBrain._newState
protected

◆ ActionsFrequency

float MoreMountains.Tools.AIBrain.ActionsFrequency = 0f

the frequency (in seconds) at which to perform actions (lower values : higher frequency, high values : lower frequency but better performance)

◆ BrainActive

bool MoreMountains.Tools.AIBrain.BrainActive = true

whether or not this brain is active

◆ DecisionFrequency

float MoreMountains.Tools.AIBrain.DecisionFrequency = 0f

the frequency (in seconds) at which to evaluate decisions

◆ Owner

GameObject MoreMountains.Tools.AIBrain.Owner

the owner of that AI Brain, usually the associated character

◆ RandomActionFrequency

Vector2 MoreMountains.Tools.AIBrain.RandomActionFrequency = new Vector2(0.5f, 1f)

the min and max values between which to randomize the action frequency

◆ RandomDecisionFrequency

Vector2 MoreMountains.Tools.AIBrain.RandomDecisionFrequency = new Vector2(0.5f, 1f)

the min and max values between which to randomize the decision frequency

◆ RandomizeFrequencies

bool MoreMountains.Tools.AIBrain.RandomizeFrequencies = false

whether or not to randomize the action and decision frequencies

◆ ResetBrainOnEnable

bool MoreMountains.Tools.AIBrain.ResetBrainOnEnable = false

◆ ResetBrainOnStart

bool MoreMountains.Tools.AIBrain.ResetBrainOnStart = true

◆ States

List<AIState> MoreMountains.Tools.AIBrain.States

the collection of states

◆ Target

Transform MoreMountains.Tools.AIBrain.Target

the current target

◆ TimeInThisState

float MoreMountains.Tools.AIBrain.TimeInThisState

the time we've spent in the current state

Property Documentation

◆ CurrentState

virtual AIState MoreMountains.Tools.AIBrain.CurrentState
getprotected set

this brain's current state


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