public static void PostProcessGeneratedGear(Thing gear, Pawn pawn)
        {
            CompQuality compQuality = gear.TryGetComp <CompQuality>();

            if (compQuality != null)
            {
                QualityCategory q = QualityUtility.GenerateQualityGeneratingPawn(pawn.kindDef);
                if (pawn.royalty != null && pawn.Faction != null)
                {
                    RoyalTitleDef currentTitle = pawn.royalty.GetCurrentTitle(pawn.Faction);
                    if (currentTitle != null)
                    {
                        q = (QualityCategory)Mathf.Clamp((int)QualityUtility.GenerateQualityGeneratingPawn(pawn.kindDef), (int)currentTitle.requiredMinimumApparelQuality, 6);
                    }
                }
                compQuality.SetQuality(q, ArtGenerationContext.Outsider);
            }
            if (gear.def.useHitPoints)
            {
                float randomInRange = pawn.kindDef.gearHealthRange.RandomInRange;
                if (randomInRange < 1f)
                {
                    int b = Mathf.RoundToInt(randomInRange * (float)gear.MaxHitPoints);
                    b = (gear.HitPoints = Mathf.Max(1, b));
                }
            }
        }
Esempio n. 2
0
        // Token: 0x0600003D RID: 61 RVA: 0x0000347A File Offset: 0x0000167A
        protected override IEnumerable <Toil> MakeNewToils()
        {
            yield return(Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch));

            yield return(Toils_Haul.StartCarryThing(TargetIndex.B, false, false, false));

            yield return(Toils_Haul.CarryHauledThingToCell(TargetIndex.A));

            yield return(new Toil
            {
                initAction = delegate()
                {
                    Venue.rehearsing = true;
                    CompArt compArt = Art.TryGetComp <CompArt>();
                    CompQuality compQuality = Art.TryGetComp <CompQuality>();
                    if (compArt != null && compQuality != null)
                    {
                        Venue.artistName = compArt.AuthorName;
                        Venue.artTitle = compArt.Title;
                        Venue.artQuality = compQuality.Quality;
                    }
                    Art.Destroy(DestroyMode.Vanish);
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            });

            yield break;
        }
Esempio n. 3
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 ((int)compQuality.Quality >= 6)
                {
                    TaleRecorder.RecordTale(TaleDefOf.CraftedArt, worker, product);
                }
            }
            if (product.def.Minifiable)
            {
                product = product.MakeMinified();
            }
            return(product);
        }
Esempio n. 4
0
            public List <Thing> createProducts()
            {
                List <Thing> generatedProducts = new List <Thing>();

                foreach (ProductConfig pc in products)
                {
                    Thing t;
                    if (pc.countClass.thingDef.MadeFromStuff)
                    {
                        t = ThingMaker.MakeThing(pc.countClass.thingDef, pc.stuff);
                    }
                    else
                    {
                        t = ThingMaker.MakeThing(pc.countClass.thingDef, null);
                    }
                    t.stackCount = pc.countClass.count;
                    MinifiedThing minifiedThing = t as MinifiedThing;
                    CompQuality   compQuality   = (minifiedThing == null) ? t.TryGetComp <CompQuality>() : minifiedThing.InnerThing.TryGetComp <CompQuality>();
                    if (compQuality != null)
                    {
                        compQuality.SetQuality(pc.quality, ArtGenerationContext.Outsider);
                    }
                    generatedProducts.Add(t);
                }
                return(generatedProducts);
            }
Esempio n. 5
0
        public static string VirtualQuality(CompQuality comp, int relativeChange = 0)
        {
            string answer = "no quality comp";

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

            QualityCategory qualityCategory = QualityCategory.Normal;

            answer = comp.Quality.ToString();

            if (relativeChange > 0)
            {
                if (comp.Quality != QualityCategory.Legendary)
                {
                    qualityCategory = comp.Quality + 1;
                }
            }
            else
            {
                if (comp.Quality != QualityCategory.Awful)
                {
                    qualityCategory = comp.Quality - 1;
                }
            }
            //answer = comp.Quality.AddLevels(relativeChange).GetLabelShort();

            answer = qualityCategory.ToString();

            return(answer);
        }
