This commit is contained in:
c0ffee 2021-07-21 13:25:06 -07:00
parent 6d4ed2a9e3
commit 1eea564e30
5 changed files with 6 additions and 25 deletions

View file

@ -279,6 +279,8 @@ namespace Rimworld_Animations {
public static Rot4 PawnHeadRotInAnimation(Pawn pawn, Rot4 regularPos) public static Rot4 PawnHeadRotInAnimation(Pawn pawn, Rot4 regularPos)
{ {
Debug.Log("Test");
if(pawn?.TryGetComp<CompBodyAnimator>() != null && pawn.TryGetComp<CompBodyAnimator>().isAnimating) if(pawn?.TryGetComp<CompBodyAnimator>() != null && pawn.TryGetComp<CompBodyAnimator>().isAnimating)
{ {
return pawn.TryGetComp<CompBodyAnimator>().headFacing; return pawn.TryGetComp<CompBodyAnimator>().headFacing;

View file

@ -32,6 +32,7 @@ namespace Rimworld_Animations {
actorsInCurrentAnimation = null; actorsInCurrentAnimation = null;
} }
PortraitsCache.SetDirty(pawn);
} }
} }
private bool Animating = false; private bool Animating = false;

View file

@ -47,9 +47,6 @@ namespace Rimworld_Animations {
foreach (CodeInstruction i in instructions) foreach (CodeInstruction i in instructions)
{ {
if (i.opcode == OpCodes.Ldfld && i.OperandIs(AccessTools.Field(typeof(PawnGraphicSet), "headGraphic"))) if (i.opcode == OpCodes.Ldfld && i.OperandIs(AccessTools.Field(typeof(PawnGraphicSet), "headGraphic")))
{ {
@ -57,13 +54,14 @@ namespace Rimworld_Animations {
yield return i; yield return i;
} }
else if (forHead && i.operand == (object)7) else if (forHead && i.opcode == OpCodes.Ldarg_S && i.operand == (object)4)
{ {
yield return new CodeInstruction(OpCodes.Ldarg_0); yield return new CodeInstruction(OpCodes.Ldarg_0);
yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(PawnRenderer), "pawn")); yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(PawnRenderer), "pawn"));
yield return new CodeInstruction(OpCodes.Ldloc_S, operand: 7); yield return new CodeInstruction(OpCodes.Ldloc_S, operand: 4);
yield return new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(AnimationUtility), "PawnHeadRotInAnimation")); yield return new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(AnimationUtility), "PawnHeadRotInAnimation"));
} }
else else

View file

@ -26,24 +26,4 @@ namespace Rimworld_Animations {
} }
[HarmonyPatch(typeof(PawnRenderer), "BodyAngle")]
public static class HarmonyPatch_PawnAngle
{
public static bool Prefix(Pawn ___pawn, ref float __result)
{
if(___pawn.TryGetComp<CompBodyAnimator>().isAnimating)
{
__result = ___pawn.TryGetComp<CompBodyAnimator>().bodyAngle;
return false;
}
return true;
}
}
} }