コード例 #1
0
ファイル: QualityUtility.cs プロジェクト: ehtnnd/RW-Decompile
        private static void QualityGenerationData()
        {
            List <TableDataGetter <QualityCategory> > list = new List <TableDataGetter <QualityCategory> >();

            list.Add(new TableDataGetter <QualityCategory>("quality", (QualityCategory q) => q.ToString()));
            list.Add(new TableDataGetter <QualityCategory>("Rewards\n(quests,\netc...? )", (QualityCategory q) => QualityUtility.DebugQualitiesStringSingle(q, new Func <QualityCategory>(QualityUtility.GenerateQualityReward))));
            list.Add(new TableDataGetter <QualityCategory>("Trader\nitems", (QualityCategory q) => QualityUtility.DebugQualitiesStringSingle(q, new Func <QualityCategory>(QualityUtility.GenerateQualityTraderItem))));
            list.Add(new TableDataGetter <QualityCategory>("Map generation\nitems and\nbuildings\n(e.g. NPC bases)", (QualityCategory q) => QualityUtility.DebugQualitiesStringSingle(q, new Func <QualityCategory>(QualityUtility.GenerateQualityBaseGen))));
            list.Add(new TableDataGetter <QualityCategory>("Gifts", (QualityCategory q) => QualityUtility.DebugQualitiesStringSingle(q, new Func <QualityCategory>(QualityUtility.GenerateQualityGift))));
            for (int i = 0; i <= 20; i++)
            {
                int localLevel = i;
                list.Add(new TableDataGetter <QualityCategory>("Made\nat skill\n" + i, (QualityCategory q) => QualityUtility.DebugQualitiesStringSingle(q, () => QualityUtility.GenerateQualityCreatedByPawn(localLevel, false))));
            }
            foreach (PawnKindDef current in from k in DefDatabase <PawnKindDef> .AllDefs
                     orderby k.combatPower
                     select k)
            {
                PawnKindDef localPk = current;
                if (localPk.RaceProps.Humanlike)
                {
                    list.Add(new TableDataGetter <QualityCategory>(string.Concat(new object[]
                    {
                        "Gear for\n",
                        localPk.defName,
                        "\nPower ",
                        localPk.combatPower.ToString("F0"),
                        "\nitemQuality:\n",
                        localPk.itemQuality
                    }), (QualityCategory q) => QualityUtility.DebugQualitiesStringSingle(q, () => QualityUtility.GenerateQualityGeneratingPawn(localPk))));
                }
            }
            DebugTables.MakeTablesDialog <QualityCategory>(QualityUtility.AllQualityCategories, list.ToArray());
        }
コード例 #2
0
        internal static void LogGenerationData()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("Qualities for trader items");
            stringBuilder.AppendLine(QualityUtility.DebugQualitiesString(new Func <QualityCategory>(QualityUtility.RandomTraderItemQuality)));
            foreach (PawnKindDef pk in DefDatabase <PawnKindDef> .AllDefs)
            {
                if (pk.RaceProps.Humanlike)
                {
                    stringBuilder.AppendLine("Qualities for items generated for pawn kind " + pk.defName);
                    stringBuilder.Append(QualityUtility.DebugQualitiesString(() => QualityUtility.RandomGeneratedGearQuality(pk)));
                    stringBuilder.AppendLine();
                }
            }
            int level;

            for (level = 0; level <= 20; level++)
            {
                stringBuilder.AppendLine();
                stringBuilder.AppendLine("Creation qualities for worker at level " + level);
                stringBuilder.Append(QualityUtility.DebugQualitiesString(() => QualityUtility.RandomCreationQuality(level)));
            }
            Log.Message(stringBuilder.ToString());
        }
コード例 #3
0
 public static QualityCategory GenerateQualityBaseGen()
 {
     if (Rand.Value < 0.3f)
     {
         return(QualityCategory.Normal);
     }
     return(QualityUtility.GenerateFromGaussian(1f, QualityCategory.Excellent, QualityCategory.Normal, QualityCategory.Awful));
 }
