BWAPI
|
00001 #pragma once 00002 00003 #include "Interface.h" 00004 #include <deque> 00005 00006 #include "UnitGroup.h" 00007 #include "Region.h" 00008 00009 struct UnitThreatTypeDef 00010 { 00011 enum type 00012 { 00013 Scout, 00014 AirToAir, 00015 AirToGround, 00016 GroundToAir, 00017 GroundToGround 00018 }; 00019 }; 00020 typedef SafeEnum<UnitThreatTypeDef> UnitThreatType; 00021 00022 class BaseClass 00023 { 00024 public: 00025 BaseClass(Region region, std::set<TilePosition> tiles, bool startLocation); 00026 BaseClass(TilePosition position, const UnitGroup &resources, Region region, std::set<TilePosition> tiles, bool startLocation); 00027 00028 void update(); 00029 00030 TilePosition getCenterBuildLocation() const { return mCenterTilePosition; } 00031 Position getCenterLocation() const { return mCenterPosition; } 00032 00033 const UnitGroup &getMinerals() const { return mMinerals; } 00034 const UnitGroup &getGeysers() const { return mGeysers; } 00035 const UnitGroup &getRefineries() const { return mRefineries; } 00036 00037 Unit getResourceDepot() const { return mResourceDepots.empty() ? StaticUnits::nullunit : mResourceDepots[0]; } 00038 bool isActive(bool activeInFuture = false) const { return (mActive || (activeInFuture && mActiveInFuture)); } 00039 00040 bool isMinedOut() const { return mMinedOut; } 00041 bool isUnderAttack() const { return mIsUnderAttack; } 00042 bool isContested() const { return mIsContested; } 00043 00044 bool isStartLocation() const { return mIsStartLocation; } 00045 00046 const UnitGroup &getBuildings() const { return mBuildings; } 00047 unsigned int getNumberOfTechBuildings() const { return mTechBuildings; } 00048 00049 Player getPlayer() const { return mPlayer; } 00050 00051 void onDiscover(Unit unit); 00052 void onMorphRenegade(Unit unit, Player previousPlayer, BWAPI::UnitType previousType); 00053 void onDestroy(Unit unit); 00054 00055 void drawDebugInfo() const; 00056 00057 Region getRegion() const { return mRegion.lock(); } 00058 00059 const std::set<TilePosition> &getTiles() const { return mTiles; } 00060 00061 bool isEnemyBase() const { return BWAPI::Broodwar->self()->isEnemy(mPlayer); } 00062 bool isMyBase() const { return mPlayer == BWAPI::Broodwar->self(); } 00063 bool isAllyBase() const { return BWAPI::Broodwar->self()->isAlly(mPlayer); } 00064 00065 Unit getClosestEnemyBuilding(Position pos); 00066 00067 const UnitGroup &getEnemyThreats() const { return mAllThreats; } 00068 const UnitGroup getDefenders() const { return mAllDefenders; } 00069 00070 bool depotCompare(const Unit &depotOne, const Unit &depotTwo); 00071 00072 unsigned int getActivateTime() const { return mActivateTime; } 00073 00074 private: 00075 Position mCenterPosition; 00076 TilePosition mCenterTilePosition; 00077 00078 UnitGroup mMinerals; 00079 UnitGroup mGeysers; 00080 UnitGroup mRefineries; 00081 00082 bool mActive; 00083 bool mActiveInFuture; 00084 unsigned int mActivateTime; 00085 00086 bool mMinedOut; 00087 bool mIsUnderAttack; 00088 bool mIsContested; 00089 unsigned int mTechBuildings; 00090 00091 bool mIsStartLocation; 00092 00093 Player mPlayer; 00094 00095 UnitGroup mBuildings; 00096 00097 std::deque<Unit> mResourceDepots; 00098 00099 WeakRegion mRegion; 00100 std::set<TilePosition> mTiles; 00101 00102 std::map<Player, int> mPlayerBuildingNumbers; 00103 UnitGroup mAllThreats; 00104 std::map<UnitThreatType, UnitGroup> mThreatTypes; 00105 00106 UnitGroup mAllDefenders; 00107 00108 UnitGroup mLiftedBuildings; 00109 00110 void updatePlayer(); 00111 00112 void addUnit(Unit unit); 00113 void removeUnit(Unit unit, Player playerToRemove, BWAPI::UnitType typeToRemove); 00114 }; 00115 00116 typedef std::tr1::shared_ptr<BaseClass> Base;