Esempio n. 6
0
        public static void DebugSpawn(ThingDef def, IntVec3 c, int stackCount = -1, bool direct = false)
        {
            if (stackCount <= 0)
            {
                stackCount = def.stackLimit;
            }
            ThingDef    stuff       = GenStuff.RandomStuffFor(def);
            Thing       thing       = ThingMaker.MakeThing(def, stuff);
            CompQuality compQuality = thing.TryGetComp <CompQuality>();

            if (compQuality != null)
            {
                compQuality.SetQuality(QualityUtility.RandomQuality(), ArtGenerationContext.Colony);
            }
            if (thing.def.Minifiable)
            {
                thing = thing.MakeMinified();
            }
            thing.stackCount = stackCount;
            if (direct)
            {
                GenPlace.TryPlaceThing(thing, c, Find.VisibleMap, ThingPlaceMode.Direct, null);
            }
            else
            {
                GenPlace.TryPlaceThing(thing, c, Find.VisibleMap, ThingPlaceMode.Near, null);
            }
        }
Esempio n. 7
0
        private static Thing CreateRandomItem(Pawn visitor, ThingDef thingDef)
        {
            ThingDef stuff = GenStuff.RandomStuffFor(thingDef);
            var      item  = ThingMaker.MakeThing(thingDef, stuff);

            item.stackCount = 1;

            CompQuality compQuality = item.TryGetComp <CompQuality>();

            if (compQuality != null)
            {
                compQuality.SetQuality(QualityUtility.RandomGeneratedGearQuality(visitor.kindDef), ArtGenerationContext.Outsider);
            }
            if (item.def.Minifiable)
            {
                item = item.MakeMinified();
            }
            if (item.def.useHitPoints)
            {
                // Make sure health is at least 60%. Otherwise too expensive items can become gifts.
                const float minHealthPct = 0.6f;
                var         healthRange  = visitor.kindDef.gearHealthRange;
                healthRange.min = minHealthPct;
                healthRange.max = Mathf.Max(minHealthPct, healthRange.max);

                var healthPct = healthRange.RandomInRange;
                if (healthPct < 1)
                {
                    int num = Mathf.RoundToInt(healthPct * item.MaxHitPoints);
                    num            = Mathf.Max(1, num);
                    item.HitPoints = num;
                }
            }
            return(item);
        }
Esempio n. 8
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;
                }
            }

            return(remember != myQuality);
        }
Esempio n. 9
0
        public Thing FromRealmThing(RealmThing realmThing)
        {
            ThingDef thingDef = DefDatabase <ThingDef> .AllDefs.First((def) => { return(def.defName == realmThing.thingDefName); });

            ThingDef stuffDef = null;

            if (realmThing.stuffDefName != "")
            {
                stuffDef = DefDatabase <ThingDef> .AllDefs.First((def) => { return(def.defName == realmThing.stuffDefName); });
            }
            Thing thing = ThingMaker.MakeThing(thingDef, stuffDef);

            thing.stackCount = realmThing.stackCount;

            CompQuality compQuality = thing.TryGetComp <CompQuality>();

            if (compQuality != null && realmThing.compQuality != -1)
            {
                compQuality.SetQuality((QualityCategory)realmThing.compQuality, ArtGenerationContext.Outsider);
            }

            thing.HitPoints = realmThing.hitPoints;

            // Minimified thing
            if (thing is MinifiedThing)
            {
                MinifiedThing minifiedThing = (MinifiedThing)thing;

                minifiedThing.InnerThing = FromRealmThing(realmThing.innerThing);
            }

            return(thing);
        }
        public static List <Thing> GenerateWeaponsCacheReward(int gunCount)
        {
            List <Thing> returnList = new List <Thing>();

            IEnumerable <ThingDef> weaponList = (from x in ThingSetMakerUtility.allGeneratableItems
                                                 where x.weaponTags != null && (x.weaponTags.Contains("SpacerGun") || x.weaponTags.Contains("SniperRifle") || x.weaponTags.Contains("GunHeavy") || x.weaponTags.Contains("IndustrialGunAdvanced"))
                                                 select x);

            for (int i = 0; i < gunCount; i++)
            {
                ThingDef thingDef;
                weaponList.TryRandomElement(out thingDef);
                if (thingDef == null)
                {
                    Log.Error("Could not resolve thingdef to spawn weapons");
                    continue;
                }
                Thing       weapon      = ThingMaker.MakeThing(thingDef);
                CompQuality compQuality = weapon.TryGetComp <CompQuality>();
                if (compQuality != null)
                {
                    compQuality.SetQuality(QualityUtility.GenerateQualityTraderItem(), ArtGenerationContext.Outsider);
                }
                returnList.Add(weapon);
            }

            return(returnList);
        }
