00001 /* 00002 * groupAI.cpp 00003 * 00004 * Created on: Feb 2, 2012 00005 * Author: sushil 00006 */ 00007 #include <groupAI.h> 00008 #include "DEBUG.h" 00009 00010 inline void FastEcslent::GroupAI::tick(double dt) { 00011 if (!commands.empty()) { 00012 //do the command 00013 commands.front()->tick(dt); 00014 if (commands.front()->done()){ // if done 00015 commands.pop_front(); // pop top 00016 if(!commands.empty()){ // if more commands 00017 commands.front()->init(); // init next command 00018 } 00019 } 00020 } 00021 } 00022 00023 void FastEcslent::GroupAI::init(){ 00024 // DEBUG(std::cout << "Starting GroupAI for Entity: " << group->gid.id << std::endl;) 00025 if(!commands.empty()){ 00026 commands.front()->init(); 00027 } 00028 } 00029 00030 void FastEcslent::GroupAI::addCommand(Command* command){ 00031 boost::mutex::scoped_lock scoped_lock(groupLock); 00032 commands.push_back(command); 00033 //command->init(); 00034 } 00035 00036 void FastEcslent::GroupAI::setCommand(Command* command){ 00037 boost::mutex::scoped_lock scoped_lock(groupLock); 00038 commands.clear(); 00039 commands.push_back(command); 00040 } 00041 00042 void FastEcslent::GroupAI::setCommandList(std::deque<Command*> cmds){ 00043 boost::mutex::scoped_lock scoped_lock(groupLock); 00044 00045 commands.clear(); 00046 commands = cmds; 00047 }