Exemple #1
0
        private static Thing PostProcessProduct(Thing product, RecipeDef recipeDef, Pawn worker)
        {
            CompQuality compQuality = product.TryGetComp <CompQuality>();

            if (compQuality != null)
            {
                if (recipeDef.workSkill == null)
                {
                    Log.Error(recipeDef + " needs workSkill because it creates a product with a quality.", false);
                }
                QualityCategory q = QualityUtility.GenerateQualityCreatedByPawn(worker, recipeDef.workSkill);
                compQuality.SetQuality(q, ArtGenerationContext.Colony);
                QualityUtility.SendCraftNotification(product, worker);
            }
            CompArt compArt = product.TryGetComp <CompArt>();

            if (compArt != null)
            {
                compArt.JustCreatedBy(worker);
                if (compQuality.Quality >= QualityCategory.Excellent)
                {
                    TaleRecorder.RecordTale(TaleDefOf.CraftedArt, new object[]
                    {
                        worker,
                        product
                    });
                }
            }
            if (product.def.Minifiable)
            {
                product = product.MakeMinified();
            }
            return(product);
        }
 public static void Postfix(ref int relevantSkillLevel, ref bool inspired, ref QualityCategory __result)
 {
     try
     {
         if (relevantSkillLevel >= minSkill[(int)QualityCategory.Legendary] && __result < QualityCategory.Legendary && Rand.Chance(legendaryChanceAt20 - ((20 - relevantSkillLevel) * gradientLegendary)))
         {
             __result = QualityCategory.Legendary;
         }
         else if (relevantSkillLevel >= minSkill[(int)QualityCategory.Masterwork] && __result < QualityCategory.Masterwork)
         {
             __result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired);
         }
         else if (relevantSkillLevel >= minSkill[(int)QualityCategory.Excellent] && __result < QualityCategory.Excellent)
         {
             __result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired);
         }
         else if (relevantSkillLevel >= minSkill[(int)QualityCategory.Good] && __result < QualityCategory.Good)
         {
             __result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired);
         }
         else if (relevantSkillLevel >= minSkill[(int)QualityCategory.Normal] && __result < QualityCategory.Normal)
         {
             __result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired);
         }
         else if (relevantSkillLevel >= minSkill[(int)QualityCategory.Poor] && __result < QualityCategory.Poor)
         {
             __result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired);
         }
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
     }
 }
        private static Thing PostProcessProduct(Thing product, RecipeDef recipeDef, IRecipeProductWorker worker)
        {
            CompQuality compQuality = product.TryGetComp <CompQuality>();

            if (compQuality != null)
            {
                if (recipeDef.workSkill == null)
                {
                    Log.Error(recipeDef + " needs workSkill because it creates a product with a quality.");
                }
                int             level           = worker.GetSkillLevel(recipeDef.workSkill);
                QualityCategory qualityCategory = QualityUtility.GenerateQualityCreatedByPawn(level, false);
                compQuality.SetQuality(qualityCategory, ArtGenerationContext.Colony);
            }
            CompArt compArt = product.TryGetComp <CompArt>();

            if (compArt != null)
            {
                if (compQuality.Quality >= QualityCategory.Excellent)
                {
                    /*
                     * TaleRecorder.RecordTale(TaleDefOf.CraftedArt, new object[]
                     * {
                     *  product
                     * });
                     */
                }
            }
            if (product.def.Minifiable)
            {
                product = product.MakeMinified();
            }
            return(product);
        }
Exemple #4
0
 public static void Postfix(ref int relevantSkillLevel, ref bool inspired, ref QualityCategory __result)
 {
     if (relevantSkillLevel >= minSkillLegendary && __result < QualityCategory.Legendary && Rand.Chance(legendaryChanceAt20 - ((20 - relevantSkillLevel) * gradientLegendary)))
     {
         __result = QualityCategory.Legendary;
     }
     else if (relevantSkillLevel >= minSkillMasterwork && __result < QualityCategory.Masterwork)
     {
         __result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired);
     }
     else if (relevantSkillLevel >= minSkillExcellent && __result < QualityCategory.Excellent)
     {
         __result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired);
     }
     else if (relevantSkillLevel >= minSkillGood && __result < QualityCategory.Good)
     {
         __result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired);
     }
     else if (relevantSkillLevel >= minSkillNormal && __result < QualityCategory.Normal)
     {
         __result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired);
     }
     else if (relevantSkillLevel >= minSkillPoor && __result < QualityCategory.Poor)
     {
         __result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired);
     }
 }
