forked from simplyWiri/Loadout-Compositing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptimizeApparel_ApparelScoreGain_Patch.cs
More file actions
30 lines (25 loc) · 1.21 KB
/
OptimizeApparel_ApparelScoreGain_Patch.cs
File metadata and controls
30 lines (25 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using HarmonyLib;
using RimWorld;
using UnityEngine;
using Verse;
namespace Inventory {
// bias the apparel score gain significantly in favour of apparel in the pawns loadout
[HarmonyPatch(typeof(JobGiver_OptimizeApparel), nameof(JobGiver_OptimizeApparel.ApparelScoreRaw))]
public static class OptimizeApparel_ApparelScoreGain_Patch {
public static void Postfix(Pawn pawn, Apparel ap, ref float __result) {
var comp = pawn.GetComp<LoadoutComponent>();
var multiplier = comp?.Loadout.WeightAtWhichLoadoutDesires(ap) ?? 0;
if (multiplier != 0) {
if (ModBase.settings.biasLoadBearingItems && Utility.massBoostingClothes.TryGetValue(ap.def, out var func)) {
var hasQuality = ap.TryGetQuality(out var quality);
var score = func(hasQuality ? quality : QualityCategory.Normal);
__result += Mathf.Lerp(0.16f, 0.24f, score / 135f);
}
__result += 0.24f; // flat bonus for being an apparel in the loadout
__result *= multiplier;
} else if ( ModBase.settings.onlyItemsFromLoadout ) {
__result = -1000f;
}
}
}
}