Ejemplo n.º 1
0
        public static void SendCraftNotification(Thing thing, Pawn worker)
        {
            if (worker == null)
            {
                return;
            }
            CompQuality compQuality = thing.TryGetComp <CompQuality>();

            if (compQuality == null)
            {
                return;
            }
            CompArt compArt = thing.TryGetComp <CompArt>();

            if (compArt == null)
            {
                if (compQuality.Quality == QualityCategory.Masterwork)
                {
                    Find.LetterStack.ReceiveLetter("LetterCraftedMasterworkLabel".Translate(), "LetterCraftedMasterworkMessage".Translate(worker.LabelShort, thing.LabelShort, worker.Named("WORKER"), thing.Named("CRAFTED")), LetterDefOf.PositiveEvent, thing);
                }
                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);
                }
            }
            else if (compQuality.Quality == QualityCategory.Masterwork)
            {
                Find.LetterStack.ReceiveLetter("LetterCraftedMasterworkLabel".Translate(), "LetterCraftedMasterworkMessageArt".Translate(compArt.GenerateImageDescription(), worker.LabelShort, thing.LabelShort, worker.Named("WORKER"), thing.Named("CRAFTED")), LetterDefOf.PositiveEvent, thing);
            }
            else if (compQuality.Quality == QualityCategory.Legendary)
            {
                Find.LetterStack.ReceiveLetter("LetterCraftedLegendaryLabel".Translate(), "LetterCraftedLegendaryMessageArt".Translate(compArt.GenerateImageDescription(), worker.LabelShort, thing.LabelShort, worker.Named("WORKER"), thing.Named("CRAFTED")), LetterDefOf.PositiveEvent, thing);
            }
        }
Ejemplo n.º 2
0
        public void SetQuality(QualityCategory q, ArtGenerationContext source)
        {
            this.qualityInt = q;
            CompArt compArt = this.parent.TryGetComp <CompArt>();

            if (compArt != null)
            {
                compArt.InitializeArt(source);
            }
        }
        public virtual void Notify_CorpseBuried(Pawn worker)
        {
            CompArt comp = base.GetComp <CompArt>();

            if (comp != null && !comp.Active)
            {
                comp.JustCreatedBy(worker);
                comp.InitializeArt(this.Corpse.InnerPawn);
            }
            base.Map.mapDrawer.MapMeshDirty(base.Position, MapMeshFlag.Things | MapMeshFlag.Buildings);
        }
Ejemplo n.º 4
0
        public override Job TryGiveJob(Pawn pawn)
        {
            bool allowedOutside = JoyUtility.EnjoyableOutsideNow(pawn, null);

            try
            {
                JoyGiver_ViewArt.candidates.AddRange(pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Art).Where(delegate(Thing thing)
                {
                    if (thing.Faction == Faction.OfPlayer && !thing.IsForbidden(pawn) && (allowedOutside || thing.Position.Roofed(thing.Map)) && pawn.CanReserveAndReach(thing, PathEndMode.Touch, Danger.None, 1, -1, null, false) && thing.IsPoliticallyProper(pawn))
                    {
                        CompArt compArt = thing.TryGetComp <CompArt>();
                        if (compArt == null)
                        {
                            Log.Error("No CompArt on thing being considered for viewing: " + thing);
                            return(false);
                        }
                        if (compArt.CanShowArt && compArt.Props.canBeEnjoyedAsArt)
                        {
                            Room room = thing.GetRoom(RegionType.Set_Passable);
                            if (room == null)
                            {
                                return(false);
                            }
                            if (room.Role != RoomRoleDefOf.Bedroom && room.Role != RoomRoleDefOf.Barracks && room.Role != RoomRoleDefOf.PrisonCell && room.Role != RoomRoleDefOf.PrisonBarracks && room.Role != RoomRoleDefOf.Hospital)
                            {
                                goto IL_014a;
                            }
                            if (pawn.ownership != null && pawn.ownership.OwnedRoom != null && pawn.ownership.OwnedRoom == room)
                            {
                                goto IL_014a;
                            }
                            return(false);
                        }
                        return(false);
                    }
                    return(false);

                    IL_014a:
                    return(true);
                }));
                Thing t = default(Thing);
                if (!((IEnumerable <Thing>)JoyGiver_ViewArt.candidates).TryRandomElementByWeight <Thing>((Func <Thing, float>)((Thing target) => Mathf.Max(target.GetStatValue(StatDefOf.Beauty, true), 0.5f)), out t))
                {
                    return(null);
                }
                return(new Job(base.def.jobDef, t));
            }
            finally
            {
                JoyGiver_ViewArt.candidates.Clear();
            }
        }
