mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
315a57e53d
sex job length matches anim length
53 lines
1.7 KiB
C#
53 lines
1.7 KiB
C#
using HarmonyLib;
|
|
using RimWorld;
|
|
using rjw;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection.Emit;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Verse.AI;
|
|
|
|
namespace Rimworld_Animations
|
|
{
|
|
[HarmonyPatch(typeof(JobDriver_SexBaseRecieverLoved), "MakeSexToil")]
|
|
public class HarmonyPatch_JobDriver_SexBaseReceiverLoved
|
|
{
|
|
public static void Postfix(JobDriver_SexBaseRecieverLoved __instance, ref Toil __result)
|
|
{
|
|
//added for sudden end of jobdriver
|
|
__result.AddFinishAction(delegate {
|
|
AnimationUtility.StopGroupAnimation(__instance.pawn);
|
|
});
|
|
}
|
|
|
|
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> codeInstructions)
|
|
{
|
|
|
|
var ins = codeInstructions.ToList();
|
|
for (int i = 0; i < ins.Count; i++)
|
|
{
|
|
if (i < ins.Count && ins[i].opcode == OpCodes.Call && ins[i].OperandIs(AccessTools.DeclaredMethod(typeof(Toils_LayDown), "LayDown")))
|
|
{
|
|
|
|
ins[i].operand = AccessTools.DeclaredMethod(typeof(HarmonyPatch_JobDriver_SexBaseReceiverLoved), "DoNotLayDown");
|
|
yield return ins[i];
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
yield return ins[i];
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public static Toil DoNotLayDown(TargetIndex bedOrRestSpotIndex, bool hasBed, bool lookForOtherJobs, bool canSleep = true, bool gainRestAndHealth = true, PawnPosture noBedLayingPosture = PawnPosture.LayingMask, bool deathrest = false)
|
|
{
|
|
return new Toil();
|
|
}
|
|
}
|
|
}
|