static void Postfix(WorkGiver_RescueDowned __instance, ref Pawn pawn, ref Thing t, ref bool forced, ref bool __result) { // mostly the original method, repeated, with three commented changes if (__result == true) { return; //new guard clause } Pawn pawn2 = t as Pawn; //if (pawn2 != null && pawn2.Downed && pawn2.Faction == pawn.Faction && !pawn2.InBed()) if (pawn2 != null && pawn2.Downed && pawn.Map.designationManager.DesignationOn(pawn2, DesignationDefOf.Tame) != null && !pawn2.InBed()) { LocalTargetInfo target = pawn2; bool ignoreOtherReservations = forced; if (pawn.CanReserve(target, 1, -1, null, ignoreOtherReservations) && !GenAI.EnemyIsNear(pawn2, 40f)) { //Thing thing = FindBed(pawn, pawn2); Thing thing = RestUtility.FindBedFor(pawn2, pawn, pawn2.HostFaction == pawn.Faction, checkSocialProperness: false); if (thing != null && pawn2.CanReserve(thing)) { __result = true; return; } __result = false; return; } } __result = false; return; }
public static void Listener(Pawn pawn, Thing t, bool forced, ref bool __result, WorkGiver_RescueDowned __instance) { Utils.genericPostFixExtraCrafterDoctorJobs(pawn, t, forced, ref __result, __instance); }