Ejemplo n.º 5
0
        public void CompleteConstruction(Pawn worker)
        {
            resourceContainer.ClearAndDestroyContents();
            Map map = base.Map;

            Destroy();
            if (this.GetStatValue(StatDefOf.WorkToBuild) > 150f && def.entityDefToBuild is ThingDef && ((ThingDef)def.entityDefToBuild).category == ThingCategory.Building)
            {
                SoundDefOf.Building_Complete.PlayOneShot(new TargetInfo(base.Position, map));
            }
            ThingDef thingDef = def.entityDefToBuild as ThingDef;
            Thing    thing    = null;

            if (thingDef != null)
            {
                thing = ThingMaker.MakeThing(thingDef, base.Stuff);
                thing.SetFactionDirect(base.Faction);
                CompQuality compQuality = thing.TryGetComp <CompQuality>();
                if (compQuality != null)
                {
                    QualityCategory q = QualityUtility.GenerateQualityCreatedByPawn(worker, SkillDefOf.Construction);
                    compQuality.SetQuality(q, ArtGenerationContext.Colony);
                    QualityUtility.SendCraftNotification(thing, worker);
                }
                CompArt compArt = thing.TryGetComp <CompArt>();
                if (compArt != null)
                {
                    if (compQuality == null)
                    {
                        compArt.InitializeArt(ArtGenerationContext.Colony);
                    }
                    compArt.JustCreatedBy(worker);
                }
                thing.HitPoints = Mathf.CeilToInt((float)HitPoints / (float)base.MaxHitPoints * (float)thing.MaxHitPoints);
                GenSpawn.Spawn(thing, base.Position, map, base.Rotation, WipeMode.FullRefund);
                Building b;
                if ((b = thing as Building) != null)
                {
                    worker.GetLord()?.AddBuilding(b);
                }
            }
            else
            {
                map.terrainGrid.SetTerrain(base.Position, (TerrainDef)def.entityDefToBuild);
                FilthMaker.RemoveAllFilth(base.Position, map);
            }
            worker.records.Increment(RecordDefOf.ThingsConstructed);
            if (thing != null && thing.GetStatValue(StatDefOf.WorkToBuild) >= 9500f)
            {
                TaleRecorder.RecordTale(TaleDefOf.CompletedLongConstructionProject, worker, thing.def);
            }
        }
Ejemplo n.º 6
0
        public virtual void Notify_CorpseBuried(Pawn worker)
        {
            CompArt comp = GetComp <CompArt>();

            if (comp != null && !comp.Active)
            {
                comp.JustCreatedBy(worker);
                comp.InitializeArt(Corpse.InnerPawn);
            }
            base.Map.mapDrawer.MapMeshDirty(base.Position, MapMeshFlag.Things | MapMeshFlag.Buildings);
            worker.records.Increment(RecordDefOf.CorpsesBuried);
            TaleRecorder.RecordTale(TaleDefOf.BuriedCorpse, worker, (Corpse != null) ? Corpse.InnerPawn : null);
        }
