Exemplo n.º 1
0
        private List <Thing> GenerateItems(Faction siteFaction)
        {
            ItemCollectionGeneratorParams parms = default(ItemCollectionGeneratorParams);

            parms.techLevel = new TechLevel?((siteFaction == null) ? TechLevel.Spacer : siteFaction.def.techLevel);
            return(ItemCollectionGeneratorDefOf.ItemStashQuest.Worker.Generate(parms));
        }
        private List <Thing> GenerateRewards(Faction alliedFaction)
        {
            ItemCollectionGeneratorParams parms = default(ItemCollectionGeneratorParams);

            parms.techLevel = new TechLevel?(alliedFaction.def.techLevel);
            return(ItemCollectionGeneratorDefOf.BanditCampQuestRewards.Worker.Generate(parms));
        }
        protected override void Generate(ItemCollectionGeneratorParams parms, List <Thing> outThings)
        {
            TraderKindDef traderKindDef = parms.traderDef ?? DefDatabase <TraderKindDef> .AllDefsListForReading.RandomElement();

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

            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 != Tradeability.Stockable)
                    {
                        Log.Error(traderKindDef + " generated carrying " + item + " which has is not Stockable. Ignoring...");
                    }
                    else
                    {
                        item.PostGeneratedForTrader(traderKindDef, forTile, traderFaction);
                        outThings.Add(item);
                    }
                }
            }
        }
        protected override void Generate(ItemCollectionGeneratorParams parms, List <Thing> outThings)
        {
            ThingDef thingDef = ItemCollectionGenerator_ResourcePod.RandomPodContentsDef();
            float    num      = Rand.Range(150f, 600f);

            while (true)
            {
                Thing thing = ThingMaker.MakeThing(thingDef, null);
                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;
                if (outThings.Count >= 7)
                {
                    break;
                }
                if (num <= thingDef.BaseMarketValue)
                {
                    break;
                }
            }
        }
        protected override void Generate(ItemCollectionGeneratorParams parms, List <Thing> outThings)
        {
            int?count = parms.count;

            parms.count = ((!count.HasValue) ? 1 : count.Value);
            float? totalMarketValue = parms.totalMarketValue;
            double value;

            if (totalMarketValue.HasValue)
            {
                value = totalMarketValue.Value;
            }
            else
            {
                IntRange   baseValueWantedRange = IncidentWorker_CaravanRequest.BaseValueWantedRange;
                float      num = (float)baseValueWantedRange.min;
                FloatRange rewardMarketValueFactorRange = IncidentWorker_CaravanRequest.RewardMarketValueFactorRange;
                float      min = num * rewardMarketValueFactorRange.min;
                IntRange   baseValueWantedRange2 = IncidentWorker_CaravanRequest.BaseValueWantedRange;
                float      num2 = (float)baseValueWantedRange2.max;
                FloatRange rewardMarketValueFactorRange2 = IncidentWorker_CaravanRequest.RewardMarketValueFactorRange;
                FloatRange floatRange = new FloatRange(min, num2 * rewardMarketValueFactorRange2.max);
                value = floatRange.RandomInRange;
            }
            parms.totalMarketValue = (float)value;
            base.Generate(parms, outThings);
        }
