public static Pawn FindNearbyPermanentlyInjuredPawn(Pawn pawn, int radius, float minSeverity) { List <Pawn> mapPawns = pawn.Map.mapPawns.AllPawnsSpawned; List <Pawn> pawnList = new List <Pawn>(); Pawn targetPawn = null; pawnList.Clear(); for (int i = 0; i < mapPawns.Count; i++) { targetPawn = mapPawns[i]; if (targetPawn != null && !targetPawn.Dead && !targetPawn.Destroyed && !Eval.IsUndead(targetPawn)) { if (targetPawn.IsColonist && (pawn.Position - targetPawn.Position).LengthHorizontal <= radius) { float injurySeverity = 0; using (IEnumerator <BodyPartRecord> enumerator = targetPawn.health.hediffSet.GetInjuredParts().GetEnumerator()) { while (enumerator.MoveNext()) { BodyPartRecord rec = enumerator.Current; IEnumerable <Hediff_Injury> arg_BB_0 = targetPawn.health.hediffSet.GetHediffs <Hediff_Injury>(); Func <Hediff_Injury, bool> arg_BB_1; arg_BB_1 = ((Hediff_Injury injury) => injury.Part == rec); foreach (Hediff_Injury current in arg_BB_0.Where(arg_BB_1)) { bool flag5 = !current.CanHealNaturally() && current.IsPermanent(); if (flag5) { injurySeverity += current.Severity; } } } } if (minSeverity != 0) { if (injurySeverity >= minSeverity) { pawnList.Add(targetPawn); } } else { if (injurySeverity != 0) { pawnList.Add(targetPawn); } } targetPawn = null; } else { targetPawn = null; } } } if (pawnList.Count > 0) { return(pawnList.RandomElement()); } else { return(null); } }