protected override void Generate(ThingSetMakerParams parms, List <Thing> outThings)
 {
     if (options.Where((Option x) => x.thingSetMaker.CanGenerate(parms)).TryRandomElementByWeight((Option x) => GetSelectionWeight(x, parms), out var result))
     {
         outThings.AddRange(result.thingSetMaker.Generate(parms));
     }
 }
        public string GenerationDataFor(TraderKindDef td)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine(td.defName);
            stringBuilder.AppendLine("Average total market value:" + this.AverageTotalStockValue(td).ToString("F0"));
            ThingSetMakerParams parms = default(ThingSetMakerParams);

            parms.traderDef = td;
            parms.tile      = new int?(-1);
            stringBuilder.AppendLine("Example generated stock:\n\n");
            foreach (Thing thing in base.Generate(parms))
            {
                MinifiedThing minifiedThing = thing as MinifiedThing;
                Thing         thing2;
                if (minifiedThing != null)
                {
                    thing2 = minifiedThing.InnerThing;
                }
                else
                {
                    thing2 = thing;
                }
                string text = thing2.LabelCap;
                text = text + " [" + (thing2.MarketValue * (float)thing2.stackCount).ToString("F0") + "]";
                stringBuilder.AppendLine(text);
            }
            return(stringBuilder.ToString());
        }
        private List <ThingStuffPairWithQuality> GeneratePossibleDefs(ThingSetMakerParams parms, out float totalMarketValue)
        {
            IEnumerable <ThingDef> enumerable = this.AllowedThingDefs(parms);

            if (!enumerable.Any <ThingDef>())
            {
                totalMarketValue = 0f;
                return(new List <ThingStuffPairWithQuality>());
            }
            TechLevel?       techLevel             = parms.techLevel;
            TechLevel        techLevel2            = (techLevel == null) ? TechLevel.Undefined : techLevel.Value;
            IntRange?        countRange            = parms.countRange;
            IntRange         intRange              = (countRange == null) ? new IntRange(1, int.MaxValue) : countRange.Value;
            FloatRange?      totalMarketValueRange = parms.totalMarketValueRange;
            FloatRange       floatRange            = (totalMarketValueRange == null) ? FloatRange.Zero : totalMarketValueRange.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;

            totalMarketValue = floatRange.RandomInRange;
            IntRange countRange2               = intRange;
            float    totalValue                = totalMarketValue;
            IEnumerable <ThingDef> allowed     = enumerable;
            TechLevel        techLevel3        = techLevel2;
            QualityGenerator qualityGenerator3 = qualityGenerator2;
            Func <ThingStuffPairWithQuality, float> getMinValue = new Func <ThingStuffPairWithQuality, float>(this.GetMinValue);
            Func <ThingStuffPairWithQuality, float> getMaxValue = new Func <ThingStuffPairWithQuality, float>(this.GetMaxValue);
            float maxMass = num;

            return(ThingSetMakerByTotalStatUtility.GenerateDefsWithPossibleTotalValue(countRange2, totalValue, allowed, techLevel3, qualityGenerator3, getMinValue, getMaxValue, null, 100, maxMass));
        }
Esempio n. 4
0
        protected virtual List <Thing> GenerateItems(Faction siteFaction, float siteThreatPoints)
        {
            ThingSetMakerParams parms = default(ThingSetMakerParams);

            parms.totalMarketValueRange = SiteTuning.ItemStashQuestMarketValueRange * SiteTuning.QuestRewardMarketValueThreatPointsFactor.Evaluate(siteThreatPoints);
            return(ThingSetMakerDefOf.Reward_ItemStashQuestContents.root.Generate(parms));
        }
        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 = 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;
                }
            }
        }