Exemplo n.º 6
0
        public string GenerationDataFor(TraderKindDef td)
        {
            StringBuilder stringBuilder = new StringBuilder();

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

            parms.traderDef = td;
            parms.tile      = new int?(-1);
            stringBuilder.AppendLine("Example generated stock:\n\n");
            foreach (Thing current in base.Generate(parms))
            {
                MinifiedThing minifiedThing = current as MinifiedThing;
                Thing         thing;
                if (minifiedThing != null)
                {
                    thing = minifiedThing.InnerThing;
                }
                else
                {
                    thing = current;
                }
                string text = thing.LabelCap;
                text = text + " [" + (thing.MarketValue * (float)thing.stackCount).ToString("F0") + "]";
                stringBuilder.AppendLine(text);
            }
            return(stringBuilder.ToString());
        }
        public List <Thing> Generate(ItemCollectionGeneratorParams parms)
        {
            List <Thing> list = new List <Thing>();

            ItemCollectionGenerator.thingsBeingGeneratedNow.Add(list);
            try
            {
                this.Generate(parms, list);
                this.PostProcess(list);
            }
            catch (Exception arg)
            {
                Log.Error("Exception while generating item collection: " + arg);
                for (int i = 0; i < list.Count; i++)
                {
                    list[i].Destroy(DestroyMode.Vanish);
                }
                list.Clear();
            }
            finally
            {
                ItemCollectionGenerator.thingsBeingGeneratedNow.Remove(list);
            }
            return(list);
        }
        protected override void Generate(ItemCollectionGeneratorParams parms, List <Thing> outThings)
        {
            PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDefOf.SpaceRefugee, Faction.OfSpacer, PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, false, 20f, false, true, true, false, false, false, false, null, null, null, null, null, null, null);
            Pawn pawn = PawnGenerator.GeneratePawn(request);

            outThings.Add(pawn);
            HealthUtility.DamageUntilDowned(pawn);
        }
Exemplo n.º 9
0
        public void GenerateThings()
        {
            ItemCollectionGeneratorParams parms = default(ItemCollectionGeneratorParams);

            parms.traderDef = this.def;
            parms.tile      = new int?(base.Map.Tile);
            this.things.TryAddRangeOrTransfer(ItemCollectionGeneratorDefOf.TraderStock.Worker.Generate(parms), true, false);
        }
        protected override void Generate(ItemCollectionGeneratorParams parms, List <Thing> outThings)
        {
            ItemCollectionGeneratorParams parms2 = parms;
            int?count = parms.count;

            parms2.count            = ((!count.HasValue) ? ItemCollectionGenerator_Meteorite.MineablesCountRange.RandomInRange : count.Value);
            parms2.extraAllowedDefs = Gen.YieldSingle(this.FindRandomMineableDef());
            outThings.AddRange(ItemCollectionGeneratorDefOf.Standard.Worker.Generate(parms2));
        }
        protected override IEnumerable <ThingDef> AllowedDefs(ItemCollectionGeneratorParams parms)
        {
            TechLevel?techLevel2 = parms.techLevel;
            TechLevel techLevel  = (!techLevel2.HasValue) ? TechLevel.Spacer : techLevel2.Value;

            return(from x in ItemCollectionGenerator_Apparel.apparel
                   where (int)x.techLevel <= (int)techLevel
                   select x);
        }
