masturbate tick fix

This commit is contained in:
c0ffee 2024-08-11 20:35:28 -07:00
parent b2c6838cb1
commit 1532339602
4 changed files with 42 additions and 0 deletions

View file

@ -0,0 +1,22 @@
using HarmonyLib;
using rjw;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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
__instance.duration = 10000000;
__instance.ticks_left = __instance.duration;
}
}
}

View file

@ -49,6 +49,25 @@ namespace Rimworld_Animations
}
}
}
else
{
//backup check for if masturbation doesn't have anim
//reset duration and ticks_left to the regular RJW values
//because of HarmonyPatch_JobDriver_Masturbate setting the values large to prevent early stoppage
foreach (Pawn participant in participants)
{
if (participant?.jobs?.curDriver is JobDriver_Sex participantJobDriver)
{
participantJobDriver.duration = (int)(xxx.is_frustrated(participant) ? (2500f * Rand.Range(0.2f, 0.7f)) : (2500f * Rand.Range(0.2f, 0.4f)));
participantJobDriver.ticks_left = participantJobDriver.duration;
}
}
}
}
public static List<Pawn> GetAllSexParticipants(this Pawn pawn)

View file

@ -124,6 +124,7 @@
<Compile Include="1.5\Source\Patches\RimworldPatches\HarmonyPatch_PawnRenderTree.cs" />
<Compile Include="1.5\Source\Patches\RimworldPatches\HarmonyPatch_Pawn_DrawTracker.cs" />
<Compile Include="1.5\Source\Patches\RimworldPatches\HarmonyPatch_Thing.cs" />
<Compile Include="1.5\Source\Patches\RJWPatches\JobDrivers\HarmonyPatch_JobDriver_Masturbate.cs" />
<Compile Include="1.5\Source\Patches\RJWPatches\JobDrivers\JobDriver_Sex\HarmonyPatch_Animate.cs" />
<Compile Include="1.5\Source\Patches\RJWPatches\JobDrivers\JobDriver_Sex\HarmonyPatch_PlaySexSounds.cs" />
<Compile Include="1.5\Source\Patches\RJWPatches\JobDrivers\JobDriver_Sex\HarmonyPatch_SexTick.cs" />