public static bool GetBedSleepingSlotPosFor(ref IntVec3 __result, Pawn pawn, Building_Bed bed) { for (int i = 0; i < bed.OwnersForReading.Count; i++) { if (bed.OwnersForReading[i] == pawn) { __result = bed.GetSleepingSlotPos(i); return(false); } } for (int j = 0; j < bed.SleepingSlotsCount; j++) { Pawn curOccupant = bed.GetCurOccupant(j); if ((j >= bed.OwnersForReading.Count || bed.OwnersForReading[j] == null) && curOccupant == pawn) { __result = bed.GetSleepingSlotPos(j); return(false); } } for (int k = 0; k < bed.SleepingSlotsCount; k++) { Pawn curOccupant2 = bed.GetCurOccupant(k); if ((k >= bed.OwnersForReading.Count || bed.OwnersForReading[k] == null) && curOccupant2 == null) { __result = bed.GetSleepingSlotPos(k); return(false); } } Log.Warning(string.Concat("Could not find good sleeping slot position for ", pawn, ". Perhaps AnyUnoccupiedSleepingSlot check is missing somewhere.")); __result = bed.GetSleepingSlotPos(0); return(false); }
static bool Prefix(Pawn pawn, Building_Bed bed, ref IntVec3 __result) { if (bed is Building_BaseMechanoidPlatform) { __result = bed.GetSleepingSlotPos(Building_BaseMechanoidPlatform.SLOTINDEX); return(false); } if (bed is Building_HackingTable) { __result = bed.GetSleepingSlotPos(Building_HackingTable.SLOTINDEX); return(false); } return(true); }
//Copied from vanilla, prefixing and replacing is safe because of the check for Building_MechanoidPlatform static bool Prefix(Building_Bed __instance, int slotIndex, ref Pawn __result) { if (!(__instance is Building_BaseMechanoidPlatform) && !(__instance is Building_HackingTable)) { return(true); } if (!__instance.Spawned) { return(false); } IntVec3 sleepingSlotPos = __instance.GetSleepingSlotPos(slotIndex); List <Thing> list = __instance.Map.thingGrid.ThingsListAt(sleepingSlotPos); for (int i = 0; i < list.Count; i++) { Pawn pawn = list[i] as Pawn; if (pawn != null) { if (pawn.CurJob != null) { __result = pawn; } } } return(false); }
private static bool IsInOrByBed(Building_Bed b, Pawn p) { for (int i = 0; i < b.SleepingSlotsCount; i++) { if (b.GetSleepingSlotPos(i).InHorDistOf(p.Position, 1f)) { return(true); } } return(false); }