コード例 #4
0
 private static string <QualityGenerationData> m__2(QualityCategory q)
 {
     if (QualityUtility.< > f__mg$cache1 == null)
     {
         QualityUtility.< > f__mg$cache1 = new Func <QualityCategory>(QualityUtility.GenerateQualityTraderItem);
     }
     return(QualityUtility.DebugQualitiesStringSingle(q, QualityUtility.< > f__mg$cache1));
 }
コード例 #5
0
 private static string <QualityGenerationData> m__4(QualityCategory q)
 {
     if (QualityUtility.< > f__mg$cache3 == null)
     {
         QualityUtility.< > f__mg$cache3 = new Func <QualityCategory>(QualityUtility.GenerateQualityGift);
     }
     return(QualityUtility.DebugQualitiesStringSingle(q, QualityUtility.< > f__mg$cache3));
 }
コード例 #6
0
        public static void AssignQuality(Thing thing, QualityGenerator?qualityGenerator)
        {
            CompQuality compQuality = thing.TryGetComp <CompQuality>();

            if (compQuality != null)
            {
                QualityCategory q = QualityUtility.GenerateQuality(qualityGenerator ?? QualityGenerator.BaseGen);
                compQuality.SetQuality(q, ArtGenerationContext.Outsider);
            }
        }
コード例 #7
0
 public static void AssignRandomBaseGenItemQuality(List <Thing> things)
 {
     for (int i = 0; i < things.Count; i++)
     {
         CompQuality compQuality = things[i].TryGetComp <CompQuality>();
         if (compQuality != null)
         {
             compQuality.SetQuality(QualityUtility.RandomBaseGenItemQuality(), ArtGenerationContext.Outsider);
         }
     }
 }
コード例 #8
0
        public static QualityCategory GenerateQualityCreatedByPawn(Pawn pawn, SkillDef relevantSkill)
        {
            int             level  = pawn.skills.GetSkill(relevantSkill).Level;
            bool            flag   = pawn.InspirationDef == InspirationDefOf.Inspired_Creativity;
            QualityCategory result = QualityUtility.GenerateQualityCreatedByPawn(level, flag);

            if (flag)
            {
                pawn.mindState.inspirationHandler.EndInspiration(InspirationDefOf.Inspired_Creativity);
            }
            return(result);
        }
コード例 #9
0
        public void CompleteConstruction(Pawn worker)
        {
            resourceContainer.ClearAndDestroyContents();
            Map map = base.Map;

            Destroy();
            if (this.GetStatValue(StatDefOf.WorkToBuild) > 150f && def.entityDefToBuild is ThingDef && ((ThingDef)def.entityDefToBuild).category == ThingCategory.Building)
            {
                SoundDefOf.Building_Complete.PlayOneShot(new TargetInfo(base.Position, map));
            }
            ThingDef thingDef = def.entityDefToBuild as ThingDef;
            Thing    thing    = null;

            if (thingDef != null)
            {
                thing = ThingMaker.MakeThing(thingDef, base.Stuff);
                thing.SetFactionDirect(base.Faction);
                CompQuality compQuality = thing.TryGetComp <CompQuality>();
                if (compQuality != null)
                {
                    QualityCategory q = QualityUtility.GenerateQualityCreatedByPawn(worker, SkillDefOf.Construction);
                    compQuality.SetQuality(q, ArtGenerationContext.Colony);
                    QualityUtility.SendCraftNotification(thing, worker);
                }
                CompArt compArt = thing.TryGetComp <CompArt>();
                if (compArt != null)
                {
                    if (compQuality == null)
                    {
                        compArt.InitializeArt(ArtGenerationContext.Colony);
                    }
                    compArt.JustCreatedBy(worker);
                }
                thing.HitPoints = Mathf.CeilToInt((float)HitPoints / (float)base.MaxHitPoints * (float)thing.MaxHitPoints);
                GenSpawn.Spawn(thing, base.Position, map, base.Rotation, WipeMode.FullRefund);
                Building b;
                if ((b = thing as Building) != null)
                {
                    worker.GetLord()?.AddBuilding(b);
                }
            }
            else
            {
                map.terrainGrid.SetTerrain(base.Position, (TerrainDef)def.entityDefToBuild);
                FilthMaker.RemoveAllFilth(base.Position, map);
            }
            worker.records.Increment(RecordDefOf.ThingsConstructed);
            if (thing != null && thing.GetStatValue(StatDefOf.WorkToBuild) >= 9500f)
            {
                TaleRecorder.RecordTale(TaleDefOf.CompletedLongConstructionProject, worker, thing.def);
            }
        }