Esempio n. 11
0
        public RealmThing ToRealmThing(Thing thing)
        {
            string stuffDefLabel = thing.Stuff != null ? thing.Stuff.defName : "";

            int         compQualityRaw = -1;
            CompQuality compQuality    = thing.TryGetComp <CompQuality>();

            if (compQuality != null)
            {
                compQualityRaw = (int)thing.TryGetComp <CompQuality>().Quality;
            }

            // Minimified thing
            RealmThing innerThing = null;

            if (thing is MinifiedThing)
            {
                MinifiedThing minifiedThing = (MinifiedThing)thing;

                innerThing = ToRealmThing(minifiedThing.InnerThing);
            }

            return(new RealmThing
            {
                thingDefName = thing.def.defName,
                stackCount = thing.stackCount,
                stuffDefName = stuffDefLabel,
                compQuality = compQualityRaw,
                hitPoints = thing.HitPoints,
                innerThing = innerThing
            });
        }
        static void Postfix(CompQuality __instance, QualityCategory q, ArtGenerationContext source)
        {
            // Can we be infused?
            CompInfusion compInfusion = __instance.parent.TryGetComp <CompInfusion> ();

            if (compInfusion != null)
            {
                var thing = __instance.parent;
                var def   = __instance.parent.def;
                // Get those Infusions rolling
                var prefix = roll(thing, q);
                var suffix = roll(thing, q);

                var tierMult = def.techLevel < TechLevel.Industrial ? 3 : 1;

                if (prefix)
                {
                    compInfusion.InitializeInfusionPrefix(GenInfusion.GetTier(q, tierMult));
                }
                if (suffix)
                {
                    compInfusion.InitializeInfusionSuffix(GenInfusion.GetTier(q, tierMult));
                }
                if (prefix || suffix)
                {
                    __instance.parent.HitPoints = __instance.parent.MaxHitPoints;
                }
            }
        }
Esempio n. 13
0
        private static Thing CreateRandomItem(Pawn visitor, ThingDef thingDef)
        {
            ThingDef stuff = GenStuff.RandomStuffFor(thingDef);
            var      item  = ThingMaker.MakeThing(thingDef, stuff);

            item.stackCount = 1;

            CompQuality compQuality = item.TryGetComp <CompQuality>();

            if (compQuality != null)
            {
                compQuality.SetQuality(QualityUtility.RandomGeneratedGearQuality(visitor.kindDef), ArtGenerationContext.Outsider);
            }
            if (item.def.Minifiable)
            {
                item = item.MakeMinified();
            }
            if (item.def.useHitPoints)
            {
                float randomInRange = visitor.kindDef.gearHealthRange.RandomInRange;
                if (randomInRange < 1f)
                {
                    int num = Mathf.RoundToInt(randomInRange * item.MaxHitPoints);
                    num            = Mathf.Max(1, num);
                    item.HitPoints = num;
                }
            }
            return(item);
        }
        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);
        }
        // Token: 0x06001566 RID: 5478 RVA: 0x0007D285 File Offset: 0x0007B485
        public Graphic SubGraphicFor(Thing thing)
        {
            CompAdvancedGraphic comp    = thing.TryGetComp <CompAdvancedGraphic>();
            CompQuality         quality = thing.TryGetComp <CompQuality>();
            CompArt             art     = thing.TryGetComp <CompArt>();

            if (comp != null)
            {
                //	Log.Message("SubGraphicFor "+ thing.Label + " found CompAdvancedGraphic int " + comp.gfxint);
                if (!comp.Props.onlyArtable || (art != null && art.Active))
                {
                    if (comp.Props.quality)
                    {
                        return(this.SubGraphicForQuality(thing, comp));
                    }
                    if (comp.Props.randomised)
                    {
                        return(this.SubGraphicRandomized(thing, comp));
                    }
                }
                if (!comp.Props.tagged.NullOrEmpty())
                {
                    Graphic sub = subGraphics.FirstOrDefault(x => x.path.Contains(comp.Props.tagged));
                    if (sub != null)
                    {
                        return(subGraphics.FirstOrDefault(x => x.path.Contains(comp.Props.tagged)));
                    }
                }
            }
            else
            {
                //	Log.Message("SubGraphicFor " + thing.Label + " Didnt find CompAdvancedGraphic");
            }
            return(this.subGraphics[0]);
        }
