//---------------------------------------------------------------------------------------------- EntityClassType StarCraftTechTree::SourceEntity(int p_typeOrResearchId) const { TName ident; TID id; UpgradeType upgrade; TechType tech; BWAPI::UnitType unitType; BWAPI::UnitType sourceType; if (BELONG(ResearchType, p_typeOrResearchId)) { // Is Tech if ((int)p_typeOrResearchId >= ((int)(RESEARCH_START + TechIdOffset))) { id = g_Database.TechMapping.GetBySecond((ResearchType)p_typeOrResearchId); ident = g_Database.TechIdentMapping.GetByFirst(id); tech = TechType::getType(ident); sourceType = tech.whatResearches(); return g_Database.EntityMapping.GetByFirst(sourceType.getID()); } // Is Upgrade else { id = g_Database.UpgradeMapping.GetBySecond((ResearchType)p_typeOrResearchId); ident = g_Database.UpgradeIdentMapping.GetByFirst(id); upgrade = UpgradeType::getType(ident); sourceType = upgrade.whatUpgrades(); return g_Database.EntityMapping.GetByFirst(sourceType.getID()); } } else if(BELONG(EntityClassType, p_typeOrResearchId)) { id = g_Database.EntityMapping.GetBySecond((EntityClassType)p_typeOrResearchId); ident = g_Database.EntityIdentMapping.GetByFirst(id); unitType = UnitType::getType(ident); sourceType = unitType.whatBuilds().first; return g_Database.EntityMapping.GetByFirst(sourceType.getID()); } return ECLASS_END; }
/*** * Check if we can research the given TechType w.r.t. tech structures * !!! Ask TheBuilder to build them otherwise. !!! */ bool Producer::checkCanTech(TechType t) { return checkHaveTech(t.whatResearches()); }