void ConstructionTask::updateRequirements()
{
	clearRequirements();

	if(!hasEnded())
	{
		reserveLocation();

		if(!finishedWithBuilder() && !mBuilder && (mProducedUnit || (mReservedLocation && mReservedLocation->isCalculated())))
		{
			Position location = mProducedUnit ? mProducedUnit->getPosition() : mReservedLocation->getPosition();
			int neededDuration = mType.getRace() == BWAPI::Races::Protoss ? BWAPI::Broodwar->getLatencyFrames() : mType.getRace() == BWAPI::Races::Zerg ? Requirement::maxTime : mType.buildTime();

			RequirementGroup requiredConditions;
			requiredConditions.addUnitFilterRequirement(40, neededDuration, UnitFilter(mType.whatBuilds().first) && UnitFilter(UnitFilterFlags::IsComplete), location);

			if(!mReservedResources && (!mProducedUnit || !mProducedUnit->exists()))
			{
				requiredConditions.addTechForTypeRequirement(mType);

				if(mType.mineralPrice() > 0) requiredConditions.addMineralRequirement(mType.mineralPrice());
				if(mType.gasPrice() > 0) requiredConditions.addGasRequirement(mType.gasPrice());
				if(mType.supplyRequired() > 0) requiredConditions.addSupplyRequirement(mType.supplyRequired());
			}

			addRequirement(requiredConditions);
		}
	}
}
Example #2
0
void TechTask::updateRequirements()
{
	clearRequirements();

	if(!mUnit && !shouldReturnUnit())
	{
		RequirementGroup requiredConditions;

		assert(mReservedResources == false);
		requiredConditions.addTechForTypeRequirement(mType);
		requiredConditions.addUnitFilterRequirement(40, mType.researchTime(), UnitFilter(mType.whatResearches()) && UnitFilter(UnitFilterFlags::IsComplete));
		requiredConditions.addMineralRequirement(mType.mineralPrice());
		requiredConditions.addGasRequirement(mType.gasPrice());

		addRequirement(requiredConditions);
	}
}
Example #3
0
void TrainTask::updateRequirements()
{
	clearRequirements();

	if(!mProductionBuilding)
	{
		RequirementGroup requiredConditions;

		freeResources();

		requiredConditions.addUnitFilterRequirement(40, mType.buildTime(), UnitFilter(mType.whatBuilds().first) && UnitFilter(UnitFilterFlags::IsComplete) && !UnitFilter(UnitFilterFlags::IsLifted));

		requiredConditions.addTechForTypeRequirement(mType);

		if(mType.mineralPrice() > 0) requiredConditions.addMineralRequirement(mType.mineralPrice());
		if(mType.gasPrice() > 0) requiredConditions.addGasRequirement(mType.gasPrice());
		if(mType.supplyRequired() > 0) requiredConditions.addSupplyRequirement(mType.supplyRequired());

		addRequirement(requiredConditions);
	}
}