protected override bool CanGenerateSub(ThingSetMakerParams parms) { if (!AllowedThingDefs(parms).Any()) { return(false); } if (parms.countRange.HasValue && parms.countRange.Value.max <= 0) { return(false); } if (!parms.totalNutritionRange.HasValue || parms.totalNutritionRange.Value.max <= 0f) { return(false); } float totalNutrition; if (parms.maxTotalMass.HasValue) { float?maxTotalMass = parms.maxTotalMass; totalNutrition = float.MaxValue; if (!(maxTotalMass == totalNutrition) && !ThingSetMakerUtility.PossibleToWeighNoMoreThan(AllowedThingDefs(parms), parms.techLevel ?? TechLevel.Undefined, parms.maxTotalMass.Value, (!parms.countRange.HasValue) ? 1 : parms.countRange.Value.min)) { return(false); } } if (!GeneratePossibleDefs(parms, out totalNutrition, nextSeed).Any()) { return(false); } return(true); }
protected override void Generate(ThingSetMakerParams parms, List <Thing> outThings) { IEnumerable <ThingDef> enumerable = AllowedThingDefs(parms); if (!enumerable.Any()) { return; } TechLevel stuffTechLevel = parms.techLevel ?? TechLevel.Undefined; IntRange intRange = parms.countRange ?? IntRange.one; float num = parms.maxTotalMass ?? float.MaxValue; int num2 = Mathf.Max(intRange.RandomInRange, 1); float num3 = 0f; for (int i = 0; i < num2; i++) { if (!ThingSetMakerUtility.TryGetRandomThingWhichCanWeighNoMoreThan(enumerable, stuffTechLevel, (num == float.MaxValue) ? float.MaxValue : (num - num3), parms.qualityGenerator, out var thingStuffPair)) { break; } Thing thing = ThingMaker.MakeThing(thingStuffPair.thing, thingStuffPair.stuff); ThingSetMakerUtility.AssignQuality(thing, parms.qualityGenerator); outThings.Add(thing); if (!(thing is Pawn)) { num3 += thing.GetStatValue(StatDefOf.Mass) * (float)thing.stackCount; } } }
protected override bool CanGenerateSub(ThingSetMakerParams parms) { if (!this.AllowedThingDefs(parms).Any <ThingDef>()) { return(false); } IntRange?countRange = parms.countRange; if (countRange != null && parms.countRange.Value.max <= 0) { return(false); } float?maxTotalMass = parms.maxTotalMass; if (maxTotalMass != null && parms.maxTotalMass != 3.40282347E+38f) { IEnumerable <ThingDef> candidates = this.AllowedThingDefs(parms); TechLevel?techLevel = parms.techLevel; TechLevel stuffTechLevel = (techLevel == null) ? TechLevel.Undefined : techLevel.Value; float value = parms.maxTotalMass.Value; IntRange? countRange2 = parms.countRange; if (!ThingSetMakerUtility.PossibleToWeighNoMoreThan(candidates, stuffTechLevel, value, (countRange2 == null) ? 1 : parms.countRange.Value.max)) { return(false); } } return(true); }
protected override bool CanGenerateSub(ThingSetMakerParams parms) { if (!this.AllowedThingDefs(parms).Any <ThingDef>()) { return(false); } IntRange?countRange = parms.countRange; if (countRange.HasValue && parms.countRange.Value.max <= 0) { return(false); } float?maxTotalMass = parms.maxTotalMass; if (maxTotalMass.HasValue && parms.maxTotalMass != 3.40282347E+38f) { IEnumerable <ThingDef> arg_E4_0 = this.AllowedThingDefs(parms); TechLevel?techLevel = parms.techLevel; TechLevel arg_E4_1 = (!techLevel.HasValue) ? TechLevel.Undefined : techLevel.Value; float arg_E4_2 = parms.maxTotalMass.Value; IntRange? countRange2 = parms.countRange; if (!ThingSetMakerUtility.PossibleToWeighNoMoreThan(arg_E4_0, arg_E4_1, arg_E4_2, (!countRange2.HasValue) ? 1 : parms.countRange.Value.max)) { return(false); } } return(true); }
protected override void Generate(ThingSetMakerParams parms, List <Thing> outThings) { IEnumerable <ThingDef> enumerable = AllowedThingDefs(parms); if (!enumerable.Any()) { return; } TechLevel stuffTechLevel = parms.techLevel ?? TechLevel.Undefined; IntRange intRange = parms.countRange ?? IntRange.one; float num = parms.maxTotalMass ?? float.MaxValue; int num2 = Mathf.Max(intRange.RandomInRange, 1); float num3 = 0f; int num4 = num2; ThingStuffPair thingStuffPair; while (num4 > 0 && ThingSetMakerUtility.TryGetRandomThingWhichCanWeighNoMoreThan(enumerable, stuffTechLevel, (num == float.MaxValue) ? float.MaxValue : (num - num3), parms.qualityGenerator, out thingStuffPair)) { Thing thing = ThingMaker.MakeThing(thingStuffPair.thing, thingStuffPair.stuff); ThingSetMakerUtility.AssignQuality(thing, parms.qualityGenerator); int num5 = num4; if (num != float.MaxValue && !(thing is Pawn)) { num5 = Mathf.Min(num5, Mathf.FloorToInt((num - num3) / thing.GetStatValue(StatDefOf.Mass))); } num4 -= (thing.stackCount = Mathf.Clamp(num5, 1, thing.def.stackLimit)); outThings.Add(thing); if (!(thing is Pawn)) { num3 += thing.GetStatValue(StatDefOf.Mass) * (float)thing.stackCount; } } }
protected override void Generate(ThingSetMakerParams parms, List <Thing> outThings) { IEnumerable <ThingDef> enumerable = this.AllowedThingDefs(parms); if (!enumerable.Any <ThingDef>()) { return; } TechLevel?techLevel = parms.techLevel; TechLevel stuffTechLevel = (!techLevel.HasValue) ? TechLevel.Undefined : techLevel.Value; IntRange? countRange = parms.countRange; IntRange intRange = (!countRange.HasValue) ? IntRange.one : countRange.Value; float? maxTotalMass = parms.maxTotalMass; float num = (!maxTotalMass.HasValue) ? 3.40282347E+38f : maxTotalMass.Value; int num2 = Mathf.Max(intRange.RandomInRange, 1); float num3 = 0f; for (int i = 0; i < num2; i++) { ThingStuffPair thingStuffPair; if (!ThingSetMakerUtility.TryGetRandomThingWhichCanWeighNoMoreThan(enumerable, stuffTechLevel, (num != 3.40282347E+38f) ? (num - num3) : 3.40282347E+38f, out thingStuffPair)) { break; } Thing thing = ThingMaker.MakeThing(thingStuffPair.thing, thingStuffPair.stuff); ThingSetMakerUtility.AssignQuality(thing, parms.qualityGenerator); outThings.Add(thing); if (!(thing is Pawn)) { num3 += thing.GetStatValue(StatDefOf.Mass, true) * (float)thing.stackCount; } } }
protected override bool CanGenerateSub(ThingSetMakerParams parms) { if (!AllowedThingDefs(parms).Any()) { return(false); } IntRange?countRange = parms.countRange; if (countRange.HasValue) { IntRange value = parms.countRange.Value; if (value.max <= 0) { return(false); } } FloatRange?totalNutritionRange = parms.totalNutritionRange; if (totalNutritionRange.HasValue) { FloatRange value2 = parms.totalNutritionRange.Value; if (!(value2.max <= 0f)) { float?maxTotalMass = parms.maxTotalMass; if (maxTotalMass.HasValue && parms.maxTotalMass != 3.40282347E+38f) { IEnumerable <ThingDef> candidates = AllowedThingDefs(parms); TechLevel?techLevel = parms.techLevel; TechLevel stuffTechLevel = techLevel.HasValue ? techLevel.Value : TechLevel.Undefined; float value3 = parms.maxTotalMass.Value; IntRange? countRange2 = parms.countRange; int count; if (countRange2.HasValue) { IntRange value4 = parms.countRange.Value; count = value4.min; } else { count = 1; } if (!ThingSetMakerUtility.PossibleToWeighNoMoreThan(candidates, stuffTechLevel, value3, count)) { return(false); } } if (!GeneratePossibleDefs(parms, out float _, nextSeed).Any()) { return(false); } return(true); } } return(false); }
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 void Reset() { ThingSetMakerUtility.allGeneratableItems.Clear(); foreach (ThingDef current in DefDatabase <ThingDef> .AllDefs) { if (ThingSetMakerUtility.CanGenerate(current)) { ThingSetMakerUtility.allGeneratableItems.Add(current); } } ThingSetMaker_Meteorite.Reset(); }
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))); }
protected override bool CanGenerateSub(ThingSetMakerParams parms) { bool result; if (!this.AllowedThingDefs(parms).Any <ThingDef>()) { result = false; } else { IntRange?countRange = parms.countRange; if (countRange != null && parms.countRange.Value.max <= 0) { result = false; } else { FloatRange?totalMarketValueRange = parms.totalMarketValueRange; if (totalMarketValueRange == null || parms.totalMarketValueRange.Value.max <= 0f) { result = false; } else { float?maxTotalMass = parms.maxTotalMass; if (maxTotalMass != null && parms.maxTotalMass != 3.40282347E+38f) { IEnumerable <ThingDef> candidates = this.AllowedThingDefs(parms); TechLevel?techLevel = parms.techLevel; TechLevel stuffTechLevel = (techLevel == null) ? TechLevel.Undefined : techLevel.Value; float value = parms.maxTotalMass.Value; IntRange? countRange2 = parms.countRange; if (!ThingSetMakerUtility.PossibleToWeighNoMoreThan(candidates, stuffTechLevel, value, (countRange2 == null) ? 1 : parms.countRange.Value.min)) { return(false); } } float num; result = this.GeneratePossibleDefs(parms, out num, this.nextSeed).Any <ThingStuffPairWithQuality>(); } } } return(result); }
protected override IEnumerable <ThingDef> AllGeneratableThingsDebugSub(ThingSetMakerParams parms) { TechLevel?techLevel2 = parms.techLevel; TechLevel techLevel = (!techLevel2.HasValue) ? TechLevel.Undefined : techLevel2.Value; foreach (ThingDef t in this.AllowedThingDefs(parms)) { float?maxTotalMass = parms.maxTotalMass; if (maxTotalMass.HasValue && parms.maxTotalMass != 3.40282347E+38f) { float?maxTotalMass2 = parms.maxTotalMass; if (ThingSetMakerUtility.GetMinMass(t, techLevel) > maxTotalMass2) { continue; } } yield return(t); } }
protected override void Generate(ThingSetMakerParams parms, List <Thing> outThings) { IEnumerable <ThingDef> enumerable = this.AllowedThingDefs(parms); if (!enumerable.Any <ThingDef>()) { return; } TechLevel?techLevel = parms.techLevel; TechLevel stuffTechLevel = (techLevel == null) ? TechLevel.Undefined : techLevel.Value; IntRange? countRange = parms.countRange; IntRange intRange = (countRange == null) ? IntRange.one : countRange.Value; float? maxTotalMass = parms.maxTotalMass; float num = (maxTotalMass == null) ? float.MaxValue : maxTotalMass.Value; int num2 = Mathf.Max(intRange.RandomInRange, 1); float num3 = 0f; int i = num2; while (i > 0) { ThingStuffPair thingStuffPair; if (!ThingSetMakerUtility.TryGetRandomThingWhichCanWeighNoMoreThan(enumerable, stuffTechLevel, (num != 3.40282347E+38f) ? (num - num3) : 3.40282347E+38f, out thingStuffPair)) { break; } Thing thing = ThingMaker.MakeThing(thingStuffPair.thing, thingStuffPair.stuff); ThingSetMakerUtility.AssignQuality(thing, parms.qualityGenerator); int num4 = i; if (num != 3.40282347E+38f && !(thing is Pawn)) { num4 = Mathf.Min(num4, Mathf.FloorToInt((num - num3) / thing.GetStatValue(StatDefOf.Mass, true))); } num4 = Mathf.Clamp(num4, 1, thing.def.stackLimit); thing.stackCount = num4; i -= num4; outThings.Add(thing); if (!(thing is Pawn)) { num3 += thing.GetStatValue(StatDefOf.Mass, true) * (float)thing.stackCount; } } }
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; }
protected override IEnumerable <ThingDef> AllGeneratableThingsDebugSub(ThingSetMakerParams parms) { TechLevel?techLevel2 = parms.techLevel; TechLevel techLevel = techLevel2.HasValue ? techLevel2.Value : TechLevel.Undefined; foreach (ThingDef item in AllowedThingDefs(parms)) { float?maxTotalMass = parms.maxTotalMass; if (maxTotalMass.HasValue && parms.maxTotalMass != 3.40282347E+38f) { float?maxTotalMass2 = parms.maxTotalMass; if (maxTotalMass2.HasValue && ThingSetMakerUtility.GetMinMass(item, techLevel) > maxTotalMass2.GetValueOrDefault()) { continue; } } FloatRange?totalNutritionRange = parms.totalNutritionRange; if (totalNutritionRange.HasValue) { FloatRange value = parms.totalNutritionRange.Value; if (value.max != 3.40282347E+38f && item.IsNutritionGivingIngestible) { float cachedNutrition = item.ingestible.CachedNutrition; FloatRange value2 = parms.totalNutritionRange.Value; if (cachedNutrition > value2.max) { continue; } } } yield return(item); /*Error: Unable to find new state assignment for yield return*/; } yield break; IL_01ee: /*Error near IL_01ef: Unexpected return in MoveNext()*/; }
protected override IEnumerable<ThingDef> AllGeneratableThingsDebugSub(ThingSetMakerParams parms) { TechLevel? techLevel2 = parms.techLevel; TechLevel techLevel = (techLevel2 == null) ? TechLevel.Undefined : techLevel2.Value; foreach (ThingDef t in this.AllowedThingDefs(parms)) { float? maxTotalMass = parms.maxTotalMass; if (maxTotalMass != null && parms.maxTotalMass != 3.40282347E+38f) { float? maxTotalMass2 = parms.maxTotalMass; if (ThingSetMakerUtility.GetMinMass(t, techLevel) > maxTotalMass2) { continue; } } FloatRange? totalNutritionRange = parms.totalNutritionRange; if (totalNutritionRange == null || parms.totalNutritionRange.Value.max == 3.40282347E+38f || !t.IsNutritionGivingIngestible || t.ingestible.CachedNutrition <= parms.totalNutritionRange.Value.max) { yield return t; } } yield break; }
protected override IEnumerable <ThingDef> AllGeneratableThingsDebugSub(ThingSetMakerParams parms) { TechLevel?techLevel2 = parms.techLevel; TechLevel techLevel = techLevel2.HasValue ? techLevel2.Value : TechLevel.Undefined; foreach (ThingDef item in AllowedThingDefs(parms)) { float?maxTotalMass = parms.maxTotalMass; if (maxTotalMass.HasValue && parms.maxTotalMass != 3.40282347E+38f) { float?maxTotalMass2 = parms.maxTotalMass; if (maxTotalMass2.HasValue && ThingSetMakerUtility.GetMinMass(item, techLevel) > maxTotalMass2.GetValueOrDefault()) { continue; } } yield return(item); /*Error: Unable to find new state assignment for yield return*/; } yield break; IL_016f: /*Error near IL_0170: Unexpected return in MoveNext()*/; }
protected override bool CanGenerateSub(ThingSetMakerParams parms) { if (!this.AllowedThingDefs(parms).Any <ThingDef>()) { return(false); } IntRange?countRange = parms.countRange; if (countRange.HasValue && parms.countRange.Value.max <= 0) { return(false); } FloatRange?totalMarketValueRange = parms.totalMarketValueRange; if (!totalMarketValueRange.HasValue || parms.totalMarketValueRange.Value.max <= 0f) { return(false); } float?maxTotalMass = parms.maxTotalMass; if (maxTotalMass.HasValue && parms.maxTotalMass != 3.40282347E+38f) { IEnumerable <ThingDef> arg_11D_0 = this.AllowedThingDefs(parms); TechLevel?techLevel = parms.techLevel; TechLevel arg_11D_1 = (!techLevel.HasValue) ? TechLevel.Undefined : techLevel.Value; float arg_11D_2 = parms.maxTotalMass.Value; IntRange? countRange2 = parms.countRange; if (!ThingSetMakerUtility.PossibleToWeighNoMoreThan(arg_11D_0, arg_11D_1, arg_11D_2, (!countRange2.HasValue) ? 1 : parms.countRange.Value.min)) { return(false); } } float num; return(this.GeneratePossibleDefs(parms, out num, this.nextSeed).Any <ThingStuffPairWithQuality>()); }
private static void CalculateAllowedThingStuffPairs(IEnumerable <ThingDef> allowed, TechLevel techLevel, QualityGenerator qualityGenerator) { allowedThingStuffPairs.Clear(); foreach (ThingDef td in allowed) { for (int i = 0; i < 5; i++) { if (GenStuff.TryRandomStuffFor(td, out ThingDef stuff, techLevel, (ThingDef x) => !ThingSetMakerUtility.IsDerpAndDisallowed(td, x, qualityGenerator))) { QualityCategory quality = td.HasComp(typeof(CompQuality)) ? QualityUtility.GenerateQuality(qualityGenerator) : QualityCategory.Normal; allowedThingStuffPairs.Add(new ThingStuffPairWithQuality(td, stuff, quality)); } } } }
protected virtual IEnumerable <ThingDef> AllowedThingDefs(ThingSetMakerParams parms) { return(ThingSetMakerUtility.GetAllowedThingDefs(parms)); }
public bool MoveNext() { uint num = (uint)this.$PC; this.$PC = -1; bool flag = false; switch (num) { case 0u: { TechLevel?techLevel2 = parms.techLevel; techLevel = ((techLevel2 == null) ? TechLevel.Undefined : techLevel2.Value); enumerator = this.AllowedThingDefs(parms).GetEnumerator(); num = 4294967293u; break; } case 1u: break; default: return(false); } try { switch (num) { } while (enumerator.MoveNext()) { t = enumerator.Current; float?maxTotalMass = parms.maxTotalMass; if (maxTotalMass != null && parms.maxTotalMass != 3.40282347E+38f) { float?maxTotalMass2 = parms.maxTotalMass; if (ThingSetMakerUtility.GetMinMass(t, techLevel) > maxTotalMass2) { continue; } } FloatRange?totalMarketValueRange = parms.totalMarketValueRange; if (totalMarketValueRange == null || parms.totalMarketValueRange.Value.max == 3.40282347E+38f || ThingSetMakerUtility.GetMinMarketValue(t, techLevel) <= parms.totalMarketValueRange.Value.max) { this.$current = t; if (!this.$disposing) { this.$PC = 1; } flag = true; return(true); } } } finally { if (!flag) { if (enumerator != null) { enumerator.Dispose(); } } } this.$PC = -1; return(false); }
protected override IEnumerable <ThingDef> AllGeneratableThingsDebugSub(ThingSetMakerParams parms) { TechLevel techLevel = parms.techLevel ?? TechLevel.Undefined; foreach (ThingDef item in AllowedThingDefs(parms)) { if ((!parms.maxTotalMass.HasValue || parms.maxTotalMass == float.MaxValue || !(ThingSetMakerUtility.GetMinMass(item, techLevel) > parms.maxTotalMass)) && (!parms.totalNutritionRange.HasValue || parms.totalNutritionRange.Value.max == float.MaxValue || !item.IsNutritionGivingIngestible || !(item.ingestible.CachedNutrition > parms.totalNutritionRange.Value.max))) { yield return(item); } } }
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)); }
protected override bool CanGenerateSub(ThingSetMakerParams parms) { if (!AllowedThingDefs(parms).Any()) { return(false); } if (parms.countRange.HasValue && parms.countRange.Value.max <= 0) { return(false); } if (parms.maxTotalMass.HasValue && parms.maxTotalMass != float.MaxValue && !ThingSetMakerUtility.PossibleToWeighNoMoreThan(AllowedThingDefs(parms), parms.techLevel ?? TechLevel.Undefined, parms.maxTotalMass.Value, (!parms.countRange.HasValue) ? 1 : parms.countRange.Value.max)) { return(false); } return(true); }
protected override IEnumerable <ThingDef> AllGeneratableThingsDebugSub(ThingSetMakerParams parms) { TechLevel techLevel = parms.techLevel ?? TechLevel.Undefined; foreach (ThingDef item in AllowedThingDefs(parms)) { if (!parms.maxTotalMass.HasValue || parms.maxTotalMass == float.MaxValue || !(ThingSetMakerUtility.GetMinMass(item, techLevel) > parms.maxTotalMass)) { yield return(item); } } }