static void Postfix(ref IEnumerable <Pawn> __result, ref CompAssignableToPawn __instance) { if (__instance.parent == null || !(__instance.parent is Building_Bed)) { return; } Building_Bed bed = (Building_Bed)__instance.parent; if (bed.Faction != Faction.OfPlayer || bed.def.building.bed_humanlike) { return; } if (bed.def.building.bed_maxBodySize <= 0.01) { return; // bodysize check is for compatibility with Dubs Hygiene - he made his bathtubs as animal beds. } if (bed.GetType().Name == "Building_MechanoidPlatform" || bed.GetType().Name == "Building_PortableChargingPlatform" || bed.def.designationCategory.defName == "WTH_Hacking") { return; // for some other mods } if (!bed.Spawned) { __result = Enumerable.Empty <Pawn>(); return; } __result = from p in Find.CurrentMap.mapPawns.AllPawns where p.RaceProps.Animal && p.Faction == Faction.OfPlayer select p; }
static void Postfix(ref IEnumerable <Gizmo> __result, ref Building_Bed __instance) { if (__instance.Faction != Faction.OfPlayer || __instance.def.building.bed_humanlike) { return; } if (__instance.def.building.bed_maxBodySize <= 0.01) { return; // bodysize check is for compatibility with Dubs Hygiene - he made his bathtubs as animal beds. } Building_Bed bed = __instance; if (bed.GetType().Name == "Building_MechanoidPlatform" || bed.GetType().Name == "Building_PortableChargingPlatform" || bed.def.designationCategory.defName == "WTH_Hacking") { return; // for some other mods } var gizmos = new List <Gizmo>(__result) { new Command_Toggle { defaultLabel = "CommandBedSetAsMedicalLabel".Translate(), defaultDesc = "CommandBedSetAsMedicalDesc".Translate(), icon = ContentFinder <Texture2D> .Get("UI/Commands/AsMedical", true), isActive = (() => bed.Medical), toggleAction = delegate { bed.Medical = !bed.Medical; }, hotKey = KeyBindingDefOf.Misc2 } }; if (!bed.Medical) { gizmos.Add( new Command_Action { defaultLabel = "CommandBedSetOwnerLabel".Translate(), icon = ContentFinder <Texture2D> .Get("UI/Commands/AssignOwner", true), defaultDesc = "CommandBedSetOwnerDesc".Translate(), action = delegate { Find.WindowStack.Add(new Dialog_AssignBuildingOwner(bed.CompAssignableToPawn)); }, hotKey = KeyBindingDefOf.Misc3 } ); } __result = gizmos.AsEnumerable(); }
public static void Swap(object __instance, Building_Bed bed, StorageSettings settings, CompMakeableBed compMakeable) { //reflection info Type guestBed = AccessTools.TypeByName("Hospitality.Building_GuestBed"); MethodInfo makeBedinfo = AccessTools.Method(guestBed, "MakeBed", new[] { typeof(Building_Bed), typeof(string) }); // Building_Bed newBed; string newName; if (bed.GetType() == guestBed) { newName = bed.def.defName.Split(new string[] { "Guest" }, StringSplitOptions.RemoveEmptyEntries)[0]; } else { newName = bed.def.defName + "Guest"; } // Thanks again to @Zamu for figuring out it was actually very simple! newBed = (Building_Bed)makeBedinfo.Invoke(__instance, new object[] { bed, newName }); newBed.SetFactionDirect(bed.Faction); var spawnedBed = (Building_Bed)GenSpawn.Spawn(newBed, bed.Position, bed.Map, bed.Rotation); spawnedBed.HitPoints = bed.HitPoints; spawnedBed.ForPrisoners = bed.ForPrisoners; // This should be on Hospitality, Orion! spawnedBed.AllComps.Clear(); spawnedBed.AllComps.AddRange(bed.AllComps); foreach (ThingComp comp in spawnedBed.AllComps) { comp.parent = spawnedBed; } compMakeable.parent.Notify_ColorChanged(); Find.Selector.Select(spawnedBed, false, true); }
public static void Swap(object __instance, Building_Bed bed, StorageSettings settings, CompMakeableBed compMakeable) { ThingDef bedLoadedBedding = null; Thing bedBedding = null; if (compMakeable != null) { if (compMakeable.Loaded) { bedLoadedBedding = compMakeable.loadedBedding; bedBedding = compMakeable.bedding; } } //reflection info Type guestBed = AccessTools.TypeByName("Hospitality.Building_GuestBed"); MethodInfo makeBedinfo = AccessTools.Method(guestBed, "MakeBed", new[] { typeof(Building_Bed), typeof(string) }); // Building_Bed newBed; string newName; if (bed.GetType() == guestBed) { newName = bed.def.defName.Split(new string[] { "Guest" }, StringSplitOptions.RemoveEmptyEntries)[0]; } else { newName = bed.def.defName + "Guest"; } // Thanks again to @Zamu for figuring out it was actually very simple! newBed = (Building_Bed)makeBedinfo.Invoke(__instance, new object[] { bed, newName }); newBed.SetFactionDirect(bed.Faction); var spawnedBed = (Building_Bed)GenSpawn.Spawn(newBed, bed.Position, bed.Map, bed.Rotation); spawnedBed.HitPoints = bed.HitPoints; spawnedBed.ForPrisoners = bed.ForPrisoners; var SpawnedCompQuality = spawnedBed.TryGetComp <CompQuality>(); if (SpawnedCompQuality != null) { SpawnedCompQuality.SetQuality(bed.GetComp <CompQuality>().Quality, ArtGenerationContext.Outsider); } var SpawnedCompMakeable = spawnedBed.TryGetComp <CompMakeableBed>(); if (SpawnedCompMakeable != null) { SpawnedCompMakeable.settings = settings; if (bedLoadedBedding != null) { SpawnedCompMakeable.LoadBedding(bedLoadedBedding, bedBedding); } } Find.Selector.Select(spawnedBed, false, true); }
public static bool ShouldRunForBed(Building_Bed bed) { if (bed == null || !bed.Spawned || bed.ForPrisoners || bed.Map == null || bed.Medical) { return(false); } if (bed.GetType().ToString().Contains("WhatTheHack")) { return(false); } return(true); }