Ejemplo n.º 1
0
        public static bool operator ==(ThingStuffPairWithQuality a, ThingStuffPairWithQuality b)
        {
            int result;

            if (a.thing == b.thing && a.stuff == b.stuff)
            {
                QualityCategory?qualityCategory  = a.quality;
                QualityCategory valueOrDefault   = qualityCategory.GetValueOrDefault();
                QualityCategory?qualityCategory2 = b.quality;
                result = ((valueOrDefault == qualityCategory2.GetValueOrDefault() && qualityCategory.HasValue == qualityCategory2.HasValue) ? 1 : 0);
            }
            else
            {
                result = 0;
            }
            return((byte)result != 0);
        }
 private RoyalTitleDef Validate(Pawn p, out QualityCategory minQuality)
 {
     minQuality = QualityCategory.Awful;
     foreach (RoyalTitle item in p.royalty.AllTitlesInEffectForReading)
     {
         List <Apparel> wornApparel = p.apparel.WornApparel;
         minQuality = item.def.requiredMinimumApparelQuality;
         for (int i = 0; i < wornApparel.Count; i++)
         {
             if (wornApparel[i].TryGetQuality(out QualityCategory qc) && (int)qc < (int)item.def.requiredMinimumApparelQuality)
             {
                 return(item.def);
             }
         }
     }
     return(null);
 }
Ejemplo n.º 3
0
        public static void AddQualityToEgg(Pawn pawn)
        {
            CompHybrid compMother = GeneticRim_CompHatcher_Hatch_Patch.motherStored?.TryGetComp <CompHybrid>();
            CompHybrid compFather = GeneticRim_CompHatcher_Hatch_Patch.fatherStored?.TryGetComp <CompHybrid>();

            if (compMother != null && compFather != null)
            {
                QualityCategory qualityMother = compMother.quality;
                QualityCategory qualityFather = compFather.quality;

                CompHybrid compHybrid = pawn.TryGetComp <CompHybrid>();
                if (compHybrid != null)
                {
                    compHybrid.quality = (QualityCategory)Math.Min((sbyte)qualityMother, (sbyte)qualityFather);
                }
            }
        }
Ejemplo n.º 4
0
 private static void Postfix(ref QualityCategory __result, Pawn pawn, SkillDef relevantSkill)
 {
     if (pawn.story?.traits?.HasTrait(VTEDefOf.VTE_Perfectionist) ?? false)
     {
         if (__result != QualityCategory.Legendary)
         {
             var newResult = (QualityCategory)((int)__result + 1);
             Log.Message(pawn + " has VTE_Perfectionist, product quality was increased from " + __result + " to " + newResult);
             __result = newResult;
         }
         if (__result == QualityCategory.Normal || __result == QualityCategory.Awful || __result == QualityCategory.Poor)
         {
             pawn.TryGiveThought(VTEDefOf.VTE_CreatedLowQualityItem);
             Log.Message(pawn + " has VTE_Perfectionist, gains VTE_CreatedLowQualityItem thought due to low quality item");
         }
     }
 }
        public static bool operator ==(ThingStuffPairWithQuality a, ThingStuffPairWithQuality b)
        {
            bool arg_5C_0;

            if (a.thing == b.thing && a.stuff == b.stuff)
            {
                QualityCategory?qualityCategory  = a.quality;
                QualityCategory arg_44_0         = qualityCategory.GetValueOrDefault();
                QualityCategory?qualityCategory2 = b.quality;
                arg_5C_0 = (arg_44_0 == qualityCategory2.GetValueOrDefault() && qualityCategory.HasValue == qualityCategory2.HasValue);
            }
            else
            {
                arg_5C_0 = false;
            }
            return(arg_5C_0);
        }
Ejemplo n.º 6
0
        public static bool TryGetQuality(this Thing t, out QualityCategory qc)
        {
            MinifiedThing minifiedThing = t as MinifiedThing;
            CompQuality   compQuality   = (minifiedThing == null) ? t.TryGetComp <CompQuality>() : minifiedThing.InnerThing.TryGetComp <CompQuality>();
            bool          result;

            if (compQuality == null)
            {
                qc     = QualityCategory.Normal;
                result = false;
            }
            else
            {
                qc     = compQuality.Quality;
                result = true;
            }
            return(result);
        }
