public static bool FindRandomSickPawn(ref Pawn __result, Pawn pawn, JoyCategory maxPatientJoy) { List <Pawn> pawnList = pawn.Map.mapPawns.FreeColonistsSpawned; List <Pawn> source = new List <Pawn>(); for (int i = 0; i < pawnList.Count; i++) { Pawn pawn2; try { pawn2 = pawnList[i]; } catch (ArgumentOutOfRangeException) { break; } if (pawn2 != null && SickPawnVisitUtility.CanVisit(pawn, pawn2, maxPatientJoy)) { source.Add(pawn2); } } Func <Pawn, float> weightSelector = (Pawn x) => VisitChanceScore(pawn, x); bool result2 = GenCollection_Patch.TryRandomElementByWeight_Pawn(source, weightSelector, out Pawn result); if (!result2) { __result = null; return(false); } __result = result; return(false); }
public override Job JobOnThing(Pawn pawn, Thing t) { Pawn patient = t as Pawn; if (patient == null) { return(null); } if (!SickPawnVisitUtility.CanVisit(pawn, patient, JoyCategory.High)) { return(null); } if (patient.health.capacities.GetEfficiency(PawnCapacityDefOf.Moving) > 0.6f) { return(null); } if (patient.health.capacities.GetEfficiency(PawnCapacityDefOf.Consciousness) < 0.6f) { return(null); } Thing t2 = FindWheelChair(pawn, patient); if (t2 != null) { return new Job(DefDatabase <JobDef> .GetNamed("TakeToWheelChair"), patient, t2) { maxNumToCarry = 1 } } ; return(null); } }
protected override Job TryGiveJob(Pawn pawn) { if (!InteractionUtility.CanInitiateInteraction(pawn)) { return(null); } Pawn patient = SickPawnVisitUtility.FindRandomSickPawn(pawn, JoyCategory.High); if (patient == null) { return(null); } Thing wheelChair = ToolsForHaulUtility.FindWheelChair(patient, pawn); if (wheelChair == null || !pawn.CanReserve(wheelChair)) { return(null); } return(new Job(DefDatabase <JobDef> .GetNamed("TakeToWheelChair"), patient, wheelChair) { maxNumToCarry = 1 }); }