Esempio n. 16
0
        public bool CountValidThing(Thing thing, Bill_Production bill, ThingDef def)
        {
            ThingDef def2 = thing.def;

            if (def2 != def)
            {
                return(false);
            }
            if (!bill.includeTainted && def2.IsApparel && ((Apparel)thing).WornByCorpse)
            {
                return(false);
            }
            if (thing.def.useHitPoints && !bill.hpRange.IncludesEpsilon((float)thing.HitPoints / (float)thing.MaxHitPoints))
            {
                return(false);
            }
            CompQuality compQuality = thing.TryGetComp <CompQuality>();

            if (compQuality != null && !bill.qualityRange.Includes(compQuality.Quality))
            {
                return(false);
            }
            if (bill.limitToAllowedStuff && !bill.ingredientFilter.Allows(thing.Stuff))
            {
                return(false);
            }
            return(true);
        }
Esempio n. 17
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);
        }
Esempio n. 18
0
        void ThrowMote()
        {
            CompQuality compQuality = parent.TryGetComp <CompQuality>();

            if (compQuality == null)
            {
                return;
            }
            string qualityLabel = compQuality.Quality.GetLabel();

            var msg = new StringBuilder();

            msg.Append(qualityLabel);
            msg.Append(" ");
            if (parent.Stuff != null)
            {
                msg.Append(parent.Stuff.LabelAsStuff);
                msg.Append(" ");
            }
            msg.Append(parent.def.label);
            Messages.Message(ResourceBank.Strings.Notice(msg.ToString()), new RimWorld.Planet.GlobalTargetInfo(parent), MessageTypeDefOf.SilentInput);

            ResourceBank.Sounds.Infused.PlayOneShotOnCamera();

            MoteMaker.ThrowText(parent.Position.ToVector3Shifted(), this.parent.Map, ResourceBank.Strings.Mote, ResourceBank.Colors.Legendary);

            isNew = false;
        }
Esempio n. 19
0
        public Thing FromRealmThing(RealmThing realmThing)
        {
            ThingDef thingDef = DefDatabase <ThingDef> .AllDefs.First((def) => { return(def.label == realmThing.thingDefLabel); });

            ThingDef stuffDef = null;

            if (realmThing.stuffDefLabel != "")
            {
                stuffDef = DefDatabase <ThingDef> .AllDefs.First((def) => { return(def.label == realmThing.stuffDefLabel); });
            }
            Thing thing = ThingMaker.MakeThing(thingDef, stuffDef);

            thing.stackCount = realmThing.stackCount;

            CompQuality compQuality = thing.TryGetComp <CompQuality>();

            if (compQuality != null && realmThing.compQuality != -1)
            {
                compQuality.SetQuality((QualityCategory)realmThing.compQuality, ArtGenerationContext.Outsider);
            }

            thing.HitPoints = realmThing.hitPoints;

            return(thing);
        }
Esempio n. 20
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);
        }
