Grail (C++)  1.3.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
grail::AIManager Class Referencefinal

The AIManager class - Manages registered entities and shared blackboards. More...

#include <AIManager.hh>

Public Member Functions

 AIManager (std::size_t threadsNumber=0)
 AIManager - Constructs a manager and spawns worker threads defined by the parameter. If threadsNumber equals 0, all calculations will be done on the main thread. More...
 
void UpdateReasoners ()
 UpdateReasoners - Lets registered entities think by updating their reasoner.
 
void UpdateEntities (float deltaTime)
 UpdateEntities - Updates entities and their assigned behaviors. More...
 
void RegisterAIEntity (const std::shared_ptr< AIEntity > &entity, int priority)
 RegisterAIEntity - Manager registers an entity with a given priority. As a result entities and their behaviors will be updated when UpdateEntities is called. Also entities will think when UpdateReasoners is called. Entities with lower priority will be updated first. More...
 
void RegisterAIEntity (const std::shared_ptr< AIEntity > &entity, const std::shared_ptr< AIEntity > &parent, int priorityOffset=1)
 RegisterAIEntity - Managers registers an entity with priority lowered by priorityOffset relative to the parent entity. As a result entities and their behaviors will be updated when UpdateEntities is called. Also entities will think when UpdateReasoners is called. Entities with lower priority will be updated first. More...
 
void RemoveAIEntity (AIEntity *entity)
 RemoveAIEntity - Manager caches given entity. Later on all cached entities will be unregistered from this manager. Unregistered entities will no longer be updated, neither will be their behaviors and reasoners. More...
 
void RegisterEntityGroup (const std::shared_ptr< EntityGroup > &entityGroup, int priority)
 RegisterEntityGroup - Manager registers an entity group (and its entities) with the given priority. As a result entities and their behaviors will be updated when UpdateEntities is called. Also entities will think when UpdateReasoners is called. Entities with lower priority will be updated first. Resulting priority of each entity in group is calculated by adding group priority and relative priority of given entity. More...
 
void RemoveEntityGroup (const std::shared_ptr< EntityGroup > &entityGroup)
 RemoveEntityGroup - Manager removes entity group and caches its entities for removal. Later on all cached entities will be unregistered from this manager. Unregistered entities will no longer be updated, neither will be their behaviors and reasoners. More...
 
bool ContainsEntity (const AIEntity &entity) const
 ContainsEntity - Checks if a given entity is registered in the manager. More...
 
BlackboardCreateBlackboard (const std::string &name)
 CreateBlackboard - Constructs blackboard owned by this manager. More...
 
void SubscribeToBlackboard (const std::string &blackboardName, AIEntity &entity)
 SubscribeToBlackboard - Subscribes a given entity to a blackboard identified by the provided blackboard name and owned by this manager. More...
 
void UnsubscribeFromBlackboard (const std::string &blackboardName, AIEntity &entity)
 
void RegisterEntityChangeObserver (IEntityChangeObserver *observer)
 RegisterEntityChangeObserver - Registers an entity change observer that will be notified via OnEntityAdded and OnEntityRemoved functions when an entity is added or removed from the manager. More...
 
void RemoveEntityChangeObserver (IEntityChangeObserver *observer)
 RemoveEntityChangeObserver - Removes an entity change observer so it no longer will be notified on adding or removing an entity from the manager. More...
 
const std::vector< std::pair< std::shared_ptr< AIEntity >, int > > & GetEntities () const
 
const std::vector< std::shared_ptr< EntityGroup > > & GetEntityGroups () const
 
const std::map< std::string, std::shared_ptr< Blackboard > > & GetSharedBlackboards () const
 

Detailed Description

The AIManager class - Manages registered entities and shared blackboards.

Constructor & Destructor Documentation

◆ AIManager()

grail::AIManager::AIManager ( std::size_t  threadsNumber = 0)

