using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Verse; using RimWorld; using rjw; using Milk; using UnityEngine; using HarmonyLib; using System.Reflection.Emit; namespace CRIALactation { [HarmonyPatch(typeof(HumanCompHasGatherableBodyResource), "CompTick")] public static class HarmonyPatch_Milk_HumanCompHasGatherableBodyResource { public static IEnumerable Transpiler(IEnumerable codeInstructions) { var ins = codeInstructions.ToList(); for(int i = 0; i < ins.Count; i++) { if (ins[i].opcode == OpCodes.Callvirt && ins.Count > i + 1 && ins[i + 1].OperandIs(60000)) { yield return ins[i]; yield return new CodeInstruction(OpCodes.Ldarg_0); yield return new CodeInstruction(OpCodes.Call, AccessTools.DeclaredMethod(typeof(HarmonyPatch_Milk_HumanCompHasGatherableBodyResource), "AdjustGatherResourceDaysForPrecept")); } else { yield return ins[i]; } } } public static float AdjustGatherResourceDaysForPrecept(float resourcesIntervalDays, HumanCompHasGatherableBodyResource __instance) { Pawn pawn = __instance.parent as Pawn; if(pawn.Ideo.HasPrecept(PreceptDefOf_Lactation.Lactating_Essential)) { return resourcesIntervalDays * 0.666f; //1.5x normal rate } return resourcesIntervalDays; } } }