BWAPI
|
00001 #pragma once 00002 00003 #include "Interface.h" 00004 00005 #include <limits> 00006 00007 #include "TypeSafeEnum.h" 00008 #include "UnitFilter.h" 00009 #include "Unit.h" 00010 00011 struct RequirementTypeDef 00012 { 00013 enum type 00014 { 00015 Mineral, 00016 Gas, 00017 Supply, 00018 Unit, 00019 UnitFilter, 00020 RequiredForUnit, 00021 RequiredForUpgrade, 00022 RequiredForTech, 00023 Time, 00024 Task, 00025 }; 00026 }; 00027 typedef SafeEnum<RequirementTypeDef> RequirementType; 00028 00029 // Forward declare Task and TaskPointer 00030 class Task; 00031 typedef std::tr1::shared_ptr<Task> TaskPointer; 00032 00033 class Requirement 00034 { 00035 public: 00036 Requirement(RequirementType type, int amount); 00037 Requirement(int priority, int duration, Unit unit, Position position); 00038 Requirement(int priority, int duration, UnitFilter unitFilter, Position position); 00039 Requirement(TaskPointer task); 00040 Requirement(BWAPI::UnitType unit); 00041 Requirement(BWAPI::TechType tech); 00042 Requirement(BWAPI::UpgradeType upgrade, int level); 00043 00044 int earliestTime(); 00045 00046 std::map<int, int> earliestUnitTime(int startTime, int endTime, std::set<Unit> ¤tUnits); 00047 00048 void reserve(int frameTime); 00049 00050 RequirementType getType() { return mType; } 00051 00052 bool unitRequirement() { return mType == RequirementType::Unit || mType == RequirementType::UnitFilter; } 00053 00054 Unit getUnit() const { return mUnit; } 00055 00056 int getDelay() { return mDelay; } 00057 00058 bool operator==(const Requirement& other) const; 00059 bool operator<(const Requirement& other) const; 00060 00061 static const int maxTime; 00062 00063 private: 00064 RequirementType mType; 00065 int mAmount; 00066 00067 UnitFilter mUnitFilter; 00068 Unit mUnit; 00069 00070 Position mPosition; 00071 int mPriority; 00072 int mDuration; 00073 int mDelay; 00074 00075 TaskPointer mTask; 00076 00077 BWAPI::UnitType mUnitType; 00078 BWAPI::TechType mTechType; 00079 BWAPI::UpgradeType mUpgradeType; 00080 00081 int earliestTimeForType(BWAPI::UnitType unitType); 00082 };