Esempio n. 7
0
        private List <ThingStuffPairWithQuality> GeneratePossibleDefs(ThingSetMakerParams parms, out float totalMarketValue)
        {
            IEnumerable <ThingDef> enumerable = AllowedThingDefs(parms);

            if (!enumerable.Any())
            {
                totalMarketValue = 0f;
                return(new List <ThingStuffPairWithQuality>());
            }
            TechLevel?       techLevel             = parms.techLevel;
            TechLevel        techLevel2            = techLevel.HasValue ? techLevel.Value : TechLevel.Undefined;
            IntRange?        countRange            = parms.countRange;
            IntRange         intRange              = (!countRange.HasValue) ? new IntRange(1, 2147483647) : countRange.Value;
            FloatRange?      totalMarketValueRange = parms.totalMarketValueRange;
            FloatRange       floatRange            = (!totalMarketValueRange.HasValue) ? FloatRange.Zero : totalMarketValueRange.Value;
            float?           maxTotalMass          = parms.maxTotalMass;
            float            num = (!maxTotalMass.HasValue) ? 3.40282347E+38f : maxTotalMass.Value;
            QualityGenerator?qualityGenerator  = parms.qualityGenerator;
            QualityGenerator qualityGenerator2 = qualityGenerator.HasValue ? qualityGenerator.Value : QualityGenerator.BaseGen;

            totalMarketValue = floatRange.RandomInRange;
            IntRange countRange2               = intRange;
            float    totalValue                = totalMarketValue;
            IEnumerable <ThingDef> allowed     = enumerable;
            TechLevel        techLevel3        = techLevel2;
            QualityGenerator qualityGenerator3 = qualityGenerator2;
            Func <ThingStuffPairWithQuality, float> getMinValue = GetMinValue;
            Func <ThingStuffPairWithQuality, float> getMaxValue = GetMaxValue;
            float maxMass = num;

            return(ThingSetMakerByTotalStatUtility.GenerateDefsWithPossibleTotalValue(countRange2, totalValue, allowed, techLevel3, qualityGenerator3, getMinValue, getMaxValue, null, 100, maxMass));
        }
Esempio n. 8
0
        public List <Thing> Generate(ThingSetMakerParams parms)
        {
            List <Thing> list = new List <Thing>();

            thingsBeingGeneratedNow.Add(list);
            try
            {
                ThingSetMakerParams parms2 = ApplyFixedParams(parms);
                Generate(parms2, list);
                PostProcess(list);
                return(list);
            }
            catch (Exception arg)
            {
                Log.Error("Exception while generating thing set: " + arg);
                for (int num = list.Count - 1; num >= 0; num--)
                {
                    list[num].Destroy();
                    list.RemoveAt(num);
                }
                return(list);
            }
            finally
            {
                thingsBeingGeneratedNow.Remove(list);
            }
        }
Esempio n. 9
0
        protected override IEnumerable <ThingDef> AllGeneratableThingsDebugSub(ThingSetMakerParams parms)
        {
            if (parms.traderDef != null)
            {
                for (int i = 0; i < parms.traderDef.stockGenerators.Count; i++)
                {
                    _003CAllGeneratableThingsDebugSub_003Ec__Iterator0 _003CAllGeneratableThingsDebugSub_003Ec__Iterator = (_003CAllGeneratableThingsDebugSub_003Ec__Iterator0) /*Error near IL_0055: stateMachine*/;
                    StockGenerator stock = parms.traderDef.stockGenerators[i];
                    using (IEnumerator <ThingDef> enumerator = (from x in DefDatabase <ThingDef> .AllDefs
                                                                where x.tradeability.TraderCanSell() && stock.HandlesThingDef(x)
                                                                select x).GetEnumerator())
                    {
                        if (enumerator.MoveNext())
                        {
                            ThingDef t = enumerator.Current;
                            yield return(t);

                            /*Error: Unable to find new state assignment for yield return*/;
                        }
                    }
                }
            }
            yield break;
IL_0155:
            /*Error near IL_0156: Unexpected return in MoveNext()*/;
        }
Esempio n. 10
0
        protected override void Generate(ThingSetMakerParams parms, List <Thing> outThings)
        {
            TraderKindDef traderKindDef = parms.traderDef ?? DefDatabase <TraderKindDef> .AllDefsListForReading.RandomElement();

            Faction traderFaction = parms.traderFaction;
            int?    tile          = parms.tile;
            int     forTile       = tile.HasValue ? parms.tile.Value : ((Find.AnyPlayerHomeMap != null) ? Find.AnyPlayerHomeMap.Tile : ((Find.CurrentMap == null) ? (-1) : Find.CurrentMap.Tile));

            for (int i = 0; i < traderKindDef.stockGenerators.Count; i++)
            {
                StockGenerator stockGenerator = traderKindDef.stockGenerators[i];
                foreach (Thing item in stockGenerator.GenerateThings(forTile))
                {
                    if (!item.def.tradeability.TraderCanSell())
                    {
                        Log.Error(traderKindDef + " generated carrying " + item + " which can't be sold by traders. Ignoring...");
                    }
                    else
                    {
                        item.PostGeneratedForTrader(traderKindDef, forTile, traderFaction);
                        outThings.Add(item);
                    }
                }
            }
        }