Exemplo n.º 12
0
        protected override void Generate(ItemCollectionGeneratorParams parms, List <Thing> outThings)
        {
            int?      count                     = parms.count;
            int       count2                    = (!count.HasValue) ? Rand.RangeInclusive(3, 6) : count.Value;
            float?    totalNutrition            = parms.totalNutrition;
            float     totalValue                = (!totalNutrition.HasValue) ? Rand.Range(5f, 10f) : totalNutrition.Value;
            TechLevel?techLevel                 = parms.techLevel;
            TechLevel techLevel2                = (!techLevel.HasValue) ? TechLevel.Spacer : techLevel.Value;
            bool?     nonHumanEdibleFoodAllowed = parms.nonHumanEdibleFoodAllowed;
            bool      flag = nonHumanEdibleFoodAllowed.HasValue && parms.nonHumanEdibleFoodAllowed.Value;
            IEnumerable <ThingDef> arg_FC_0;

            if (flag)
            {
                arg_FC_0 = ItemCollectionGenerator_Food.food;
            }
            else
            {
                arg_FC_0 = from x in ItemCollectionGenerator_Food.food
                           where x.ingestible.HumanEdible
                           select x;
            }
            IEnumerable <ThingDef> enumerable = arg_FC_0;

            if (!flag)
            {
                enumerable = from x in enumerable
                             where x.ingestible.preferability > FoodPreferability.NeverForNutrition
                             select x;
            }
            FoodPreferability?minPreferability = parms.minPreferability;

            if (minPreferability.HasValue)
            {
                enumerable = from x in enumerable
                             where x.ingestible.preferability >= parms.minPreferability.Value
                             select x;
            }
            if (!enumerable.Any <ThingDef>())
            {
                return;
            }
            int numMeats = (from x in enumerable
                            where x.IsMeat
                            select x).Count <ThingDef>();
            int numLeathers = (from x in enumerable
                               where x.IsLeather
                               select x).Count <ThingDef>();
            Func <ThingDef, float> weightSelector = (ThingDef x) => ItemCollectionGeneratorUtility.AdjustedSelectionWeight(x, numMeats, numLeathers);
            List <ThingStuffPair>  list           = ItemCollectionGeneratorByTotalValueUtility.GenerateDefsWithPossibleTotalValue(count2, totalValue, enumerable, techLevel2, (Thing x) => x.def.ingestible.nutrition, (ThingStuffPair x) => x.thing.ingestible.nutrition, (ThingStuffPair x) => x.thing.ingestible.nutrition * (float)x.thing.stackLimit, weightSelector, 100);

            for (int i = 0; i < list.Count; i++)
            {
                outThings.Add(ThingMaker.MakeThing(list[i].thing, list[i].stuff));
            }
            ItemCollectionGeneratorByTotalValueUtility.IncreaseStackCountsToTotalValue(outThings, totalValue, (Thing x) => x.def.ingestible.nutrition);
        }
        private static Thing GenerateRewardFor(ThingDef thingDef, int quantity, Faction faction)
        {
            TechLevel value = (faction != null) ? faction.def.techLevel : TechLevel.Spacer;
            ItemCollectionGeneratorParams parms = default(ItemCollectionGeneratorParams);

            parms.totalMarketValue = new float?(thingDef.BaseMarketValue * (float)quantity * IncidentWorker_CaravanRequest.RewardMarketValueFactorRange.RandomInRange);
            parms.techLevel        = new TechLevel?(value);
            parms.validator        = ((ThingDef td) => td != thingDef);
            return(ItemCollectionGeneratorDefOf.CaravanRequestRewards.Worker.Generate(parms)[0]);
        }
        protected override void Generate(ItemCollectionGeneratorParams parms, List <Thing> outThings)
        {
            int?count = parms.count;

            parms.count = new int?((!count.HasValue) ? 1 : count.Value);
            float?totalMarketValue = parms.totalMarketValue;

            parms.totalMarketValue = new float?((!totalMarketValue.HasValue) ? ((float)ItemCollectionGenerator_BanditCampQuestRewards.RewardMarketValueRange.RandomInRange) : totalMarketValue.Value);
            base.Generate(parms, outThings);
        }
        protected override void Generate(ItemCollectionGeneratorParams parms, List <Thing> outThings)
        {
            int?count = parms.count;

            parms.count = ((!count.HasValue) ? 1 : count.Value);
            float?totalMarketValue = parms.totalMarketValue;

            parms.totalMarketValue = ((!totalMarketValue.HasValue) ? ((float)ItemCollectionGenerator_PeaceTalksGift.GiftMarketValueRange.RandomInRange) : totalMarketValue.Value);
            base.Generate(parms, outThings);
        }
        protected override void Generate(ItemCollectionGeneratorParams parms, List <Thing> outThings)
        {
            int num = Rand.Range(-300, 3000);

            if (num > 0)
            {
                Thing thing = ThingMaker.MakeThing(ThingDefOf.Silver, null);
                thing.stackCount = num;
                outThings.Add(thing);
            }
        }
        protected override IEnumerable <ThingDef> AllowedDefs(ItemCollectionGeneratorParams parms)
        {
            ItemCollectionGenerator_RawResources.< AllowedDefs > c__AnonStorey0 <AllowedDefs> c__AnonStorey = new ItemCollectionGenerator_RawResources.< AllowedDefs > c__AnonStorey0();
            ItemCollectionGenerator_RawResources.< AllowedDefs > c__AnonStorey0 arg_28_0 = < AllowedDefs > c__AnonStorey;
            TechLevel?techLevel = parms.techLevel;

            arg_28_0.techLevel = ((!techLevel.HasValue) ? TechLevel.Spacer : techLevel.Value);
            return(from x in ItemCollectionGenerator_RawResources.rawResources
                   where x.techLevel <= < AllowedDefs > c__AnonStorey.techLevel
                   select x);
        }
        protected override void Generate(ItemCollectionGeneratorParams parms, List <Thing> outThings)
        {
            TechLevel?techLevel  = parms.techLevel;
            TechLevel techLevel2 = (!techLevel.HasValue) ? TechLevel.Spacer : techLevel.Value;

            this.CalculatePossibleItemCollectionGenerators(techLevel2);
            if (this.possibleItemCollectionGenerators.Any())
            {
                Pair <ItemCollectionGeneratorDef, ItemCollectionGeneratorParams> pair = this.possibleItemCollectionGenerators.RandomElement();
                outThings.AddRange(pair.First.Worker.Generate(pair.Second));
            }
        }
        protected override void Generate(ItemCollectionGeneratorParams parms, List <Thing> outThings)
        {
            int?      count      = parms.count;
            int       num        = (!count.HasValue) ? Rand.RangeInclusive(10, 20) : count.Value;
            TechLevel?techLevel  = parms.techLevel;
            TechLevel techLevel2 = (!techLevel.HasValue) ? TechLevel.Spacer : techLevel.Value;

            for (int i = 0; i < num; i++)
            {
                outThings.Add(this.GenerateSingle(techLevel2));
            }
        }
        protected override IEnumerable <ThingDef> AllowedDefs(ItemCollectionGeneratorParams parms)
        {
            TechLevel?techLevel2 = parms.techLevel;
            TechLevel techLevel  = (!techLevel2.HasValue) ? TechLevel.Spacer : techLevel2.Value;

            if ((int)techLevel >= 5)
            {
                return(from x in ItemCollectionGenerator_Weapons.weapons
                       where (int)x.techLevel >= 4 && (int)x.techLevel <= (int)techLevel
                       select x);
            }
            return(from x in ItemCollectionGenerator_Weapons.weapons
                   where (int)x.techLevel <= (int)techLevel
                   select x);
        }
        protected override void Generate(ItemCollectionGeneratorParams parms, List <Thing> outThings)
        {
            int?                 count            = parms.count;
            int                  num              = (!count.HasValue) ? Rand.RangeInclusive(1, 3) : count.Value;
            float?               totalMarketValue = parms.totalMarketValue;
            float                num2             = (!totalMarketValue.HasValue) ? Rand.Range(1500f, 4000f) : totalMarketValue.Value;
            TechLevel?           techLevel        = parms.techLevel;
            TechLevel            techLevel2       = (!techLevel.HasValue) ? TechLevel.Spacer : techLevel.Value;
            Predicate <ThingDef> validator        = parms.validator;

            for (int i = 0; i < num; i++)
            {
                outThings.Add(this.GenerateReward(num2 / (float)num, techLevel2, validator));
            }
        }
