diff --git a/1.1/Assemblies/Rimworld-Animations.dll b/1.1/Assemblies/Rimworld-Animations.dll index 09d10ae..98a3529 100644 Binary files a/1.1/Assemblies/Rimworld-Animations.dll and b/1.1/Assemblies/Rimworld-Animations.dll differ diff --git a/Source/Comps/CompBodyAnimator.cs b/Source/Comps/CompBodyAnimator.cs index 120a3b2..2d1a379 100644 --- a/Source/Comps/CompBodyAnimator.cs +++ b/Source/Comps/CompBodyAnimator.cs @@ -28,16 +28,28 @@ namespace Rimworld_Animations { if(value == true) { xxx.DrawNude(pawn); } else { - pawn.Position = anchor.ToIntVec3(); - pawn.Notify_Teleported(false, true); - pawn.pather.StopDead(); pawn.Drawer.renderer.graphics.ResolveAllGraphics(); + resetPosition = true; } PortraitsCache.SetDirty(pawn); } } - private bool Animating; + + public bool resetPosition { + get { + if (resetPos) { + resetPos = false; + return true; + } + return false; + } + set { + resetPos = value; + } + } + + private bool Animating, resetPos = false; private bool mirror = false; private int actor; @@ -45,6 +57,7 @@ namespace Rimworld_Animations { private int curStage = 0; private float clipPercent = 0; + public IntVec3 positionReset; public Vector3 anchor, deltaPos, headBob; public float bodyAngle, headAngle; public Rot4 headFacing, bodyFacing; @@ -55,11 +68,13 @@ namespace Rimworld_Animations { public void setAnchor(IntVec3 pos) { + positionReset = pos; anchor = pos.ToVector3Shifted(); } public void setAnchor(Thing thing) { - + //center on bed + positionReset = thing.Position; if(thing is Building_Bed) { anchor = thing.Position.ToVector3(); if (((Building_Bed)thing).SleepingSlotsCount == 2) { @@ -117,16 +132,17 @@ namespace Rimworld_Animations { public override void CompTick() { base.CompTick(); - if(Animating) { + if(isAnimating) { tickAnim(); if (pawn?.jobs?.curDriver == null || (pawn?.jobs?.curDriver != null && !(pawn?.jobs?.curDriver is rjw.JobDriver_Sex))) { + isAnimating = false; } } } public void animatePawn(ref Vector3 rootLoc, ref float angle, ref Rot4 bodyFacing, ref Rot4 headFacing) { - if(!Animating) { + if(!isAnimating) { return; } rootLoc = anchor + deltaPos; @@ -142,13 +158,13 @@ namespace Rimworld_Animations { public void tickAnim() { - if (!Animating) return; + if (!isAnimating) return; animTicks++; if (animTicks < anim.animationTimeTicks) { tickStage(); } else { - Animating = false; + isAnimating = false; } } diff --git a/Source/Patches/HarmonyPatch_Pawn_DrawTracker.cs b/Source/Patches/HarmonyPatch_Pawn_DrawTracker.cs index 73856ae..569720f 100644 --- a/Source/Patches/HarmonyPatch_Pawn_DrawTracker.cs +++ b/Source/Patches/HarmonyPatch_Pawn_DrawTracker.cs @@ -6,6 +6,7 @@ using System.Text; using System.Threading.Tasks; using UnityEngine; using Verse; +using Verse.AI; namespace Rimworld_Animations { @@ -13,13 +14,36 @@ namespace Rimworld_Animations { public static class HarmonyPatch_Pawn_DrawTracker { public static bool Prefix(ref Pawn ___pawn, ref Vector3 __result) { - if(___pawn.TryGetComp() != null && ___pawn.TryGetComp().isAnimating) { - __result = ___pawn.TryGetComp().anchor + ___pawn.TryGetComp().deltaPos; - ___pawn.Position = __result.ToIntVec3(); - return false; + if(___pawn.TryGetComp() != null) { + + if(___pawn.TryGetComp().isAnimating) { + __result = ___pawn.TryGetComp().anchor + ___pawn.TryGetComp().deltaPos; + ___pawn.Position = __result.ToIntVec3(); + return false; + } else if(___pawn.TryGetComp().resetPosition) { + //resetting position to anchor + __result = ___pawn.TryGetComp().anchor; + ___pawn.Position = ___pawn.TryGetComp().positionReset; + return false; + + } + } return true; } } + + [HarmonyPatch(typeof(Pawn_PathFollower), "StartPath")] + public static class HarmonyPatch_ResetPositionIfPathing { + public static void Prefix(ref Pawn ___pawn) { + + if(___pawn.TryGetComp() != null) { + if(___pawn.TryGetComp().isAnimating || ___pawn.TryGetComp().resetPosition) { + ___pawn.TryGetComp().isAnimating = false; + ___pawn.Position = ___pawn.TryGetComp().positionReset; + } + } + } + } } diff --git a/Source/Patches/rjwPatches/HarmonyPatch_JobDriver_SexBaseInitiator.cs b/Source/Patches/rjwPatches/HarmonyPatch_JobDriver_SexBaseInitiator.cs index 35331b0..04656da 100644 --- a/Source/Patches/rjwPatches/HarmonyPatch_JobDriver_SexBaseInitiator.cs +++ b/Source/Patches/rjwPatches/HarmonyPatch_JobDriver_SexBaseInitiator.cs @@ -146,9 +146,10 @@ namespace Rimworld_Animations { for (int i = 0; i < parteners.Count; i++) { //prevents pawns who started a new anim from stopping their new anim - if (!((parteners[i].jobs.curDriver as JobDriver_SexBaseInitiator) != null && (parteners[i].jobs.curDriver as JobDriver_SexBaseInitiator).Target != __instance.pawn)) + if (!((parteners[i].jobs.curDriver as JobDriver_SexBaseInitiator) != null && (parteners[i].jobs.curDriver as JobDriver_SexBaseInitiator).Target != __instance.pawn)) { parteners[i].TryGetComp().isAnimating = false; - + } + } __instance.Target.TryGetComp().isAnimating = false;