示例#1
0
UnitGroup TrainTask::getFinishedUnits()
{
	UnitGroup returnUnits;

	if(mProductionBuilding)
		returnUnits.insert(mProductionBuilding);
	if(mProducedUnit)
		returnUnits.insert(mProducedUnit);

	return returnUnits;
}
示例#2
0
UnitGroup ConstructionTask::getFinishedUnits()
{
	UnitGroup returnUnits;

	if(mBuilder && finishedWithBuilder())
		returnUnits.insert(mBuilder);

	if(mProducedUnit && mProducedUnit->exists() && isCompleted())
		returnUnits.insert(mProducedUnit);

	return returnUnits;
}
示例#3
0
UnitGroup GatherTask::getFinishedUnits()
{
	UnitGroup returnUnits;

	if(mWorkerOne)
		returnUnits.insert(mWorkerOne);
	if(mWorkerTwo)
		returnUnits.insert(mWorkerTwo);
	if(mWorkerThree)
		returnUnits.insert(mWorkerThree);

	return returnUnits;
}
UnitGroup ObserverScoutTask::getFinishedUnits()
{
	UnitGroup returnUnits;

	returnUnits.insert(mUnit);

	return returnUnits;
}
示例#5
0
void UnitGroupManager::onUnitDiscover(BWAPI::Unit* unit)
{
	unitOwner[unit]=unit->getPlayer();
	unitType[unit]=unit->getType();
	data[unit->getPlayer()][unit->getType()].insert(unit);
	allOwnedUnits[unit->getPlayer()].insert(unit);
	allUnits.insert(unit);
}
示例#6
0
UnitGroup RequirementGroup::getUnits() const
{
	UnitGroup units;
	for(std::vector<Requirement>::const_iterator requirement = mUnitRequirements.begin(); requirement != mUnitRequirements.end(); ++requirement)
		units.insert(requirement->getUnit());

	return units;
}
示例#7
0
UnitGroup TechTask::getFinishedUnits()
{
	UnitGroup returnUnits;

	if(mUnit)
		returnUnits.insert(mUnit);

	return returnUnits;
}
示例#8
0
std::vector<UnitGroup> UnitHelper::getClusters(const UnitGroup &units, int distance, int minSize)
{
    std::vector<UnitGroup> clusters;

    for each(Unit unit in units)
    {
        std::vector<size_t> clustersInRange;
        for(size_t i = 0; i < clusters.size(); ++i)
        {
            for each(Unit clusterUnit in clusters[i])
            {
                if(unit->getPosition().getApproxDistance(clusterUnit->getPosition()) <= distance)
                {
                    clustersInRange.push_back(i);
                    break;
                }
            }
        }

        if(clustersInRange.empty())
        {
            UnitGroup newCluster;
            newCluster.insert(unit);
            clusters.push_back(newCluster);
        }
        else
        {
            clusters[clustersInRange[0]].insert(unit);

            for(size_t i = 1; i < clustersInRange.size(); ++i)
            {
                for each(Unit clusterUnit in clusters[clustersInRange[i]])
                {
                    clusters[clustersInRange[0]].insert(clusterUnit);
                }
                clusters[clustersInRange[i]].clear();
            }
        }