using HarmonyLib; using rjw; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Verse; using Verse.AI; namespace Rimworld_Animations { [HarmonyPatch(typeof(JobDriver_Masturbate), "SetupDurationTicks")] public class HarmonyPatch_JobDriver_Masturbate { public static void Postfix(JobDriver_Masturbate __instance) { //prevent early stoppage of masturbate jobdriver during animation /* not needed anymore? Ticks are assigned during animation __instance.duration = 10000000; __instance.ticks_left = __instance.duration; */ } } [HarmonyPatch(typeof(JobDriver_Masturbate), "MakeNewToils")] public class HarmonyPatch_JobDriver_Masturbate2 { public static void Postfix(JobDriver_Masturbate __instance, ref IEnumerable __result) { var toils = __result.ToList(); //sex toil toils[1].initAction += delegate () { CompExtendedAnimator pawnAnimator = __instance.pawn.TryGetComp(); // if pawn was given an animation to play, if (pawnAnimator.IsAnimating) { //set duration of masturbate toil to anim length toils[1].defaultDuration = pawnAnimator.AnimationLength; } }; __result = toils.AsEnumerable(); } } }