mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
Further checks to make sure pawn doesn't clip oob
This commit is contained in:
parent
65b08eb2f4
commit
d70bd8b912
4 changed files with 56 additions and 15 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue