BWAPI
|
#include <TaskPump.h>
Public Member Functions | |
TaskPump (BWAPI::UnitType type, TaskType taskType, BuildingLocation location=BuildingLocation::Base) | |
void | update () |
void | changeTargetQuantity (int iQuantity) |
Private Attributes | |
BWAPI::UnitType | mType |
TaskType | mTaskType |
BuildingLocation | mLocation |
int | mTargetQuantity |
std::list< TaskPointer > | mQueuedItems |
Definition at line 8 of file TaskPump.h.
TaskPump::TaskPump | ( | BWAPI::UnitType | type, |
TaskType | taskType, | ||
BuildingLocation | location = BuildingLocation::Base |
||
) |
Definition at line 5 of file TaskPump.cpp.
: mType(type) , mTaskType(taskType) , mLocation(location) , mTargetQuantity(0) { }
void TaskPump::changeTargetQuantity | ( | int | iQuantity | ) | [inline] |
Definition at line 15 of file TaskPump.h.
References mTargetQuantity.
Referenced by ResourceManagerClass::update().
{ mTargetQuantity = iQuantity; }
void TaskPump::update | ( | ) |
Definition at line 13 of file TaskPump.cpp.
References Singleton< T >::Instance(), mLocation, mQueuedItems, mTargetQuantity, mTaskType, and mType.
Referenced by ResourceManagerClass::update().
{ for(std::list<TaskPointer>::iterator it = mQueuedItems.begin(); it != mQueuedItems.end();) { if((*it)->hasEnded()) mQueuedItems.erase(it++); else ++it; } int currentTotal = mQueuedItems.size(); for(std::list<TaskPointer>::iterator it2 = mQueuedItems.begin(); it2 != mQueuedItems.end();) { if(currentTotal > mTargetQuantity && !(*it2)->inProgress()) { (*it2)->cancel(); mQueuedItems.erase(it2++); --currentTotal; } else ++it2; } while(currentTotal > mTargetQuantity && !mQueuedItems.empty()) { (*mQueuedItems.rbegin())->cancel(); mQueuedItems.pop_back(); --currentTotal; } while(currentTotal < mTargetQuantity) { TaskPointer tempPtr = TaskManager::Instance().build(mType, mTaskType, mLocation); mQueuedItems.push_back(tempPtr); ++currentTotal; } }
BuildingLocation TaskPump::mLocation [private] |
Definition at line 20 of file TaskPump.h.
Referenced by update().
std::list<TaskPointer> TaskPump::mQueuedItems [private] |
Definition at line 24 of file TaskPump.h.
Referenced by update().
int TaskPump::mTargetQuantity [private] |
Definition at line 22 of file TaskPump.h.
Referenced by changeTargetQuantity(), and update().
TaskType TaskPump::mTaskType [private] |
Definition at line 19 of file TaskPump.h.
Referenced by update().
BWAPI::UnitType TaskPump::mType [private] |
Definition at line 18 of file TaskPump.h.
Referenced by update().