本文整理汇总了C++中bwapi::TilePosition::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ TilePosition::isValid方法的具体用法?C++ TilePosition::isValid怎么用?C++ TilePosition::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bwapi::TilePosition
的用法示例。
在下文中一共展示了TilePosition::isValid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assignWorkersToUnassignedBuildings
// STEP 2: ASSIGN WORKERS TO BUILDINGS WITHOUT THEM
void BuildingManager::assignWorkersToUnassignedBuildings()
{
// for each building that doesn't have a builder, assign one
buildingData.begin(ConstructionData::Unassigned);
while (buildingData.hasNextBuilding(ConstructionData::Unassigned))
{
Building & b = buildingData.getNextBuilding(ConstructionData::Unassigned);
if (debugMode) { BWAPI::Broodwar->printf("Assigning Worker To: %s", b.type.getName().c_str()); }
// remove all refineries after 3, i don't know why this happens
if (b.type.isRefinery() && (BWAPI::Broodwar->self()->allUnitCount(b.type) >= 3))
{
buildingData.removeCurrentBuilding(ConstructionData::Unassigned);
break;
}
// grab a worker unit from WorkerManager which is closest to this final position
BWAPI::UnitInterface* workerToAssign = WorkerManager::Instance().getBuilder(b);
// if the worker exists
if (workerToAssign)
{
//BWAPI::Broodwar->printf("VALID WORKER BEING ASSIGNED: %d", workerToAssign->getID());
// TODO: special case of terran building whose worker died mid construction
// send the right click command to the buildingUnit to resume construction
// skip the buildingsAssigned step and push it back into buildingsUnderConstruction
// set the worker we have assigned
b.builderUnit = workerToAssign;
// re-search for a building location with the builder unit ignored for space
BWAPI::TilePosition testLocation = getBuildingLocation(b);
// hopefully this will not blow up
if (!testLocation.isValid())
{
continue;
}
// set the final position of the building
b.finalPosition = testLocation;
// reserve this space
BuildingPlacer::Instance().reserveTiles(b.finalPosition, b.type.tileWidth(), b.type.tileHeight());
// this building has now been assigned
buildingData.addBuilding(ConstructionData::Assigned, b);
// remove this Building
buildingData.removeCurrentBuilding(ConstructionData::Unassigned);
}
}
}
示例2: assignWorkersToUnassignedBuildings
// STEP 2: ASSIGN WORKERS TO BUILDINGS WITHOUT THEM
void BuildingManager::assignWorkersToUnassignedBuildings()
{
// for each building that doesn't have a builder, assign one
for (Building & b : _buildings)
{
if (b.status != BuildingStatus::Unassigned)
{
continue;
}
if (_debugMode) { BWAPI::Broodwar->printf("Assigning Worker To: %s", b.type.getName().c_str()); }
if (createdHatchery && !isCreepStarted() && createdHatcheriesVector.size() >= 1 && startedPool)
{
//BWAPI::TilePosition myHatch = createdSunkenVector[0];
b.builderUnit = sunkenUnit;
}
else
{
BWAPI::Unit workerToAssign = WorkerManager::Instance().getBuilder(b);
if (workerToAssign)
{
b.builderUnit = workerToAssign;
}
}
//BWAPI::Broodwar->printf("VALID WORKER BEING ASSIGNED: %d", workerToAssign->getID());
// TODO: special case of terran building whose worker died mid construction
// send the right click command to the buildingUnit to resume construction
// skip the buildingsAssigned step and push it back into buildingsUnderConstruction
BWAPI::TilePosition testLocation = getBuildingLocation(b);
if (!testLocation.isValid())
{
continue;
}
b.finalPosition = testLocation;
// reserve this building's space
BuildingPlacer::Instance().reserveTiles(b.finalPosition, b.type.tileWidth(), b.type.tileHeight());
b.status = BuildingStatus::Assigned;
}
}
示例3: assignWorkersToUnassignedBuildings
// STEP 2: ASSIGN WORKERS TO BUILDINGS WITHOUT THEM
void BuildingManager::assignWorkersToUnassignedBuildings()
{
// for each building that doesn't have a builder, assign one
for (Building & b : _buildings)
{
if (b.status != BuildingStatus::Unassigned)
{
continue;
}
if (_debugMode) { BWAPI::Broodwar->printf("Assigning Worker To: %s",b.type.getName().c_str()); }
// grab a worker unit from WorkerManager which is closest to this final position
BWAPI::Unit workerToAssign = WorkerManager::Instance().getBuilder(b);
if (workerToAssign)
{
//BWAPI::Broodwar->printf("VALID WORKER BEING ASSIGNED: %d", workerToAssign->getID());
// TODO: special case of terran building whose worker died mid construction
// send the right click command to the buildingUnit to resume construction
// skip the buildingsAssigned step and push it back into buildingsUnderConstruction
b.builderUnit = workerToAssign;
BWAPI::TilePosition testLocation = getBuildingLocation(b);
if (!testLocation.isValid())
{
continue;
}
b.finalPosition = testLocation;
// reserve this building's space
BuildingPlacer::Instance().reserveTiles(b.finalPosition,b.type.tileWidth(),b.type.tileHeight());
b.status = BuildingStatus::Assigned;
}
}
}