BWAPI
|
00001 /* 00002 * Agent.h 00003 */ 00004 #pragma once 00005 #include "State.h" 00006 #include <Common.h> 00007 00008 #include <BWAPI.h> 00009 00010 class Manager; 00011 00012 00013 class Agent 00014 { 00015 protected: 00016 BWAPI::Unit &unit; // The Unit this Agent controls 00017 State state; // The State this Agent is in 00018 00019 BWAPI::Unit *unitTarget; // Targeted unit (for gather, attack, etc.) 00020 BWAPI::Position positionTarget; // Targeted position (for moving, evade, etc.) 00021 BWAPI::UnitType unitTypeTarget; // Targeted unit type (for production of units, buildings, etc.) 00022 00023 bool buildingReserved; // Have we reserved space for a building yet? 00024 BWAPI::TilePosition buildingLocation; // Location to build target building at 00025 00026 Manager *parentManager; 00027 00028 public: 00029 /* 00030 * update - Called on each frame to update this agent's state and unit. 00031 */ 00032 virtual void update(); 00033 00034 /* draw - draw debug info to screen */ 00035 virtual void draw(); 00036 00037 bool operator==(const Agent& other); 00038 00039 // attr_accessors 00040 inline void setState(State state) { this->state = state; } 00041 inline void setUnitTarget(BWAPI::Unit *target) { unitTarget = target; } 00042 inline void setPositionTarget(const BWAPI::Position& target) { positionTarget = target; } 00043 inline void setUnitTypeTarget(const BWAPI::UnitType& target) { unitTypeTarget = target; } 00044 00045 bool unitTypeTargetValid() { 00046 int typeTargetID = unitTypeTarget.getID(); 00047 return typeTargetID >= 0 && 00048 typeTargetID < NUM_UNIT_TYPES && 00049 typeTargetID != BWAPI::UnitTypes::None; 00050 } 00051 00052 inline const State getState() const { return state; } 00053 inline const BWAPI::Unit& getUnit() const { return unit; } 00054 inline BWAPI::Unit& getUnit() { return unit; } 00055 inline const BWAPI::Position& getPositionTarget() const { return positionTarget; } 00056 inline const BWAPI::UnitType& getUnitTypeTarget() const { return unitTypeTarget; } 00057 inline BWAPI::Unit* getUnitTarget() const { return unitTarget; } 00058 00059 void setParentManager(Manager *manager); 00060 const std::string getParentManagerName() const; 00061 00062 protected: 00063 // C'tor (must be called from subclass) 00064 Agent(BWAPI::Unit &u); 00065 };