Пример #1
0
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);
		}
	}
}
Пример #2
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);
	}
}