Exemple #5
0
        protected void DoEffect()
        {
            Thing target = base.TargetA.Thing;
            Map   map    = target.Map;

            target.Destroy(DestroyMode.WillReplace);
            Thing       wall        = ThingMaker.MakeThing(ThingDef.Named("Engraved" + target.def.building.unsmoothedThing.defName), target.Stuff);
            CompQuality compQuality = wall.TryGetComp <CompQuality>();

            if (compQuality != null)
            {
                int             level           = this.pawn.skills.GetSkill(SkillDefOf.Artistic).Level;
                QualityCategory qualityCategory = QualityUtility.GenerateQualityCreatedByPawn(level, false);
                compQuality.SetQuality(qualityCategory, ArtGenerationContext.Colony);
            }
            CompArt compArt = wall.TryGetComp <CompArt>();

            if (compArt != null)
            {
                compArt.JustCreatedBy(this.pawn);
                if (compQuality.Quality >= QualityCategory.Excellent)
                {
                    TaleRecorder.RecordTale(TaleDefOf.CraftedArt, new object[]
                    {
                        this.pawn,
                        wall
                    });
                }
            }
            wall.SetFaction(this.pawn.Faction, null);
            GenSpawn.Spawn(wall, target.Position, map, target.Rotation, WipeMode.Vanish, false);
            map.designationManager.TryRemoveDesignation(target.Position, DesignationDefOf.EngraveWall);
        }
        // Token: 0x0600009F RID: 159 RVA: 0x00004884 File Offset: 0x00002A84
        protected override float GetFinalQuality()
        {
            var num  = (float)GetQualityModifier(QualityUtility.GenerateQualityCreatedByPawn(Lead, SkillDefOf.Social));
            var num2 = (float)GetQualityModifier(QualityUtility.GenerateQualityCreatedByPawn(Lead, SkillDefOf.Artistic));

            return(Lead.health.capacities.GetLevel(PawnCapacityDefOf.Talking) * Rand.Range(num, num + num2));
        }
        // Token: 0x06000018 RID: 24 RVA: 0x0000322C File Offset: 0x0000142C
        private static Thing PostProcessProduct(Thing product, RecipeDef recipeDef, Pawn worker)
        {
            string[] array = new string[6];
            array[0] = "post processing: product ";
            int   num   = 1;
            Thing thing = product;

            array[num] = ((thing != null) ? thing.ToString() : null);
            array[2]   = " recipeDef ";
            array[3]   = ((recipeDef != null) ? recipeDef.ToString() : null);
            array[4]   = " worker ";
            array[5]   = ((worker != null) ? worker.ToString() : null);
            Log.Message(string.Concat(array), false);
            CompQuality compQuality = product.TryGetComp <CompQuality>();
            bool        flag        = compQuality != null;

            if (flag)
            {
                bool flag2 = recipeDef.workSkill == null;
                if (flag2)
                {
                    Log.Error(((recipeDef != null) ? recipeDef.ToString() : null) + " needs workSkill because it creates a product with a quality.", false);
                }
                int             relevantSkillLevel = 1;
                QualityCategory q     = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, false);
                bool            flag3 = worker.InspirationDef == InspirationDefOf.Inspired_Creativity && (product.def.IsArt || (product.def.minifiedDef != null && product.def.minifiedDef.IsArt));
                if (flag3)
                {
                    int relevantSkillLevel2 = 4;
                    q = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel2, false);
                }
                compQuality.SetQuality(q, ArtGenerationContext.Colony);
            }
            CompArt compArt = product.TryGetComp <CompArt>();
            bool    flag4   = compArt != null;

            if (flag4)
            {
                compArt.JustCreatedBy(worker);
            }
            bool minifiable = product.def.Minifiable;

            if (minifiable)
            {
                product = product.MakeMinified();
            }
            string[] array2 = new string[6];
            array2[0] = "end post processing:product ";
            int   num2   = 1;
            Thing thing2 = product;

            array2[num2] = ((thing2 != null) ? thing2.ToString() : null);
            array2[2]    = " recipeDef ";
            array2[3]    = ((recipeDef != null) ? recipeDef.ToString() : null);
            array2[4]    = " worker ";
            array2[5]    = ((worker != null) ? worker.ToString() : null);
            Log.Message(string.Concat(array2), false);
            return(product);
        }
