Grail (C++)  1.4.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
grail::AIEntity Class Reference

The AIEntity class - Defines a basic object which can execute behaviors. More...

#include <AIEntity.hh>

Collaboration diagram for grail::AIEntity:

Public Member Functions

 AIEntity (const std::string &name="")
 AIEntity - Constructs an AIEntity with the given name. More...
 
 AIEntity (const AIEntity &)=delete
 
 AIEntity (AIEntity &&)=delete
 
AIEntityoperator= (const AIEntity &)=delete
 
AIEntityoperator= (AIEntity &&)=delete
 
void SetReasoner (std::unique_ptr< Reasoner > newReasoner)
 SetReasoner. More...
 
const BehaviorGetCurrentBehavior () const
 GetCurrentBehavior. More...
 
BehaviorGetCurrentBehavior ()
 GetCurrentBehavior. More...
 
std::unique_ptr< BehaviorGetUniqueCurrentBehavior ()
 GetUniqueCurrentBehavior. More...
 
std::unique_ptr< BehaviorMoveSuspendedBehavior ()
 GetPreviousBehavior. More...
 
std::unique_ptr< ReasonerTakeOwnershipOfReasoner ()
 GetCurrentReasoner. More...
 
ReasonerGetReasoner ()
 
void StageBehavior (std::unique_ptr< Behavior > behavior)
 StageBehavior - Finishes the current behavior and starts a new one. More...
 
bool HasStagedBehavior () const
 HasStagedBehavior - checks whether this entity has behavior awaiting its execution. More...
 
bool HasActiveBehavior () const
 HasActiveBehavior - Checks whether current behavior is not nullptr. More...
 
void AddSharedBlackboard (const std::string &name, std::shared_ptr< Blackboard > &sharedBlackboard)
 AddSharedBlackboard - Inserts pair of key and blackboard into container of shared blackboards. More...
 
void RemoveSharedBlackboard (const std::string &name)
 RemoveSharedBlackboard - Removes shared blackboard entry. More...
 
std::shared_ptr< BlackboardGetSharedBlackboard (const std::string &name) const
 GetSharedBlackboard - Gets shared blackboard identified by given key. More...
 
BlackboardGetBlackboard ()
 GetBlackboard. More...
 
const BlackboardGetBlackboard () const
 GetBlackboard. More...
 
void AddReasonerChangeObserver (IReasonerChangeObserver *observer)
 AddReasonerChangeObserver - Adds a reasoner change observer that will be notified via calling OnReasonerSet function when a new reasoner is assigned to entity. More...
 
void RemoveReasonerChangeObserver (IReasonerChangeObserver *observer)
 RemoveReasonerChangeObserver - Removes a reasoner change observer so it won't be notified of reasoner changes anymore. More...
 
void SetId (size_t id)
 
size_t GetId () const
 
const std::string & GetName () const
 
std::string GetCurrentBehaviorName () const
 

Static Public Member Functions

static void ResetNextID (const size_t nextId=0)
 ResetNextID - Resets taken entity IDs. Useful when a game has ended but entities were not destroyed, like ending play in editor or soft resetting a level. More...
 

Protected Member Functions

virtual void Update (float deltaTime)
 Update - User defined method. Should in some way update entity's state. More...
 

Protected Attributes

std::unique_ptr< Reasonerreasoner
 
std::map< std::string, std::shared_ptr< Blackboard > > sharedBlackboards {}
 

Friends

class AIManager
 
class GrailStateSnapshotGenerator
 
class EntityToken
 

Detailed Description

The AIEntity class - Defines a basic object which can execute behaviors.

Constructor & Destructor Documentation

◆ AIEntity()

grail::AIEntity::AIEntity ( const std::string &  name = "")

AIEntity - Constructs an AIEntity with the given name.

Parameters
name

Member Function Documentation

◆ AddReasonerChangeObserver()

void grail::AIEntity::AddReasonerChangeObserver ( IReasonerChangeObserver observer)