Esempio n. 11
0
        public List <Thing> Generate(ThingSetMakerParams parms)
        {
            List <Thing> list = new List <Thing>();

            ThingSetMaker.thingsBeingGeneratedNow.Add(list);
            try
            {
                ThingSetMakerParams parms2 = this.ApplyFixedParams(parms);
                this.Generate(parms2, list);
                this.PostProcess(list);
            }
            catch (Exception arg)
            {
                Log.Error("Exception while generating thing set: " + arg, false);
                for (int i = list.Count - 1; i >= 0; i--)
                {
                    list[i].Destroy(DestroyMode.Vanish);
                    list.RemoveAt(i);
                }
            }
            finally
            {
                ThingSetMaker.thingsBeingGeneratedNow.Remove(list);
            }
            return(list);
        }
Esempio n. 12
0
        private ThingSetMakerParams ApplyFixedParams(ThingSetMakerParams parms)
        {
            ThingSetMakerParams result = this.fixedParams;

            Gen.ReplaceNullFields <ThingSetMakerParams>(ref result, parms);
            return(result);
        }
Esempio n. 13
0
        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 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;
                }
            }
        }
        public override void InitFromValue(float rewardValue, RewardsGeneratorParams parms, out float valueActuallyUsed)
        {
            items.Clear();
            bool  flag = true;
            float x2   = (Find.TickManager.TicksGame - Find.History.lastPsylinkAvailable).TicksToDays();

            if (Rand.Chance(QuestTuning.DaysSincePsylinkAvailableToGuaranteedNeuroformerChance.Evaluate(x2)) && ModsConfig.RoyaltyActive && (parms.disallowedThingDefs == null || !parms.disallowedThingDefs.Contains(ThingDefOf.PsychicAmplifier)) && rewardValue >= 600f && parms.giverFaction != Faction.Empire)
            {
                items.Add(ThingMaker.MakeThing(ThingDefOf.PsychicAmplifier));
                rewardValue -= items[0].MarketValue;
                if (rewardValue < 100f)
                {
                    flag = false;
                }
            }
            if (flag)
            {
                FloatRange          value  = rewardValue * new FloatRange(0.7f, 1.3f);
                ThingSetMakerParams parms2 = default(ThingSetMakerParams);
                parms2.totalMarketValueRange = value;
                parms2.makingFaction         = parms.giverFaction;
                if (!parms.disallowedThingDefs.NullOrEmpty())
                {
                    parms2.validator = (ThingDef x) => !parms.disallowedThingDefs.Contains(x);
                }
                items.AddRange(ThingSetMakerDefOf.Reward_ItemsStandard.root.Generate(parms2));
            }
            valueActuallyUsed = TotalMarketValue;
        }
Esempio n. 16
0
        private ThingSetMakerParams ApplyFixedParams(ThingSetMakerParams parms)
        {
            ThingSetMakerParams replaceIn = fixedParams;

            Gen.ReplaceNullFields(ref replaceIn, parms);
            return(replaceIn);
        }
Esempio n. 17
0
        protected override void Generate(ThingSetMakerParams parms, List <Thing> outThings)
        {
            PodContentsType podContentsType = parms.podContentsType ?? Gen.RandomEnumValue <PodContentsType>(disallowFirstValue: true);

            switch (podContentsType)
            {
            case PodContentsType.AncientFriendly:
                outThings.Add(GenerateFriendlyAncient());
                break;

            case PodContentsType.AncientIncapped:
                outThings.Add(GenerateIncappedAncient());
                break;

            case PodContentsType.AncientHostile:
                outThings.Add(GenerateAngryAncient());
                break;

            case PodContentsType.Slave:
                outThings.Add(GenerateSlave());
                break;

            case PodContentsType.AncientHalfEaten:
                outThings.Add(GenerateHalfEatenAncient());
                outThings.AddRange(GenerateScarabs());
                break;

            default:
                Log.Error("Pod contents type not handled: " + podContentsType);
                break;

            case PodContentsType.Empty:
                break;
            }
        }
		private List<ThingStuffPairWithQuality> GeneratePossibleDefs(ThingSetMakerParams parms, out float totalNutrition, int seed)
		{
			Rand.PushState(seed);
			List<ThingStuffPairWithQuality> result = this.GeneratePossibleDefs(parms, out totalNutrition);
			Rand.PopState();
			return result;
		}
