AiMalgam Core 1.1.0
API documentation for the generic Unity3D AI System
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Properties | Events | List of all members
NikosAssets.AiMalgam.AiMalgamEntity Class Reference

The core and mandatory MonoBehaviour to represent an AI entity with its linked AI systems More...

Public Member Functions

virtual void AddDescriptor (AiMalgamBaseDescriptor descriptor)
 Add another AiMalgamBaseDescriptor to Descriptors (distinct instance) and emit the OnDescriptorListChanged event on success More...
 
virtual bool RemoveDescriptor (AiMalgamBaseDescriptor descriptor)
 Remove an existing AiMalgamBaseDescriptor to Descriptors and emit the OnDescriptorListChanged event on removal success More...
 
virtual void AddEngine (AiMalgamBaseEngineWrapper baseEngineWrapper)
 Add another AiMalgamBaseEngineWrapper to Engines (distinct instance) and emit the OnEnginesListChanged event on success More...
 
virtual bool RemoveEngine (AiMalgamBaseEngineWrapper baseEngineWrapper)
 Remove an existing AiMalgamBaseEngineWrapper to Engines and emit the OnEnginesListChanged event on removal success More...
 
virtual void CleanInvalidEngines ()
 Helper method to remove old (and wrong) AiMalgamBaseEngineWrappers from Engines
 
virtual void CleanInvalidDescriptors ()
 Helper method to remove old (and wrong) AiMalgamBaseDescriptors from Descriptors
 
virtual void RemoveAllActionsAcrossAllEngines ()
 
virtual bool AddStateDistinct (AiMalgamState state, AiMalgamBaseEngineWrapper baseEngineWrapper=null)
 Adds the state to currentStates (distinct) and emits the OnStateChangedUnityEvent and OnStateChanged events on success More...
 
virtual bool RemoveState (AiMalgamState state, AiMalgamBaseEngineWrapper baseEngineWrapper=null)
 Remove the state from currentStates and emit the OnStateChangedUnityEvent and OnStateChanged events on success More...
 
virtual List< BaseDescriptor > GetDescriptorsByHash< BaseDescriptor > (int hash)
 Get the AiMalgamBaseDescriptors that match their AiMalgamBaseDescriptor.DescriptorTypeSupportedHash with the given hash More...
 
virtual AiMalgamBaseEngineWrapper GetEngineByHash (int hash)
 Get the AiMalgamBaseEngineWrapper that matches its AiMalgamBaseEngineWrapper.ActionTypeSupportedHash with the given hash More...
 
virtual List< AiMalgamBaseEngineWrapperGetEnginesByHash (int hash)
 Get the AiMalgamBaseEngineWrappers that match their AiMalgamBaseEngineWrapper.ActionTypeSupportedHash with the given hash More...
 
virtual AiMalgamApplyActionSettingResult ValidateSettings (AiMalgamBaseSettings baseSettings, out AiMalgamBaseEngineWrapper outEngine)
 Validate the given baseSettings by checking if their supported AiMalgamBaseEngineWrapper exists in Engines and if AiMalgamBaseEngineWrapper.AiMalgamBaseEngineWrapper.ValidateSettings also validates More...
 
virtual AiMalgamApplyActionSettingResult ApplyAndValidateSettings (AiMalgamBaseSettings baseSettings, bool ignoreValidation=false)
 Optionally (ignoreValidation == false) validate the given baseSettings by checking if their supported AiMalgamBaseEngineWrapper exists in Engines and if AiMalgamBaseEngineWrapper.AiMalgamBaseEngineWrapper.ValidateSettings also validates and finally apply the settings in AiMalgamBaseEngineWrapper.AiMalgamBaseEngineWrapper.ApplySettings More...
 

Public Attributes

OnStateChangedUnityEvent OnStateChangedUnityEvent
 
List< AiMalgamStatecurrentStates = new List<AiMalgamState>()
 Represents IAiMalgamBaseActionWrappers or independent AiMalgamStates associated with this entity
 

Protected Member Functions