AddReasonerChangeObserver - Adds a reasoner change observer that will be notified via calling OnReasonerSet function when a new reasoner is assigned to entity.

Parameters
observer

◆ AddSharedBlackboard()

void grail::AIEntity::AddSharedBlackboard ( const std::string &  name,
std::shared_ptr< Blackboard > &  sharedBlackboard 
)

AddSharedBlackboard - Inserts pair of key and blackboard into container of shared blackboards.

Parameters
name
sharedBlackboard

◆ GetBlackboard() [1/2]

const Blackboard & grail::AIEntity::GetBlackboard ( )

GetBlackboard.

Returns
blackboard owned by this entity

◆ GetBlackboard() [2/2]

const Blackboard& grail::AIEntity::GetBlackboard ( ) const

GetBlackboard.

Returns
blackboard owned by this entity

◆ GetCurrentBehavior() [1/2]

Behavior* grail::AIEntity::GetCurrentBehavior ( )

GetCurrentBehavior.

Returns
pointer to currently assigned behavior

◆ GetCurrentBehavior() [2/2]

Behavior * grail::AIEntity::GetCurrentBehavior ( ) const

GetCurrentBehavior.

Returns
pointer to const currently assigned behavior

◆ GetSharedBlackboard()

std::shared_ptr< Blackboard > grail::AIEntity::GetSharedBlackboard ( const std::string &  name) const

GetSharedBlackboard - Gets shared blackboard identified by given key.

Parameters
name
Returns
pointer to shared blackboard, nullptr if key is not found

◆ GetUniqueCurrentBehavior()

std::unique_ptr< Behavior > grail::AIEntity::GetUniqueCurrentBehavior ( )

GetUniqueCurrentBehavior.

Returns
unique pointer to currently assigned behavior

◆ HasActiveBehavior()

bool grail::AIEntity::HasActiveBehavior ( ) const

HasActiveBehavior - Checks whether current behavior is not nullptr.

Returns
false if nullptr, true otherwise

◆ HasStagedBehavior()

bool grail::AIEntity::HasStagedBehavior ( ) const

HasStagedBehavior - checks whether this entity has behavior awaiting its execution.

Returns
true if there is staged behavior, false if there isn't

◆ MoveSuspendedBehavior()

std::unique_ptr< Behavior > grail::AIEntity::MoveSuspendedBehavior ( )

GetPreviousBehavior.

Returns
raw pointer to previously assigned behavior

◆ RemoveReasonerChangeObserver()

void grail::AIEntity::RemoveReasonerChangeObserver ( IReasonerChangeObserver observer)

RemoveReasonerChangeObserver - Removes a reasoner change observer so it won't be notified of reasoner changes anymore.

Parameters
observer

◆ RemoveSharedBlackboard()

void grail::AIEntity::RemoveSharedBlackboard ( const std::string &  name)

RemoveSharedBlackboard - Removes shared blackboard entry.

Parameters
name- removed blackboard's name

◆ ResetNextID()

void grail::AIEntity::ResetNextID ( const size_t  nextId = 0)
static

ResetNextID - Resets taken entity IDs. Useful when a game has ended but entities were not destroyed, like ending play in editor or soft resetting a level.

Parameters
nextId- optional next available entity id

◆ SetReasoner()

void grail::AIEntity::SetReasoner ( std::unique_ptr< Reasoner newReasoner)

SetReasoner.

Parameters
reasoner

◆ StageBehavior()

void grail::AIEntity::StageBehavior ( std::unique_ptr< Behavior behavior)

StageBehavior - Finishes the current behavior and starts a new one.

Parameters
behavior

◆ TakeOwnershipOfReasoner()

std::unique_ptr< Reasoner > grail::AIEntity::TakeOwnershipOfReasoner ( )

GetCurrentReasoner.

Returns
current reasoner

◆ Update()

void grail::AIEntity::Update ( float  deltaTime)
protectedvirtual

Update - User defined method. Should in some way update entity's state.

Parameters
deltaTime

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