コード例 #10
0
        public static QualityCategory GenerateQualityBaseGen()
        {
            QualityCategory result;

            if (Rand.Value < 0.3f)
            {
                result = QualityCategory.Normal;
            }
            else
            {
                result = QualityUtility.GenerateFromGaussian(1f, QualityCategory.Excellent, QualityCategory.Normal, QualityCategory.Awful);
            }
            return(result);
        }
コード例 #11
0
        public static QualityCategory GenerateQualityTraderItem()
        {
            if (Rand.Value < 0.25f)
            {
                return(QualityCategory.Normal);
            }
            QualityCategory qualityCategory = QualityUtility.GenerateFromGaussian(1.18f, QualityCategory.Masterwork, QualityCategory.Normal, QualityCategory.Poor);

            if (qualityCategory == QualityCategory.Poor && Rand.Value < 0.6f)
            {
                qualityCategory = QualityUtility.GenerateFromGaussian(1.18f, QualityCategory.Masterwork, QualityCategory.Normal, QualityCategory.Poor);
            }
            return(qualityCategory);
        }
コード例 #12
0
 private static void CalculateAllowedThingStuffPairs(IEnumerable <ThingDef> allowed, TechLevel techLevel, QualityGenerator qualityGenerator)
 {
     allowedThingStuffPairs.Clear();
     foreach (ThingDef td in allowed)
     {
         for (int i = 0; i < 5; i++)
         {
             if (GenStuff.TryRandomStuffFor(td, out ThingDef stuff, techLevel, (ThingDef x) => !ThingSetMakerUtility.IsDerpAndDisallowed(td, x, qualityGenerator)))
             {
                 QualityCategory quality = td.HasComp(typeof(CompQuality)) ? QualityUtility.GenerateQuality(qualityGenerator) : QualityCategory.Normal;
                 allowedThingStuffPairs.Add(new ThingStuffPairWithQuality(td, stuff, quality));
             }
         }
     }
 }
コード例 #13
0
        internal static void QualityGenerationData()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("Qualities of items/buildings generated from various sources");
            stringBuilder.AppendLine("---------------------------------------------------------------------");
            stringBuilder.AppendLine("Rewards (quests, etc...? )");
            stringBuilder.AppendLine(QualityUtility.DebugQualitiesString(() => QualityUtility.GenerateQualityReward()));
            stringBuilder.AppendLine("Trader items");
            stringBuilder.AppendLine(QualityUtility.DebugQualitiesString(() => QualityUtility.GenerateQualityTraderItem()));
            stringBuilder.AppendLine("Map generation items and buildings (usually NPC bases)");
            stringBuilder.AppendLine(QualityUtility.DebugQualitiesString(() => QualityUtility.GenerateQualityBaseGen()));
            stringBuilder.AppendLine("Gifts");
            stringBuilder.AppendLine(QualityUtility.DebugQualitiesString(() => QualityUtility.GenerateQualityGift()));
            using (IEnumerator <PawnKindDef> enumerator = (from k in DefDatabase <PawnKindDef> .AllDefs
                                                           orderby k.combatPower
                                                           select k).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    PawnKindDef pk = enumerator.Current;
                    if (pk.RaceProps.Humanlike)
                    {
                        stringBuilder.AppendLine(string.Concat(new object[]
                        {
                            "Items generated to equip pawn kind: ",
                            pk.defName,
                            " (",
                            pk.combatPower.ToString("F0"),
                            " points, itemQuality ",
                            pk.itemQuality,
                            ")"
                        }));
                        stringBuilder.Append(QualityUtility.DebugQualitiesString(() => QualityUtility.GenerateQualityGeneratingPawn(pk)));
                        stringBuilder.AppendLine();
                    }
                }
            }
            int level;

            for (level = 0; level <= 20; level++)
            {
                stringBuilder.AppendLine();
                stringBuilder.AppendLine("Items/buildings made by crafter/builder at skill level " + level);
                stringBuilder.Append(QualityUtility.DebugQualitiesString(() => QualityUtility.GenerateQualityCreatedByPawn(level, false)));
            }
            Log.Message(stringBuilder.ToString(), false);
        }
