Ejemplo n.º 1
0
        protected override void ScatterAt(IntVec3 loc, Map map, GenStepParams parms, int stackCount = 1)
        {
            if (!TryGetRandomValidRotation(loc, map, out Rot4 rot))
            {
                Log.Warning("Could not find any valid rotation for " + thingDef);
                return;
            }
            if (clearSpaceSize > 0)
            {
                foreach (IntVec3 item in GridShapeMaker.IrregularLump(loc, map, clearSpaceSize))
                {
                    item.GetEdifice(map)?.Destroy();
                }
            }
            Thing thing = ThingMaker.MakeThing(thingDef, stuff);

            if (thingDef.Minifiable)
            {
                thing = thing.MakeMinified();
            }
            if (thing.def.category == ThingCategory.Item)
            {
                thing.stackCount = stackCount;
                thing.SetForbidden(value: true, warnOnFail: false);
                GenPlace.TryPlaceThing(thing, loc, map, ThingPlaceMode.Near, out Thing lastResultingThing);
                if (nearPlayerStart && lastResultingThing != null && lastResultingThing.def.category == ThingCategory.Item && TutorSystem.TutorialMode)
                {
                    Find.TutorialState.AddStartingItem(lastResultingThing);
                }
            }
            else
            {
                GenSpawn.Spawn(thing, loc, map, rot);
            }
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo 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.", 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);
        }
Ejemplo n.º 4
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);
        }
        // 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);
        }
        protected override void ScatterAt(IntVec3 loc, Map map, int stackCount = 1)
        {
            Rot4 rot;

            if (!this.TryGetRandomValidRotation(loc, map, out rot))
            {
                Log.Warning("Could not find any valid rotation for " + this.thingDef, false);
            }
            else
            {
                if (this.clearSpaceSize > 0)
                {
                    foreach (IntVec3 c in GridShapeMaker.IrregularLump(loc, map, this.clearSpaceSize))
                    {
                        Building edifice = c.GetEdifice(map);
                        if (edifice != null)
                        {
                            edifice.Destroy(DestroyMode.Vanish);
                        }
                    }
                }
                Thing thing = ThingMaker.MakeThing(this.thingDef, this.stuff);
                if (this.thingDef.Minifiable)
                {
                    thing = thing.MakeMinified();
                }
                if (thing.def.category == ThingCategory.Item)
                {
                    thing.stackCount = stackCount;
                    thing.SetForbidden(true, false);
                    Thing thing2;
                    GenPlace.TryPlaceThing(thing, loc, map, ThingPlaceMode.Near, out thing2, null, null);
                    if (this.nearPlayerStart && thing2 != null && thing2.def.category == ThingCategory.Item && TutorSystem.TutorialMode)
                    {
                        Find.TutorialState.AddStartingItem(thing2);
                    }
                }
                else
                {
                    GenSpawn.Spawn(thing, loc, map, rot, WipeMode.Vanish, false);
                }
            }
        }
Ejemplo n.º 7
0
        public static void Refund(Thing thing, Map map, CellRect avoidThisRect)
        {
            bool flag = false;

            if (thing.def.Minifiable)
            {
                MinifiedThing minifiedThing = thing.MakeMinified();
                if (GenPlace.TryPlaceThing(minifiedThing, thing.Position, map, ThingPlaceMode.Near, null, (IntVec3 x) => !avoidThisRect.Contains(x)))
                {
                    flag = true;
                }
                else
                {
                    minifiedThing.GetDirectlyHeldThings().Clear();
                    minifiedThing.Destroy(DestroyMode.Vanish);
                }
            }
            if (!flag)
            {
                GenLeaving.DoLeavingsFor(thing, map, DestroyMode.Refund, thing.OccupiedRect(), (IntVec3 x) => !avoidThisRect.Contains(x));
                thing.Destroy(DestroyMode.Vanish);
            }
        }