|
BWAPI
|
#include <StructureAgent.h>


Public Member Functions | |
| virtual void | update () |
| StructureAgent (BWAPI::Unit &u) | |
Definition at line 7 of file StructureAgent.h.
| StructureAgent::StructureAgent | ( | BWAPI::Unit & | u | ) | [inline] |
Definition at line 11 of file StructureAgent.h.
: Agent(u) {}
| void StructureAgent::update | ( | ) | [virtual] |
Reimplemented from Agent.
Reimplemented in BarracksAgent, CommandCenterAgent, and RefineryAgent.
Definition at line 4 of file StructureAgent.cpp.
References BuildState, IdleState, Agent::state, TrainState, Agent::unit, and Agent::unitTypeTarget.
{
// Send Units to nearest chokepoint
BWTA::Chokepoint* chokepoint = BWTA::getNearestChokepoint(unit.getPosition());
if( chokepoint != NULL )
unit.setRallyPoint(chokepoint->getCenter());
switch (state)
{
case IdleState:
// fall through
case TrainState:
if (!unit.isTraining() && !unit.isBeingConstructed())
{
unit.train(unitTypeTarget);
}
else
{
//state = IdleState;
}
break;
case BuildState:
if (unitTypeTarget.isAddon())
{
if (unit.getAddon()->getType().getID() != unitTypeTarget.getID())
unit.buildAddon(unitTypeTarget);
else
state = IdleState;
}
}
}
1.7.6.1