本文整理汇总了C++中bwapi::UnitType::getRace方法的典型用法代码示例。如果您正苦于以下问题:C++ UnitType::getRace方法的具体用法?C++ UnitType::getRace怎么用?C++ UnitType::getRace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bwapi::UnitType
的用法示例。
在下文中一共展示了UnitType::getRace方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetActionID
ActionID ActionTypeData::GetActionID(const BWAPI::UnitType & type)
{
const RaceID raceID = GetRaceID(type.getRace());
BOSS_ASSERT(raceID < Races::NUM_RACES, "Race ID invalid: %d %s", (int)raceID, type.getName().c_str());
for (ActionID a(0); a < ActionTypeData::GetNumActionTypes(raceID); ++a)
{
const ActionTypeData & data = GetActionTypeData(raceID, a);
if (data.isUnit() && data.getUnitType() == type)
{
return data.getActionID();
}
}
BOSS_ASSERT(false, "Could not find UnitType: %d %s", type.getID(), type.getName().c_str());
return 0;
}
示例2: setShortName
// UnitType constructor
ActionTypeData::ActionTypeData(BWAPI::UnitType t, const ActionID id)
: type (UnitType)
, unit (t)
, raceID (GetRaceID(t.getRace()))
, actionID (id)
, mineralPriceVal (t.mineralPrice() * Constants::RESOURCE_SCALE)
, gasPriceVal (t.gasPrice() * Constants::RESOURCE_SCALE)
, supplyRequiredVal (t.supplyRequired())
, supplyProvidedVal (t.supplyProvided())
, buildTimeVal (t.buildTime())
, numberProduced (1)
, name (t.getName())
, metaName (t.getName())
, building (t.isBuilding())
, worker (t.isWorker())
, refinery (t.isRefinery())
, resourceDepot (t.isResourceDepot())
, supplyProvider (t.supplyProvided() > 0 && !t.isResourceDepot())
, canProduceBool (t.isBuilding() && t.canProduce())
, canAttackBool (t.canAttack())
, whatBuildsUnitType (t.whatBuilds().first)
, addon (t.isAddon())
, morphed (false)
, reqAddon (false)
, reqAddonID (0)
{
if (t == BWAPI::UnitTypes::Zerg_Zergling || t == BWAPI::UnitTypes::Zerg_Scourge)
{
numberProduced = 2;
}
if (t == BWAPI::UnitTypes::Zerg_Lair ||
t == BWAPI::UnitTypes::Zerg_Hive ||
t == BWAPI::UnitTypes::Zerg_Greater_Spire ||
t == BWAPI::UnitTypes::Zerg_Lurker ||
t == BWAPI::UnitTypes::Zerg_Guardian ||
t == BWAPI::UnitTypes::Zerg_Sunken_Colony ||
t == BWAPI::UnitTypes::Zerg_Spore_Colony)
{
morphed = true;
}
setShortName();
}
示例3:
MetaType::MetaType (BWAPI::UnitType t)
: _unitType(t)
, _type(MetaTypes::Unit)
, _race(t.getRace())
{
}
示例4: calculatePrerequisites
// returns an ActionSet of prerequisites for a given action
ActionSet calculatePrerequisites(StarcraftAction & action)
{
ActionSet pre;
if (DEBUG_StarcraftData)
{
printf("DEBUG: Hello\n");
printf("DEBUG: %d \t%s \t%s\n", getAction(action), action.getName().c_str(), actions[getAction(action)].getName().c_str());
}
// if it's a UnitType
if (action.getType() == StarcraftAction::UnitType)
{
std::map<BWAPI::UnitType, int> requiredUnits = action.getUnitType().requiredUnits();
BWAPI::UnitType actionType = action.getUnitType();
// if it's a protoss building that isn't a Nexus or Assimilator, we need a pylon (indirectly)
if (actionType.getRace() == BWAPI::Races::Protoss && actionType.isBuilding() && !actionType.isResourceDepot() &&
!(actionType == BWAPI::UnitTypes::Protoss_Pylon) && !(actionType == BWAPI::UnitTypes::Protoss_Assimilator))
{
pre.add(getAction(BWAPI::UnitTypes::Protoss_Pylon));
}
// for each of the required UnitTypes
for (std::map<BWAPI::UnitType, int>::iterator unitIt = requiredUnits.begin(); unitIt != requiredUnits.end(); unitIt++)
{
if (DEBUG_StarcraftData) printf("\tPRE: %s\n", unitIt->first.getName().c_str());
BWAPI::UnitType type = unitIt->first;
// add the action to the ActionSet if it is not a larva
if (type != BWAPI::UnitTypes::Zerg_Larva)
{
//printf("\t\tAdding %s\n", type.getName().c_str());
pre.add(getAction(type));
}
}
// if there is a TechType required
if (action.getUnitType().requiredTech() != BWAPI::TechTypes::None)
{
if (DEBUG_StarcraftData) printf("\tPRE: %s\n", action.getUnitType().requiredTech().getName().c_str());
// add it to the ActionSet
pre.add(getAction(action.getUnitType().requiredTech()));
}
}
// if it's a TechType
if (action.getType() == StarcraftAction::TechType)
{
if (action.getTechType().whatResearches() != BWAPI::UnitTypes::None)
{
if (DEBUG_StarcraftData) printf("\tPRE: %s\n", action.getTechType().whatResearches().getName().c_str());
// add what researches it
pre.add(getAction(action.getTechType().whatResearches()));
}
}
// if it's an UpgradeType
if (action.getType() == StarcraftAction::UpgradeType)
{
if (action.getUpgradeType().whatUpgrades() != BWAPI::UnitTypes::None)
{
if (DEBUG_StarcraftData) printf("\tPRE: %s\n", action.getUpgradeType().whatUpgrades().getName().c_str());
// add what upgrades it
pre.add(getAction(action.getUpgradeType().whatUpgrades()));
}
}
//printf("Finish Prerequisites\n");
return pre;
}
示例5: GetActionTypeData
ActionTypeData ActionTypeData::GetActionTypeData(const BWAPI::UnitType & a)
{
return GetActionTypeData(GetRaceID(a.getRace()), GetActionID(a));
}