Esempio n. 21
0
        public static void _SendCraftNotification(Thing thing, Pawn worker)

        {
            Nrcq_settings cnSetting = new Nrcq_settings();

            if (worker == null || cnSetting.crafting_notification == false)
            {
                return;
            }
            CompQuality compQuality = thing.TryGetComp <CompQuality>();

            if (compQuality == null)
            {
                return;
            }

            if (compQuality.Quality == QualityCategory.Masterwork)
            {
                Messages.Message("MessageCraftedMasterwork".Translate(worker.LabelShort, thing.LabelShort, worker.Named("WORKER"), thing.Named("CRAFTED")), thing, MessageTypeDefOf.PositiveEvent, true);
            }
            else if (compQuality.Quality == QualityCategory.Legendary)
            {
                Find.LetterStack.ReceiveLetter("LetterCraftedLegendaryLabel".Translate(), "LetterCraftedLegendaryMessage".Translate(worker.LabelShort, thing.LabelShort, worker.Named("WORKER"), thing.Named("CRAFTED")), LetterDefOf.PositiveEvent, thing, null, null);
            }
        }
        // Token: 0x06001568 RID: 5480 RVA: 0x0007D2D0 File Offset: 0x0007B4D0
        public Graphic SubGraphicForQuality(Thing thing, CompAdvancedGraphic advancedWeaponGraphic)
        {
            CompQuality quality = thing.TryGetComp <CompQuality>();

            if (quality == null)
            {
                Log.Warning(string.Format("WARNING!! {0} is set to use quality graphics but has no CompQuality, using random graphic", thing.Label));
                Rand.PushState();
                advancedWeaponGraphic.gfxint = Rand.RangeInclusive(0, subGraphics.Length - 1);
                Rand.PopState();
            }
            if (advancedWeaponGraphic.gfxint == -1)
            {
                if ((int)quality.Quality >= (int)advancedWeaponGraphic.Props.minQuality)
                {
                    int i = (int)quality.Quality - (int)advancedWeaponGraphic.Props.minQuality + 1;
                    advancedWeaponGraphic.gfxint = Math.Min(i, subGraphics.Length - 1);
                }
                else
                {
                    advancedWeaponGraphic.gfxint = 0;
                }
            }
            return(subGraphics[advancedWeaponGraphic.gfxint]);
        }
Esempio n. 23
0
        public static Texture2D Quality2Mat(CompQuality qualityComp)
        {
            Texture2D Answer = null;

            switch ((int)qualityComp.Quality)
            {
            case (int)QualityCategory.Awful:
            case (int)QualityCategory.Poor:
                //case (int)QualityCategory.Shoddy:
                Answer = MyGizmo.QualityBadGz;
                break;

            case (int)QualityCategory.Normal:
            case (int)QualityCategory.Good:
                //case (int)QualityCategory.Superior:
                Answer = MyGizmo.QualityNormalGz;
                break;

            case (int)QualityCategory.Excellent:
            case (int)QualityCategory.Masterwork:
            case (int)QualityCategory.Legendary:

                Answer = MyGizmo.QualityGoodGz;
                break;
            }
            return(Answer);
        }
Esempio n. 24
0
        public static float Quality2Size(CompQuality qualityComp)
        {
            float Answer = 0f;

            switch ((int)qualityComp.Quality)
            {
            case (int)QualityCategory.Awful:
            //case (int)QualityCategory.Superior:
            case (int)QualityCategory.Legendary:
                Answer = 1f;
                break;

            //case (int)QualityCategory.Shoddy:
            case (int)QualityCategory.Good:
            case (int)QualityCategory.Masterwork:
                Answer = .9f;
                break;

            case (int)QualityCategory.Poor:
            case (int)QualityCategory.Normal:
            case (int)QualityCategory.Excellent:
                Answer = .75f;
                break;
            }
            return(Answer);
        }
        // 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);
        }
Esempio n. 26
0
 public static bool WorstQuality(CompQuality compQuality)
 {
     if (compQuality == null)
     {
         return(false);
     }
     return(compQuality.Quality == QualityCategory.Awful);
 }
Esempio n. 27
0
 //Quality
 public static bool BestQuality(CompQuality compQuality)
 {
     if (compQuality == null)
     {
         return(false);
     }
     return(compQuality.Quality == QualityCategory.Legendary);
 }
Esempio n. 28
0
        public override void PostPostMake()
        {
            CompQuality     comp          = base.parent.GetComp <CompQuality>();
            QualityCategory offsetQuality = (QualityCategory)Mathf.Clamp((int)comp.Quality + Props.qualityChange, (int)QualityCategory.Awful, (int)QualityCategory.Legendary);

            // Will regenerate art in colony context in the MakeRecipeProducts patch
            comp.SetQuality(offsetQuality, ArtGenerationContext.Outsider);
            base.parent.AllComps.Remove(this);
        }
Esempio n. 29
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);
        }
Esempio n. 30
0
        protected override void PostProcessRecipeProduct(Thing thing)
        {
            CompQuality compQuality = thing.TryGetComp <CompQuality>();

            if (compQuality != null)
            {
                compQuality.SetQuality(GetRandomProductionQuality(), ArtGenerationContext.Colony);
            }
        }