BWAPI
|
#include <AgentManager.h>
Public Member Functions | |
~AgentManager () | |
void | addAgent (Unit *unit) |
void | removeAgent (Unit *unit) |
void | morphDrone (Unit *unit) |
void | computeActions () |
int | getNoWorkers () |
int | noMiningWorkers () |
BaseAgent * | findClosestFreeWorker (TilePosition pos) |
bool | isAnyAgentRepairingThisAgent (BaseAgent *repairedAgent) |
int | countNoUnits (UnitType type) |
int | countNoBases () |
vector< BaseAgent * > | getAgents () |
int | size () |
BaseAgent * | getAgent (int unitID) |
BaseAgent * | getAgent (UnitType type) |
void | requestOverlord (TilePosition pos) |
BaseAgent * | getClosestAgent (TilePosition pos, UnitType type) |
BaseAgent * | getClosestBase (TilePosition pos) |
TilePosition | getClosestDetector (TilePosition startPos) |
bool | unitsInArea (TilePosition pos, int tileWidth, int tileHeight, int unitID) |
void | cleanup () |
Static Public Member Functions | |
static AgentManager * | getInstance () |
The AgentManager class is a container that holds a list of all active agents in the game. Each unit, worker, building or or addon is assigned to an agent. See the MainAgents, StructureAgents and UnitAgents folders for detailed information about each specific type of agent.
The AgentManager is implemented as a singleton class. Each class that needs to access AgentManager can request an instance, and all classes shares the same AgentManager instance.
Author: Johan Hagelback (johan.hagelback@gmail.com)
void AgentManager::addAgent | ( | Unit * | unit | ) |
Adds an agent to the container. Is called each time a new unit is built.
void AgentManager::cleanup | ( | ) |
Removes inactive agents from the container. Shouldn't be called too often.
void AgentManager::computeActions | ( | ) |
Called each update to issue commands from all active agents.
int AgentManager::countNoBases | ( | ) |
Returns the number of bases the player has.
int AgentManager::countNoUnits | ( | UnitType | type | ) |
Returns the number of own units of a specific type.
Returns the closest free worker from the specified position, or NULL if not found.
BaseAgent * AgentManager::getAgent | ( | int | unitID | ) |
Returns a reference to the agent associated with a specific unit, or NULL if the unit doesn't exist.
BaseAgent * AgentManager::getAgent | ( | UnitType | type | ) |
Returns the first agent in the list of the specified type, or NULL if not found.
vector< BaseAgent * > AgentManager::getAgents | ( | ) |
Returns a list of all agents in the container.
BaseAgent * AgentManager::getClosestAgent | ( | TilePosition | pos, |
UnitType | type | ||
) |
Returns the closest agent in the list of the specified type, or NULL if not found.
Returns the closest base agent (Terran Command Center, Protoss Nexus), in the list, or NULL if not found.
TilePosition AgentManager::getClosestDetector | ( | TilePosition | startPos | ) |
Returns the position of the closest detector unit relative to startPos. Returns TilePosition(-1, -1) if none was found.
AgentManager * AgentManager::getInstance | ( | ) | [static] |
int AgentManager::getNoWorkers | ( | ) |
Returns the current number of active worker units.
bool AgentManager::isAnyAgentRepairingThisAgent | ( | BaseAgent * | repairedAgent | ) |
Checks if any agent has the task to repair this specified agent.
void AgentManager::morphDrone | ( | Unit * | unit | ) |
Called when a Zerg Drone is morphed into another unit.
int AgentManager::noMiningWorkers | ( | ) |
Returns the current number of active workers gathering minerals.
void AgentManager::removeAgent | ( | Unit * | unit | ) |
Removes an agent from the container. Is called each time a unit is destroyed. The agents are not directly removed, but set to inactive and are removed during the cleanup.
void AgentManager::requestOverlord | ( | TilePosition | pos | ) |
Requests a free Zerg Overlord to move to the specified position.
int AgentManager::size | ( | ) |
Returns the number of agents the exists in the vector.
bool AgentManager::unitsInArea | ( | TilePosition | pos, |
int | tileWidth, | ||
int | tileHeight, | ||
int | unitID | ||
) |
Checks if there are any units in an area. The unit with id unitID is allowed.