コード例 #14
0
        public static QualityCategory GenerateQuality(QualityGenerator qualityGenerator)
        {
            switch (qualityGenerator)
            {
            case QualityGenerator.BaseGen:
                return(QualityUtility.GenerateQualityBaseGen());

            case QualityGenerator.Reward:
                return(QualityUtility.GenerateQualityReward());

            case QualityGenerator.Gift:
                return(QualityUtility.GenerateQualityGift());

            default:
                throw new NotImplementedException(qualityGenerator.ToString());
            }
        }
コード例 #15
0
        public static QualityCategory GenerateQualityTraderItem()
        {
            QualityCategory result;

            if (Rand.Value < 0.25f)
            {
                result = QualityCategory.Normal;
            }
            else
            {
                QualityCategory qualityCategory = QualityUtility.GenerateFromGaussian(1.18f, QualityCategory.Masterwork, QualityCategory.Normal, QualityCategory.Poor);
                if (qualityCategory == QualityCategory.Poor && Rand.Value < 0.6f)
                {
                    qualityCategory = QualityUtility.GenerateFromGaussian(1.18f, QualityCategory.Masterwork, QualityCategory.Normal, QualityCategory.Poor);
                }
                result = qualityCategory;
            }
            return(result);
        }
コード例 #16
0
 public override void PostPostGeneratedForTrader(TraderKindDef trader, int forTile, Faction forFaction)
 {
     SetQuality(QualityUtility.GenerateQualityTraderItem(), ArtGenerationContext.Outsider);
 }
コード例 #17
0
 public static QualityCategory GenerateQualityReward()
 {
     return(QualityUtility.GenerateFromGaussian(1f, QualityCategory.Legendary, QualityCategory.Excellent, QualityCategory.Good));
 }
コード例 #18
0
 public static QualityCategory RandomBaseGenItemQuality()
 {
     return(QualityUtility.RandomTraderItemQuality());
 }
コード例 #19
0
 private static QualityCategory <QualityGenerationData> m__2()
 {
     return(QualityUtility.GenerateQualityBaseGen());
 }
コード例 #20
0
 internal QualityCategory <> m__1()
 {
     return(QualityUtility.GenerateQualityCreatedByPawn(this.localLevel, false));
 }
コード例 #21
0
 private static void CalculateAllowedThingStuffPairs(IEnumerable <ThingDef> allowed, TechLevel techLevel, QualityGenerator qualityGenerator)
 {
     ThingSetMakerByTotalStatUtility.allowedThingStuffPairs.Clear();
     foreach (ThingDef thingDef in allowed)
     {
         for (int i = 0; i < 5; i++)
         {
             ThingDef stuff;
             if (GenStuff.TryRandomStuffFor(thingDef, out stuff, techLevel))
             {
                 QualityCategory quality = (!thingDef.HasComp(typeof(CompQuality))) ? QualityCategory.Normal : QualityUtility.GenerateQuality(qualityGenerator);
                 ThingSetMakerByTotalStatUtility.allowedThingStuffPairs.Add(new ThingStuffPairWithQuality(thingDef, stuff, quality));
             }
         }
     }
 }
コード例 #22
0
 private static QualityCategory <QualityGenerationData> m__3()
 {
     return(QualityUtility.GenerateQualityGift());
 }
コード例 #23
0
 internal string <> m__0(QualityCategory q)
 {
     return(QualityUtility.DebugQualitiesStringSingle(q, () => QualityUtility.GenerateQualityCreatedByPawn(this.localLevel, false)));
 }