virtual void Awake ()
 
virtual void Start ()
 
virtual void OnEnable ()
 
virtual void OnDisable ()
 
virtual void OnDestroy ()
 
virtual void OnValidate ()
 
virtual void InvokeStateChanged (AiMalgamBaseEngineWrapper engine, AiMalgamState state, bool addedOrRemoved)
 

Protected Attributes

List< AiMalgamBaseDescriptor_descriptors = new List<AiMalgamBaseDescriptor>()
 Additional data containers also used in AiMalgamBaseConditionForDescriptors<DescriptorType> for AI decision making
 
List< AiMalgamBaseEngineWrapper_engines = new List<AiMalgamBaseEngineWrapper>()
 AiMalgamBaseEngineWrappers attached to this entity, which run their respective and supported IAiMalgamBaseActionWrappers on
 

Properties

List< AiMalgamBaseDescriptorDescriptors [get]
 Additional data containers also used in AiMalgamBaseConditionForDescriptors<DescriptorType> for AI decision making
 
List< AiMalgamBaseEngineWrapperEngines [get]
 AiMalgamBaseEngineWrappers attached to this entity, which run their respective and supported IAiMalgamBaseActionWrappers on
 

Events

Action< AiMalgamBaseEngineWrapper, bool > OnEnginesListChanged
 
Action< AiMalgamBaseDescriptor, bool > OnDescriptorListChanged
 
Action< AiMalgamBaseEngineWrapper, AiMalgamState, bool > OnStateChanged
 

Detailed Description

The core and mandatory MonoBehaviour to represent an AI entity with its linked AI systems

Member Function Documentation

◆ AddDescriptor()

virtual void NikosAssets.AiMalgam.AiMalgamEntity.AddDescriptor ( AiMalgamBaseDescriptor  descriptor)
virtual

Add another AiMalgamBaseDescriptor to Descriptors (distinct instance) and emit the OnDescriptorListChanged event on success

Parameters
descriptorThe AiMalgamBaseDescriptor to add

◆ AddEngine()

virtual void NikosAssets.AiMalgam.AiMalgamEntity.AddEngine ( AiMalgamBaseEngineWrapper  baseEngineWrapper)
virtual

Add another AiMalgamBaseEngineWrapper to Engines (distinct instance) and emit the OnEnginesListChanged event on success

Parameters
baseEngineWrapperThe AiMalgamBaseEngineWrapper to add to Engines

◆ AddStateDistinct()

virtual bool NikosAssets.AiMalgam.AiMalgamEntity.AddStateDistinct ( AiMalgamState  state,
AiMalgamBaseEngineWrapper  baseEngineWrapper = null 
)
virtual

Adds the state to currentStates (distinct) and emits the OnStateChangedUnityEvent and OnStateChanged events on success

Parameters
stateThe AiMalgamState to add to currentStates
baseEngineWrapperThe AiMalgamBaseEngineWrapper which caused this call
Returns
false, if currentStates already contained the given state , or if it was null. Otherwise true

◆ ApplyAndValidateSettings()

virtual AiMalgamApplyActionSettingResult NikosAssets.AiMalgam.AiMalgamEntity.ApplyAndValidateSettings ( AiMalgamBaseSettings  baseSettings,
bool  ignoreValidation = false 
)
virtual

Optionally (ignoreValidation == false) validate the given baseSettings by checking if their supported AiMalgamBaseEngineWrapper exists in Engines and if AiMalgamBaseEngineWrapper.AiMalgamBaseEngineWrapper.ValidateSettings also validates and finally apply the settings in AiMalgamBaseEngineWrapper.AiMalgamBaseEngineWrapper.ApplySettings

Parameters
baseSettingsThe AiMalgamBaseSettings apply (and optionally validate)
ignoreValidationDo we validate the given AiMalgamBaseSettings or jump into applying them. The only thing that is left validating (if set to true), is to check if the matching AiMalgamBaseEngineWrapper exists
Returns
AiMalgamApplyActionSettingResult

