Exemplo n.º 1
0
        public static void Swap(Building_Bed bed)
        {
            bool forPrisoners = bed.ForPrisoners; // Store this, since it changes during spawn

            Building_Bed newBed;

            if (bed.IsGuestBed())
            {
                newBed = (Building_Bed)MakeBed(bed, bed.def.defName.Split(new[] { "Guest" }, StringSplitOptions.RemoveEmptyEntries)[0]);
            }
            else
            {
                newBed = (Building_GuestBed)MakeBed(bed, bed.def.defName + "Guest");
            }

            newBed.SetFactionDirect(bed.Faction);
            var spawnedBed = (Building_Bed)GenSpawn.Spawn(newBed, bed.Position, bed.Map, bed.Rotation);

            spawnedBed.HitPoints    = bed.HitPoints;
            spawnedBed.ForPrisoners = forPrisoners;

            var compQuality = spawnedBed.TryGetComp <CompQuality>();

            compQuality?.SetQuality(bed.GetComp <CompQuality>().Quality, ArtGenerationContext.Outsider);
            //var compArt = bed.TryGetComp<CompArt>();
            //if (compArt != null)
            //{
            //    var art = spawnedBed.GetComp<CompArt>();
            //    Traverse.Create(art).Field("authorNameInt").SetValue(Traverse.Create(compArt).Field("authorNameInt").GetValue());
            //    Traverse.Create(art).Field("titleInt").SetValue(Traverse.Create(compArt).Field("titleInt").GetValue());
            //    Traverse.Create(art).Field("taleRef").SetValue(Traverse.Create(compArt).Field("taleRef").GetValue());
            //
            //    // TODO: Make this work, art is now destroyed
            //}
            Find.Selector.Select(spawnedBed, false);
        }