Skip to content

Commit

Permalink
restore pharamacist compat
Browse files Browse the repository at this point in the history
  • Loading branch information
alextd committed Nov 17, 2018
1 parent 65f286f commit 29550bb
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Source/GetPawnMedicalCareCategory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,28 @@ static class GetPawnMedicalCareCategory
static MethodInfo pharmacistTendAdvice;
static GetPawnMedicalCareCategory()
{
Log.Message($"Trying to find Pharmacist");
Type pharmacist = AccessTools.TypeByName("Pharmacist.PharmacistUtility");
if (pharmacist == null) return;

pharmacistTendAdvice = AccessTools.Method(pharmacist, "TendAdvice");
pharmacistTendAdvice = AccessTools.Method(pharmacist, "TendAdvice", new Type[] { typeof(Pawn)});
Log.Message($"Pharmacist type is {pharmacist}, advice is {pharmacistTendAdvice}");
}

public static MedicalCareCategory GetCare(this Pawn pawn)
{
MedicalCareCategory care;
if (pharmacistTendAdvice != null)
return (MedicalCareCategory)pharmacistTendAdvice.Invoke(pawn, new object[] { });

return pawn.playerSettings?.medCare ?? MedicalCareCategory.NoCare;
{
care = (MedicalCareCategory)pharmacistTendAdvice.Invoke(null, new object[] { pawn });
Log.Message($"Pharmacist tend advicefor {pawn} is {care}");
}
else
{
care = pawn.playerSettings?.medCare ?? MedicalCareCategory.NoCare;
Log.Message($"Care for {pawn} is {care}");
}
return care;
}
}
}

0 comments on commit 29550bb

Please sign in to comment.