Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using HarmonyLib;
- using RimWorld;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using UnityEngine;
- using Verse;
- using Verse.AI;
- namespace PrisonerBedSetOwner.Patch
- {
- [HarmonyPatch(typeof(Building_Bed), "GetGizmos")]
- class PatchBuilding_BedGetGizmos
- {
- static IEnumerable<Gizmo> Postfix(IEnumerable<Gizmo> list, Building_Bed __instance)
- {
- foreach (Gizmo gizmo in list)
- {
- yield return gizmo;
- }
- if (__instance.def.building.bed_humanlike && __instance.Faction == Faction.OfPlayer && __instance.ForPrisoners)
- {
- yield return new Command_Action
- {
- defaultLabel = "CommandThingSetOwnerLabel".Translate(),
- icon = ContentFinder<Texture2D>.Get("UI/Commands/AssignOwner", true),
- defaultDesc = "CommandBedSetOwnerDesc".Translate(),
- action = delegate ()
- {
- Find.WindowStack.Add(new Dialog_AssignBuildingOwner(__instance.CompAssignableToPawn));
- },
- hotKey = KeyBindingDefOf.Misc3
- };
- }
- yield break;
- }
- }
- [HarmonyPatch(typeof(CompAssignableToPawn_Bed), "AssigningCandidates", MethodType.Getter)]
- class PatchCompAssignableToPawn
- {
- static bool Prefix(ref IEnumerable<Pawn> __result, CompAssignableToPawn __instance)
- {
- Building_Bed bed = __instance.parent as Building_Bed;
- if (bed == null || !bed.Spawned || !bed.ForPrisoners) return true;
- __result = bed.Map.mapPawns.PrisonersOfColony;
- return false;
- }
- }
- [HarmonyPatch(typeof(WorkGiver_Warden_TakeToBed), "TakeToPreferredBedJob")]
- class PatchWorkGiver_Warden_TakeToBedTakeToPreferredBedJob
- {
- static bool Prefix(ref Job __result, Pawn prisoner)
- {
- Building_Bed bed = prisoner.ownership?.OwnedBed;
- Room bedroom = bed?.GetRoom();
- Room room = prisoner.GetRoom(RegionType.Set_Passable);
- if (room != null && bedroom != null && room != bedroom)
- {
- __result = JobMaker.MakeJob(JobDefOf.EscortPrisonerToBed, prisoner, bed);
- __result.count = 1;
- return false;
- }
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement