private static ThingDef RandomPodContentsDef() { int numMeats = (from x in PossiblePodContentsDefs() where x.IsMeat select x).Count(); int numLeathers = (from x in PossiblePodContentsDefs() where x.IsLeather select x).Count(); return(PossiblePodContentsDefs().RandomElementByWeight((ThingDef d) => ThingSetMakerUtility.AdjustedBigCategoriesSelectionWeight(d, numMeats, numLeathers))); }
public static ThingDef RandomPodContentsDef(bool mustBeResource = false) { IEnumerable <ThingDef> source = PossiblePodContentsDefs(); if (mustBeResource) { source = source.Where((ThingDef x) => x.stackLimit > 1); } int numMeats = source.Where((ThingDef x) => x.IsMeat).Count(); int numLeathers = source.Where((ThingDef x) => x.IsLeather).Count(); return(source.RandomElementByWeight((ThingDef d) => ThingSetMakerUtility.AdjustedBigCategoriesSelectionWeight(d, numMeats, numLeathers))); }
private List<ThingStuffPairWithQuality> GeneratePossibleDefs(ThingSetMakerParams parms, out float totalNutrition) { IEnumerable<ThingDef> enumerable = this.AllowedThingDefs(parms); List<ThingStuffPairWithQuality> result; if (!enumerable.Any<ThingDef>()) { totalNutrition = 0f; result = new List<ThingStuffPairWithQuality>(); } else { IntRange? countRange = parms.countRange; IntRange intRange = (countRange == null) ? new IntRange(1, int.MaxValue) : countRange.Value; FloatRange? totalNutritionRange = parms.totalNutritionRange; FloatRange floatRange = (totalNutritionRange == null) ? FloatRange.Zero : totalNutritionRange.Value; TechLevel? techLevel = parms.techLevel; TechLevel techLevel2 = (techLevel == null) ? TechLevel.Undefined : techLevel.Value; float? maxTotalMass = parms.maxTotalMass; float num = (maxTotalMass == null) ? float.MaxValue : maxTotalMass.Value; QualityGenerator? qualityGenerator = parms.qualityGenerator; QualityGenerator qualityGenerator2 = (qualityGenerator == null) ? QualityGenerator.BaseGen : qualityGenerator.Value; totalNutrition = floatRange.RandomInRange; int numMeats = enumerable.Count((ThingDef x) => x.IsMeat); int numLeathers = enumerable.Count((ThingDef x) => x.IsLeather); Func<ThingDef, float> func = (ThingDef x) => ThingSetMakerUtility.AdjustedBigCategoriesSelectionWeight(x, numMeats, numLeathers); IntRange countRange2 = intRange; float totalValue = totalNutrition; IEnumerable<ThingDef> allowed = enumerable; TechLevel techLevel3 = techLevel2; QualityGenerator qualityGenerator3 = qualityGenerator2; Func<ThingStuffPairWithQuality, float> getMinValue = (ThingStuffPairWithQuality x) => x.GetStatValue(StatDefOf.Nutrition); Func<ThingStuffPairWithQuality, float> getMaxValue = (ThingStuffPairWithQuality x) => x.GetStatValue(StatDefOf.Nutrition) * (float)x.thing.stackLimit; Func<ThingDef, float> weightSelector = func; float maxMass = num; result = ThingSetMakerByTotalStatUtility.GenerateDefsWithPossibleTotalValue(countRange2, totalValue, allowed, techLevel3, qualityGenerator3, getMinValue, getMaxValue, weightSelector, 100, maxMass); } return result; }
private List <ThingStuffPairWithQuality> GeneratePossibleDefs(ThingSetMakerParams parms, out float totalNutrition) { IEnumerable <ThingDef> enumerable = AllowedThingDefs(parms); if (!enumerable.Any()) { totalNutrition = 0f; return(new List <ThingStuffPairWithQuality>()); } IntRange countRange = parms.countRange ?? new IntRange(1, int.MaxValue); FloatRange floatRange = parms.totalNutritionRange ?? FloatRange.Zero; TechLevel techLevel = parms.techLevel ?? TechLevel.Undefined; float maxMass = parms.maxTotalMass ?? float.MaxValue; QualityGenerator qualityGenerator = parms.qualityGenerator ?? QualityGenerator.BaseGen; totalNutrition = floatRange.RandomInRange; int numMeats = enumerable.Count((ThingDef x) => x.IsMeat); int numLeathers = enumerable.Count((ThingDef x) => x.IsLeather); return(ThingSetMakerByTotalStatUtility.GenerateDefsWithPossibleTotalValue_NewTmp3(weightSelector: (ThingDef x) => ThingSetMakerUtility.AdjustedBigCategoriesSelectionWeight(x, numMeats, numLeathers), countRange: countRange, totalValue: totalNutrition, allowed: enumerable, techLevel: techLevel, qualityGenerator: qualityGenerator, getMinValue: (ThingStuffPairWithQuality x) => x.GetStatValue(StatDefOf.Nutrition), getMaxValue: (ThingStuffPairWithQuality x) => x.GetStatValue(StatDefOf.Nutrition) * (float)x.thing.stackLimit, getSingleThingValue: (ThingStuffPairWithQuality x) => x.GetStatValue(StatDefOf.Nutrition), tries: 100, maxMass: maxMass)); }
internal float <> m__0(ThingDef x) { return(ThingSetMakerUtility.AdjustedBigCategoriesSelectionWeight(x, this.numMeats, this.numLeathers)); }