diff --git a/1.2/Assemblies/Rimworld-Animations.dll b/1.2/Assemblies/Rimworld-Animations.dll index 9b4e693..c6044aa 100644 Binary files a/1.2/Assemblies/Rimworld-Animations.dll and b/1.2/Assemblies/Rimworld-Animations.dll differ diff --git a/About/Manifest.xml b/About/Manifest.xml index 1ffa310..f0113b3 100644 --- a/About/Manifest.xml +++ b/About/Manifest.xml @@ -1,5 +1,5 @@  Rimworld-Animations - 1.0.16 + 1.1.0 \ No newline at end of file diff --git a/Rimworld-Animations.csproj b/Rimworld-Animations.csproj index 98c35d0..7bae38d 100644 --- a/Rimworld-Animations.csproj +++ b/Rimworld-Animations.csproj @@ -45,7 +45,7 @@ False - ..\rjw-master\1.2\Assemblies\RJW.dll + ..\RJW\1.2\Assemblies\RJW.dll False @@ -105,6 +105,7 @@ + diff --git a/Source/Comps/CompBodyAnimator.cs b/Source/Comps/CompBodyAnimator.cs index 4d3c791..941c304 100644 --- a/Source/Comps/CompBodyAnimator.cs +++ b/Source/Comps/CompBodyAnimator.cs @@ -159,9 +159,8 @@ namespace Rimworld_Animations { //tick once for initialization tickAnim(); - - } + public override void CompTick() { base.CompTick(); @@ -208,8 +207,16 @@ namespace Rimworld_Animations { if (animTicks < anim.animationTimeTicks) { tickStage(); } else { + + if(LoopNeverending()) + { + ResetOnLoop(); + } else + { + isAnimating = false; + } + - isAnimating = false; } } @@ -227,9 +234,16 @@ namespace Rimworld_Animations { } if(curStage >= anim.animationStages.Count) { - isAnimating = false; - pawn.jobs.curDriver.ReadyForNextToil(); - + if (LoopNeverending()) + { + ResetOnLoop(); + } + else + { + isAnimating = false; + pawn.jobs.curDriver.ReadyForNextToil(); + } + } else { tickClip(); } @@ -444,5 +458,26 @@ namespace Rimworld_Animations { tickAnim(); } + public bool LoopNeverending() + { + if(pawn?.jobs?.curDriver != null && + (pawn.jobs.curDriver is JobDriver_Sex) && (pawn.jobs.curDriver as JobDriver_Sex).neverendingsex || + (pawn.jobs.curDriver is JobDriver_SexBaseReciever) && (pawn.jobs.curDriver as JobDriver_Sex).Partner?.jobs?.curDriver != null && ((pawn.jobs.curDriver as JobDriver_Sex).Partner.jobs.curDriver as JobDriver_Sex).neverendingsex) + { + return true; + } + + return false; + } + + public void ResetOnLoop() + { + curStage = 1; + animTicks = 0; + stageTicks = 0; + clipTicks = 0; + + tickAnim(); + } } } diff --git a/Source/JobDrivers/JobDriver_SexCasualForAnimation.cs b/Source/JobDrivers/JobDriver_SexCasualForAnimation.cs index 3fabe14..7b9aba0 100644 --- a/Source/JobDrivers/JobDriver_SexCasualForAnimation.cs +++ b/Source/JobDrivers/JobDriver_SexCasualForAnimation.cs @@ -64,7 +64,6 @@ namespace Rimworld_Animations { pawn.TryGetComp().isAnimating = false; } - ticks_left--; if(Gen.IsHashIntervalTick(pawn, ticks_between_hearts)) { MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart); } diff --git a/Source/Patches/rjwPatches/HarmonyPatch_JobDriver_SexBaseInitiator.cs b/Source/Patches/rjwPatches/HarmonyPatch_JobDriver_SexBaseInitiator.cs index 2967cd4..af0b9df 100644 --- a/Source/Patches/rjwPatches/HarmonyPatch_JobDriver_SexBaseInitiator.cs +++ b/Source/Patches/rjwPatches/HarmonyPatch_JobDriver_SexBaseInitiator.cs @@ -13,7 +13,6 @@ namespace Rimworld_Animations { [HarmonyPatch(typeof(JobDriver_SexBaseInitiator), "Start")] static class HarmonyPatch_JobDriver_SexBaseInitiator_Start { public static void Postfix(ref JobDriver_SexBaseInitiator __instance) { - /* These particular jobs need special code don't play anim for now @@ -52,16 +51,31 @@ namespace Rimworld_Animations { bool quickie = (__instance is JobDriver_SexQuick) && AnimationSettings.fastAnimForQuickie; + int preAnimDuration = __instance.duration; + int AnimationTimeTicks = 0; + + if (bed != null) { - RerollAnimations(Target, __instance.duration, bed as Thing, __instance.sexType, quickie, sexProps: __instance.Sexprops); - } + RerollAnimations(Target, out AnimationTimeTicks, bed as Thing, __instance.sexType, quickie, sexProps: __instance.Sexprops); + } else { - RerollAnimations(Target, __instance.duration, sexType: __instance.sexType, fastAnimForQuickie: quickie, sexProps: __instance.Sexprops); + RerollAnimations(Target, out AnimationTimeTicks, sexType: __instance.sexType, fastAnimForQuickie: quickie, sexProps: __instance.Sexprops); } + + + //Modify Orgasm ticks to only orgasm as many times as RJW stock orgasm allows + if(AnimationTimeTicks != 0) + { + __instance.orgasmstick = preAnimDuration * __instance.orgasmstick / AnimationTimeTicks; + } + + } } - public static void RerollAnimations(Pawn pawn, int duration, Thing bed = null, xxx.rjwSextype sexType = xxx.rjwSextype.None, bool fastAnimForQuickie = false, rjw.SexProps sexProps = null) { + public static void RerollAnimations(Pawn pawn, out int AnimationTimeTicks, Thing bed = null, xxx.rjwSextype sexType = xxx.rjwSextype.None, bool fastAnimForQuickie = false, rjw.SexProps sexProps = null) { + + AnimationTimeTicks = 0; if(pawn == null || !(pawn.jobs?.curDriver is JobDriver_SexBaseReciever)) { Log.Error("Error: Tried to reroll animations when pawn isn't sexing"); @@ -88,8 +102,6 @@ namespace Rimworld_Animations { bool mirror = GenTicks.TicksGame % 2 == 0; - Log.Message("Now playing " + anim.defName + (AnimationSettings.debugMode && mirror ? " mirrored" : "")); - IntVec3 pos = pawn.Position; if(pawnsToAnimate.Count > anim.actors.Count) @@ -112,9 +124,14 @@ namespace Rimworld_Animations { bool shiver = pawnsToAnimate[i].jobs.curDriver is JobDriver_SexBaseRecieverRaped; pawnsToAnimate[i].TryGetComp().StartAnimation(anim, pawnsToAnimate, i, mirror, shiver, fastAnimForQuickie); + (pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).ticks_left = anim.animationTimeTicks; - (pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).ticksLeftThisToil = anim.animationTimeTicks; + (pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).sex_ticks = anim.animationTimeTicks; (pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).duration = anim.animationTimeTicks; + + + AnimationTimeTicks = anim.animationTimeTicks; + if(!AnimationSettings.hearts) { (pawnsToAnimate[i].jobs.curDriver as JobDriver_Sex).ticks_between_hearts = Int32.MaxValue; } diff --git a/Source/Patches/rjwPatches/HarmonyPatch_PlaySexSounds.cs b/Source/Patches/rjwPatches/HarmonyPatch_PlaySexSounds.cs new file mode 100644 index 0000000..6544f13 --- /dev/null +++ b/Source/Patches/rjwPatches/HarmonyPatch_PlaySexSounds.cs @@ -0,0 +1,25 @@ +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), "PlaySexSound")] + class HarmonyPatch_PlaySexSounds + { + public static bool Prefix(JobDriver_Sex __instance) + { + if (__instance.pawn.TryGetComp().isAnimating) + { + return false; + } + + return true; + } + } +} diff --git a/Source/Patches/rjwPatches/HarmonyPatch_SexTick.cs b/Source/Patches/rjwPatches/HarmonyPatch_SexTick.cs index c645d18..42889ae 100644 --- a/Source/Patches/rjwPatches/HarmonyPatch_SexTick.cs +++ b/Source/Patches/rjwPatches/HarmonyPatch_SexTick.cs @@ -1,53 +1,86 @@ -using System; +using HarmonyLib; +using rjw; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using HarmonyLib; -using RimWorld; using Verse; -using rjw; -using Verse.Sound; +using Verse.AI; -namespace Rimworld_Animations { +namespace Rimworld_Animations +{ + [HarmonyPatch(typeof(JobDriver_Sex), "SexTick")] + public class HarmonyPatch_SexTick + { + public static bool Prefix(JobDriver_Sex __instance, Pawn pawn, Thing target) + { - [HarmonyPatch(typeof(JobDriver_Sex), "SexTick")] - public static class HarmonyPatch_SexTick { + Log.Message(pawn.Name + " ticks left: " + __instance.ticks_left); + Log.Message(pawn.Name + " sex ticks: " + __instance.sex_ticks); - public static bool Prefix(ref JobDriver_Sex __instance, ref Pawn pawn, ref Thing target, ref bool pawnnude, ref bool partnernude) { + if (!(target is Pawn) || + !( + (target as Pawn)?.jobs?.curDriver is JobDriver_SexBaseReciever + && + ((target as Pawn).jobs.curDriver as JobDriver_SexBaseReciever).parteners.Any() + && + ((target as Pawn).jobs.curDriver as JobDriver_SexBaseReciever).parteners[0] == pawn)) + { - Pawn pawn2 = target as Pawn; + __instance.ticks_left--; + __instance.sex_ticks--; + __instance.Orgasm(); - if (pawn == null || pawn2 == null) { - return true; + return false; + } + + return true; + } + + } + + [HarmonyPatch(typeof(JobDriver_Sex), "Orgasm")] + public class HarmonyPatch_Orgasm + { + public static bool Prefix(JobDriver_Sex __instance) + { + //todo: remove this code on next update + if (__instance.pawn.jobs.curDriver is JobDriver_SexBaseRecieverLoved || + __instance.pawn.jobs.curDriver is JobDriver_SexBaseRecieverRaped) return true; + + if (__instance.sex_ticks > __instance.orgasmstick) + { + return false; } + __instance.orgasms++; + __instance.PlayCumSound(); + __instance.PlayOrgasmVoice(); + __instance.CalculateSatisfactionPerTick(); - - if (pawn.IsHashIntervalTick(__instance.ticks_between_thrusts)) { - - __instance.ChangePsyfocus(pawn, pawn2); - - __instance.Animate(pawn, pawn2); - - if (!AnimationSettings.soundOverride || pawn.TryGetComp() == null || !pawn.TryGetComp().isAnimating) { - __instance.PlaySexSound(); - } - - if (!__instance.isRape) { - pawn.GainComfortFromCellIfPossible(); - pawn2?.GainComfortFromCellIfPossible(); - } + if (__instance.pawn?.jobs?.curDriver is JobDriver_SexBaseInitiator) + { + SexUtility.SatisfyPersonal(__instance.pawn, __instance.Partner, __instance.sexType, __instance.isRape, true, __instance.satisfaction); } - if (!xxx.has_quirk(pawn, "Endytophile")) { - if (pawnnude) { - SexUtility.DrawNude(pawn); - } - if (pawn2 != null && partnernude) { - SexUtility.DrawNude(pawn2); + else + { + if (__instance.pawn?.jobs?.curDriver is JobDriver_SexBaseReciever) + { + Pawn pawn = __instance.pawn; + Pawn_JobTracker jobs3 = __instance.pawn.jobs; + SexUtility.SatisfyPersonal(pawn, (__instance.pawn.jobs.curDriver as JobDriver_SexBaseReciever).parteners.FirstOrFallback(null), __instance.sexType, false, false, __instance.satisfaction); } + + } + Log.Message(xxx.get_pawnname(__instance.pawn) + " Orgasmed", false); + __instance.sex_ticks = __instance.Roll_Orgasm_Duration_Reset(); + if (__instance.neverendingsex) + { + __instance.ticks_left = __instance.duration; } return false; } - } + + } }