Further checks to make sure pawn doesn't clip oob

This commit is contained in:
Platinum 2020-04-16 11:51:26 -07:00
parent 65b08eb2f4
commit d70bd8b912
4 changed files with 56 additions and 15 deletions

View file

@ -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<CompBodyAnimator>() != null && ___pawn.TryGetComp<CompBodyAnimator>().isAnimating) {
__result = ___pawn.TryGetComp<CompBodyAnimator>().anchor + ___pawn.TryGetComp<CompBodyAnimator>().deltaPos;
___pawn.Position = __result.ToIntVec3();
return false;
if(___pawn.TryGetComp<CompBodyAnimator>() != null) {
if(___pawn.TryGetComp<CompBodyAnimator>().isAnimating) {
__result = ___pawn.TryGetComp<CompBodyAnimator>().anchor + ___pawn.TryGetComp<CompBodyAnimator>().deltaPos;
___pawn.Position = __result.ToIntVec3();
return false;
} else if(___pawn.TryGetComp<CompBodyAnimator>().resetPosition) {
//resetting position to anchor
__result = ___pawn.TryGetComp<CompBodyAnimator>().anchor;
___pawn.Position = ___pawn.TryGetComp<CompBodyAnimator>().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<CompBodyAnimator>() != null) {
if(___pawn.TryGetComp<CompBodyAnimator>().isAnimating || ___pawn.TryGetComp<CompBodyAnimator>().resetPosition) {
___pawn.TryGetComp<CompBodyAnimator>().isAnimating = false;
___pawn.Position = ___pawn.TryGetComp<CompBodyAnimator>().positionReset;
}
}
}
}
}

View file

@ -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<CompBodyAnimator>().isAnimating = false;
}
}
__instance.Target.TryGetComp<CompBodyAnimator>().isAnimating = false;