Skip to content

Commit

Permalink
fix tending and interaction error
Browse files Browse the repository at this point in the history
check if inventory contains any valid medicince before trying to select
the best option.
  • Loading branch information
FluffierThanThou committed Aug 27, 2021
1 parent 5452f28 commit a2ba778
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Binary file modified Assemblies/Pharmacist.dll
Binary file not shown.
10 changes: 7 additions & 3 deletions Source/HarmonyPatches/HealthAIUtility_FindBestMedicine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// HealthAIUtility_FindBestMedicine.cs
// 2017-02-11

using System.Collections.Generic;
using System.Linq;
using HarmonyLib;
using RimWorld;
Expand Down Expand Up @@ -43,9 +44,12 @@ bool allowedPredicate(Thing m) {
//
// thanks to KennethSammael for adding this check in the unofficial 1.3 update,
// this code is adapted from his changes.
__result = healer.inventory.innerContainer
.Where(allowedPredicate)
.MaxBy(potencyGetter);
// Update; I adapted it badly. The fault was all mine.
IEnumerable<Thing> options = healer.inventory.innerContainer
.Where(allowedPredicate);
if (options.Any()) {
__result = options.MaxBy(potencyGetter);
}
if (__result is not null || onlyUseInventory) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion modinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"version": {
"major": 3,
"minor": 2,
"build": 147
"build": 148
},
"author": {
"name": "Fluffy",
Expand Down

0 comments on commit a2ba778

Please sign in to comment.