1 #ifndef GRAIL_AI_ENTITY_H
2 #define GRAIL_AI_ENTITY_H
5 #include "Blackboard.hh"
44 AIEntity(
const std::string& name =
"");
57 void SetReasoner(std::unique_ptr<Reasoner> newReasoner);
112 void AddSharedBlackboard(
const std::string& name, std::shared_ptr<Blackboard>& sharedBlackboard);
137 void SetId(
size_t id);
138 size_t GetId()
const;
139 const std::string& GetName()
const;
140 std::string GetCurrentBehaviorName()
const;
147 virtual void Update(
float deltaTime);
149 std::unique_ptr<Reasoner> reasoner;
150 std::map<std::string, std::shared_ptr<Blackboard>> sharedBlackboards{};
153 void SelectBehavior();
154 void ExecuteBehavior(
float deltaTime);
155 void SuspendPreviousBehavior();
156 void SetupNextBehavior(std::unique_ptr<Behavior> behavior);
158 void ChangeStatus(Status newStatus);
159 bool ChangeStatusNonBlocking(Status newStatus);
162 Status GetStatusNonBlocking();
164 std::unique_ptr<Behavior> stagedBehavior =
nullptr;
165 std::unique_ptr<Behavior> currentBehavior =
nullptr;
166 std::unique_ptr<Behavior> suspendedBehavior =
nullptr;
168 std::mutex entityMutex{};
169 std::mutex statusMutex{};
170 mutable std::mutex behaviorMutex{};
171 mutable std::mutex stagingMutex{};
172 std::vector<IReasonerChangeObserver*> reasonerChangeObservers{};
174 Status status = Status::FREE;
The AIEntity class - Defines a basic object which can execute behaviors.
Definition: AIEntity.hh:39
virtual void Update(float deltaTime)
Update - User defined method. Should in some way update entity's state.
Definition: AIEntity.cpp:109
std::shared_ptr< Blackboard > GetSharedBlackboard(const std::string &name) const
GetSharedBlackboard - Gets shared blackboard identified by given key.
Definition: AIEntity.cpp:99
void AddSharedBlackboard(const std::string &name, std::shared_ptr< Blackboard > &sharedBlackboard)
AddSharedBlackboard - Inserts pair of key and blackboard into container of shared blackboards.
Definition: AIEntity.cpp:94
bool HasActiveBehavior() const
HasActiveBehavior - Checks whether current behavior is not nullptr.
Definition: AIEntity.cpp:89
bool HasStagedBehavior() const
HasStagedBehavior - checks whether this entity has behavior awaiting its execution.
Definition: AIEntity.cpp:83
std::unique_ptr< Reasoner > & GetCurrentReasoner()
GetCurrentReasoner.
Definition: AIEntity.cpp:47
std::unique_ptr< Behavior > GetUniqueCurrentBehavior()
GetUniqueCurrentBehavior.
Definition: AIEntity.cpp:37
void StageBehavior(std::unique_ptr< Behavior > behavior)
SetNewBehavior - Finishes current behavior and starts new one.
Definition: AIEntity.cpp:52
std::unique_ptr< Behavior > MoveSuspendedBehavior()
GetPreviousBehavior.
Definition: AIEntity.cpp:42
void SetReasoner(std::unique_ptr< Reasoner > newReasoner)
SetReasoner.
Definition: AIEntity.cpp:22
const Behavior * GetCurrentBehavior() const
GetCurrentBehavior.
Definition: AIEntity.cpp:27
Blackboard & GetBlackboard()
GetBlackboard.
Definition: AIEntity.cpp:220
The AIManager class - Manages registered entities and shared blackboards.
Definition: AIManager.hh:35
A high-level abstraction of actions in the game.
Definition: Behavior.hh:20
The Blackboard class - grail's universal data container.
Definition: Blackboard.hh:21
Definition: AIEntity.hh:27
The Reasoner class - Entity's "brain", assigns them behaviors chosen by user-defined algorithms.
Definition: Reasoner.hh:20
Definition: SynchronizedEntityContainer.h:13