Ejemplo n.º 7
0
        public static TaleData_Thing GenerateFrom(Thing t)
        {
            TaleData_Thing taleData_Thing = new TaleData_Thing();

            taleData_Thing.thingID  = t.thingIDNumber;
            taleData_Thing.thingDef = t.def;
            taleData_Thing.stuff    = t.Stuff;
            t.TryGetQuality(out taleData_Thing.quality);
            CompArt compArt = t.TryGetComp <CompArt>();

            if (compArt != null && compArt.Active)
            {
                taleData_Thing.title = compArt.Title;
            }
            return(taleData_Thing);
        }
Ejemplo n.º 8
0
        protected override void FillTab()
        {
            Rect rect = new Rect(0f, 0f, WinSize.x, WinSize.y).ContractedBy(10f);

            Text.Font = GameFont.Medium;
            Widgets.Label(rect, SelectedCompArt.Title);
            if (cachedImageSource != SelectedCompArt || cachedTaleRef != SelectedCompArt.TaleRef)
            {
                cachedImageDescription = SelectedCompArt.GenerateImageDescription();
                cachedImageSource      = SelectedCompArt;
                cachedTaleRef          = SelectedCompArt.TaleRef;
            }
            Rect rect2 = rect;

            rect2.yMin += 35f;
            Text.Font   = GameFont.Small;
            Widgets.Label(rect2, cachedImageDescription);
        }
Ejemplo n.º 9
0
        public override Job TryGiveJob(Pawn pawn)
        {
            bool allowedOutside = JoyUtility.EnjoyableOutsideNow(pawn);

            try
            {
                candidates.AddRange(pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Art).Where(delegate(Thing thing)
                {
                    if (thing.Faction != Faction.OfPlayer || thing.IsForbidden(pawn) || (!allowedOutside && !thing.Position.Roofed(thing.Map)) || !pawn.CanReserveAndReach(thing, PathEndMode.Touch, Danger.None) || !thing.IsPoliticallyProper(pawn))
                    {
                        return(false);
                    }
                    CompArt compArt = thing.TryGetComp <CompArt>();
                    if (compArt == null)
                    {
                        Log.Error("No CompArt on thing being considered for viewing: " + thing);
                        return(false);
                    }
                    if (!compArt.CanShowArt || !compArt.Props.canBeEnjoyedAsArt)
                    {
                        return(false);
                    }
                    Room room = thing.GetRoom();
                    if (room == null)
                    {
                        return(false);
                    }
                    if ((room.Role == RoomRoleDefOf.Bedroom || room.Role == RoomRoleDefOf.Barracks || room.Role == RoomRoleDefOf.PrisonCell || room.Role == RoomRoleDefOf.PrisonBarracks || room.Role == RoomRoleDefOf.Hospital) && (pawn.ownership == null || pawn.ownership.OwnedRoom == null || pawn.ownership.OwnedRoom != room))
                    {
                        return(false);
                    }
                    return(true);
                }));
                if (!candidates.TryRandomElementByWeight((Thing target) => Mathf.Max(target.GetStatValue(StatDefOf.Beauty), 0.5f), out Thing result))
                {
                    return(null);
                }
                return(new Job(def.jobDef, result));
            }
            finally
            {
                candidates.Clear();
            }
        }
Ejemplo n.º 10
0
        protected override void FillTab()
        {
            Rect rect  = new Rect(0f, 0f, ITab_Art.WinSize.x, ITab_Art.WinSize.y).ContractedBy(10f);
            Rect rect2 = rect;

            Text.Font = GameFont.Medium;
            Widgets.Label(rect2, this.SelectedCompArt.Title);
            if (ITab_Art.cachedImageSource != this.SelectedCompArt || ITab_Art.cachedTaleRef != this.SelectedCompArt.TaleRef)
            {
                ITab_Art.cachedImageDescription = this.SelectedCompArt.GenerateImageDescription();
                ITab_Art.cachedImageSource      = this.SelectedCompArt;
                ITab_Art.cachedTaleRef          = this.SelectedCompArt.TaleRef;
            }
            Rect rect3 = rect;

            rect3.yMin += 35f;
            Text.Font   = GameFont.Small;
            Widgets.Label(rect3, ITab_Art.cachedImageDescription);
        }
