BWAPI
|
#include <Agent.h>
Public Member Functions | |
virtual void | update () |
virtual void | draw () |
bool | operator== (const Agent &other) |
void | setState (State state) |
void | setUnitTarget (BWAPI::Unit *target) |
void | setPositionTarget (const BWAPI::Position &target) |
void | setUnitTypeTarget (const BWAPI::UnitType &target) |
bool | unitTypeTargetValid () |
const State | getState () const |
const BWAPI::Unit & | getUnit () const |
BWAPI::Unit & | getUnit () |
const BWAPI::Position & | getPositionTarget () const |
const BWAPI::UnitType & | getUnitTypeTarget () const |
BWAPI::Unit * | getUnitTarget () const |
void | setParentManager (Manager *manager) |
const std::string | getParentManagerName () const |
Protected Member Functions | |
Agent (BWAPI::Unit &u) | |
Protected Attributes | |
BWAPI::Unit & | unit |
State | state |
BWAPI::Unit * | unitTarget |
BWAPI::Position | positionTarget |
BWAPI::UnitType | unitTypeTarget |
bool | buildingReserved |
BWAPI::TilePosition | buildingLocation |
Manager * | parentManager |
Agent::Agent | ( | BWAPI::Unit & | u | ) | [protected] |
Definition at line 15 of file Agent.cpp.
: unit(u) , state(IdleState) , unitTarget(NULL) , positionTarget() , unitTypeTarget(UnitTypes::None) , buildingReserved(false) , buildingLocation() , parentManager(NULL) { }
void Agent::draw | ( | ) | [virtual] |
Definition at line 53 of file Agent.cpp.
References AttackState, BWAPI::Broodwar, GatherState, getParentManagerName(), positionTarget, state, StateStrings, unit, unitTarget, UnitTypeStrings, unitTypeTarget, and unitTypeTargetValid().
{ const int px = unit.getPosition().x(); const int py = unit.getPosition().y(); const int radius = unit.getRight() - px; // Draw owner, state, type if (state != GatherState) Broodwar->drawTextMap(px, py, "(%s, %s%s)", getParentManagerName().c_str(), StateStrings[state], unitTypeTargetValid() ? (string(", ") += string(UnitTypeStrings[unitTypeTarget.getID()])).c_str() : ""); // Note: drawing this stuff all the time clutters things up massively, but can be useful // TODO: look into adding a global chat flag to toggle this stuff (/debuginfo or something) if( 1 ) //unit.isSelected() ) { Broodwar->drawCircleMap(px, py, radius, Colors::Yellow); // Draw line to position target if its valid if( positionTarget.isValid() && positionTarget != Positions::None && positionTarget != Positions::Unknown && positionTarget.x() != 0 && positionTarget.y() != 0 ) { const int tx = positionTarget.x(); const int ty = positionTarget.y(); Broodwar->drawLineMap(px, py, tx, ty, Colors::Green); Broodwar->drawTextMap(tx, ty, "(%d, %d)", tx, ty); } // Draw a line to the unit target if its valid if( unitTarget != NULL ) { const Position targetPos = unitTarget->getPosition(); if( targetPos.isValid() && targetPos != Positions::None && targetPos != Positions::Unknown && targetPos.x() != 0 && targetPos.y() != 0 ) { const int tx = unitTarget->getPosition().x(); const int ty = unitTarget->getPosition().y(); Broodwar->drawLineMap(px, py, tx, ty, Colors::Red); Broodwar->drawTextMap(tx, ty, "id: %x", unitTarget); } } } if (state == AttackState) { // Draw our attack range Position unitPosition = unit.getPosition(); int x = unitPosition.x(); int y = unitPosition.y(); int attackRadius = unit.getType().seekRange(); Broodwar->drawCircle(CoordinateType::Map, x, y, attackRadius, BWAPI::Colors::White); } // Draw our current target position Position targetPosition = unit.getTargetPosition(); Broodwar->drawLineMap(unit.getPosition().x(), unit.getPosition().y(), targetPosition.x(), targetPosition.y(), Colors::Yellow); }
const std::string Agent::getParentManagerName | ( | ) | const |
Definition at line 47 of file Agent.cpp.
References Manager::getName(), and parentManager.
Referenced by draw().
{ return (parentManager != NULL) ? parentManager->getName() : "None"; }
const BWAPI::Position& Agent::getPositionTarget | ( | ) | const [inline] |
Definition at line 55 of file Agent.h.
References positionTarget.
Referenced by Squad::update().
{ return positionTarget; }
const State Agent::getState | ( | ) | const [inline] |
Definition at line 52 of file Agent.h.
References state.
Referenced by BuildManager::update().
{ return state; }
const BWAPI::Unit& Agent::getUnit | ( | ) | const [inline] |
Definition at line 53 of file Agent.h.
References unit.
Referenced by CombatManager::addNewAgents(), ResourceManager::getClosestMineralPatch(), ResourceManager::getNumWorkersGathering(), GasManager::getNumWorkersGathering(), Strategizer::remap(), and Strategizer::updateAgentManagerMap().
{ return unit; }
BWAPI::Unit& Agent::getUnit | ( | ) | [inline] |
BWAPI::Unit* Agent::getUnitTarget | ( | ) | const [inline] |
Definition at line 57 of file Agent.h.
References unitTarget.
Referenced by Squad::update().
{ return unitTarget; }
const BWAPI::UnitType& Agent::getUnitTypeTarget | ( | ) | const [inline] |
Definition at line 56 of file Agent.h.
References unitTypeTarget.
Referenced by Squad::update().
{ return unitTypeTarget; }
bool Agent::operator== | ( | const Agent & | other | ) |
void Agent::setParentManager | ( | Manager * | manager | ) |
Definition at line 41 of file Agent.cpp.
References parentManager.
Referenced by Strategizer::redistributeAgents().
{ if( manager != NULL ) parentManager = manager; }
void Agent::setPositionTarget | ( | const BWAPI::Position & | target | ) | [inline] |
Definition at line 42 of file Agent.h.
References positionTarget.
Referenced by CombatManager::addNewAgents(), ResourceManager::makeAgentGatherMinerals(), Squad::update(), and CombatManager::update().
{ positionTarget = target; }
void Agent::setState | ( | State | state | ) | [inline] |
Definition at line 40 of file Agent.h.
References state.
Referenced by ResourceManager::makeAgentGatherMinerals(), GasManager::update(), Squad::update(), and CombatManager::update().
void Agent::setUnitTarget | ( | BWAPI::Unit * | target | ) | [inline] |
Definition at line 41 of file Agent.h.
References unitTarget.
Referenced by ResourceManager::makeAgentGatherMinerals(), and Squad::update().
{ unitTarget = target; }
void Agent::setUnitTypeTarget | ( | const BWAPI::UnitType & | target | ) | [inline] |
Definition at line 43 of file Agent.h.
References unitTypeTarget.
Referenced by ResourceManager::makeAgentGatherMinerals(), GasManager::update(), and Squad::update().
{ unitTypeTarget = target; }
bool Agent::unitTypeTargetValid | ( | ) | [inline] |
Definition at line 45 of file Agent.h.
References NUM_UNIT_TYPES, and unitTypeTarget.
Referenced by draw().
{ int typeTargetID = unitTypeTarget.getID(); return typeTargetID >= 0 && typeTargetID < NUM_UNIT_TYPES && typeTargetID != BWAPI::UnitTypes::None; }
void Agent::update | ( | ) | [virtual] |
Reimplemented in BarracksAgent, FirebatAgent, MarineAgent, MedicAgent, SCVAgent, SiegeTankAgent, CommandCenterAgent, RefineryAgent, ActorAgent, GroundAgent, and StructureAgent.
Definition at line 35 of file Agent.cpp.
References buildingLocation, BuildState, positionTarget, and state.
Referenced by Manager::update().
{ if( state == BuildState ) positionTarget = Position(buildingLocation); }
BWAPI::TilePosition Agent::buildingLocation [protected] |
Definition at line 24 of file Agent.h.
Referenced by SCVAgent::update(), and update().
bool Agent::buildingReserved [protected] |
Definition at line 23 of file Agent.h.
Referenced by SCVAgent::update().
Manager* Agent::parentManager [protected] |
Definition at line 26 of file Agent.h.
Referenced by getParentManagerName(), and setParentManager().
BWAPI::Position Agent::positionTarget [protected] |
Definition at line 20 of file Agent.h.
Referenced by draw(), getPositionTarget(), setPositionTarget(), ActorAgent::update(), MedicAgent::update(), and update().
State Agent::state [protected] |
Definition at line 17 of file Agent.h.
Referenced by draw(), getState(), setState(), ActorAgent::update(), StructureAgent::update(), CommandCenterAgent::update(), MedicAgent::update(), SCVAgent::update(), and update().
BWAPI::Unit& Agent::unit [protected] |
Definition at line 16 of file Agent.h.
Referenced by draw(), ActorAgent::getClosestPosition(), getUnit(), ActorAgent::isOccupiedPosition(), operator==(), ActorAgent::update(), StructureAgent::update(), CommandCenterAgent::update(), MedicAgent::update(), and SCVAgent::update().
BWAPI::Unit* Agent::unitTarget [protected] |
Definition at line 19 of file Agent.h.
Referenced by draw(), getUnitTarget(), setUnitTarget(), and SCVAgent::update().
BWAPI::UnitType Agent::unitTypeTarget [protected] |
Definition at line 21 of file Agent.h.
Referenced by draw(), getUnitTypeTarget(), setUnitTypeTarget(), unitTypeTargetValid(), StructureAgent::update(), and SCVAgent::update().