Esempio n. 19
0
        private List <Thing> GenerateRewards(Faction alliedFaction, float siteThreatPoints)
        {
            ThingSetMakerParams parms = default(ThingSetMakerParams);

            parms.totalMarketValueRange = new FloatRange?(SiteTuning.BanditCampQuestRewardMarketValueRange * SiteTuning.QuestRewardMarketValueThreatPointsFactor.Evaluate(siteThreatPoints));
            return(ThingSetMakerDefOf.Reward_StandardByDropPod.root.Generate(parms));
        }
        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);
        }
Esempio n. 21
0
        public override float ExtraSelectionWeightFactor(ThingSetMakerParams parms)
        {
            int  num  = 0;
            bool flag = false;

            foreach (ResearchProjectDef allDef in DefDatabase <ResearchProjectDef> .AllDefs)
            {
                if (!allDef.IsFinished && allDef.PrerequisitesCompleted)
                {
                    if (!allDef.TechprintRequirementMet && !PlayerItemAccessibilityUtility.PlayerOrQuestRewardHas(allDef.Techprint, allDef.techprintCount - allDef.TechprintsApplied))
                    {
                        flag = true;
                    }
                    else
                    {
                        num++;
                    }
                }
            }
            if (!flag)
            {
                return(1f);
            }
            return(Mathf.RoundToInt(ResearchableProjectsCountToSelectionWeightCurve.Evaluate(num)));
        }
        public static List <Thing> GenerateGifts(Faction faction, Map map)
        {
            ThingSetMakerParams parms = default(ThingSetMakerParams);

            parms.totalMarketValueRange = DiplomacyTuning.VisitorGiftTotalMarketValueRangeBase * DiplomacyTuning.VisitorGiftTotalMarketValueFactorFromPlayerWealthCurve.Evaluate(map.wealthWatcher.WealthTotal);
            return(ThingSetMakerDefOf.VisitorGift.root.Generate(parms));
        }
Esempio n. 23
0
        protected override void Generate(ThingSetMakerParams parms, List <Thing> outThings)
        {
            tmpGenerated.Clear();
            ThingDef result3;

            if (parms.countRange.HasValue)
            {
                int num = Mathf.Max(parms.countRange.Value.RandomInRange, 1);
                for (int i = 0; i < num; i++)
                {
                    if (!TechprintUtility.TryGetTechprintDefToGenerate(parms.makingFaction, out ThingDef result, tmpGenerated))
                    {
                        break;
                    }
                    tmpGenerated.Add(result);
                    outThings.Add(ThingMaker.MakeThing(result));
                }
            }
            else if (parms.totalMarketValueRange.HasValue)
            {
                float    num2 = parms.totalMarketValueRange.Value.RandomInRange * marketValueFactor;
                ThingDef result2;
                for (float num3 = 0f; TechprintUtility.TryGetTechprintDefToGenerate(parms.makingFaction, out result2, tmpGenerated, num2 - num3) || (!tmpGenerated.Any() && TechprintUtility.TryGetTechprintDefToGenerate(parms.makingFaction, out result2, tmpGenerated)); num3 += result2.BaseMarketValue)
                {
                    tmpGenerated.Add(result2);
                    outThings.Add(ThingMaker.MakeThing(result2));
                }
            }
            else if (TechprintUtility.TryGetTechprintDefToGenerate(parms.makingFaction, out result3, tmpGenerated))
            {
                tmpGenerated.Add(result3);
                outThings.Add(ThingMaker.MakeThing(result3));
            }
            tmpGenerated.Clear();
        }
