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> reasoner);
106 void AddSharedBlackboard(
const std::string& name, std::shared_ptr<Blackboard>& sharedBlackboard);
130 void SetId(
size_t id);
131 size_t GetId()
const;
132 const std::string& GetName()
const;
133 std::string GetCurrentBehaviorName()
const;
140 virtual void Update(
float deltaTime);
142 std::unique_ptr<Reasoner> playingModel;
143 std::map<std::string, std::shared_ptr<Blackboard>> sharedBlackboards{};
146 void SelectBehavior();
147 void ExecuteBehavior(
float deltaTime);
148 void FinishPreviousBehavior();
149 void SetupNextBehavior(std::unique_ptr<Behavior> behavior);
151 void ChangeStatus(Status newStatus);
152 bool ChangeStatusNonBlocking(Status newStatus);
155 Status GetStatusNonBlocking();
157 std::unique_ptr<Behavior> currentBehavior =
nullptr;
158 Behavior* previousBehavior =
nullptr;
159 std::atomic<bool> wasPreviousBehaviorCaptured{
false};
161 std::mutex entityMutex{};
162 std::mutex statusMutex{};
163 mutable std::mutex behaviorMutex{};
164 std::vector<IReasonerChangeObserver*> reasonerChangeObservers{};
166 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:104
void SetReasoner(std::unique_ptr< Reasoner > reasoner)
SetReasoner.
Definition: AIEntity.cpp:21
Behavior * GetPreviousBehavior()
GetPreviousBehavior.
Definition: AIEntity.cpp:41
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:89
bool HasActiveBehavior() const
HasActiveBehavior - Checks whether current behavior is not nullptr.
Definition: AIEntity.cpp:84
std::unique_ptr< Reasoner > & GetCurrentReasoner()
GetCurrentReasoner.
Definition: AIEntity.cpp:47
std::unique_ptr< Behavior > GetUniqueCurrentBehavior()
GetUniqueCurrentBehavior.
Definition: AIEntity.cpp:36
const Behavior * GetCurrentBehavior() const
GetCurrentBehavior.
Definition: AIEntity.cpp:26
const std::shared_ptr< Blackboard > GetSharedBlackboard(const std::string &name) const
GetSharedBlackboard - Gets shared blackboard identified by given key.
Definition: AIEntity.cpp:94
Blackboard & GetBlackboard()
GetBlackboard.
Definition: AIEntity.cpp:207
void SetNewBehavior(std::unique_ptr< Behavior > behavior)
SetNewBehavior - Finishes current behavior and starts new one.
Definition: AIEntity.cpp:52
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