Exemplo n.º 22
0
        protected override void Generate(ItemCollectionGeneratorParams parms, List <Thing> outThings)
        {
            TraderKindDef traderKindDef = parms.traderDef ?? DefDatabase <TraderKindDef> .AllDefsListForReading.RandomElement <TraderKindDef>();

            Faction traderFaction = parms.traderFaction;
            int?    tile          = parms.tile;
            int     forTile;

            if (tile.HasValue)
            {
                forTile = parms.tile.Value;
            }
            else if (Find.AnyPlayerHomeMap != null)
            {
                forTile = Find.AnyPlayerHomeMap.Tile;
            }
            else if (Find.VisibleMap != null)
            {
                forTile = Find.VisibleMap.Tile;
            }
            else
            {
                forTile = -1;
            }
            for (int i = 0; i < traderKindDef.stockGenerators.Count; i++)
            {
                StockGenerator stockGenerator = traderKindDef.stockGenerators[i];
                foreach (Thing current in stockGenerator.GenerateThings(forTile))
                {
                    if (current.def.tradeability != Tradeability.Stockable)
                    {
                        Log.Error(string.Concat(new object[]
                        {
                            traderKindDef,
                            " generated carrying ",
                            current,
                            " which has is not Stockable. Ignoring..."
                        }));
                    }
                    else
                    {
                        current.PostGeneratedForTrader(traderKindDef, forTile, traderFaction);
                        outThings.Add(current);
                    }
                }
            }
        }
