|
BWAPI
|
#include <SCVAgent.h>


Public Member Functions | |
| SCVAgent (BWAPI::Unit &u) | |
| virtual void | update () |
Private Attributes | |
| BWAPI::TilePosition | buildLocation |
| bool | wasConstructing |
| BWAPI::Unit * | constructingStructure |
Definition at line 10 of file SCVAgent.h.
| SCVAgent::SCVAgent | ( | BWAPI::Unit & | u | ) |
Definition at line 14 of file SCVAgent.cpp.
: GroundAgent(u) , wasConstructing(false) , constructingStructure(NULL) { }
| void SCVAgent::update | ( | ) | [virtual] |
Reimplemented from GroundAgent.
Definition at line 20 of file SCVAgent.cpp.
References BWAPI::Broodwar, Agent::buildingLocation, Agent::buildingReserved, BuildState, constructingStructure, GatherState, IdleState, TacticalBuildingPlacer::instance(), TacticalBuildingPlacer::reserveBuildLocation(), Agent::state, Agent::unit, Agent::unitTarget, and Agent::unitTypeTarget.
{
switch (state) {
case IdleState:
// be idle
break;
case GatherState:
// Gather minerals
if (unitTarget->getType().isMineralField())
{
if (!unit.isGatheringMinerals())
unit.gather(unitTarget);
}
// Gather gas
else if (unitTarget->getType().isRefinery())
{
if (!unit.isGatheringGas())
unit.gather(unitTarget);
}
break;
case BuildState:
// Return cargo
//if (unit.isCarryingGas() || unit.isCarryingMinerals()) {
// unit.returnCargo();
//}
// Done?
if (!unit.isConstructing() && constructingStructure != NULL)
{
if (constructingStructure->isCompleted())
{
constructingStructure = NULL;
buildingReserved = false;
state = IdleState;
}
}
// Reserve a build location
else if (!buildingReserved)
{
TacticalBuildingPlacer &tbp = TacticalBuildingPlacer::instance();
buildingLocation = tbp.instance().reserveBuildLocation(unitTypeTarget, Broodwar->self()->getStartLocation(), &unit);
if (buildingLocation != TilePositions::None)
{
buildingReserved = true;
}
unit.move(Position(buildingLocation));
}
// Build it
else if (buildingReserved && !unit.isConstructing())
{
unit.build(buildingLocation, unitTypeTarget);
}
// Building...
else if (unit.isConstructing())
{
constructingStructure = unit.getBuildUnit();
}
break;
}
GroundAgent::update();
}
BWAPI::TilePosition SCVAgent::buildLocation [private] |
Definition at line 17 of file SCVAgent.h.
BWAPI::Unit* SCVAgent::constructingStructure [private] |
Definition at line 20 of file SCVAgent.h.
Referenced by update().
bool SCVAgent::wasConstructing [private] |
Definition at line 18 of file SCVAgent.h.
1.7.6.1