diff --git a/1.3/Assemblies/Rimworld-Animations.dll b/1.3/Assemblies/Rimworld-Animations.dll index 886ab6e..2afbfbc 100644 Binary files a/1.3/Assemblies/Rimworld-Animations.dll and b/1.3/Assemblies/Rimworld-Animations.dll differ diff --git a/1.3/Source/Comps/CompBodyAnimator.cs b/1.3/Source/Comps/CompBodyAnimator.cs index 9e0c9b1..c7c2ce4 100644 --- a/1.3/Source/Comps/CompBodyAnimator.cs +++ b/1.3/Source/Comps/CompBodyAnimator.cs @@ -405,7 +405,7 @@ namespace Rimworld_Animations { public Vector3 getPawnHeadPosition() { - Vector3 headPos = anchor + deltaPos + Quaternion.AngleAxis(bodyAngle, Vector3.up) * (pawn.Drawer.renderer.BaseHeadOffsetAt(headFacing) + headBob); + Vector3 headPos = anchor + deltaPos + headBob; return headPos; diff --git a/1.3/Source/Patches/OtherModPatches/HarmonyPatch_AlienRace.cs b/1.3/Source/Patches/OtherModPatches/HarmonyPatch_AlienRace.cs index 0f864e0..9758822 100644 --- a/1.3/Source/Patches/OtherModPatches/HarmonyPatch_AlienRace.cs +++ b/1.3/Source/Patches/OtherModPatches/HarmonyPatch_AlienRace.cs @@ -23,13 +23,32 @@ namespace Rimworld_Animations { { Quaternion headQuatInAnimation = Quaternion.AngleAxis(pawnAnimator.headAngle, Vector3.up); + Quaternion bodyQuatInAnimation = Quaternion.AngleAxis(pawnAnimator.bodyAngle, Vector3.up); Rot4 headRotInAnimation = pawnAnimator.headFacing; Vector3 headPositionInAnimation = pawnAnimator.getPawnHeadPosition(); headPositionInAnimation.y = loc.y; - GenDraw.DrawMeshNowOrLater(mesh: graphic.MeshAt(rot: headRotInAnimation), loc: headPositionInAnimation, //+ (bodyAddon.alignWithHead ? headOffset : Vector3.zero) + v.RotatedBy(Mathf.Acos(Quaternion.Dot(Quaternion.identity, quat)) * 2f * 57.29578f), - quat: Quaternion.AngleAxis(angle: num, axis: Vector3.up) * headQuatInAnimation, mat: graphic.MatAt(rot: pawnAnimator.headFacing), drawNow: drawNow);; + AlienPartGenerator.AlienComp comp = pawn.GetComp(); + AlienPartGenerator.RotationOffset offset = bodyAddon.defaultOffsets.GetOffset(pawnAnimator.headFacing); + AlienPartGenerator.RotationOffset offset2 = bodyAddon.offsets.GetOffset(pawnAnimator.headFacing); + + Vector3 a = (offset != null) ? offset.GetOffset(renderFlags.FlagSet(PawnRenderFlags.Portrait), pawn.story.bodyType, comp.crownType) : Vector3.zero; + var vec = a + ((offset2 != null) ? offset2.GetOffset(renderFlags.FlagSet(PawnRenderFlags.Portrait), pawn.story.bodyType, comp.crownType) : Vector3.zero); + vec.y = (bodyAddon.inFrontOfBody ? (0.3f + vec.y) : (-0.3f - vec.y)); + if (headRotInAnimation == Rot4.North) + { + if (bodyAddon.layerInvert) + { + vec.y = -vec.y; + } + } + if (headRotInAnimation == Rot4.East) + { + vec.x = -vec.x; + } + GenDraw.DrawMeshNowOrLater(mesh: graphic.MeshAt(rot: headRotInAnimation), loc: headPositionInAnimation + (bodyAddon.alignWithHead ? headOffset : Vector3.zero) + vec.RotatedBy(Mathf.Acos(Quaternion.Dot(Quaternion.identity, bodyQuatInAnimation)) * 2f * 57.29578f), + quat: Quaternion.AngleAxis(angle: num, axis: Vector3.up) * headQuatInAnimation, mat: graphic.MatAt(rot: pawnAnimator.headFacing), drawNow: drawNow); } else @@ -37,17 +56,15 @@ namespace Rimworld_Animations { GenDraw.DrawMeshNowOrLater(mesh, loc, quat, mat, drawNow); } } - public static IEnumerable Transpiler(IEnumerable instructions) { List ins = instructions.ToList(); + Type[] type = new Type[] { typeof(Mesh), typeof(Vector3), typeof(Quaternion), typeof(Material), typeof(bool) }; + for (int i = 0; i < ins.Count; i++) { - Type[] type = new Type[] { typeof(Mesh), typeof(Vector3), typeof(Quaternion), typeof(Material), typeof(bool) }; - - if (ins[i].OperandIs(AccessTools.Method(typeof(GenDraw), "DrawMeshNowOrLater", type))) {