Exemplo n.º 23
0
 protected override void GeneratePawns(PawnGroupMakerParms parms, PawnGroupMaker groupMaker, List <Pawn> outPawns, bool errorOnZeroResults = true)
 {
     if (!this.CanGenerateFrom(parms, groupMaker))
     {
         if (errorOnZeroResults)
         {
             Log.Error("Cannot generate trader caravan for " + parms.faction + ".");
         }
     }
     else if (!parms.faction.def.caravanTraderKinds.Any())
     {
         Log.Error("Cannot generate trader caravan for " + parms.faction + " because it has no trader kinds.");
     }
     else
     {
         PawnGenOption pawnGenOption = groupMaker.traders.FirstOrDefault((PawnGenOption x) => !x.kind.trader);
         if (pawnGenOption != null)
         {
             Log.Error("Cannot generate arriving trader caravan for " + parms.faction + " because there is a pawn kind (" + pawnGenOption.kind.LabelCap + ") who is not a trader but is in a traders list.");
         }
         else
         {
             PawnGenOption pawnGenOption2 = groupMaker.carriers.FirstOrDefault((PawnGenOption x) => !x.kind.RaceProps.packAnimal);
             if (pawnGenOption2 != null)
             {
                 Log.Error("Cannot generate arriving trader caravan for " + parms.faction + " because there is a pawn kind (" + pawnGenOption2.kind.LabelCap + ") who is not a carrier but is in a carriers list.");
             }
             else
             {
                 TraderKindDef traderKindDef = (parms.traderKind == null) ? parms.faction.def.caravanTraderKinds.RandomElementByWeight((TraderKindDef traderDef) => traderDef.commonality) : parms.traderKind;
                 Pawn          pawn          = this.GenerateTrader(parms, groupMaker, traderKindDef);
                 outPawns.Add(pawn);
                 ItemCollectionGeneratorParams parms2 = default(ItemCollectionGeneratorParams);
                 parms2.traderDef     = traderKindDef;
                 parms2.tile          = parms.tile;
                 parms2.traderFaction = parms.faction;
                 List <Thing> wares = ItemCollectionGeneratorDefOf.TraderStock.Worker.Generate(parms2).InRandomOrder(null).ToList();
                 foreach (Pawn slavesAndAnimalsFromWare in this.GetSlavesAndAnimalsFromWares(parms, pawn, wares))
                 {
                     outPawns.Add(slavesAndAnimalsFromWare);
                 }
                 this.GenerateCarriers(parms, groupMaker, pawn, wares, outPawns);
                 this.GenerateGuards(parms, groupMaker, pawn, wares, outPawns);
             }
         }
     }
 }
        protected override IEnumerable <ThingDef> AllowedDefs(ItemCollectionGeneratorParams parms)
        {
            ItemCollectionGenerator_Weapons.< AllowedDefs > c__AnonStorey0 <AllowedDefs> c__AnonStorey = new ItemCollectionGenerator_Weapons.< AllowedDefs > c__AnonStorey0();
            ItemCollectionGenerator_Weapons.< AllowedDefs > c__AnonStorey0 arg_28_0 = < AllowedDefs > c__AnonStorey;
            TechLevel?techLevel = parms.techLevel;

            arg_28_0.techLevel = ((!techLevel.HasValue) ? TechLevel.Spacer : techLevel.Value);
            if (< AllowedDefs > c__AnonStorey.techLevel >= TechLevel.Spacer)
            {
                return(from x in ItemCollectionGenerator_Weapons.weapons
                       where x.techLevel >= TechLevel.Industrial && x.techLevel <= < AllowedDefs > c__AnonStorey.techLevel
                       select x);
            }
            return(from x in ItemCollectionGenerator_Weapons.weapons
                   where x.techLevel <= < AllowedDefs > c__AnonStorey.techLevel
                   select x);
        }
        public float AverageTotalStockValue(TraderKindDef td)
        {
            ItemCollectionGeneratorParams parms = default(ItemCollectionGeneratorParams);

            parms.traderDef = td;
            parms.tile      = -1;
            float num = 0f;

            for (int i = 0; i < 50; i++)
            {
                foreach (Thing item in base.Generate(parms))
                {
                    num += item.MarketValue * (float)item.stackCount;
                }
            }
            return((float)(num / 50.0));
        }