Exemple #8
0
        // Token: 0x06000004 RID: 4 RVA: 0x00002160 File Offset: 0x00000360
        private List <Thing> CreateLoot()
        {
            List <Thing> list = new List <Thing>();
            int          ItemCount;

            if (PropsResourceBox.spawnAll)
            {
                ItemCount = PropsResourceBox.possibleItems.Count;
            }
            else
            {
                ItemCount = Rand.RangeInclusive(PropsResourceBox.minItems, PropsResourceBox.maxItems);
            }
            for (int i = 0; i < ItemCount; i++)
            {
                ThingDef named = null;
                int      PerItemCount;
                int      j = 0;
                if (PropsResourceBox.PerItemCount != 0)
                {
                    PerItemCount = PropsResourceBox.PerItemCount;
                }
                else
                {
                    PerItemCount = Rand.RangeInclusive(PropsResourceBox.minPerItem, PropsResourceBox.maxPerItem);
                }
                if (!PropsResourceBox.possibleItems.NullOrEmpty())
                {
                    if (PropsResourceBox.spawnAll)
                    {
                        named = PropsResourceBox.possibleItems[i];
                    }
                    else
                    {
                        named = PropsResourceBox.possibleItems.RandomElement();
                    }
                }
                if (named != null)
                {
                    Thing thing = ThingMaker.MakeThing(named, GenStuff.RandomStuffFor(named));
                    thing.stackCount = PerItemCount;
                    CompQuality compQuality = ThingCompUtility.TryGetComp <CompQuality>(thing);
                    if (compQuality != null)
                    {
                        QualityCategory qualityCategory = QualityUtility.GenerateQualityCreatedByPawn(Rand.RangeInclusive(0, 19), false);
                        compQuality.SetQuality(qualityCategory, 0);
                    }
                    CompArt compArt = ThingCompUtility.TryGetComp <CompArt>(thing);
                    if (compArt != null)
                    {
                        compArt.InitializeArt(0);
                    }
                    list.Add(thing);
                }
            }
            return(list);
        }
Exemple #9
0
        // Token: 0x0600008B RID: 139 RVA: 0x000041B8 File Offset: 0x000023B8
        protected virtual float GetFinalQuality()
        {
            var num          = (float)GetQualityModifier(Venue.artQuality);
            var num2         = (float)GetQualityModifier(QualityUtility.GenerateQualityCreatedByPawn(Lead, SkillDefOf.Social));
            var statModifier = GetStatModifier();

            if (Venue.VenueDef.performersNeeded > 1)
            {
                num2 = (0.6f * num2) + (0.4f * (float)GetQualityModifier(QualityUtility.GenerateQualityCreatedByPawn(Support, SkillDefOf.Social)));
            }
            num2 *= statModifier;
            return(Rand.Range(num2, num2 + num));
        }
        public static void FinalizeReplace(Thing thing, ThingDef stuff, Pawn worker = null)
        {
            DeconstructDropStuff(thing);

            thing.ChangeStuff(stuff);

            if (worker != null && thing.TryGetComp <CompQuality>() is CompQuality compQuality)
            {
                QualityCategory qualityCreatedByPawn = QualityUtility.GenerateQualityCreatedByPawn(worker, SkillDefOf.Construction);
                compQuality.SetQuality(qualityCreatedByPawn, ArtGenerationContext.Colony);
                QualityUtility.SendCraftNotification(thing, worker);
            }
        }
