Skip to content

Commit

Permalink
Pharmacist support for priority care
Browse files Browse the repository at this point in the history
  • Loading branch information
alextd committed Oct 3, 2018
1 parent 30d9999 commit 2eb6135
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Source/MedicineGrabbing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ public static void FilterInjuriesForMedCount(List<Hediff> hediffs)
//We're gonna use priorityCare, so remove anything less than that
//Should check if medicine is available, but you just set to use it so this will assume you have it
MedicalCareCategory defaultCare = hediffs.First().pawn.playerSettings.medCare;
try
{
((Action)(() =>
{defaultCare = Pharmacist.PharmacistUtility.TendAdvice(hediffs.First().pawn);
}))();
}
catch (Exception) { }
hediffs.RemoveAll(delegate (Hediff h)
{
if (PriorityCareComp.Get().TryGetValue(h, out MedicalCareCategory heCare))
Expand Down
23 changes: 22 additions & 1 deletion Source/SetMedForHediff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,16 @@ public static bool Prefix(Hediff __instance, ref float __result)
if(PriorityCareComp.Get().TryGetValue(__instance, out MedicalCareCategory hediffCare))
{
MedicalCareCategory defaultCare = __instance.pawn.playerSettings.medCare;

try
{
((Action)(() =>
{
defaultCare = Pharmacist.PharmacistUtility.TendAdvice(__instance.pawn);
}))();
}
catch (Exception) { }

int diff = ((int)hediffCare) - ((int)defaultCare);
__result += diff*5;//Raise priority for higher meds, lower for lower meds.
return false;
Expand Down Expand Up @@ -274,7 +284,18 @@ public static bool AllowsMedicineForHediff(Pawn deliveree, ThingDef med)
return heCare.AllowsMedicine(med);
}

return deliveree.playerSettings.medCare.AllowsMedicine(med);
//Not required but hey why dont I patch this in for Pharmacist
MedicalCareCategory care = deliveree.playerSettings.medCare;
try
{
((Action)(() =>
{
care = Pharmacist.PharmacistUtility.TendAdvice(deliveree);
}))();
}
catch (Exception) { }

return care.AllowsMedicine(med);
}
}

Expand Down

0 comments on commit 2eb6135

Please sign in to comment.