public static void InferSkillBias(this ResearchProjectDef tech) { //0. variables for diagnostics int matchesCount = 0, thingsCount = 0, recipesCount = 0, recipeThingsCount = 0, recipeSkillsCount = 0, terrainsCount = 0; List <string> keywords = new List <string>(); bool usedPreReq = false; //1. check what it unlocks List <Pair <Def, string> > unlocks = GetUnlockDefsAndDescs(tech); IEnumerable <Def> defs = unlocks.Select(x => x.First).AsEnumerable(); IEnumerable <ThingDef> thingDefs = defs.Where(d => d is ThingDef).Select(d => d as ThingDef); IEnumerable <RecipeDef> recipeDefs = defs.Where(d => d is RecipeDef).Select(d => d as RecipeDef); IEnumerable <TerrainDef> terrainDefs = defs.Where(d => d is TerrainDef).Select(d => d as TerrainDef); //2. look for skills based on unlocked stuff //a. checking by query on the research tree matchesCount = tech.CheckKeywordsFor(keywords); //b. checking by unlocked things if (thingDefs.Count() > 0) { thingsCount = tech.CheckUnlockedThings(thingDefs); } //c. checking by unlocked recipes if (recipeDefs.Count() > 0) { recipesCount = tech.CheckUnlockedRecipes(ref recipeThingsCount, ref recipeSkillsCount, recipeDefs); } //d. checking by unlocked terrainDefs if (terrainDefs.Count() > 0) { terrainsCount = CheckUnlockedTerrains(terrainDefs); } //e. special cases if (HarmonyPatches.RunSpecialCases) { tech.CheckSpecialCases(keywords); } //f. If necessary, consider the skills already assigned to its prerequisites if (!FindSkills(x => x.relevant).Any()) { usedPreReq = tech.CopyFromPreReq(); } //3. Figure out Bias. List <SkillDef> relevantSkills = GetSkillBiasAndReset().ToList(); bool success = !relevantSkills.NullOrEmpty(); if (success) { LinkTechAndSkills(tech, relevantSkills); } //4. Telling humans what's going on, depending on the settings StringBuilder report = new StringBuilder(); if (Prefs.LogVerbose) { if (!success || usedPreReq) { GatherNoMatchesDetails(thingDefs.EnumerableCount(), recipeDefs.EnumerableCount(), terrainDefs.EnumerableCount(), report); } if (success && FullStartupReport) { GatherSuccessDetails(tech, matchesCount, thingsCount, recipesCount, recipeThingsCount, recipeSkillsCount, terrainsCount, keywords, usedPreReq, relevantSkills, report); Log.Message($"{tech.LabelCap}: {report}", true); } } NoMatchesWarning(tech, usedPreReq, relevantSkills, success, report); }