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

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

            if (compArt != null)
            {
                compArt.JustCreatedBy(worker);
                if (compQuality.Quality >= QualityCategory.Excellent)
                {
                    TaleRecorder.RecordTale(TaleDefOf.CraftedArt, new object[]
                    {
                        worker,
                        product
                    });
                }
            }
            if (product.def.Minifiable)
            {
                product = product.MakeMinified();
            }
            return(product);
        }
Beispiel #2
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);
        }
Beispiel #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);
        }
        // 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);
        }
 internal static void _Notify_CorpseBuried(this Building_Grave _this, Pawn worker)
 {
     CompArt comp = _this.GetComp<CompArt>();
     if (comp != null && !comp.Active)
     {
         comp.JustCreatedBy(worker);
         comp.InitializeArt(_this.Corpse.InnerPawn);
         worker.needs.mood.thoughts.memories.TryGainMemoryThought(ThoughtDefOfPsychology.FilledGraveBleedingHeart);
     }
     _this.Map.mapDrawer.MapMeshDirty(_this.Position, MapMeshFlag.Buildings);
 }
Beispiel #6
0
        // Token: 0x060000EF RID: 239 RVA: 0x00008640 File Offset: 0x00006840
        public static bool CompleteConstruction_Prefix(Frame __instance, Pawn worker)
        {
            bool flag = !worker.RaceProps.Humanlike;
            bool result;

            if (flag)
            {
                Thing thing = __instance.holdingOwner.Take(__instance);
                __instance.resourceContainer.ClearAndDestroyContents(DestroyMode.Vanish);
                Map map = worker.Map;
                __instance.Destroy(DestroyMode.Vanish);
                bool flag2 = __instance.GetStatValue(StatDefOf.WorkToBuild, true) > 150f && __instance.def.entityDefToBuild is ThingDef && ((ThingDef)__instance.def.entityDefToBuild).category == ThingCategory.Building;
                if (flag2)
                {
                    SoundDefOf.Building_Complete.PlayOneShot(new TargetInfo(thing.Position, map, false));
                }
                ThingDef thingDef = __instance.def.entityDefToBuild as ThingDef;
                Thing    thing2   = null;
                bool     flag3    = thingDef != null;
                if (flag3)
                {
                    thing2 = ThingMaker.MakeThing(thingDef, thing.Stuff);
                    thing2.SetFactionDirect(thing.Faction);
                    CompQuality compQuality = thing2.TryGetComp <CompQuality>();
                    bool        flag4       = compQuality != null;
                    if (flag4)
                    {
                        int             relevantSkillLevel = 1;
                        QualityCategory q = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, false);
                        compQuality.SetQuality(q, ArtGenerationContext.Colony);
                        QualityUtility.SendCraftNotification(thing2, worker);
                    }
                    CompArt compArt = thing2.TryGetComp <CompArt>();
                    bool    flag5   = compArt != null;
                    if (flag5)
                    {
                        bool flag6 = compQuality == null;
                        if (flag6)
                        {
                            compArt.InitializeArt(ArtGenerationContext.Colony);
                        }
                        compArt.JustCreatedBy(worker);
                    }
                    thing2.HitPoints = Mathf.CeilToInt((float)__instance.HitPoints / (float)thing.MaxHitPoints * (float)thing2.MaxHitPoints);
                    GenSpawn.Spawn(thing2, thing.Position, worker.Map, thing.Rotation, WipeMode.Vanish, false);
                }
                else
                {
                    map.terrainGrid.SetTerrain(thing.Position, (TerrainDef)__instance.def.entityDefToBuild);
                    FilthMaker.RemoveAllFilth(thing.Position, map);
                }
                worker.records.Increment(RecordDefOf.ThingsConstructed);
                bool flag7 = thing2 != null && thing2.GetStatValue(StatDefOf.WorkToBuild, true) >= 9500f;
                if (flag7)
                {
                    TaleRecorder.RecordTale(TaleDefOf.CompletedLongConstructionProject, new object[]
                    {
                        worker,
                        thing2.def
                    });
                }
                result = false;
            }
            else
            {
                result = true;
            }
            return(result);
        }