Esempio n. 24
0
        private static List <Thing> GenerateRewardsFor(ThingDef thingDef, int quantity, Faction faction, Map map)
        {
            ThingSetMakerParams parms = default(ThingSetMakerParams);

            parms.totalMarketValueRange = RewardValueFactorRange * RewardValueFactorFromWealthCurve.Evaluate(map.wealthWatcher.WealthTotal) * thingDef.BaseMarketValue * (float)quantity;
            parms.validator             = ((ThingDef td) => td != thingDef);
            List <Thing> list = null;

            for (int i = 0; i < 10; i++)
            {
                if (list != null)
                {
                    for (int j = 0; j < list.Count; j++)
                    {
                        list[j].Destroy();
                    }
                    list = null;
                }
                list = ThingSetMakerDefOf.Reward_TradeRequest.root.Generate(parms);
                float num = 0f;
                for (int k = 0; k < list.Count; k++)
                {
                    num += list[k].MarketValue * (float)list[k].stackCount;
                }
                if (num > thingDef.BaseMarketValue * (float)quantity)
                {
                    break;
                }
            }
            return(list);
        }
Esempio n. 25
0
        protected override void Generate(ThingSetMakerParams parms, List <Thing> outThings)
        {
            ThingDef thingDef = RandomPodContentsDef();
            float    num      = Rand.Range(150f, 600f);

            do
            {
                Thing thing = ThingMaker.MakeThing(thingDef);
                int   num2  = Rand.Range(20, 40);
                if (num2 > thing.def.stackLimit)
                {
                    num2 = thing.def.stackLimit;
                }
                if ((float)num2 * thing.def.BaseMarketValue > num)
                {
                    num2 = Mathf.FloorToInt(num / thing.def.BaseMarketValue);
                }
                if (num2 == 0)
                {
                    num2 = 1;
                }
                thing.stackCount = num2;
                outThings.Add(thing);
                num -= (float)num2 * thingDef.BaseMarketValue;
            }while (outThings.Count < 7 && !(num <= thingDef.BaseMarketValue));
        }
Esempio n. 26
0
        protected override void Generate(ThingSetMakerParams parms, List <Thing> outThings)
        {
            Pawn pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(PawnKindDefOf.SpaceRefugee, DownedRefugeeQuestUtility.GetRandomFactionForRefugee(), PawnGenerationContext.NonPlayer, -1, forceGenerateNewPawn: false, newborn: false, allowDead: false, allowDowned: false, canGeneratePawnRelations: true, mustBeCapableOfViolence: false, 20f));

            outThings.Add(pawn);
            HealthUtility.DamageUntilDowned(pawn);
        }
        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;
                }
            }
        }
Esempio n. 28
0
        protected override IEnumerable <ThingDef> AllGeneratableThingsDebugSub(ThingSetMakerParams parms)
        {
            for (int i = 0; i < options.Count; i++)
            {
                float weight = options[i].weight;
                float?weightIfPlayerHasNoItem = options[i].weightIfPlayerHasNoItem;
                if (weightIfPlayerHasNoItem.HasValue)
                {
                    weight = Mathf.Max(weight, options[i].weightIfPlayerHasNoItem.Value);
                }
                if (!(weight <= 0f))
                {
                    using (IEnumerator <ThingDef> enumerator = options[i].thingSetMaker.AllGeneratableThingsDebug(parms).GetEnumerator())
                    {
                        if (enumerator.MoveNext())
                        {
                            ThingDef t = enumerator.Current;
                            yield return(t);

                            /*Error: Unable to find new state assignment for yield return*/;
                        }
                    }
                }
            }
            yield break;
IL_0198:
            /*Error near IL_0199: Unexpected return in MoveNext()*/;
        }
        protected override void Generate(ThingSetMakerParams parms, List <Thing> outThings)
        {
            PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDefOf.SpaceRefugee, DownedRefugeeQuestUtility.GetRandomFactionForRefugee(), PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, false, 20f, false, true, true, false, false, false, false, null, null, null, null, null, null, null, null);
            Pawn pawn = PawnGenerator.GeneratePawn(request);

            outThings.Add(pawn);
            HealthUtility.DamageUntilDowned(pawn);
        }
 private float GetSelectionWeight(Option option, ThingSetMakerParams parms)
 {
     if (option.weightIfPlayerHasNoItem.HasValue && !PlayerItemAccessibilityUtility.PlayerOrQuestRewardHas(option.weightIfPlayerHasNoItemItem))
     {
         return(option.weightIfPlayerHasNoItem.Value * option.thingSetMaker.ExtraSelectionWeightFactor(parms));
     }
     return(option.weight * option.thingSetMaker.ExtraSelectionWeightFactor(parms));
 }