◆ GetDescriptorsByHash< BaseDescriptor >()

virtual List< BaseDescriptor > NikosAssets.AiMalgam.AiMalgamEntity.GetDescriptorsByHash< BaseDescriptor > ( int  hash)
virtual

Get the AiMalgamBaseDescriptors that match their AiMalgamBaseDescriptor.DescriptorTypeSupportedHash with the given hash

Parameters
hashThe hash to match against AiMalgamBaseDescriptor.AiMalgamBaseDescriptor.DescriptorTypeSupportedHash
Template Parameters
BaseDescriptorThe AiMalgamBaseDescriptor type to cast
Returns
AiMalgamBaseDescriptors list of type BaseDescriptor
Type Constraints
BaseDescriptor :AiMalgamBaseDescriptor 

◆ GetEngineByHash()

virtual AiMalgamBaseEngineWrapper NikosAssets.AiMalgam.AiMalgamEntity.GetEngineByHash ( int  hash)
virtual

Get the AiMalgamBaseEngineWrapper that matches its AiMalgamBaseEngineWrapper.ActionTypeSupportedHash with the given hash

Parameters
hashThe hash to match against AiMalgamBaseEngineWrapper.AiMalgamBaseEngineWrapper.ActionTypeSupportedHash
Returns
AiMalgamBaseEngineWrapper

◆ GetEnginesByHash()

virtual List< AiMalgamBaseEngineWrapper > NikosAssets.AiMalgam.AiMalgamEntity.GetEnginesByHash ( int  hash)
virtual

Get the AiMalgamBaseEngineWrappers that match their AiMalgamBaseEngineWrapper.ActionTypeSupportedHash with the given hash

Parameters
hashThe hash to match against AiMalgamBaseEngineWrapper.AiMalgamBaseEngineWrapper.ActionTypeSupportedHash
Returns
AiMalgamBaseEngineWrappers list

◆ RemoveDescriptor()

virtual bool NikosAssets.AiMalgam.AiMalgamEntity.RemoveDescriptor ( AiMalgamBaseDescriptor  descriptor)
virtual

Remove an existing AiMalgamBaseDescriptor to Descriptors and emit the OnDescriptorListChanged event on removal success

Parameters
descriptorThe AiMalgamBaseDescriptor to remove from Descriptors
Returns
Removal success

◆ RemoveEngine()

virtual bool NikosAssets.AiMalgam.AiMalgamEntity.RemoveEngine ( AiMalgamBaseEngineWrapper  baseEngineWrapper)
virtual

Remove an existing AiMalgamBaseEngineWrapper to Engines and emit the OnEnginesListChanged event on removal success

Parameters
baseEngineWrapperThe AiMalgamBaseEngineWrapper to remove from Engines
Returns
Removal success

◆ RemoveState()

virtual bool NikosAssets.AiMalgam.AiMalgamEntity.RemoveState ( AiMalgamState  state,
AiMalgamBaseEngineWrapper  baseEngineWrapper = null 
)
virtual

Remove the state from currentStates and emit the OnStateChangedUnityEvent and OnStateChanged events on success

Parameters
stateThe AiMalgamState to remove from currentStates
baseEngineWrapperThe AiMalgamBaseEngineWrapper which caused this call
Returns
false, if currentStates did not contain the given state , or if it was null. Otherwise true

◆ ValidateSettings()

virtual AiMalgamApplyActionSettingResult NikosAssets.AiMalgam.AiMalgamEntity.ValidateSettings ( AiMalgamBaseSettings  baseSettings,
out AiMalgamBaseEngineWrapper  outEngine 
)
virtual

Validate the given baseSettings by checking if their supported AiMalgamBaseEngineWrapper exists in Engines and if AiMalgamBaseEngineWrapper.AiMalgamBaseEngineWrapper.ValidateSettings also validates

Parameters
baseSettingsThe AiMalgamBaseSettings to validate
outEngineThe found (or not found) AiMalgamBaseEngineWrapper for the given baseSettings
Returns
AiMalgamApplyActionSettingResult