|
BWAPI
|
00001 #include <Common.h> 00002 #ifndef OVERLORDMANAGER_H 00003 #define OVERLORDMANAGER_H 00004 #include <BWAPI.h> 00005 #include "MicroManager.h" 00006 #include "../MapGrid.h" 00007 #include "../UnitInfoState.h" 00008 #include <map> 00009 #include <algorithm> 00010 00011 class OverlordCompareDistance { 00012 00013 // the zergling we are comparing this to 00014 BWAPI::Position attackPosition; 00015 00016 public: 00017 00018 // constructor, takes in a zergling to compare distance to 00019 OverlordCompareDistance(BWAPI::Position p) : attackPosition(p) {} 00020 00021 // the sorting comparison operator 00022 bool operator() (BWAPI::Unit * u1, BWAPI::Unit * u2) { 00023 00024 return u1->getDistance(attackPosition) < u2->getDistance(attackPosition); 00025 } 00026 }; 00027 00028 00029 class OverlordManager { 00030 00031 int range, frame, xi, yi; 00032 00033 OverlordManager(); 00034 00035 static OverlordManager * instance; 00036 00037 std::map<BWAPI::Unit *, BWAPI::Position> overlord_positions; 00038 std::map<BWAPI::Unit *, bool> overlord_tethered; 00039 00040 BWAPI::Position closestUnoccupiedPosition(BWAPI::Unit * unit); 00041 void fillAirThreats(std::vector<AirThreat> & threats, UnitVector & candidates); 00042 double2 getFleeVector(const std::vector<AirThreat> & threats, BWAPI::Unit * overlord); 00043 00044 BWAPI::Unit * overlordScout; 00045 00046 std::vector<AirThreat> threats; 00047 00048 // Dave added these 00049 BWAPI::Position ourStartPosition; 00050 BWAPI::Position firstOverlordScoutPosition; 00051 00052 public: 00053 00054 00055 static OverlordManager * getInstance(); 00056 00057 void update(); 00058 void onStart(); 00059 void setAttackPosition(BWAPI::Position attackPosition); 00060 void onOverlordCreate(BWAPI::Unit * unit); 00061 void onOverlordDestroy(BWAPI::Unit * unit); 00062 void tetherAllOverlords(); 00063 00064 BWAPI::Unit * getClosestOverlord(BWAPI::Position p); 00065 00066 void tetherOverlord(BWAPI::Unit * unit); 00067 void untetherOverlord(BWAPI::Unit * unit); 00068 00069 bool overlordNear(BWAPI::Position p, double dist); 00070 bool overlordAssigned(BWAPI::Position p); 00071 00072 00073 00074 00075 }; 00076 #endif 00077
1.7.6.1