Ejemplo n.º 11
0
            internal bool <> m__0(Thing thing)
            {
                bool result;

                if (thing.Faction != Faction.OfPlayer || thing.IsForbidden(this.pawn) || (!this.allowedOutside && !thing.Position.Roofed(thing.Map)) || !this.pawn.CanReserveAndReach(thing, PathEndMode.Touch, Danger.None, 1, -1, null, false) || !thing.IsPoliticallyProper(this.pawn))
                {
                    result = false;
                }
                else
                {
                    CompArt compArt = thing.TryGetComp <CompArt>();
                    if (compArt == null)
                    {
                        Log.Error("No CompArt on thing being considered for viewing: " + thing, false);
                        result = false;
                    }
                    else if (!compArt.CanShowArt || !compArt.Props.canBeEnjoyedAsArt)
                    {
                        result = false;
                    }
                    else
                    {
                        Room room = thing.GetRoom(RegionType.Set_Passable);
                        if (room == null)
                        {
                            result = false;
                        }
                        else
                        {
                            if (room.Role == RoomRoleDefOf.Bedroom || room.Role == RoomRoleDefOf.Barracks || room.Role == RoomRoleDefOf.PrisonCell || room.Role == RoomRoleDefOf.PrisonBarracks || room.Role == RoomRoleDefOf.Hospital)
                            {
                                if (this.pawn.ownership == null || this.pawn.ownership.OwnedRoom == null || this.pawn.ownership.OwnedRoom != room)
                                {
                                    return(false);
                                }
                            }
                            result = true;
                        }
                    }
                }
                return(result);
            }
Ejemplo n.º 12
0
        public void CompleteConstruction(Pawn worker)
        {
            this.resourceContainer.ClearAndDestroyContents(DestroyMode.Vanish);
            Map map = base.Map;

            this.Destroy(DestroyMode.Vanish);
            if (this.GetStatValue(StatDefOf.WorkToBuild, true) > 150.0 && base.def.entityDefToBuild is ThingDef && ((ThingDef)base.def.entityDefToBuild).category == ThingCategory.Building)
            {
                SoundDefOf.BuildingComplete.PlayOneShot(new TargetInfo(base.Position, map, false));
            }
            ThingDef thingDef = base.def.entityDefToBuild as ThingDef;
            Thing    thing    = null;

            if (thingDef != null)
            {
                thing = ThingMaker.MakeThing(thingDef, base.Stuff);
                thing.SetFactionDirect(base.Faction);
                CompQuality compQuality = thing.TryGetComp <CompQuality>();
                if (compQuality != null)
                {
                    int level = worker.skills.GetSkill(SkillDefOf.Construction).Level;
                    compQuality.SetQuality(QualityUtility.RandomCreationQuality(level), ArtGenerationContext.Colony);
                }
                CompArt compArt = thing.TryGetComp <CompArt>();
                if (compArt != null)
                {
                    if (compQuality == null)
                    {
                        compArt.InitializeArt(ArtGenerationContext.Colony);
                    }
                    compArt.JustCreatedBy(worker);
                }
                thing.HitPoints = Mathf.CeilToInt((float)this.HitPoints / (float)base.MaxHitPoints * (float)thing.MaxHitPoints);
                GenSpawn.Spawn(thing, base.Position, map, base.Rotation, false);
            }
            else
            {
                map.terrainGrid.SetTerrain(base.Position, (TerrainDef)base.def.entityDefToBuild);
                FilthMaker.RemoveAllFilth(base.Position, map);
            }
            if (thingDef != null && (thingDef.passability == Traversability.Impassable || thingDef.Fillage == FillCategory.Full) && (thing == null || !(thing is Building_Door)))
            {
                foreach (IntVec3 item in GenAdj.CellsOccupiedBy(base.Position, base.Rotation, base.def.Size))
                {
                    foreach (Thing item2 in map.thingGrid.ThingsAt(item).ToList())
                    {
                        if (item2 is Plant)
                        {
                            item2.Destroy(DestroyMode.KillFinalize);
                        }
                        else if (item2.def.category == ThingCategory.Item || item2 is Pawn)
                        {
                            GenPlace.TryMoveThing(item2, item2.Position, item2.Map);
                        }
                    }
                }
            }
            worker.records.Increment(RecordDefOf.ThingsConstructed);
            if (thing != null && thing.GetStatValue(StatDefOf.WorkToBuild, true) >= 10000.0)
            {
                TaleRecorder.RecordTale(TaleDefOf.CompletedLongConstructionProject, worker, thing.def);
            }
        }