コード例 #24
0
        // Token: 0x060000D7 RID: 215 RVA: 0x000066F8 File Offset: 0x000048F8
        public void CompleteConstruction(Pawn worker)
        {
            Map  map  = base.Map;
            bool flag = this.GetStatValue(StatDefOf.WorkToBuild, true) > 150f && this.def.entityDefToBuild is ThingDef && ((ThingDef)this.def.entityDefToBuild).category == ThingCategory.Building;

            if (flag)
            {
                SoundDefOf.Building_Complete.PlayOneShot(new TargetInfo(base.Position, map, false));
            }
            ThingDef thingDef = this.def.entityDefToBuild as ThingDef;
            Thing    thing    = null;
            bool     flag2    = thingDef != null;

            if (flag2)
            {
                thing = ThingMaker.MakeThing(thingDef, base.Stuff);
                thing.SetFactionDirect(base.Faction);
                CompQuality compQuality = thing.TryGetComp <CompQuality>();
                bool        flag3       = compQuality != null;
                if (flag3)
                {
                    int relevantSkillLevel = 1;
                    compQuality.SetQuality(QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, false), ArtGenerationContext.Colony);
                }
                CompArt compArt = thing.TryGetComp <CompArt>();
                bool    flag4   = compArt != null;
                if (flag4)
                {
                    bool flag5 = compQuality == null;
                    if (flag5)
                    {
                        compArt.InitializeArt(ArtGenerationContext.Colony);
                    }
                    compArt.JustCreatedBy(worker);
                }
                thing.HitPoints = Mathf.CeilToInt((float)this.HitPoints / (float)base.MaxHitPoints * (float)thing.MaxHitPoints);
                GenSpawn.Spawn(thing, base.Position, map, base.Rotation, WipeMode.FullRefund, false);
            }
            else
            {
                map.terrainGrid.SetTerrain(base.Position, (TerrainDef)this.def.entityDefToBuild);
                FilthMaker.RemoveAllFilth(base.Position, map);
            }
            bool flag6 = thingDef != null && (thingDef.passability == Traversability.Impassable || thingDef.Fillage == FillCategory.Full) && (thing == null || !(thing is Building_Door));

            if (flag6)
            {
                foreach (IntVec3 c in GenAdj.CellsOccupiedBy(base.Position, base.Rotation, this.def.Size))
                {
                    foreach (Thing thing2 in map.thingGrid.ThingsAt(c).ToList <Thing>())
                    {
                        bool flag7 = thing2 is Plant;
                        if (flag7)
                        {
                            thing2.Destroy(DestroyMode.KillFinalize);
                        }
                        else
                        {
                            bool flag8 = thing2.def.category == ThingCategory.Item || thing2 is Pawn;
                            if (flag8)
                            {
                                GenPlace.TryPlaceThing(thing2, thing2.Position, thing2.Map, ThingPlaceMode.Near, null, null, default(Rot4));
                            }
                        }
                    }
                }
            }
            worker.records.Increment(RecordDefOf.ThingsConstructed);
        }
コード例 #25
0
 internal QualityCategory <> m__0()
 {
     return(QualityUtility.GenerateQualityGeneratingPawn(this.pk));
 }
コード例 #26
0
        public static QualityCategory GenerateQualityCreatedByPawn(int relevantSkillLevel, bool inspired)
        {
            float num = 0f;

            switch (relevantSkillLevel)
            {
            case 0:
                num += 0.7f;
                break;

            case 1:
                num += 1.1f;
                break;

            case 2:
                num += 1.5f;
                break;

            case 3:
                num += 1.8f;
                break;

            case 4:
                num += 2f;
                break;

            case 5:
                num += 2.2f;
                break;

            case 6:
                num += 2.4f;
                break;

            case 7:
                num += 2.6f;
                break;

            case 8:
                num += 2.8f;
                break;

            case 9:
                num += 2.95f;
                break;

            case 10:
                num += 3.1f;
                break;

            case 11:
                num += 3.25f;
                break;

            case 12:
                num += 3.4f;
                break;

            case 13:
                num += 3.5f;
                break;

            case 14:
                num += 3.6f;
                break;

            case 15:
                num += 3.7f;
                break;

            case 16:
                num += 3.8f;
                break;

            case 17:
                num += 3.9f;
                break;

            case 18:
                num += 4f;
                break;

            case 19:
                num += 4.1f;
                break;

            case 20:
                num += 4.2f;
                break;
            }
            int num2 = (int)Rand.GaussianAsymmetric(num, 0.6f, 0.8f);

            num2 = Mathf.Clamp(num2, 0, 5);
            if (num2 == 5 && Rand.Value < 0.5f)
            {
                num2 = (int)Rand.GaussianAsymmetric(num, 0.6f, 0.95f);
                num2 = Mathf.Clamp(num2, 0, 5);
            }
            QualityCategory qualityCategory = (QualityCategory)num2;

            if (inspired)
            {
                qualityCategory = QualityUtility.AddLevels(qualityCategory, 2);
            }
            return(qualityCategory);
        }