Ejemplo n.º 7
0
        public static QualityCategory Previous(this QualityCategory qc)
        {
            switch (qc)
            {
            case QualityCategory.Legendary: return(QualityCategory.Masterwork);

            case QualityCategory.Masterwork: return(QualityCategory.Excellent);

            case QualityCategory.Excellent: return(QualityCategory.Good);

            case QualityCategory.Good: return(QualityCategory.Normal);

            case QualityCategory.Normal: return(QualityCategory.Poor);

            default:
                return(QualityCategory.Awful);
            }
        }
        public override bool AllowStackWith(Thing other)
        {
            if (other.TryGetComp <CompQuality>() != null)
            {
                QualityCategory quality1 = other.TryGetComp <CompQuality>().Quality;
                QualityCategory quality2 = this.parent.TryGetComp <CompQuality>().Quality;


                if (quality1 != quality2)
                {
                    return(false);
                }
            }



            return(base.AllowStackWith(other));
        }
        public override void DoEffect(Pawn usedBy)
        {
            base.DoEffect(usedBy);
            Map map = usedBy.MapHeld;

            //DropCellFinder.TryFindDropSpotNear(usedBy.PositionHeld, map, out IntVec3 intVec3, false, false);
            Thing thing1 = ThingMaker.MakeThing(PSFDefOf.Apparel_PolarisShieldBelt_II);
            Thing thing2 = ThingMaker.MakeThing(PSFDefOf.Polarisbloc_CygnusStandardArmor);
            Thing thing3 = ThingMaker.MakeThing(PSFDefOf.Polarisbloc_CygnusStandardTights);
            Thing thing4 = ThingMaker.MakeThing(PSFDefOf.Polarisbloc_AlkaidStrategyAssistant);
            Thing thing5 = ThingMaker.MakeThing(PSFDefOf.Polarisbloc_ThubanTacticalGoggles);
            Thing thing6 = ThingMaker.MakeThing(PSFDefOf.Polarisbloc_CaniculaRifle);
            Thing thing7 = ThingMaker.MakeThing(PSFDefOf.Polarisbloc_EmergencyFood);

            thing7.stackCount = 5;
            List <Thing> things = new List <Thing>
            {
                thing1,
                thing2,
                thing3,
                thing4,
                thing5,
                thing6,
                thing7
            };

            if (this.parent.GetComp <CompQuality>() != null)
            {
                QualityCategory quality = this.parent.GetComp <CompQuality>().Quality;
                foreach (Thing qThing in from x in things
                         where x.TryGetComp <CompQuality>() != null
                         select x)
                {
                    qThing.TryGetComp <CompQuality>().SetQuality(quality, ArtGenerationContext.Outsider);
                }
            }
            //DropPodUtility.DropThingsNear(intVec3, map, things, 110, false, false, true, false);
            //Find.LetterStack.ReceiveLetter("LetterLabelPolarisblocGetDropSupply".Translate(), "PolarisblocGetDropSupply".Translate(), LetterDefOf.PositiveEvent, new TargetInfo(intVec3, map, false), null);
            foreach (Thing thing in things)
            {
                GenPlace.TryPlaceThing(thing, usedBy.PositionHeld, usedBy.MapHeld, ThingPlaceMode.Near);
            }
            return;
        }