Ejemplo n.º 13
0
        // Token: 0x060000D7 RID: 215 RVA: 0x000066F8 File Offset: 0x000048F8
        public void CompleteConstruction(Pawn worker)
        {
            Map  map  = base.Map;
            bool flag = this.GetStatValue(StatDefOf.WorkToBuild, true) > 150f && this.def.entityDefToBuild is ThingDef && ((ThingDef)this.def.entityDefToBuild).category == ThingCategory.Building;

            if (flag)
            {
                SoundDefOf.Building_Complete.PlayOneShot(new TargetInfo(base.Position, map, false));
            }
            ThingDef thingDef = this.def.entityDefToBuild as ThingDef;
            Thing    thing    = null;
            bool     flag2    = thingDef != null;

            if (flag2)
            {
                thing = ThingMaker.MakeThing(thingDef, base.Stuff);
                thing.SetFactionDirect(base.Faction);
                CompQuality compQuality = thing.TryGetComp <CompQuality>();
                bool        flag3       = compQuality != null;
                if (flag3)
                {
                    int relevantSkillLevel = 1;
                    compQuality.SetQuality(QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, false), ArtGenerationContext.Colony);
                }
                CompArt compArt = thing.TryGetComp <CompArt>();
                bool    flag4   = compArt != null;
                if (flag4)
                {
                    bool flag5 = compQuality == null;
                    if (flag5)
                    {
                        compArt.InitializeArt(ArtGenerationContext.Colony);
                    }
                    compArt.JustCreatedBy(worker);
                }
                thing.HitPoints = Mathf.CeilToInt((float)this.HitPoints / (float)base.MaxHitPoints * (float)thing.MaxHitPoints);
                GenSpawn.Spawn(thing, base.Position, map, base.Rotation, WipeMode.FullRefund, false);
            }
            else
            {
                map.terrainGrid.SetTerrain(base.Position, (TerrainDef)this.def.entityDefToBuild);
                FilthMaker.RemoveAllFilth(base.Position, map);
            }
            bool flag6 = thingDef != null && (thingDef.passability == Traversability.Impassable || thingDef.Fillage == FillCategory.Full) && (thing == null || !(thing is Building_Door));

            if (flag6)
            {
                foreach (IntVec3 c in GenAdj.CellsOccupiedBy(base.Position, base.Rotation, this.def.Size))
                {
                    foreach (Thing thing2 in map.thingGrid.ThingsAt(c).ToList <Thing>())
                    {
                        bool flag7 = thing2 is Plant;
                        if (flag7)
                        {
                            thing2.Destroy(DestroyMode.KillFinalize);
                        }
                        else
                        {
                            bool flag8 = thing2.def.category == ThingCategory.Item || thing2 is Pawn;
                            if (flag8)
                            {
                                GenPlace.TryPlaceThing(thing2, thing2.Position, thing2.Map, ThingPlaceMode.Near, null, null, default(Rot4));
                            }
                        }
                    }
                }
            }
            worker.records.Increment(RecordDefOf.ThingsConstructed);
        }