コード例 #27
0
        public void CompleteConstruction(Pawn worker)
        {
            this.resourceContainer.ClearAndDestroyContents(DestroyMode.Vanish);
            Map map = base.Map;

            this.Destroy(DestroyMode.Vanish);
            if (this.GetStatValue(StatDefOf.WorkToBuild, true) > 150.0 && base.def.entityDefToBuild is ThingDef && ((ThingDef)base.def.entityDefToBuild).category == ThingCategory.Building)
            {
                SoundDefOf.BuildingComplete.PlayOneShot(new TargetInfo(base.Position, map, false));
            }
            ThingDef thingDef = base.def.entityDefToBuild as ThingDef;
            Thing    thing    = null;

            if (thingDef != null)
            {
                thing = ThingMaker.MakeThing(thingDef, base.Stuff);
                thing.SetFactionDirect(base.Faction);
                CompQuality compQuality = thing.TryGetComp <CompQuality>();
                if (compQuality != null)
                {
                    int level = worker.skills.GetSkill(SkillDefOf.Construction).Level;
                    compQuality.SetQuality(QualityUtility.RandomCreationQuality(level), ArtGenerationContext.Colony);
                }
                CompArt compArt = thing.TryGetComp <CompArt>();
                if (compArt != null)
                {
                    if (compQuality == null)
                    {
                        compArt.InitializeArt(ArtGenerationContext.Colony);
                    }
                    compArt.JustCreatedBy(worker);
                }
                thing.HitPoints = Mathf.CeilToInt((float)this.HitPoints / (float)base.MaxHitPoints * (float)thing.MaxHitPoints);
                GenSpawn.Spawn(thing, base.Position, map, base.Rotation, false);
            }
            else
            {
                map.terrainGrid.SetTerrain(base.Position, (TerrainDef)base.def.entityDefToBuild);
                FilthMaker.RemoveAllFilth(base.Position, map);
            }
            if (thingDef != null && (thingDef.passability == Traversability.Impassable || thingDef.Fillage == FillCategory.Full) && (thing == null || !(thing is Building_Door)))
            {
                foreach (IntVec3 item in GenAdj.CellsOccupiedBy(base.Position, base.Rotation, base.def.Size))
                {
                    foreach (Thing item2 in map.thingGrid.ThingsAt(item).ToList())
                    {
                        if (item2 is Plant)
                        {
                            item2.Destroy(DestroyMode.KillFinalize);
                        }
                        else if (item2.def.category == ThingCategory.Item || item2 is Pawn)
                        {
                            GenPlace.TryMoveThing(item2, item2.Position, item2.Map);
                        }
                    }
                }
            }
            worker.records.Increment(RecordDefOf.ThingsConstructed);
            if (thing != null && thing.GetStatValue(StatDefOf.WorkToBuild, true) >= 10000.0)
            {
                TaleRecorder.RecordTale(TaleDefOf.CompletedLongConstructionProject, worker, thing.def);
            }
        }
コード例 #28
0
        private Thing GenerateReward(float value, TechLevel techLevel, Predicate <ThingDef> validator = null)
        {
            if (Rand.Chance(0.5f) && (validator == null || validator(ThingDefOf.Silver)))
            {
                Thing thing = ThingMaker.MakeThing(ThingDefOf.Silver, null);
                thing.stackCount = ThingUtility.RoundedResourceStackCount(Mathf.Max(GenMath.RoundRandom(value), 1));
                return(thing);
            }
            ThingDef thingDef = default(ThingDef);

            if (Rand.Chance(0.35f) && (from x in ItemCollectionGeneratorUtility.allGeneratableItems
                                       where x.itemGeneratorTags != null && x.itemGeneratorTags.Contains(ItemCollectionGeneratorUtility.SpecialRewardTag) && (validator == null || validator(x)) && Mathf.Abs((float)(1.0 - x.BaseMarketValue / value)) <= 0.34999999403953552
                                       select x).TryRandomElement <ThingDef>(out thingDef))
            {
                Thing       thing2      = ThingMaker.MakeThing(thingDef, GenStuff.RandomStuffFor(thingDef));
                CompQuality compQuality = thing2.TryGetComp <CompQuality>();
                if (compQuality != null)
                {
                    compQuality.SetQuality(QualityUtility.RandomBaseGenItemQuality(), ArtGenerationContext.Outsider);
                }
                return(thing2);
            }
            if (Rand.Chance(0.13f))
            {
                float    minExpensiveMineableResourceMarketValue = ThingDefOf.Uranium.BaseMarketValue;
                ThingDef thingDef2 = default(ThingDef);
                if ((from x in ItemCollectionGenerator_Meteorite.mineables
                     where x.building.isResourceRock && x.building.mineableThing.BaseMarketValue >= minExpensiveMineableResourceMarketValue && (validator == null || validator(x.building.mineableThing))
                     select x).TryRandomElement <ThingDef>(out thingDef2))
                {
                    float    num           = (float)(value * 0.89999997615814209);
                    ThingDef mineableThing = thingDef2.building.mineableThing;
                    Thing    thing3        = ThingMaker.MakeThing(mineableThing, null);
                    thing3.stackCount = Mathf.Max(GenMath.RoundRandom(num / mineableThing.BaseMarketValue), 1);
                    return(thing3);
                }
            }
            Option option2 = (from option in ItemCollectionGeneratorUtility.allGeneratableItems.Select(delegate(ThingDef td)
            {
                if ((int)td.techLevel > (int)techLevel)
                {
                    return(null);
                }
                if (td.itemGeneratorTags != null && td.itemGeneratorTags.Contains(ItemCollectionGeneratorUtility.SpecialRewardTag))
                {
                    return(null);
                }
                if (!td.IsWithinCategory(ThingCategoryDefOf.Apparel) && !td.IsWithinCategory(ThingCategoryDefOf.Weapons) && !td.IsWithinCategory(ThingCategoryDefOf.Art) && (td.building == null || !td.Minifiable) && (td.tradeTags == null || !td.tradeTags.Contains("Exotic")))
                {
                    return(null);
                }
                if (validator != null && !validator(td))
                {
                    return(null);
                }
                ThingDef stuff = null;
                if (td.MadeFromStuff && !GenStuff.TryRandomStuffByCommonalityFor(td, out stuff, techLevel))
                {
                    return(null);
                }
                Option option3 = new Option();
                option3.thingDef = td;
                option3.quality = ((!td.HasComp(typeof(CompQuality))) ? QualityCategory.Normal : QualityUtility.RandomQuality());
                option3.stuff = stuff;
                return(option3);
            })
                              where option != null
                              select option).MinBy(delegate(Option option)
            {
                float value2 = StatDefOf.MarketValue.Worker.GetValue(StatRequest.For(option.thingDef, option.stuff, option.quality), true);
                return(Mathf.Abs(value - value2));
            });
            Thing       thing4       = ThingMaker.MakeThing(option2.thingDef, option2.stuff);
            CompQuality compQuality2 = thing4.TryGetComp <CompQuality>();

            if (compQuality2 != null)
            {
                compQuality2.SetQuality(option2.quality, ArtGenerationContext.Outsider);
            }
            return(thing4);
        }
コード例 #29
0
 public static QualityCategory GenerateQualityGift()
 {
     return(QualityUtility.GenerateFromGaussian(1f, QualityCategory.Legendary, QualityCategory.Normal, QualityCategory.Normal));
 }
コード例 #30
0
 private static void CalculateAllowedThingStuffPairs(IEnumerable <ThingDef> allowed, TechLevel techLevel, QualityGenerator qualityGenerator)
 {
     allowedThingStuffPairs.Clear();
     foreach (ThingDef item in allowed)
     {
         for (int i = 0; i < 5; i++)
         {
             if (GenStuff.TryRandomStuffFor(item, out ThingDef stuff, techLevel))
             {
                 QualityCategory quality = (!item.HasComp(typeof(CompQuality))) ? QualityCategory.Normal : QualityUtility.GenerateQuality(qualityGenerator);
                 allowedThingStuffPairs.Add(new ThingStuffPairWithQuality(item, stuff, quality));
             }
         }
     }
 }