private static PawnKindDef determinePawnKind(Map map, Predicate <PawnKindDef> isAnimal, float inBiomeWeightNormalized, float outBiomeWeightNormalized, int rndInt, int pawnHandlingLevel, List <string> factionFarmAnimalRestrictions, List <string> factionWildAnimalRestrictions) { PawnKindDef pawnKindDef = null; if (factionWildAnimalRestrictions.NullOrEmpty() && rndInt <= inBiomeWeightNormalized) { (from a in map.Biome.AllWildAnimals where map.mapTemperature.SeasonAcceptableFor(a.race) && IsMountableUtility.isAllowedInModOptions(a.defName) select a).TryRandomElementByWeight((PawnKindDef def) => calculateCommonality(def, map, pawnHandlingLevel), out pawnKindDef); } else if (rndInt <= inBiomeWeightNormalized + outBiomeWeightNormalized) { (from a in DefDatabase <PawnKindDef> .AllDefs where isAnimal(a) && a.wildSpawn_spawnWild && map.mapTemperature.SeasonAcceptableFor(a.race) && IsMountableUtility.isAllowedInModOptions(a.defName) && (factionWildAnimalRestrictions.NullOrEmpty() || factionWildAnimalRestrictions.Contains(a.defName)) select a).TryRandomElementByWeight((PawnKindDef def) => calculateCommonality(def, map, pawnHandlingLevel), out pawnKindDef); } else { (from a in DefDatabase <PawnKindDef> .AllDefs where isAnimal(a) && !a.wildSpawn_spawnWild && map.mapTemperature.SeasonAcceptableFor(a.race) && IsMountableUtility.isAllowedInModOptions(a.defName) && (factionFarmAnimalRestrictions.NullOrEmpty() || factionFarmAnimalRestrictions.Contains(a.defName)) select a).TryRandomElementByWeight((PawnKindDef def) => 1 - def.RaceProps.wildness, out pawnKindDef); } return(pawnKindDef); }
private static PawnKindDef determinePawnKind(Map map, Predicate <PawnKindDef> isAnimal, float inBiomeWeightNormalized, float outBiomeWeightNormalized, int rndInt, int pawnHandlingLevel, List <string> factionFarmAnimalRestrictions, List <string> factionWildAnimalRestrictions, IncidentParms parms) { PawnKindDef pawnKindDef = null; float averageCommonality = AverageAnimalCommonality(map); Predicate <PawnKindDef> canUseAnimal = (PawnKindDef a) => map.mapTemperature.SeasonAcceptableFor(a.race) && IsMountableUtility.isAllowedInModOptions(a.defName) && parms.points > a.combatPower * 2f; if (factionWildAnimalRestrictions.NullOrEmpty() && rndInt <= inBiomeWeightNormalized) { (from a in map.Biome.AllWildAnimals where canUseAnimal(a) select a).TryRandomElementByWeight((PawnKindDef def) => calculateCommonality(def, map, pawnHandlingLevel), out pawnKindDef); } else if (rndInt <= inBiomeWeightNormalized + outBiomeWeightNormalized) { (from a in Base.animalsWithBiome where isAnimal(a) && canUseAnimal(a) && (factionWildAnimalRestrictions.NullOrEmpty() || factionWildAnimalRestrictions.Contains(a.defName)) select a).TryRandomElementByWeight((PawnKindDef def) => calculateCommonality(def, map, pawnHandlingLevel, averageCommonality), out pawnKindDef); } else { (from a in Base.animalsWithoutBiome where isAnimal(a) && canUseAnimal(a) && (factionFarmAnimalRestrictions.NullOrEmpty() || factionFarmAnimalRestrictions.Contains(a.defName)) select a).TryRandomElementByWeight((PawnKindDef def) => calculateCommonality(def, map, pawnHandlingLevel, averageCommonality), out pawnKindDef); } return(pawnKindDef); }