diff --git a/1.5/Assemblies/Rimworld-Animations.dll b/1.5/Assemblies/Rimworld-Animations.dll index 8cd47b3..0d8e28a 100644 Binary files a/1.5/Assemblies/Rimworld-Animations.dll and b/1.5/Assemblies/Rimworld-Animations.dll differ diff --git a/1.5/Source/Patches/RJWPatches/JobDrivers/HarmonyPatch_JobDriver_SexBaseInitiator.cs b/1.5/Source/Patches/RJWPatches/JobDrivers/HarmonyPatch_JobDriver_SexBaseInitiator.cs index b229832..75e43cc 100644 --- a/1.5/Source/Patches/RJWPatches/JobDrivers/HarmonyPatch_JobDriver_SexBaseInitiator.cs +++ b/1.5/Source/Patches/RJWPatches/JobDrivers/HarmonyPatch_JobDriver_SexBaseInitiator.cs @@ -6,134 +6,93 @@ using RimWorld; using Verse; using rjw; -namespace Rimworld_Animations -{ +namespace Rimworld_Animations { [HarmonyPatch(typeof(JobDriver_SexBaseInitiator), "Start")] - static class HarmonyPatch_JobDriver_SexBaseInitiator_Start - { - public static void Postfix(ref JobDriver_SexBaseInitiator __instance) - { + static class HarmonyPatch_JobDriver_SexBaseInitiator_Start { + public static void Postfix(ref JobDriver_SexBaseInitiator __instance) { - Pawn pawn = __instance.pawn; - Pawn partner = __instance.Target as Pawn; + Pawn pawn = __instance.pawn; + Pawn partner = __instance.Target as Pawn; + - if (partner == null) - partner = pawn; + if (partner?.jobs?.curDriver is JobDriver_SexBaseReciever partnerSexBaseReceiver) { - List participants = GetAllSexParticipants(pawn); - GroupAnimationDef groupAnimation = AnimationUtility.FindGroupAnimation(participants, out int reorder); + Pawn Target = __instance.Target as Pawn; - if (groupAnimation != null) - { - Thing anchor = (Thing)__instance.Bed ?? partner; + List participants = partnerSexBaseReceiver.parteners.Append(partner).ToList(); - AnimationUtility.StartGroupAnimation(participants, groupAnimation, reorder, anchor); - int animTicks = AnimationUtility.GetAnimationLength(pawn); + GroupAnimationDef groupAnimation = AnimationUtility.FindGroupAnimation(participants, out int reorder); - foreach (Pawn participant in participants) + if (groupAnimation != null) { - if (RJWAnimationSettings.debugMode) + Thing anchor = (Thing)__instance.Bed ?? partner; + + AnimationUtility.StartGroupAnimation(participants, groupAnimation, reorder, anchor); + int animTicks = AnimationUtility.GetAnimationLength(pawn); + + foreach(Pawn participant in participants) { - Log.Message("Participant: " + participant.Name); - Log.Message("JobDriver: " + participant.CurJobDef.defName); - } + if (RJWAnimationSettings.debugMode) + { + Log.Message("Participant: " + participant.Name); + Log.Message("JobDriver: " + participant.CurJobDef.defName); - //null ref check for pawns that might have lost their jobs or become null for some reason - if (participant?.jobs?.curDriver is JobDriver_Sex participantJobDriver) - { - participantJobDriver.ticks_left = animTicks; - participantJobDriver.sex_ticks = animTicks; - participantJobDriver.orgasmStartTick = animTicks; - participantJobDriver.duration = animTicks; - } - } - } - } + } - public static List GetAllSexParticipants(this Pawn pawn) + //null ref check for pawns that might have lost their jobs or become null for some reason + if (participant?.jobs?.curDriver is JobDriver_Sex participantJobDriver) + { + participantJobDriver.ticks_left = animTicks; + participantJobDriver.sex_ticks = animTicks; + participantJobDriver.orgasmStartTick = animTicks; + participantJobDriver.duration = animTicks; + } + } + } + } + } + + static IEnumerable NonSexActRulePackDefNames = new String[] + { + "MutualHandholdingRP", + "MutualMakeoutRP", + }; + + public static bool NonSexualAct(JobDriver_SexBaseInitiator sexBaseInitiator) { - List participants = new List(); - - if (pawn?.jobs?.curDriver == null || - (pawn.jobs.curDriver is JobDriver_Sex) == false) - return participants; - - var receiver = pawn.GetSexReceiver(); - - if (receiver != null) + if(NonSexActRulePackDefNames.Contains(sexBaseInitiator.Sexprops.rulePack)) { - participants = (receiver.jobs.curDriver as JobDriver_SexBaseReciever).parteners; - participants.AddDistinct(receiver); - - return participants; + return true; } - - participants.AddDistinct(pawn); - - return participants; + return false; } + } - public static Pawn GetSexReceiver(this Pawn pawn) - { - if (pawn?.jobs?.curDriver == null) - return null; - if (pawn.jobs.curDriver is JobDriver_SexBaseReciever) - return pawn; + [HarmonyPatch(typeof(JobDriver_SexBaseInitiator), "End")] + static class HarmonyPatch_JobDriver_SexBaseInitiator_End { - JobDriver_SexBaseInitiator jobDriver = pawn.jobs.curDriver as JobDriver_SexBaseInitiator; + public static void Prefix(ref JobDriver_SexBaseInitiator __instance) + { + //stop pawn animating + AnimationUtility.StopGroupAnimation(__instance.pawn); - if (jobDriver?.Partner?.jobs?.curDriver == null) - return null; - - if (jobDriver.Partner.jobs.curDriver is JobDriver_SexBaseReciever) - return jobDriver.Partner; - - return null; - } - - static IEnumerable NonSexActRulePackDefNames = new String[] - { - "MutualHandholdingRP", - "MutualMakeoutRP", - }; - - public static bool NonSexualAct(JobDriver_SexBaseInitiator sexBaseInitiator) - { - if (NonSexActRulePackDefNames.Contains(sexBaseInitiator.Sexprops.rulePack)) + //stop partner animating + if (__instance.Partner is Pawn partner) { - return true; - } - return false; - } - } + AnimationUtility.StopGroupAnimation(partner); + } - - [HarmonyPatch(typeof(JobDriver_SexBaseInitiator), "End")] - static class HarmonyPatch_JobDriver_SexBaseInitiator_End - { - - public static void Prefix(ref JobDriver_SexBaseInitiator __instance) - { - //stop pawn animating - AnimationUtility.StopGroupAnimation(__instance.pawn); - - //stop partner animating - if (__instance.Partner is Pawn partner) + //stop partner's other partners (threesome pawns) animating + //added null ref checks for instances when pawns get nulled or lose their jobs + if (__instance.Partner?.jobs?.curDriver is JobDriver_SexBaseReciever partnerReceiverJob) { - AnimationUtility.StopGroupAnimation(partner); - } - - //stop partner's other partners (threesome pawns) animating - //added null ref checks for instances when pawns get nulled or lose their jobs - if (__instance.Partner?.jobs?.curDriver is JobDriver_SexBaseReciever partnerReceiverJob) - { - foreach (Pawn pawn in partnerReceiverJob.parteners) + foreach(Pawn pawn in partnerReceiverJob.parteners) { - if (pawn != null) AnimationUtility.StopGroupAnimation(pawn); - } + if (pawn != null) AnimationUtility.StopGroupAnimation(pawn); + } } - } - } + } + } }