Further checks to make sure pawn doesn't clip oob
This commit is contained in:
parent
65b08eb2f4
commit
d70bd8b912
Binary file not shown.
|
@ -28,16 +28,28 @@ namespace Rimworld_Animations {
|
||||||
if(value == true) {
|
if(value == true) {
|
||||||
xxx.DrawNude(pawn);
|
xxx.DrawNude(pawn);
|
||||||
} else {
|
} else {
|
||||||
pawn.Position = anchor.ToIntVec3();
|
|
||||||
pawn.Notify_Teleported(false, true);
|
|
||||||
pawn.pather.StopDead();
|
|
||||||
pawn.Drawer.renderer.graphics.ResolveAllGraphics();
|
pawn.Drawer.renderer.graphics.ResolveAllGraphics();
|
||||||
|
resetPosition = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PortraitsCache.SetDirty(pawn);
|
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 bool mirror = false;
|
||||||
private int actor;
|
private int actor;
|
||||||
|
|
||||||
|
@ -45,6 +57,7 @@ namespace Rimworld_Animations {
|
||||||
private int curStage = 0;
|
private int curStage = 0;
|
||||||
private float clipPercent = 0;
|
private float clipPercent = 0;
|
||||||
|
|
||||||
|
public IntVec3 positionReset;
|
||||||
public Vector3 anchor, deltaPos, headBob;
|
public Vector3 anchor, deltaPos, headBob;
|
||||||
public float bodyAngle, headAngle;
|
public float bodyAngle, headAngle;
|
||||||
public Rot4 headFacing, bodyFacing;
|
public Rot4 headFacing, bodyFacing;
|
||||||
|
@ -55,11 +68,13 @@ namespace Rimworld_Animations {
|
||||||
|
|
||||||
public void setAnchor(IntVec3 pos)
|
public void setAnchor(IntVec3 pos)
|
||||||
{
|
{
|
||||||
|
positionReset = pos;
|
||||||
anchor = pos.ToVector3Shifted();
|
anchor = pos.ToVector3Shifted();
|
||||||
}
|
}
|
||||||
public void setAnchor(Thing thing) {
|
public void setAnchor(Thing thing) {
|
||||||
|
|
||||||
//center on bed
|
//center on bed
|
||||||
|
positionReset = thing.Position;
|
||||||
if(thing is Building_Bed) {
|
if(thing is Building_Bed) {
|
||||||
anchor = thing.Position.ToVector3();
|
anchor = thing.Position.ToVector3();
|
||||||
if (((Building_Bed)thing).SleepingSlotsCount == 2) {
|
if (((Building_Bed)thing).SleepingSlotsCount == 2) {
|
||||||
|
@ -117,16 +132,17 @@ namespace Rimworld_Animations {
|
||||||
public override void CompTick() {
|
public override void CompTick() {
|
||||||
base.CompTick();
|
base.CompTick();
|
||||||
|
|
||||||
if(Animating) {
|
if(isAnimating) {
|
||||||
tickAnim();
|
tickAnim();
|
||||||
if (pawn?.jobs?.curDriver == null || (pawn?.jobs?.curDriver != null && !(pawn?.jobs?.curDriver is rjw.JobDriver_Sex))) {
|
if (pawn?.jobs?.curDriver == null || (pawn?.jobs?.curDriver != null && !(pawn?.jobs?.curDriver is rjw.JobDriver_Sex))) {
|
||||||
|
|
||||||
isAnimating = false;
|
isAnimating = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void animatePawn(ref Vector3 rootLoc, ref float angle, ref Rot4 bodyFacing, ref Rot4 headFacing) {
|
public void animatePawn(ref Vector3 rootLoc, ref float angle, ref Rot4 bodyFacing, ref Rot4 headFacing) {
|
||||||
|
|
||||||
if(!Animating) {
|
if(!isAnimating) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rootLoc = anchor + deltaPos;
|
rootLoc = anchor + deltaPos;
|
||||||
|
@ -142,13 +158,13 @@ namespace Rimworld_Animations {
|
||||||
|
|
||||||
public void tickAnim() {
|
public void tickAnim() {
|
||||||
|
|
||||||
if (!Animating) return;
|
if (!isAnimating) return;
|
||||||
|
|
||||||
animTicks++;
|
animTicks++;
|
||||||
if (animTicks < anim.animationTimeTicks) {
|
if (animTicks < anim.animationTimeTicks) {
|
||||||
tickStage();
|
tickStage();
|
||||||
} else {
|
} else {
|
||||||
Animating = false;
|
isAnimating = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Verse;
|
using Verse;
|
||||||
|
using Verse.AI;
|
||||||
|
|
||||||
namespace Rimworld_Animations {
|
namespace Rimworld_Animations {
|
||||||
|
|
||||||
|
@ -13,13 +14,36 @@ namespace Rimworld_Animations {
|
||||||
public static class HarmonyPatch_Pawn_DrawTracker {
|
public static class HarmonyPatch_Pawn_DrawTracker {
|
||||||
public static bool Prefix(ref Pawn ___pawn, ref Vector3 __result) {
|
public static bool Prefix(ref Pawn ___pawn, ref Vector3 __result) {
|
||||||
|
|
||||||
if(___pawn.TryGetComp<CompBodyAnimator>() != null && ___pawn.TryGetComp<CompBodyAnimator>().isAnimating) {
|
if(___pawn.TryGetComp<CompBodyAnimator>() != null) {
|
||||||
__result = ___pawn.TryGetComp<CompBodyAnimator>().anchor + ___pawn.TryGetComp<CompBodyAnimator>().deltaPos;
|
|
||||||
___pawn.Position = __result.ToIntVec3();
|
if(___pawn.TryGetComp<CompBodyAnimator>().isAnimating) {
|
||||||
return false;
|
__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;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,9 +146,10 @@ namespace Rimworld_Animations {
|
||||||
for (int i = 0; i < parteners.Count; i++) {
|
for (int i = 0; i < parteners.Count; i++) {
|
||||||
|
|
||||||
//prevents pawns who started a new anim from stopping their new anim
|
//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;
|
parteners[i].TryGetComp<CompBodyAnimator>().isAnimating = false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__instance.Target.TryGetComp<CompBodyAnimator>().isAnimating = false;
|
__instance.Target.TryGetComp<CompBodyAnimator>().isAnimating = false;
|
||||||
|
|
Loading…
Reference in New Issue