diff --git a/1.3/Assemblies/Rimworld-Animations.dll b/1.3/Assemblies/Rimworld-Animations.dll index 8125458..f297c22 100644 Binary files a/1.3/Assemblies/Rimworld-Animations.dll and b/1.3/Assemblies/Rimworld-Animations.dll differ diff --git a/1.3/Source/Comps/CompThingAnimator.cs b/1.3/Source/Comps/CompThingAnimator.cs index 967e3b6..d3e4839 100644 --- a/1.3/Source/Comps/CompThingAnimator.cs +++ b/1.3/Source/Comps/CompThingAnimator.cs @@ -1,4 +1,5 @@ -using rjw; +using RimWorld; +using rjw; using System; using System.Collections.Generic; using System.Linq; @@ -14,7 +15,7 @@ namespace Rimworld_Animations { Pawn pawn; - public bool isAnimating = false; + public bool isAnimating = false, mirror; int animTicks = 0, stageTicks = 0, clipTicks = 0, curStage = 0; float rotation = 0; @@ -33,12 +34,13 @@ namespace Rimworld_Animations { } - public void StartAnimation(AnimationDef anim, Pawn pawn) + public void StartAnimation(AnimationDef anim, Pawn pawn, bool mirror = false) { isAnimating = true; this.anim = anim; this.pawn = pawn; + this.mirror = mirror; animTicks = 0; stageTicks = 0; @@ -151,18 +153,71 @@ namespace Rimworld_Animations { calculateDrawValues(); } + public void setAnchor(Thing thing) + { + + //center on bed + if (thing is Building_Bed) + { + anchor = thing.Position.ToVector3(); + if (((Building_Bed)thing).SleepingSlotsCount == 2) + { + if (thing.Rotation.AsInt == 0) + { + anchor.x += 1; + anchor.z += 1; + } + else if (thing.Rotation.AsInt == 1) + { + anchor.x += 1; + } + else if (thing.Rotation.AsInt == 3) + { + anchor.z += 1; + } + + } + else + { + if (thing.Rotation.AsInt == 0) + { + anchor.x += 0.5f; + anchor.z += 1f; + } + else if (thing.Rotation.AsInt == 1) + { + anchor.x += 1f; + anchor.z += 0.5f; + } + else if (thing.Rotation.AsInt == 2) + { + anchor.x += 0.5f; + } + else + { + anchor.z += 0.5f; + } + } + } + else + { + anchor = thing.Position.ToVector3Shifted(); + } + + anchor -= new Vector3(0.5f, 0, 0.5f); + } private void calculateDrawValues() { //shift up and right 0.5f to align center - deltaPos = new Vector3(clip.PositionX.Evaluate(clipPercent) + 0.5f/* todo * (mirror ? -1 : 1) */, AltitudeLayer.Item.AltitudeFor(), clip.PositionZ.Evaluate(clipPercent) + 0.5f); + deltaPos = new Vector3((clip.PositionX.Evaluate(clipPercent)) * (mirror ? -1 : 1) + 0.5f, AltitudeLayer.Item.AltitudeFor(), clip.PositionZ.Evaluate(clipPercent) + 0.5f); Log.Message("Clip percent: " + clipPercent + " deltaPos: " + deltaPos); - rotation = clip.Rotation.Evaluate(clipPercent); + rotation = clip.Rotation.Evaluate(clipPercent) * (mirror ? -1 : 1); } public void AnimateThing(Thing thing) { - thing.Graphic.Draw(deltaPos + anchor, Rot4.North, thing, rotation); + thing.Graphic.Draw(deltaPos + anchor, mirror ? Rot4.West : Rot4.East, thing, rotation); } public bool LoopNeverending() diff --git a/Patch_SexToysMasturbation/1.3/Assemblies/Patch_SexToysMasturbation.dll b/Patch_SexToysMasturbation/1.3/Assemblies/Patch_SexToysMasturbation.dll index 490d03d..3aca8b1 100644 Binary files a/Patch_SexToysMasturbation/1.3/Assemblies/Patch_SexToysMasturbation.dll and b/Patch_SexToysMasturbation/1.3/Assemblies/Patch_SexToysMasturbation.dll differ diff --git a/Patch_SexToysMasturbation/Source/Patches/HarmonyPatch_JobDriver_SexBaseInitiator.cs b/Patch_SexToysMasturbation/Source/Patches/HarmonyPatch_JobDriver_SexBaseInitiator.cs index 279ea01..ef3f4fb 100644 --- a/Patch_SexToysMasturbation/Source/Patches/HarmonyPatch_JobDriver_SexBaseInitiator.cs +++ b/Patch_SexToysMasturbation/Source/Patches/HarmonyPatch_JobDriver_SexBaseInitiator.cs @@ -20,33 +20,42 @@ namespace Patch_SexToysMasturbation if(__instance is JobDriver_MasturbateWithToy masturbateJobDriver) { + Log.Message("Rerolling animations..."); Pawn pawn = masturbateJobDriver.pawn; Thing sexToy = masturbateJobDriver.dildo; - RerollAnimationsForSexToy(pawn, sexToy); + RerollAnimationsForSexToy(pawn, sexToy, masturbateJobDriver.Bed); } } - public static void RerollAnimationsForSexToy(Pawn pawn, Thing thing) + public static void RerollAnimationsForSexToy(Pawn pawn, Thing thing, Thing bed) { CompSexToy sextoy = thing.TryGetComp(); SexToyAnimationDef anim = AnimSexToyUtility.tryFindAnimation(sextoy, pawn); - - if (anim != null) { Log.Message("Playing anim " + anim.defName); - pawn.TryGetComp().setAnchor(pawn.Position); - thing.TryGetComp().setAnchor(pawn.Position); + if(bed != null) + { + pawn.TryGetComp().setAnchor(bed); + thing.TryGetComp().setAnchor(bed); + } + else + { + pawn.TryGetComp().setAnchor(pawn.Position); + thing.TryGetComp().setAnchor(pawn.Position); + } - pawn.TryGetComp().StartAnimation(anim, new List { pawn }, 0); - thing.TryGetComp().StartAnimation(anim, pawn); + bool mirror = GenTicks.TicksGame % 2 == 0; + + pawn.TryGetComp().StartAnimation(anim, new List { pawn }, 0, mirror); + thing.TryGetComp().StartAnimation(anim, pawn, mirror); (pawn.jobs.curDriver as JobDriver_Sex).ticks_left = anim.animationTimeTicks; (pawn.jobs.curDriver as JobDriver_Sex).sex_ticks = anim.animationTimeTicks;