mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
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:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user