Exemple #11
0
        public static void FinalizeReplace(Thing thing, ThingDef stuff, Pawn worker = null)
        {
            DeconstructDropStuff(thing);

            thing.SetStuffDirect(stuff);
            thing.HitPoints = thing.MaxHitPoints;             //Deconstruction/construction implicitly repairs
            thing.Notify_ColorChanged();

            if (worker != null && thing.TryGetComp <CompQuality>() is CompQuality compQuality)
            {
                QualityCategory qualityCreatedByPawn = QualityUtility.GenerateQualityCreatedByPawn(worker, SkillDefOf.Construction);
                compQuality.SetQuality(qualityCreatedByPawn, ArtGenerationContext.Colony);
                QualityUtility.SendCraftNotification(thing, worker);
            }
        }
        public static void ScatterWeaponsWhere(CellRect within, int num, Map map, Predicate <ThingDef> validator)
        {
            List <ThingStuffPair> source = MapGenUtility.GetWeapons(validator);

            for (int i = 0; i < num; i++)
            {
                ThingStuffPair thingStuffPair = source.RandomElement <ThingStuffPair>();
                Thing          thing          = ThingMaker.MakeThing(thingStuffPair.thing, thingStuffPair.stuff);
                CompQuality    compQuality    = thing.TryGetComp <CompQuality>();
                if (compQuality != null)
                {
                    compQuality.SetQuality(QualityUtility.GenerateQualityCreatedByPawn(12, false), ArtGenerationContext.Outsider);
                }
                IntVec3 loc2;
                if (thing != null && CellFinder.TryFindRandomCellInsideWith(within, (IntVec3 loc) => loc.Standable(map), out loc2))
                {
                    GenSpawn.Spawn(thing, loc2, map);
                }
            }
        }
 public static void Postfix(ref int relevantSkillLevel, ref bool inspired, ref QualityCategory __result)
 {
     try
     {
         // Check first if it hit the random legendary chance, and if so, set it and move on.
         if (relevantSkillLevel >= minSkill[(int)QualityCategory.Legendary] && __result < QualityCategory.Legendary &&
             Rand.Chance(legendaryChanceAt20 - ((20 - relevantSkillLevel) * gradientLegendary)))
         {
             __result = QualityCategory.Legendary;
         }
         else
         {
             // Not a random legendary, step backwards through quality levels until we match the rolled quality or we find the minimum for this skill level
             // start at masterwork because legendary is handled already
             for (int i = (int)QualityCategory.Masterwork; i > (int)QualityCategory.Awful; i--)
             {
                 if (relevantSkillLevel >= minSkill[i]
                     // if inspiration then quality to meet is two levels higher. For example if excellent is guaranteed then it's gonna be for sure legendary
                     && ((!inspired && __result < (QualityCategory)i) || (inspired && __result < (QualityCategory)Math.Min(i + 2, (int)QualityCategory.Legendary))))
                 {
                     if (setQualityInsteadOfReroll)
                     {
                         __result = (QualityCategory)(inspired ? Math.Min(i + 2, (int)QualityCategory.Legendary) : i);
                     }
                     else
                     {
                         __result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired);
                     }
                     break;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
     }
 }
        // Token: 0x06000018 RID: 24 RVA: 0x00002910 File Offset: 0x00000B10
        public static bool Prefix(ref Thing __result, Thing product, RecipeDef recipeDef)
        {
            bool result;

            if (recipeDef == RecipeDefOf.Make_Gachapon)
            {
                var product1 = product;
                var source   = from def in DefDatabase <ThingDef> .AllDefs
                               where def.IsStuff && def.stuffProps.CanMake(product1.def)
                               select def;
                var stuffDirect =
                    source.RandomElementByWeightWithFallback(x => x.stuffProps.commonality, RimWorld.ThingDefOf.Steel);
                product.SetStuffDirect(stuffDirect);
                var compQuality = product.TryGetComp <CompQuality>();
                if (compQuality != null)
                {
                    var q = QualityUtility.GenerateQualityCreatedByPawn(6, Rand.Chance(0.2f));
                    compQuality.SetQuality(q, ArtGenerationContext.Colony);
                }

                product.HitPoints = product.MaxHitPoints;
                var minifiable = product.def.Minifiable;
                if (minifiable)
                {
                    product = product.MakeMinified();
                }

                __result = product;
                result   = false;
            }
            else
            {
                result = true;
            }

            return(result);
        }
        private IEnumerable <Thing> CreateLoot()
        {
            var lootList = new List <Thing>();
            // RNG Here will be biased towards the SetMinimum, so it'll be more likely to get closer to SetMinimum than getting to SetMaximum.
            var spawnCount = Rand.RangeInclusive(SetMinimum, Rand.RangeInclusive(SetMinimum, SetMaximum));

            /*
             * Bonus Loot chance by default was multiplied by 2 the reward count, but it also would reduce
             * the chances by a factor of 2 if a bonus was already applied to the exact same box with the same
             * hash ID (so if you were to reload the world without saving, the same box would be there and chances
             * would be reduced instead of increased). This code just says screw that and always increases it as
             * long as the config option is enabled.
             */
            if (ModLootBoxes.Settings.UseBonusLootChance)
            {
                spawnCount = GenMath.RoundRandom(spawnCount * ModLootBoxes.Settings.BonusLootChance);
            }

            spawnCount = Math.Max(1, spawnCount);

            while (spawnCount > 0)
            {
                spawnCount--;
                var chosenReward  = RewardTable.RandomElementByWeight(k => k.Weight * k.Weight);
                var groupedReward = chosenReward.Rewards.GroupBy(k => DefDatabase <ThingDef> .GetNamed(k.ItemDefName))
                                    .Where(k => k.Key != null).ToList();

                foreach (var group in groupedReward)
                {
                    var targetDef = group.Key;
                    foreach (var reward in group)
                    {
                        var min = Math.Max(reward.MinimumDropCount, 1);
                        var max = Math.Max(reward.MaximumDropCount, min);
                        if (reward.RandomizeDropCountUpTo > max)
                        {
                            max = Rand.RangeInclusive(max, reward.RandomizeDropCountUpTo);
                        }

                        var countToDo = Rand.RangeInclusive(min, max);
                        while (countToDo > 0)
                        {
                            var count = Math.Min(countToDo, targetDef.stackLimit);
                            countToDo -= count;

                            var thing = ThingMaker.MakeThing(targetDef, GenStuff.RandomStuffFor(targetDef));
                            thing.stackCount = count;

                            var compQuality = thing.TryGetComp <CompQuality>();
                            if (compQuality != null)
                            {
                                var q = QualityUtility.GenerateQualityCreatedByPawn(Rand.RangeInclusive(0, 19), false);
                                compQuality.SetQuality(q, ArtGenerationContext.Outsider);
                            }

                            var compArt = thing.TryGetComp <CompArt>();
                            compArt?.InitializeArt(ArtGenerationContext.Outsider);
                            lootList.Add(thing);
                        }
                    }
                }
            }

            return(lootList);
        }
Exemple #16
0
        // Token: 0x060000EF RID: 239 RVA: 0x00008640 File Offset: 0x00006840
        public static bool CompleteConstruction_Prefix(Frame __instance, Pawn worker)
        {
            bool flag = !worker.RaceProps.Humanlike;
            bool result;

            if (flag)
            {
                Thing thing = __instance.holdingOwner.Take(__instance);
                __instance.resourceContainer.ClearAndDestroyContents(DestroyMode.Vanish);
                Map map = worker.Map;
                __instance.Destroy(DestroyMode.Vanish);
                bool flag2 = __instance.GetStatValue(StatDefOf.WorkToBuild, true) > 150f && __instance.def.entityDefToBuild is ThingDef && ((ThingDef)__instance.def.entityDefToBuild).category == ThingCategory.Building;
                if (flag2)
                {
                    SoundDefOf.Building_Complete.PlayOneShot(new TargetInfo(thing.Position, map, false));
                }
                ThingDef thingDef = __instance.def.entityDefToBuild as ThingDef;
                Thing    thing2   = null;
                bool     flag3    = thingDef != null;
                if (flag3)
                {
                    thing2 = ThingMaker.MakeThing(thingDef, thing.Stuff);
                    thing2.SetFactionDirect(thing.Faction);
                    CompQuality compQuality = thing2.TryGetComp <CompQuality>();
                    bool        flag4       = compQuality != null;
                    if (flag4)
                    {
                        int             relevantSkillLevel = 1;
                        QualityCategory q = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, false);
                        compQuality.SetQuality(q, ArtGenerationContext.Colony);
                        QualityUtility.SendCraftNotification(thing2, worker);
                    }
                    CompArt compArt = thing2.TryGetComp <CompArt>();
                    bool    flag5   = compArt != null;
                    if (flag5)
                    {
                        bool flag6 = compQuality == null;
                        if (flag6)
                        {
                            compArt.InitializeArt(ArtGenerationContext.Colony);
                        }
                        compArt.JustCreatedBy(worker);
                    }
                    thing2.HitPoints = Mathf.CeilToInt((float)__instance.HitPoints / (float)thing.MaxHitPoints * (float)thing2.MaxHitPoints);
                    GenSpawn.Spawn(thing2, thing.Position, worker.Map, thing.Rotation, WipeMode.Vanish, false);
                }
                else
                {
                    map.terrainGrid.SetTerrain(thing.Position, (TerrainDef)__instance.def.entityDefToBuild);
                    FilthMaker.RemoveAllFilth(thing.Position, map);
                }
                worker.records.Increment(RecordDefOf.ThingsConstructed);
                bool flag7 = thing2 != null && thing2.GetStatValue(StatDefOf.WorkToBuild, true) >= 9500f;
                if (flag7)
                {
                    TaleRecorder.RecordTale(TaleDefOf.CompletedLongConstructionProject, new object[]
                    {
                        worker,
                        thing2.def
                    });
                }
                result = false;
            }
            else
            {
                result = true;
            }
            return(result);
        }
        public void ResolveNegotiations(Pawn playerNegotiator, Pawn otherNegotiator)
        {
            if (Rand.Chance(0.95f))
            {
                QualityCategory qualityCategory = QualityUtility.GenerateQualityCreatedByPawn(playerNegotiator.skills.GetSkill(SkillDefOf.Social).Level, false);
                int             num             = 0;
                string          text            = "";
                switch (qualityCategory)
                {
                case QualityCategory.Awful:
                    num  = -5;
                    text = TranslatorFormattedStringExtensions.Translate("RD_DiplomacyAwful", playerNegotiator.Label, this.requestingFaction.Name, num);     //"The flailing diplomatic "strategy" of {0} seemed chiefly to involve wild swings between aggression and panic, peppered liberally with lewd insults involving the negotiator for {1}'s antecedents. Your already strained relations have, understandably, worsened ({2} to relations).";
                    break;

                case QualityCategory.Poor:
                    num  = -1;
                    text = TranslatorFormattedStringExtensions.Translate("RD_DiplomacyPoor"     //"The chief negotiation tactic employed by {0} seemed to be staring bored at the wall. This did little to diffuse tensions and engender a feeling of respect ({2} to relations))";
                                                                         , playerNegotiator.Label, this.requestingFaction.Name, num);
                    break;

                case QualityCategory.Normal:
                case QualityCategory.Good:
                    num  = 8;
                    text = TranslatorFormattedStringExtensions.Translate("RD_DiplomacyNormalGood"     //"{0}'s negotiation adequately dealt with some minor disputes you have with {1}. Your relations have improved by {2}.";

                                                                         , playerNegotiator.Label, this.requestingFaction.Name, num);
                    break;

                case QualityCategory.Excellent:
                    num  = 16;
                    text = TranslatorFormattedStringExtensions.Translate("RD_DiplomacyExcellent"     //"{0}'s easy, but unyielding manner dealt well with a number of the negotiator for {1}'s concerns. Your relations have improved by {2}";

                                                                         , playerNegotiator.Label, this.requestingFaction.Name, num);
                    break;

                case QualityCategory.Masterwork:
                case QualityCategory.Legendary:
                    num  = 32;
                    text = TranslatorFormattedStringExtensions.Translate("RD_DiplomacyMasterWorkLegendary"     //"{0} made diplomacy look as easy as breathing, with an almost magical ability to make {1}'s negotiator see your perspective. Your relations have undergone a substantial improvement of {2}.";

                                                                         , playerNegotiator.Label, this.requestingFaction.Name, num);
                    break;
                }
                DiaNode   diaNode   = new DiaNode(text);
                DiaOption diaOption = new DiaOption("OK".Translate());
                diaOption.resolveTree = true;
                diaNode.options.Add(diaOption);
                Dialog_NodeTree window = new Dialog_NodeTree(diaNode, false, false, null);
                Find.WindowStack.Add(window);
                this.facOriginalRelationship += num;
                this.active = false;
                ThingComp comp = this.Negotiator.GetComp <CompNegotiator>();
                if (comp != null)
                {
                    this.Negotiator.AllComps.Remove(comp);
                }
            }
            else
            {
                DiaNode   diaNode2   = new DiaNode("RD_NegotiationsTrap".Translate()); //"The negotiations are a trap!"
                DiaOption diaOption2 = new DiaOption("OK".Translate());
                diaOption2.resolveTree = true;
                diaNode2.options.Add(diaOption2);
                Dialog_NodeTree window2 = new Dialog_NodeTree(diaNode2, false, false, null);
                Find.WindowStack.Add(window2);
                this.requestingFaction.TryAffectGoodwillWith(Faction.OfPlayer, -101);
            }
        }
        private List <Thing> CreateLoot()
        {
            Dictionary <string, float> lootEntries = new Dictionary <string, float>();

            string[] arr       = GenMagic.Magic(LootTable).Split('|');
            int      setsMin   = int.Parse(arr[0]);
            int      setsMax   = int.Parse(arr[1]);
            int      setsCount = GenMagic.GetRealCount(parent, Rand.RangeInclusive(setsMin, Rand.RangeInclusive(setsMin, setsMax)));

            //Log.Message("min: " + setsMin + ", max: " + setsMax + ", final: " + setsCount);
            for (int i = 2, iLen = arr.Length; i < iLen; i++)
            {
                string str = arr[i];
                int    pos = str.FirstIndexOf(c => c == ';');
                lootEntries.Add(str.Substring(pos + 1), float.Parse(str.Substring(0, pos)));
                //Log.Message("key : " + str.Substring(pos + 1) + ", val: " + float.Parse(str.Substring(0, pos)));
            }
            List <Thing> lootList = new List <Thing>();

            for (int i = 0; i < setsCount; i++)
            {
                string chosenSet = lootEntries.RandomElementByWeight(kvp => kvp.Value * kvp.Value).Key;
                //Log.Message("chosen set: " + chosenSet);
                arr = chosenSet.Split(';');
                for (int j = 0, jLen = arr.Length; j < jLen; j++)
                {
                    string[] inner = arr[j].Split(',');
                    int      min   = (inner.Length <= 1) ? 1 : int.Parse(inner[1]);
                    int      max   = (inner.Length <= 2) ? min : int.Parse(inner[2]);
                    if (inner.Length >= 4)
                    {
                        max = Rand.RangeInclusive(max, int.Parse(inner[3]));
                    }
                    ThingDef def = DefDatabase <ThingDef> .GetNamed(inner[0]);

                    //Log.Message("def: " + def.defName + ", min: " + min + ", max: " + max);
                    if (def != null)
                    {
                        int countToDo = Rand.RangeInclusive(min, max);
                        while (countToDo > 0)
                        {
                            int count = Math.Min(countToDo, def.stackLimit);
                            countToDo -= count;
                            Thing thing = ThingMaker.MakeThing(def, GenStuff.RandomStuffFor(def));
                            thing.stackCount = count;
                            //Log.Message("thing: " + thing + ", stuff: " + thing.Stuff + ", count: " + count);
                            CompQuality compQuality = thing.TryGetComp <CompQuality>();
                            if (compQuality != null)
                            {
                                QualityCategory q = QualityUtility.GenerateQualityCreatedByPawn(Rand.RangeInclusive(0, 19), false);
                                compQuality.SetQuality(q, ArtGenerationContext.Outsider);
                            }
                            CompArt compArt = thing.TryGetComp <CompArt>();
                            if (compArt != null)
                            {
                                compArt.InitializeArt(ArtGenerationContext.Outsider);
                            }
                            lootList.Add(thing);
                        }
                    }
                }
            }
            return(lootList);
        }