Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public static void FinalizeReplace(Thing thing, ThingDef stuff, Pawn worker = null)
        {
            DeconstructDropStuff(thing);

            thing.ChangeStuff(stuff);

            if (worker != null && thing.TryGetComp <CompQuality>() is CompQuality compQuality)
            {
                QualityCategory qualityCreatedByPawn = QualityUtility.GenerateQualityCreatedByPawn(worker, SkillDefOf.Construction);
                compQuality.SetQuality(qualityCreatedByPawn, ArtGenerationContext.Colony);
                QualityUtility.SendCraftNotification(thing, worker);
            }
        }
Exemplo n.º 3
0
        public static void FinalizeReplace(Thing thing, ThingDef stuff, Pawn worker = null)
        {
            DeconstructDropStuff(thing);

            thing.SetStuffDirect(stuff);
            thing.HitPoints = thing.MaxHitPoints;             //Deconstruction/construction implicitly repairs
            thing.Notify_ColorChanged();

            if (worker != null && thing.TryGetComp <CompQuality>() is CompQuality compQuality)
            {
                QualityCategory qualityCreatedByPawn = QualityUtility.GenerateQualityCreatedByPawn(worker, SkillDefOf.Construction);
                compQuality.SetQuality(qualityCreatedByPawn, ArtGenerationContext.Colony);
                QualityUtility.SendCraftNotification(thing, worker);
            }
        }
Exemplo n.º 4
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);
        }