Exemplo n.º 26
0
        public float AverageTotalStockValue(TraderKindDef td)
        {
            ItemCollectionGeneratorParams parms = default(ItemCollectionGeneratorParams);

            parms.traderDef = td;
            parms.tile      = new int?(-1);
            float num = 0f;

            for (int i = 0; i < 50; i++)
            {
                foreach (Thing current in base.Generate(parms))
                {
                    num += current.MarketValue * (float)current.stackCount;
                }
            }
            return(num / 50f);
        }
        private void CalculatePossibleItemCollectionGenerators(TechLevel techLevel)
        {
            this.possibleItemCollectionGenerators.Clear();
            if ((int)techLevel >= (int)ThingDefOf.AIPersonaCore.techLevel)
            {
                ItemCollectionGeneratorDef    standard = ItemCollectionGeneratorDefOf.Standard;
                ItemCollectionGeneratorParams second   = default(ItemCollectionGeneratorParams);
                second.extraAllowedDefs = Gen.YieldSingle(ThingDefOf.AIPersonaCore);
                second.count            = 1;
                this.possibleItemCollectionGenerators.Add(new Pair <ItemCollectionGeneratorDef, ItemCollectionGeneratorParams>(standard, second));
                if (Rand.Chance(0.25f) && !this.PlayerOrItemStashHasAIPersonaCore())
                {
                    return;
                }
            }
            if ((int)techLevel >= (int)ThingDefOf.MechSerumNeurotrainer.techLevel)
            {
                ItemCollectionGeneratorDef    standard2 = ItemCollectionGeneratorDefOf.Standard;
                ItemCollectionGeneratorParams second2   = default(ItemCollectionGeneratorParams);
                second2.extraAllowedDefs = Gen.YieldSingle(ThingDefOf.MechSerumNeurotrainer);
                second2.count            = ItemCollectionGenerator_ItemStashQuest.NeurotrainersCountRange.RandomInRange;
                this.possibleItemCollectionGenerators.Add(new Pair <ItemCollectionGeneratorDef, ItemCollectionGeneratorParams>(standard2, second2));
            }
            List <ThingDef> allGeneratableItems = ItemCollectionGeneratorUtility.allGeneratableItems;

            for (int i = 0; i < allGeneratableItems.Count; i++)
            {
                ThingDef thingDef = allGeneratableItems[i];
                if ((int)techLevel >= (int)thingDef.techLevel && thingDef.itemGeneratorTags != null && thingDef.itemGeneratorTags.Contains(ItemCollectionGeneratorUtility.SpecialRewardTag))
                {
                    ItemCollectionGeneratorDef    standard3 = ItemCollectionGeneratorDefOf.Standard;
                    ItemCollectionGeneratorParams second3   = default(ItemCollectionGeneratorParams);
                    second3.extraAllowedDefs = Gen.YieldSingle(thingDef);
                    second3.count            = 1;
                    this.possibleItemCollectionGenerators.Add(new Pair <ItemCollectionGeneratorDef, ItemCollectionGeneratorParams>(standard3, second3));
                }
            }
            ItemCollectionGeneratorParams second4 = default(ItemCollectionGeneratorParams);

            second4.count            = ItemCollectionGenerator_ItemStashQuest.ThingsCountRange.RandomInRange;
            second4.totalMarketValue = ItemCollectionGenerator_ItemStashQuest.TotalMarketValueRange.RandomInRange;
            second4.techLevel        = techLevel;
            this.possibleItemCollectionGenerators.Add(new Pair <ItemCollectionGeneratorDef, ItemCollectionGeneratorParams>(ItemCollectionGeneratorDefOf.Weapons, second4));
            this.possibleItemCollectionGenerators.Add(new Pair <ItemCollectionGeneratorDef, ItemCollectionGeneratorParams>(ItemCollectionGeneratorDefOf.RawResources, second4));
            this.possibleItemCollectionGenerators.Add(new Pair <ItemCollectionGeneratorDef, ItemCollectionGeneratorParams>(ItemCollectionGeneratorDefOf.Apparel, second4));
        }
