BWAPI
|
00001 #pragma once 00002 #include "../Layer3ScriptTypes.h" 00003 #include "L3PrimitiveLocation.h" 00004 00005 class L3BaseLocation : public virtual BaseLocation, public Layer3ScriptTypes, public L3PrimitiveLocation 00006 { 00007 public: 00008 template <class LocationTypes> 00009 L3BaseLocation(LocationTypes* dummy, const BWTA::BaseLocation* location, Region* parent) 00010 : BaseLocation(dummy, location, parent) 00011 , PrimitiveLocation(parent) 00012 , L3PrimitiveLocation(parent) 00013 , StaticLocation(parent) 00014 , m_collectMineralsEndedEventHandler(*this) 00015 , m_collectGasEndedEventHandler(*this) 00016 , m_probeRecruitedEventHandler(*this) 00017 , m_collectMinerals(*this, new CollectMinerals(PRIORITY_COLLECT_MINERALS, &PersistentUnitGroup::EmptyGroup, this)) 00018 , m_collectGas(*this, new CollectGas(PRIORITY_COLLECT_GAS, &PersistentUnitGroup::EmptyGroup, this)) 00019 , m_recruitProbes(*this) 00020 , m_buildAssimilators(*this) 00021 { 00022 m_collectMinerals->getTerminateEvent().subscribe(&m_collectMineralsEndedEventHandler, m_collectMinerals); 00023 m_collectGas->getTerminateEvent().subscribe(&m_collectGasEndedEventHandler, m_collectGas); 00024 } 00025 00026 ~L3BaseLocation() 00027 { 00028 } 00029 00030 size_t getNbProbesOnMinerals() const 00031 { 00032 return m_collectMinerals->getGroup()->size(); 00033 } 00034 CollectMinerals* getCollectMinerals() 00035 { 00036 return m_collectMinerals; 00037 } 00038 00039 size_t getNbProbesOnGas() const 00040 { 00041 return m_collectGas->getGroup()->size(); 00042 } 00043 CollectGas* getCollectGas() 00044 { 00045 return m_collectGas; 00046 } 00047 00048 bool hasEnemyArmyUnits() const; 00049 00050 void buildAssimilator(); 00051 00052 void executeCollectResources(); 00053 00054 void executeRecruitProbes(); 00055 void cancelRecruitProbes(); 00056 00057 // 00058 // Events 00059 // 00060 void onCollectMineralsEnded(void* data); 00061 void onCollectGasEnded(void* data); 00062 void onProbeRecruited(void* data, const layer2::Recruit* recruit, BWAPI::Unit* probe, StaticLocation* location); 00063 00064 protected: 00065 std::string probesName(const std::string suffix) 00066 { 00067 std::stringstream ss; 00068 ss << "Location#" << getId() << "-Probes" << suffix; 00069 return ss.str(); 00070 } 00071 00072 EVENT_HANDLER(L3BaseLocation, onCollectMineralsEnded) m_collectMineralsEndedEventHandler; 00073 EVENT_HANDLER(L3BaseLocation, onCollectGasEnded) m_collectGasEndedEventHandler; 00074 EVENT_HANDLER3(L3BaseLocation, onProbeRecruited, const layer2::Recruit*, BWAPI::Unit*, PrimitiveLocation*) m_probeRecruitedEventHandler; 00075 00076 ProcessContainer<CollectMinerals> m_collectMinerals; 00077 ProcessContainer<CollectGas> m_collectGas; 00078 ProcessContainer<Recruit> m_recruitProbes; 00079 ProcessContainerList<Build> m_buildAssimilators; 00080 };