AIManager - Constructs a manager and spawns worker threads defined by the parameter. If threadsNumber equals 0, all calculations will be done on the main thread.

Parameters
threadsNumber

Member Function Documentation

◆ ContainsEntity()

bool grail::AIManager::ContainsEntity ( const AIEntity entity) const

ContainsEntity - Checks if a given entity is registered in the manager.

Parameters
entity
Returns
true if the entity is registered in manager, false otherwise.

◆ CreateBlackboard()

Blackboard & grail::AIManager::CreateBlackboard ( const std::string &  name)

CreateBlackboard - Constructs blackboard owned by this manager.

Parameters
name
Returns
constructed blackboard

◆ RegisterAIEntity() [1/2]

void grail::AIManager::RegisterAIEntity ( const std::shared_ptr< AIEntity > &  entity,
const std::shared_ptr< AIEntity > &  parent,
int  priorityOffset = 1 
)

RegisterAIEntity - Managers registers an entity with priority lowered by priorityOffset relative to the parent entity. As a result entities and their behaviors will be updated when UpdateEntities is called. Also entities will think when UpdateReasoners is called. Entities with lower priority will be updated first.

Parameters
entity
parent
priorityOffset

◆ RegisterAIEntity() [2/2]

void grail::AIManager::RegisterAIEntity ( const std::shared_ptr< AIEntity > &  entity,
int  priority 
)

RegisterAIEntity - Manager registers an entity with a given priority. As a result entities and their behaviors will be updated when UpdateEntities is called. Also entities will think when UpdateReasoners is called. Entities with lower priority will be updated first.

Parameters
entity
priority

◆ RegisterEntityChangeObserver()

void grail::AIManager::RegisterEntityChangeObserver ( IEntityChangeObserver observer)

RegisterEntityChangeObserver - Registers an entity change observer that will be notified via OnEntityAdded and OnEntityRemoved functions when an entity is added or removed from the manager.

Parameters
observer

◆ RegisterEntityGroup()

void grail::AIManager::RegisterEntityGroup ( const std::shared_ptr< EntityGroup > &  entityGroup,
int  priority 
)

RegisterEntityGroup - Manager registers an entity group (and its entities) with the given priority. As a result entities and their behaviors will be updated when UpdateEntities is called. Also entities will think when UpdateReasoners is called. Entities with lower priority will be updated first. Resulting priority of each entity in group is calculated by adding group priority and relative priority of given entity.

Parameters
entityGroup
priority

◆ RemoveAIEntity()

void grail::AIManager::RemoveAIEntity ( AIEntity entity)

RemoveAIEntity - Manager caches given entity. Later on all cached entities will be unregistered from this manager. Unregistered entities will no longer be updated, neither will be their behaviors and reasoners.

Parameters
entity

◆ RemoveEntityChangeObserver()

void grail::AIManager::RemoveEntityChangeObserver ( IEntityChangeObserver observer)

RemoveEntityChangeObserver - Removes an entity change observer so it no longer will be notified on adding or removing an entity from the manager.

Parameters
observer

◆ RemoveEntityGroup()

void grail::AIManager::RemoveEntityGroup ( const std::shared_ptr< EntityGroup > &  entityGroup)

RemoveEntityGroup - Manager removes entity group and caches its entities for removal. Later on all cached entities will be unregistered from this manager. Unregistered entities will no longer be updated, neither will be their behaviors and reasoners.

Parameters
entityGroup

◆ SubscribeToBlackboard()

void grail::AIManager::SubscribeToBlackboard ( const std::string &  blackboardName,
AIEntity entity 
)

SubscribeToBlackboard - Subscribes a given entity to a blackboard identified by the provided blackboard name and owned by this manager.

Parameters
blackboardName
entity

◆ UpdateEntities()

void grail::AIManager::UpdateEntities ( float  deltaTime)

UpdateEntities - Updates entities and their assigned behaviors.

Parameters
deltaTime

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