Exemplo n.º 28
0
 protected override void Generate(ItemCollectionGeneratorParams parms, List <Thing> outThings)
 {
     if (Rand.Chance(0.9f))
     {
         Thing thing = ThingMaker.MakeThing(ThingDefOf.Luciferium, null);
         thing.stackCount = ItemCollectionGenerator_AncientTempleContents.LuciferiumCountRange.RandomInRange;
         outThings.Add(thing);
     }
     if (Rand.Chance(0.9f))
     {
         int randomInRange = ItemCollectionGenerator_AncientTempleContents.ArtifactsCountRange.RandomInRange;
         for (int i = 0; i < randomInRange; i++)
         {
             ThingDef def  = ItemCollectionGenerator_Artifacts.artifacts.RandomElement <ThingDef>();
             Thing    item = ThingMaker.MakeThing(def, null);
             outThings.Add(item);
         }
     }
 }
        protected override void Generate(ItemCollectionGeneratorParams parms, List <Thing> outThings)
        {
            int?count = parms.count;

            parms.count = new int?((!count.HasValue) ? 1 : count.Value);
            float?totalMarketValue = parms.totalMarketValue;
            float arg_98_0;

            if (totalMarketValue.HasValue)
            {
                arg_98_0 = totalMarketValue.Value;
            }
            else
            {
                FloatRange floatRange = new FloatRange((float)IncidentWorker_CaravanRequest.BaseValueWantedRange.min * IncidentWorker_CaravanRequest.RewardMarketValueFactorRange.min, (float)IncidentWorker_CaravanRequest.BaseValueWantedRange.max * IncidentWorker_CaravanRequest.RewardMarketValueFactorRange.max);
                arg_98_0 = floatRange.RandomInRange;
            }
            parms.totalMarketValue = new float?(arg_98_0);
            base.Generate(parms, outThings);
        }
Exemplo n.º 30
0
        private bool TryConvertOnePawnToSmallTrader(List <Pawn> pawns, Faction faction, Map map)
        {
            if (faction.def.visitorTraderKinds.NullOrEmpty <TraderKindDef>())
            {
                return(false);
            }
            Pawn pawn = pawns.RandomElement <Pawn>();
            Lord lord = pawn.GetLord();

            pawn.mindState.wantsToTradeWithColony = true;
            PawnComponentsUtility.AddAndRemoveDynamicComponents(pawn, true);
            TraderKindDef traderKindDef = faction.def.visitorTraderKinds.RandomElementByWeight((TraderKindDef traderDef) => traderDef.commonality);

            pawn.trader.traderKind = traderKindDef;
            pawn.inventory.DestroyAll(DestroyMode.Vanish);
            ItemCollectionGeneratorParams parms = default(ItemCollectionGeneratorParams);

            parms.traderDef     = traderKindDef;
            parms.tile          = new int?(map.Tile);
            parms.traderFaction = faction;
            foreach (Thing current in ItemCollectionGeneratorDefOf.TraderStock.Worker.Generate(parms))
            {
                Pawn pawn2 = current as Pawn;
                if (pawn2 != null)
                {
                    if (pawn2.Faction != pawn.Faction)
                    {
                        pawn2.SetFaction(pawn.Faction, null);
                    }
                    IntVec3 loc = CellFinder.RandomClosewalkCellNear(pawn.Position, map, 5, null);
                    GenSpawn.Spawn(pawn2, loc, map);
                    lord.AddPawn(pawn2);
                }
                else if (!pawn.inventory.innerContainer.TryAdd(current, true))
                {
                    current.Destroy(DestroyMode.Vanish);
                }
            }
            PawnInventoryGenerator.GiveRandomFood(pawn);
            return(true);
        }