Ejemplo n.º 10
0
        static IEnumerator <float> RollChance(ChanceDef chanceDef, Thing thing, QualityCategory q)
        {
            foreach (var slotChance in chanceDef.slots)
            {
                float chance = chanceDef.Chance(q) * slotChance;
                bool  roll   = Rand.Chance(chance);
                #if DEBUG
                Log.Message($"   > Rolled {roll} with {chance}");
                #endif
                if (roll)
                {
                    yield return(chance);
                }
                else
                {
                    break;
                }
            }

            if (thing.def.apparel != null && chanceDef.slotBonusPerParts > 0)
            {
                int bonus = thing.def.apparel.bodyPartGroups.Count % chanceDef.slotBonusPerParts;

                float firstSlotChance = chanceDef.slots.FirstOrFallback(1f);

                #if DEBUG
                Log.Message($"   + Bonus {bonus}");
                #endif

                for (int i = 1; i <= bonus; i++)
                {
                    float chance = chanceDef.Chance(q) * firstSlotChance * 0.8f / i;

                    if (Rand.Chance(chance))
                    {
                        yield return(chance);
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }
Ejemplo n.º 11
0
        //Quality - Building
        public static bool ChangeQuality(Building building, CompQuality comp = null, bool better = true)
        {
            if (comp == null)
            {
                comp = building?.TryGetComp <CompQuality>();
            }

            if (comp == null)
            {
                return(false);
            }

            QualityCategory myQuality = comp.Quality;
            QualityCategory remember  = myQuality;

            if (better)
            {
                if (myQuality != QualityCategory.Legendary)
                {
                    myQuality = myQuality + 1;
                }
            }
            else
            {
                if (myQuality != QualityCategory.Awful)
                {
                    myQuality = myQuality - 1;
                }
            }

            /*
             * if (better)
             * {
             *  comp?.SetQuality(myQuality.AddLevels(1), ArtGenerationContext.Colony);
             *
             * }
             * else
             * {
             *  comp.SetQuality(myQuality.AddLevels(-1), ArtGenerationContext.Colony);
             * }
             */

            return(remember != myQuality);
        }
Ejemplo n.º 12
0
        static void Postfix(Pawn pawn, SkillDef relevantSkill, ref QualityCategory __result)
        {
            if (__result == QualityCategory.Legendary)
            {
                return; // Can't improve.
            }
            bool mod = relevantSkill == SkillDefOf.Construction || relevantSkill == SkillDefOf.Crafting;

            if (!mod)
            {
                return; // Doesn't affect art or other work types...
            }
            if (pawn?.story?.traits == null)
            {
                return;
            }
            if (!pawn.story.traits.HasTrait(RFDefOf.RF_BlessingOfZir))
            {
                return;
            }

            // Bump up quality one level.
            // For reference, an inspiration increases it 2 levels.
            var old = __result;

            if (__result < QualityCategory.Normal)
            {
                __result = QualityCategory.Normal;
            }
            else
            {
                __result += 1;
            }

            if (pawn.IsColonist)
            {
                Vector3 pos = pawn.DrawPos + new Vector3(0, 0, 1);
                pos.y = AltitudeLayer.MoteOverhead.AltitudeFor();
                MoteMaker.ThrowText(pos, pawn.Map, "RF.Blessing.IncreasedMessage".Translate(__result.GetLabel()), Color.green);
            }

            Core.Log($"Running Blessing of Zir on {pawn.LabelCap}: increased quality to {__result} from {old}");
        }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
0
        static void Postfix(int relevantSkillLevel, bool inspired, ref QualityCategory __result)
        {
            var setting = LoadedModManager.GetMod <Mod_RW_Tweak>().Setting;

            if (!setting.noRandomQuality)
            {
                return;
            }
            for (var i = 0; i < setting.qualityThreshold.Count; i++)
            {
                if (relevantSkillLevel <= setting.qualityThreshold[i])
                {
                    __result = (QualityCategory)i;
                    return;
                }
            }

            __result = QualityCategory.Legendary;
        }
Ejemplo n.º 15
0
 private static void Postfix(ref QualityCategory __result, Pawn pawn, SkillDef relevantSkill, bool __state)
 {
     if (pawn.HasTrait(VTEDefOf.VTE_Perfectionist))
     {
         if (__result != QualityCategory.Legendary)
         {
             var newResult = (QualityCategory)((int)__result + 1);
             __result = newResult;
         }
         if (__result == QualityCategory.Normal || __result == QualityCategory.Awful || __result == QualityCategory.Poor)
         {
             pawn.TryGiveThought(VTEDefOf.VTE_CreatedLowQualityItem);
         }
         if (__result == QualityCategory.Legendary && !__state)
         {
             __result = QualityCategory.Masterwork;
         }
     }
 }
Ejemplo n.º 16
0
        public float GetPriceMultiplierForQuality(QualityCategory qualityCategory)
        {
            switch (qualityCategory)
            {
            case QualityCategory.Awful:
            {
                return(0.8f);
            }

            case QualityCategory.Poor:
            {
                return(0.9f);
            }

            case QualityCategory.Normal:
            {
                return(1f);
            }

            case QualityCategory.Good:
            {
                return(1.1f);
            }

            case QualityCategory.Excellent:
            {
                return(1.2f);
            }

            case QualityCategory.Masterwork:
            {
                return(1.3f);
            }

            case QualityCategory.Legendary:
            {
                return(1.5f);
            }
            }

            return(1f);
        }
Ejemplo n.º 17
0
        public static void Prefix(ResolveParams rp)
        {
            if (SurvivalToolsSettings.toolMapGen)
            {
                List <Thing> things = ST_ThingSetMakerDefOf.MapGen_AncientRuinsSurvivalTools.root.Generate();
                foreach (Thing thing in things)
                {
                    // Custom quality generator
                    if (thing.TryGetComp <CompQuality>() is CompQuality qualityComp)
                    {
                        QualityCategory newQuality = (QualityCategory)(AccessTools.Method(typeof(QualityUtility), "GenerateFromGaussian").
                                                                       Invoke(null, new object[] { 1f, QualityCategory.Normal, QualityCategory.Poor, QualityCategory.Awful }));
                        qualityComp.SetQuality(newQuality, ArtGenerationContext.Outsider);
                    }

                    // Set stuff
                    if (thing.def.MadeFromStuff)
                    {
                        // All stuff which the tool can be made from and has a market value of less than or equal to 3, excluding small-volume
                        List <ThingDef> validStuff = DefDatabase <ThingDef> .AllDefsListForReading.Where(
                            t => !t.smallVolume && t.IsStuff &&
                            GenStuff.AllowedStuffsFor(thing.def).Contains(t) &&
                            t.BaseMarketValue <= SurvivalToolUtility.MapGenToolMaxStuffMarketValue).ToList();

                        // Set random stuff based on stuff's market value and commonality
                        thing.SetStuffDirect(validStuff.RandomElementByWeight(
                                                 t => StuffMarketValueRemainderToCommonalityCurve.Evaluate(SurvivalToolUtility.MapGenToolMaxStuffMarketValue - t.BaseMarketValue) *
                                                 t.stuffProps?.commonality ?? 1f));
                    }

                    // Set hit points
                    if (thing.def.useHitPoints)
                    {
                        thing.HitPoints = Mathf.RoundToInt(thing.MaxHitPoints * SurvivalToolUtility.MapGenToolHitPointsRange.RandomInRange);
                    }

                    rp.singleThingToSpawn = thing;
                    BaseGen.symbolStack.Push("thing", rp);
                }
            }
        }
Ejemplo n.º 18
0
        public static StatRequest For(BuildableDef def, ThingDef stuffDef, QualityCategory quality = QualityCategory.Normal)
        {
            StatRequest result;

            if (def == null)
            {
                Log.Error("StatRequest for null def.", false);
                result = StatRequest.ForEmpty();
            }
            else
            {
                result = new StatRequest
                {
                    thingInt           = null,
                    defInt             = def,
                    stuffDefInt        = stuffDef,
                    qualityCategoryInt = quality
                };
            }
            return(result);
        }
        public static void SetRandomQualityWeighted(this Thing thing, QualityCategory minQuality = QualityCategory.Awful, QualityCategory maxQuality = QualityCategory.Legendary)
        {
            var val = Random.Range(0, 1f);
            var min = (int)minQuality;
            var max = (int)maxQuality;

            QualityCategory clamp(int toClamp)
            {
                return((QualityCategory)Mathf.Max(Mathf.Min(toClamp, max), min));
            }

            if (val < .05)
            {
                thing.SetQuality(clamp(0));
            }
            else if (val < .2)
            {
                thing.SetQuality(clamp(1));
            }
            else if (val < .6)
            {
                thing.SetQuality(clamp(2));
            }
            else if (val < .85)
            {
                thing.SetQuality(clamp(3));
            }
            else if (val < .95)
            {
                thing.SetQuality(clamp(4));
            }
            else if (val < .98)
            {
                thing.SetQuality(clamp(5));
            }
            else
            {
                thing.SetQuality(clamp(6));
            }
        }
Ejemplo n.º 20
0
        public static string GetLabel(this QualityCategory cat)
        {
            string result;

            switch (cat)
            {
            case QualityCategory.Awful:
                result = "QualityCategory_Awful".Translate();
                break;

            case QualityCategory.Poor:
                result = "QualityCategory_Poor".Translate();
                break;

            case QualityCategory.Normal:
                result = "QualityCategory_Normal".Translate();
                break;

            case QualityCategory.Good:
                result = "QualityCategory_Good".Translate();
                break;

            case QualityCategory.Excellent:
                result = "QualityCategory_Excellent".Translate();
                break;

            case QualityCategory.Masterwork:
                result = "QualityCategory_Masterwork".Translate();
                break;

            case QualityCategory.Legendary:
                result = "QualityCategory_Legendary".Translate();
                break;

            default:
                throw new ArgumentException();
            }
            return(result);
        }
        private static string DebugQualitiesString(Func <QualityCategory> qualityGenerator)
        {
            int                    num           = 10000;
            StringBuilder          stringBuilder = new StringBuilder();
            List <QualityCategory> list          = new List <QualityCategory>();

            for (int i = 0; i < num; i++)
            {
                list.Add(qualityGenerator());
            }
            using (List <QualityCategory> .Enumerator enumerator = QualityUtility.AllQualityCategories.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    QualityCategory qu = enumerator.Current;
                    stringBuilder.AppendLine(qu.ToString() + " - " + ((float)(from q in list
                                                                              where q == qu
                                                                              select q).Count <QualityCategory>() / (float)num).ToStringPercent());
                }
            }
            return(stringBuilder.ToString());
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Draw choices for preview quality.
        /// </summary>
        /// <param name="widgetRow"> Helper for drawing. </param>
        protected virtual void DrawPreviewQuality(WidgetRow widgetRow)
        {
            ValidateArg.NotNull(widgetRow, nameof(widgetRow));

            GUI.color   = Color.grey;
            Text.Anchor = TextAnchor.MiddleLeft;
            widgetRow.LabelWithHighlight(UIText.PreviewQuality.TranslateSimple(), UIText.PreviewQualityTooltip.TranslateSimple());
            GUI.color = Color.white;

            if (widgetRow.ButtonIcon(TexResource.TriangleLeft))
            {
                _qualityPreview = _qualityPreview.Previous();
            }

            Text.Anchor = TextAnchor.MiddleCenter;
            widgetRow.Label(_qualityPreview.GetLabel(), GenUI.GetWidthCached(UIText.TenCharsString));

            if (widgetRow.ButtonIcon(TexResource.TriangleRight))
            {
                _qualityPreview = _qualityPreview.Next();
            }
        }
Ejemplo n.º 23
0
        static QualityUtility()
        {
            AllQualityCategories = new List <QualityCategory>();
            IEnumerator enumerator = Enum.GetValues(typeof(QualityCategory)).GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    QualityCategory item = (QualityCategory)enumerator.Current;
                    AllQualityCategories.Add(item);
                }
            }
            finally
            {
                IDisposable disposable;
                if ((disposable = (enumerator as IDisposable)) != null)
                {
                    disposable.Dispose();
                }
            }
        }
        private float QualityMultiplier(QualityCategory qc)
        {
            float result;

            switch (qc)
            {
            case QualityCategory.Awful:
                result = this.factorAwful;
                break;

            case QualityCategory.Poor:
                result = this.factorPoor;
                break;

            case QualityCategory.Normal:
                result = this.factorNormal;
                break;

            case QualityCategory.Good:
                result = this.factorGood;
                break;

            case QualityCategory.Excellent:
                result = this.factorExcellent;
                break;

            case QualityCategory.Masterwork:
                result = this.factorMasterwork;
                break;

            case QualityCategory.Legendary:
                result = this.factorLegendary;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(result);
        }
Ejemplo n.º 25
0
 private void CacheTradeables()
 {
     this.cachedCurrencyTradeable = (from x in TradeSession.deal.AllTradeables
                                     where x.IsCurrency
                                     select x).FirstOrDefault();
     this.cachedTradeables = (from tr in TradeSession.deal.AllTradeables
                              where !tr.IsCurrency
                              orderby(!tr.TraderWillTrade) ? (-1) : 0 descending
                              select tr).ThenBy((Tradeable tr) => tr, this.sorter1.Comparer).ThenBy((Tradeable tr) => tr, this.sorter2.Comparer).ThenBy(TransferableUIUtility.DefaultListOrderPriority)
                             .ThenBy((Tradeable tr) => tr.ThingDef.label)
                             .ThenBy(delegate(Tradeable tr)
     {
         QualityCategory result = default(QualityCategory);
         if (tr.AnyThing.TryGetQuality(out result))
         {
             return((int)result);
         }
         return(-1);
     })
                             .ThenBy((Tradeable tr) => tr.AnyThing.HitPoints)
                             .ToList();
 }
        static QualityUtility()
        {
            IEnumerator enumerator = Enum.GetValues(typeof(QualityCategory)).GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    object          obj  = enumerator.Current;
                    QualityCategory item = (QualityCategory)obj;
                    QualityUtility.AllQualityCategories.Add(item);
                }
            }
            finally
            {
                IDisposable disposable;
                if ((disposable = (enumerator as IDisposable)) != null)
                {
                    disposable.Dispose();
                }
            }
        }
