Added missing from ModularizedTacticalAI :/

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6019 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
feynman
2013-04-18 21:14:34 +00:00
parent 26383d83a8
commit aa5bed7850
10 changed files with 439 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
#include "../include/PlanList.h"
#include "../../TacticalAI/AIInternals.h"
#include <stdexcept>
namespace AI
{
namespace tactical
{
PlanList::PlanList(SOLDIERTYPE* npc)
: Plan(npc)
{
}
PlanList::~PlanList()
{
for(std::deque<Plan*>::iterator subplan_iter(subplans_.begin()); subplan_iter != subplans_.end(); ++subplan_iter)
delete *subplan_iter;
}
void PlanList::add_subplan(Plan* p)
{
if(!p)
throw std::logic_error("No empty plans in PlanList allowed");
subplans_.push_back(p);
}
void PlanList::execute(PlanInputData& environment)
{
while(!subplans_.empty() && subplans_.front()->done())
{
delete subplans_.front();
subplans_.pop_front();
DEBUGAIMSG("Plan done, switching to next...");
}
if(subplans_.empty())
return;
subplans_.front()->execute(environment);
}
bool PlanList::done() const
{
return subplans_.empty();
}
}
}