BWAPI
|
00001 #pragma once 00002 #include "Macro/Arbitrator.h" 00003 #include <BWAPI.h> 00004 #include "Macro/BuildingPlacer.h" 00005 class ProductionManager : public Arbitrator::Controller<BWAPI::Unit*,double> 00006 { 00007 public: 00008 ProductionManager(Arbitrator::Arbitrator<BWAPI::Unit*,double>* arbitrator, BuildingPlacer* placer); 00009 virtual void onOffer(std::set<BWAPI::Unit*> units); 00010 virtual void onRevoke(BWAPI::Unit* unit, double bid); 00011 virtual void update(); 00012 virtual std::string getName() const; 00013 virtual std::string getShortName() const; 00014 00015 void onRemoveUnit(BWAPI::Unit* unit); 00016 bool train(BWAPI::UnitType type, bool forceNoAddon=false); 00017 int getPlannedCount(BWAPI::UnitType type) const; 00018 int getStartedCount(BWAPI::UnitType type) const; 00019 BWAPI::UnitType getBuildType(BWAPI::Unit* unit) const; 00020 00021 private: 00022 class ProductionUnitType 00023 { 00024 public: 00025 BWAPI::UnitType type; 00026 bool forceNoAddon; 00027 }; 00028 class Unit 00029 { 00030 public: 00031 ProductionUnitType type; 00032 int lastAttemptFrame; 00033 BWAPI::Unit* unit; 00034 bool started; 00035 }; 00036 bool canMake(BWAPI::Unit* builder, BWAPI::UnitType type); 00037 Arbitrator::Arbitrator<BWAPI::Unit*,double>* arbitrator; 00038 std::map<BWAPI::UnitType,std::list<ProductionUnitType > > productionQueues; 00039 std::map<BWAPI::Unit*,Unit> producingUnits; 00040 BuildingPlacer* placer; 00041 std::map<BWAPI::UnitType, int> plannedCount; 00042 std::map<BWAPI::UnitType, int> startedCount; 00043 };