mirror of
https://github.com/Shabakur/RJW_More_.git
synced 2024-08-14 23:57:04 +00:00
50 lines
2.1 KiB
C#
50 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Reflection.Emit;
|
|
using System.Reflection;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using HarmonyLib;
|
|
using Verse;
|
|
using RimWorld;
|
|
using rjw;
|
|
|
|
namespace shabe_genesaddons
|
|
{
|
|
[HarmonyPatch(typeof(PregnancyHelper), "DoEgg")]
|
|
static class PatchPregnancyHelper
|
|
{
|
|
[HarmonyTranspiler]
|
|
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator il)
|
|
{
|
|
//MethodInfo isinsectincubator = AccessTools.Method(typeof(GeneUtility), "IsInsectIncubator");
|
|
MethodInfo maxeggsizemul = AccessTools.Method(typeof(GeneUtility), "MaxEggSizeMul");
|
|
FieldInfo partner = AccessTools.Field(typeof(SexProps), "partner");
|
|
|
|
Label skiplabel = il.DefineLabel();
|
|
bool finished = false;
|
|
foreach (CodeInstruction codeInstruction in instructions)
|
|
{
|
|
if (!finished)
|
|
{
|
|
if (codeInstruction.opcode == OpCodes.Ldc_R4 && codeInstruction.operand.ToString() == "0")
|
|
{
|
|
yield return new CodeInstruction(OpCodes.Ldarg_0, null);
|
|
yield return new CodeInstruction(OpCodes.Ldfld, partner);
|
|
//yield return new CodeInstruction(OpCodes.Call, isinsectincubator);
|
|
yield return new CodeInstruction(OpCodes.Callvirt, maxeggsizemul);
|
|
//yield return new CodeInstruction(OpCodes.Brfalse_S, skiplabel);
|
|
yield return new CodeInstruction(OpCodes.Ldloc_0, null);
|
|
//yield return new CodeInstruction(OpCodes.Ldc_R4, 2f);
|
|
yield return new CodeInstruction(OpCodes.Mul, null);
|
|
yield return new CodeInstruction(OpCodes.Stloc_0, null);
|
|
//codeInstruction.labels.Add(skiplabel);
|
|
finished = true;
|
|
}
|
|
}
|
|
yield return codeInstruction;
|
|
}
|
|
}
|
|
}
|
|
}
|