Ejemplo n.º 27
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.");
                }
                int             level           = worker.skills.GetSkill(recipeDef.workSkill).Level;
                QualityCategory qualityCategory = QualityUtility.RandomCreationQuality(level);
                if (worker.InspirationDef == InspirationDefOf.InspiredArt && (product.def.IsArt || (product.def.minifiedDef != null && product.def.minifiedDef.IsArt)))
                {
                    qualityCategory = qualityCategory.AddLevels(3);
                    worker.mindState.inspirationHandler.EndInspiration(InspirationDefOf.InspiredArt);
                }
                compQuality.SetQuality(qualityCategory, ArtGenerationContext.Colony);
            }
            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
     {
         // 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());
     }
 }
Ejemplo n.º 29
0
        public static Thing MakeThingWithoutID(ThingDef def, ThingDef stuff, QualityCategory quality)
        {
            Thing thing = (Thing)Activator.CreateInstance(def.thingClass);

            thing.def = def;
            if (def.MadeFromStuff)
            {
                thing.SetStuffDirect(stuff);
            }
            if (thing.def.useHitPoints)
            {
                thing.HitPoints = thing.MaxHitPoints;
            }

            if (thing is ThingWithComps thingWithComps)
            {
                thingWithComps.InitializeComps();
            }

            thing.TryGetComp <CompQuality>()?.SetQuality(quality, ArtGenerationContext.Outsider);

            return(thing);
        }
        public override void Execute(int amount, string boughtBy)
        {
            var weaponThingDefs = DefDatabase <ThingDef> .AllDefs.Where(def => { return(def.equipmentType == EquipmentType.Primary); });

            var randomWeaponDefList = weaponThingDefs.ToList().TakeRandom(amount);
            var weaponThings        = randomWeaponDefList.Select(weaponDef => {
                var stuffForThing = GenStuff.RandomStuffFor(weaponDef);
                var thing         = ThingMaker.MakeThing(weaponDef, stuffForThing);
                thing.SetForbidden(true);

                var thingQualityComp = thing.TryGetComp <CompQuality>();
                if (thingQualityComp != null)
                {
                    Array qualityValues           = Enum.GetValues(typeof(QualityCategory));
                    QualityCategory randomQuality = (QualityCategory)qualityValues.GetValue(Rand.Range(0, qualityValues.Length));

                    thingQualityComp.SetQuality(randomQuality, ArtGenerationContext.Colony);
                }
                return(thing);
            });

            DropPodManager.createDropOfThings(weaponThings.ToList(), Name, Description);
        }
Ejemplo n.º 31
0
 private static void GeneratePawnWeapon(ref Pawn pawn, QualityCategory weaponQuality, ThingDef weaponDef)
 {
     ThingWithComps weapon = ThingMaker.MakeThing(weaponDef) as ThingWithComps;
     weapon.TryGetComp<CompQuality>().SetQuality(weaponQuality, ArtGenerationContext.Outsider);
     pawn.equipment.AddEquipment(weapon);
 }
Ejemplo n.º 32
0
 private static void GeneratePawnApparel(ref Pawn pawn, QualityCategory apparelQuality, ThingDef apparelDef, ThingDef apparelStuff, Color apparelColor, bool applyColor = true)
 {
     Apparel apparel = ThingMaker.MakeThing(apparelDef, apparelStuff) as Apparel;
     if (applyColor)
     {
         apparel.SetColor(apparelColor);
     }
     apparel.TryGetComp<CompQuality>().SetQuality(apparelQuality, ArtGenerationContext.Outsider);
     pawn.apparel.Wear(apparel);
 }