mirror of
https://gitgud.io/c0ffeeeeeeee/coffees-rjw-ideology-addons.git
synced 2024-08-14 23:57:38 +00:00
lactation production boost
This commit is contained in:
parent
5752647b4f
commit
a2327fc291
5 changed files with 76 additions and 5 deletions
|
@ -0,0 +1,64 @@
|
|||
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<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> 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.5f;
|
||||
}
|
||||
|
||||
return resourcesIntervalDays;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue