fixed: invis sleeping

sex job length matches anim length
This commit is contained in:
c0ffee 2024-04-22 14:46:00 -07:00
parent c33072614b
commit 315a57e53d
9 changed files with 104 additions and 11 deletions

View File

@ -51,6 +51,23 @@ namespace Rimworld_Animations {
}
}
public int AnimationLength
{
get
{
if (!IsAnimating) return 0;
int groupAnimLength = 0;
foreach(AnimationDef anim in animationQueue)
{
groupAnimLength += anim.durationTicks;
}
return groupAnimLength;
}
}
public Vector3 getAnchor()
{
return anchor.getDrawPos();

View File

@ -37,7 +37,7 @@ namespace Rimworld_Animations {
bool quickie = (__instance is JobDriver_SexQuick) && AnimationSettings.fastAnimForQuickie;
int preAnimDuration = __instance.duration;
int AnimationTimeTicks = 0;
List<Pawn> participants = partnerSexBaseReceiver.parteners.Append(partner).ToList();
@ -45,16 +45,16 @@ namespace Rimworld_Animations {
if (groupAnimation != null)
{
AnimationUtility.StartGroupAnimation(participants, groupAnimation, reorder, partner);
}
int animTicks = AnimationUtility.GetAnimationLength(pawn);
//Modify Orgasm ticks to only orgasm as many times as RJW stock orgasm allows
if (AnimationTimeTicks != 0)
{
__instance.orgasmstick = preAnimDuration * __instance.orgasmstick / AnimationTimeTicks;
foreach(Pawn participant in participants)
{
(participant.jobs.curDriver as JobDriver_Sex).ticks_left = animTicks;
(participant.jobs.curDriver as JobDriver_Sex).sex_ticks = animTicks;
(participant.jobs.curDriver as JobDriver_Sex).orgasmStartTick = animTicks;
(participant.jobs.curDriver as JobDriver_Sex).duration = animTicks;
}
}
}
}

View File

@ -0,0 +1,39 @@
using HarmonyLib;
using rjw;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace Rimworld_Animations
{
[HarmonyPatch(typeof(JobDriver_Sex), "Animate")]
public class HarmonyPatch_Animate
{
public static bool Prefix(ref JobDriver_Sex __instance, ref Pawn pawn, ref Thing target)
{
//remove all bumping stuff in animations; keep draw nude code
if (target != null)
{
Pawn pawn2 = target as Pawn;
if (!__instance.isEndytophile)
{
SexUtility.DrawNude(pawn, false);
if (pawn2 != null)
{
SexUtility.DrawNude(pawn2, false);
return false;
}
}
}
else if (!__instance.isEndytophile)
{
SexUtility.DrawNude(pawn, false);
}
return false;
}
}
}

View File

@ -1,8 +1,10 @@
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;
@ -19,5 +21,32 @@ namespace Rimworld_Animations
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();
}
}
}

View File

@ -95,5 +95,11 @@ namespace Rimworld_Animations {
}
public static int GetAnimationLength(Pawn pawn)
{
return pawn.TryGetComp<CompExtendedAnimator>().AnimationLength;
}
}
}

View File

@ -46,6 +46,7 @@
</Reference>
<Reference Include="RJW">
<HintPath>..\rjw\1.5\Assemblies\RJW.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="RJW-ToysAndMasturbation">
<HintPath>..\rjw-toys-and-masturbation\Assemblies\RJW-ToysAndMasturbation.dll</HintPath>
@ -104,8 +105,9 @@
<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\HarmonyPatch_PlaySexSounds.cs" />
<Compile Include="1.5\Source\Patches\RJWPatches\HarmonyPatch_SexTick.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" />
<Compile Include="1.5\Source\Patches\RJWPatches\HarmonyPatch_WorkGiverSex.cs" />
<Compile Include="1.5\Source\Patches\RJWPatches\JobDrivers\HarmonyPatch_JobDriver_JoinInBed.cs" />
<Compile Include="1.5\Source\Patches\RJWPatches\JobDrivers\HarmonyPatch_JobDriver_Sex.cs" />