mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
fix rotation
This commit is contained in:
parent
ce60841f22
commit
4808eeb47b
3 changed files with 24 additions and 7 deletions
Binary file not shown.
|
@ -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;
|
||||
|
||||
|
|
|
@ -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.AlienComp>();
|
||||
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
|
||||
|
@ -38,16 +57,14 @@ namespace Rimworld_Animations {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
List<CodeInstruction> 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)))
|
||||
{
|
||||
|
||||
|
|
Loading…
Reference in a new issue