-
-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Operations That Cannot Fail Should Use Lowest Quality Medicine #36
base: 1.3
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// WorkGiver_DoBill_GetMedicalCareCategory.cs | ||
// Copyright Karel Kroeze, 2018-2018 | ||
|
||
using HarmonyLib; | ||
using RimWorld; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using Verse; | ||
using Verse.AI; | ||
|
||
namespace Pharmacist.Properties | ||
{ | ||
[HarmonyPatch(typeof(WorkGiver_DoBill), "AddEveryMedicineToRelevantThings")] | ||
public static class WorkGiver_DoBill_AddEveryMedicineToRelevantThings | ||
{ | ||
public static bool Prefix(Pawn pawn, Thing billGiver, List<Thing> relevantThings, Predicate<Thing> baseValidator, Map map) | ||
{ | ||
Pawn patient = billGiver as Pawn; | ||
//MedicalCareCategory medicalCareCategory = GetMedicalCareCategory(billGiver); | ||
MedicalCareCategory medicalCareCategory = PharmacistUtility.TendAdvice(patient, InjurySeverity.Operation); | ||
List<Thing> list = map.listerThings.ThingsInGroup(ThingRequestGroup.Medicine); | ||
List<Thing> tmpMedicine = (List<Thing>)(typeof(WorkGiver_DoBill).GetField("tmpMedicine", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null)); | ||
tmpMedicine.Clear(); | ||
for (int i = 0; i < list.Count; i++) | ||
{ | ||
Thing thing = list[i]; | ||
if (medicalCareCategory.AllowsMedicine(thing.def) && baseValidator(thing) && pawn.CanReach(thing, PathEndMode.OnCell, Danger.Deadly)) | ||
{ | ||
tmpMedicine.Add(thing); | ||
} | ||
} | ||
float inverter = 1f; | ||
if (patient.BillStack.FirstShouldDoNow.recipe.defName == "Anesthetize") { inverter = -1f; } | ||
tmpMedicine.SortBy((Thing x) => 0f - (x.GetStatValue(StatDefOf.MedicalPotency) * inverter), (Thing x) => x.Position.DistanceToSquared(billGiver.Position)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. heya, I know it's been ages since you made this PR, but did you check if this affects op chances? Don't more advanced meds increase success chances? Because pawns will pick up stacks of meds at once, if this affects operations in that they pick up crappy meds for anestesis and whatever affects the op itself, that might be an issue. |
||
relevantThings.AddRange(tmpMedicine); | ||
tmpMedicine.Clear(); | ||
return false; | ||
} | ||
} | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we're here, this line obsoletes the other patch.