rjw-quirks/RJW-Quirks/HarmonyPatches/Patch_JobGiver_Masturbate.cs

60 lines
2.0 KiB
C#

using HarmonyLib;
using rjw;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Verse;
using rjwquirks.Modules.Quirks;
namespace rjwquirks.HarmonyPatches
{
/*[HarmonyPatch(typeof(JobGiver_Masturbate))]
public class Patch_JobGiver_Masturbate
{
[HarmonyTranspiler]
[HarmonyPatch("TryGiveJob")]
public static IEnumerable<CodeInstruction> ApplyQuirkToMasturbate(IEnumerable<CodeInstruction> instructions)
{
MethodInfo Frustrated = AccessTools.Method(typeof(xxx), nameof(xxx.is_frustrated));
MethodInfo Apply = AccessTools.Method(typeof(Patch_JobGiver_Masturbate), nameof(ApplyQuirk));
var labels = instructions.ElementAt(0).labels.ListFullCopy<Label>();
Log.Warning(labels.Count.ToString());
bool found = false;
foreach (CodeInstruction i in instructions)
{
if (i.opcode == OpCodes.Call && i.operand as MethodInfo == Frustrated)
{
yield return new CodeInstruction(OpCodes.Ldarg_1);
yield return new CodeInstruction(OpCodes.Call, Apply);
yield return new CodeInstruction(OpCodes.Brtrue_S, labels[4]);
found = true;
}
if (found && i.opcode == OpCodes.Call && i.operand as MethodInfo == Frustrated)
{
yield return new CodeInstruction(OpCodes.Ldarg_1);
yield return new CodeInstruction(OpCodes.Call, Apply);
yield return new CodeInstruction(OpCodes.Brtrue_S, labels[5]);
found = false;
}
yield return i;
}
}
public static bool ApplyQuirk(Pawn pawn)
{
if (pawn.GetQuirks() != null)
return pawn.HasQuirk(QuirkDefOf.Exhibitionist);
return false;
}
}*/
}