33#ifndef DVD_AI_PROCESSOR_H_
34#define DVD_AI_PROCESSOR_H_
50 virtual void addEntityRef(
AIEntity* entity);
57 virtual void registerAction(
const GOAPAction& action);
58 virtual void registerActionSet(
const GOAPActionSet& actionSet);
60 void registerGoal(
const GOAPGoal& goal);
64 const GOAPGoalList::iterator it =
65 eastl::find_if(begin(_goals),
67 [&goalName](
const GOAPGoal& goal)
noexcept ->
bool
69 return goal.
name() == goalName;
72 if (it != end(_goals)) {
89 activateGoal(goal.name());
96 if (goal !=
nullptr) {
97 _activeGoals.push_back(goal);
99 return goal !=
nullptr;
105 if (_activeGoals.empty())
110 eastl::sort(begin(_activeGoals), end(_activeGoals),
115 _activeGoal = _activeGoals.back();
117 assert(_activeGoal !=
nullptr);
123 if (goal ==
nullptr) {
126 if (_activeGoals.empty()) {
130 auto*
const it = eastl::find_if(
131 begin(_activeGoals), end(_activeGoals),
132 [goal](
GOAPGoal const* actGoal)
noexcept {
133 return actGoal->
name() == goal->
name();
136 if (it == end(_activeGoals)) {
140 _activeGoals.erase(it);
145 if (_activeGoal !=
nullptr) {
146 if (_activeGoal->plan(_worldState, _actionSet)) {
147 popActiveGoal(_activeGoal);
152 _planLog =
"Plan Log: \n";
153 _planLog.append(
"\t OpenList: \n");
154 _planLog.append(_activeGoal->getOpenList());
155 _planLog.append(
"\t ClosedList: \n");
156 _planLog.append(_activeGoal->getClosedList());
157 invalidateCurrentPlan();
165 if (_activeGoal ==
nullptr)
170 const GOAPPlan& plan = _activeGoal->getCurrentPlan();
176 assert(_currentStep <
U32_MAX - 1u);
179 const GOAPAction* crtAction = getActiveAction();
180 if (!crtAction || !performAction(*crtAction))
182 invalidateCurrentPlan();
190 if (_activeGoal ==
nullptr)
192 return "no active goal!";
196 const GOAPPlan& plan = _activeGoal->getCurrentPlan();
199 Util::StringFormat( returnString,
"{} - {}\n", returnString, printActionStats(*action) );
207 _activeGoal =
nullptr;
213 assert(_activeGoal !=
nullptr);
214 const GOAPPlan& plan = _activeGoal->getCurrentPlan();
215 if ( _currentStep ==
U32_MAX || _currentStep >= plan.size())
220 return plan[_currentStep];
225 const string&
getPlanLog() const noexcept {
return _planLog; }
227 virtual const char* printActionStats(
const GOAPAction& planStep)
const;
243 virtual string toString(
bool state =
false)
const = 0;
Provides a scene-level AI implementation.
virtual bool processInput(U64 deltaTimeUS)=0
const GOAPAction * getActiveAction() const
GOAPWorldState & worldState() noexcept
virtual void initInternal()=0
const GOAPWorldState & worldState() const noexcept
GOAPGoal * getActiveGoal() const noexcept
virtual bool performActionStep(GOAPAction::operationsIterator step)=0
bool activateGoal(const string &name)
Although we want the goal to be activated, it might not be the most relevant in the current scene sta...
virtual bool update(U64 deltaTimeUS, NPC *unitRef=nullptr)=0
virtual bool processData(U64 deltaTimeUS)=0
virtual string toString(bool state=false) const =0
virtual void processMessage(AIEntity &sender, AIMsg msg, const std::any &msg_content)=0
const GOAPGoalList & goalList() const noexcept
const string & getPlanLog() const noexcept
virtual GOAPGoal * findGoal(const string &goalName)
AIManager & _parentManager
bool popActiveGoal(GOAPGoal *goal)
virtual bool performAction(const GOAPAction &planStep)=0
vector< GOAPGoal * > _activeGoals
GOAPWorldState _worldState
GOAPGoal * findRelevantGoal()
Get the most relevant goal and set it as active.
GOAPGoalList & goalList() noexcept
virtual void invalidateCurrentPlan()
void worldState(const GOAPWorldState &state)
const Divide::string & name() const noexcept
F32 relevancy() const noexcept
NPC base class. Every character in the game is an NPC by default except the Player.
hashMap< I32, bool >::const_iterator operationsIterator
vector< const GOAPAction * > GOAPActionSet
vector< GOAPGoal > GOAPGoalList
vector< const GOAPAction * > GOAPPlan
Handle console commands that start with a forward slash.
eastl::vector< Type > vector