mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
fixed HAR offsets
This commit is contained in:
parent
7ca301f90a
commit
4bf4af7217
5 changed files with 22 additions and 28 deletions
Binary file not shown.
|
@ -5,18 +5,17 @@ using UnityEngine;
|
||||||
using Verse;
|
using Verse;
|
||||||
using Rimworld_Animations;
|
using Rimworld_Animations;
|
||||||
|
|
||||||
namespace Rimworld_Animations
|
namespace Rimworld_Animations {
|
||||||
{
|
|
||||||
/* todo: fix for 1.4
|
|
||||||
[StaticConstructorOnStartup]
|
[StaticConstructorOnStartup]
|
||||||
public static class PawnWoundDrawerExtension
|
public static class PawnWoundDrawerExtension
|
||||||
{
|
{
|
||||||
public static void RenderOverBody(this PawnWoundDrawer pawnWoundDrawer, Vector3 drawLoc, Mesh bodyMesh, Quaternion quat, bool drawNow, BodyTypeDef.WoundLayer layer, Rot4 pawnRot, bool? overApparel = null, Pawn pawn = null, PawnRenderFlags flags = new PawnRenderFlags())
|
public static void RenderPawnOverlay(this PawnWoundDrawer pawnWoundDrawer, Vector3 drawLoc, Mesh bodyMesh, Quaternion quat, bool drawNow, PawnOverlayDrawer.OverlayLayer layer, Rot4 pawnRot, bool? overApparel = null, Pawn pawn = null, PawnRenderFlags flags = new PawnRenderFlags())
|
||||||
{
|
{
|
||||||
if (pawn == null)
|
if (pawn == null)
|
||||||
{ return; }
|
{ return; }
|
||||||
|
|
||||||
if (!flags.FlagSet(PawnRenderFlags.Portrait) && layer == BodyTypeDef.WoundAnchor.)
|
if (!flags.FlagSet(PawnRenderFlags.Portrait) && layer == PawnOverlayDrawer.OverlayLayer.Head)
|
||||||
{
|
{
|
||||||
CompBodyAnimator pawnAnimator = pawn.TryGetComp<CompBodyAnimator>();
|
CompBodyAnimator pawnAnimator = pawn.TryGetComp<CompBodyAnimator>();
|
||||||
if (pawnAnimator != null && pawnAnimator.isAnimating && pawn.Drawer.renderer.graphics.headGraphic != null)
|
if (pawnAnimator != null && pawnAnimator.isAnimating && pawn.Drawer.renderer.graphics.headGraphic != null)
|
||||||
|
@ -29,9 +28,8 @@ namespace Rimworld_Animations
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pawnWoundDrawer.RenderOverBody(drawLoc, bodyMesh, quat, drawNow, layer, pawnRot, overApparel);
|
pawnWoundDrawer.RenderPawnOverlay(drawLoc, bodyMesh, quat, drawNow, layer, pawnRot, overApparel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,13 +18,11 @@ namespace Rimworld_Animations {
|
||||||
{
|
{
|
||||||
static HarmonyPatch_AlienRace()
|
static HarmonyPatch_AlienRace()
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
(new Harmony("rjwanim")).Patch(AccessTools.Method(AccessTools.TypeByName("AlienRace.HarmonyPatches"), "DrawAddons"),
|
(new Harmony("rjwanim")).Patch(AccessTools.Method(AccessTools.TypeByName("AlienRace.HarmonyPatches"), "DrawAddons"),
|
||||||
prefix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_AlienRace), "Prefix_AnimateHeadAddons")));
|
prefix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_AlienRace), "Prefix_AnimateHeadAddons")));
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* todo: replace jank prefix with this
|
||||||
public static void Prefix_DrawAddonsFinalHook(ref Pawn pawn, ref AlienPartGenerator.BodyAddon addon, ref Rot4 rot, ref Graphic graphic, ref Vector3 offsetVector, ref float angle, ref Material mat)
|
public static void Prefix_DrawAddonsFinalHook(ref Pawn pawn, ref AlienPartGenerator.BodyAddon addon, ref Rot4 rot, ref Graphic graphic, ref Vector3 offsetVector, ref float angle, ref Material mat)
|
||||||
{
|
{
|
||||||
CompBodyAnimator animator = pawn.TryGetComp<CompBodyAnimator>();
|
CompBodyAnimator animator = pawn.TryGetComp<CompBodyAnimator>();
|
||||||
|
@ -38,7 +36,7 @@ namespace Rimworld_Animations {
|
||||||
{
|
{
|
||||||
rot = animator.headFacing;
|
rot = animator.headFacing;
|
||||||
angle = animator.headAngle;
|
angle = animator.headAngle;
|
||||||
offsetVector += angle * animator.headBob;
|
offsetVector += animator.deltaPos + animator.bodyAngle * animator.headBob;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -49,8 +47,7 @@ namespace Rimworld_Animations {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/*
|
|
||||||
public static bool Prefix_AnimateHeadAddons(PawnRenderFlags renderFlags, Vector3 vector, Vector3 headOffset, Pawn pawn, Quaternion quat, Rot4 rotation)
|
public static bool Prefix_AnimateHeadAddons(PawnRenderFlags renderFlags, Vector3 vector, Vector3 headOffset, Pawn pawn, Quaternion quat, Rot4 rotation)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -61,6 +58,9 @@ namespace Rimworld_Animations {
|
||||||
AlienPartGenerator.AlienComp comp = pawn.GetComp<AlienPartGenerator.AlienComp>();
|
AlienPartGenerator.AlienComp comp = pawn.GetComp<AlienPartGenerator.AlienComp>();
|
||||||
CompBodyAnimator pawnAnimator = pawn.TryGetComp<CompBodyAnimator>();
|
CompBodyAnimator pawnAnimator = pawn.TryGetComp<CompBodyAnimator>();
|
||||||
|
|
||||||
|
bool flag = renderFlags.FlagSet(PawnRenderFlags.Portrait);
|
||||||
|
bool flag2 = renderFlags.FlagSet(PawnRenderFlags.Invisible);
|
||||||
|
|
||||||
for (int i = 0; i < addons.Count; i++)
|
for (int i = 0; i < addons.Count; i++)
|
||||||
{
|
{
|
||||||
AlienPartGenerator.BodyAddon ba = addons[index: i];
|
AlienPartGenerator.BodyAddon ba = addons[index: i];
|
||||||
|
@ -73,9 +73,9 @@ namespace Rimworld_Animations {
|
||||||
forceDrawForBody = true;
|
forceDrawForBody = true;
|
||||||
}
|
}
|
||||||
AlienPartGenerator.RotationOffset offset = ba.defaultOffsets.GetOffset((ba.drawnInBed && !forceDrawForBody) || ba.alignWithHead ? pawnAnimator.headFacing : pawnAnimator.bodyFacing);
|
AlienPartGenerator.RotationOffset offset = ba.defaultOffsets.GetOffset((ba.drawnInBed && !forceDrawForBody) || ba.alignWithHead ? pawnAnimator.headFacing : pawnAnimator.bodyFacing);
|
||||||
Vector3 a = (offset != null) ? offset.GetOffset(renderFlags.FlagSet(PawnRenderFlags.Portrait), pawn.story.bodyType, comp.crownType) : Vector3.zero;
|
Vector3 a = (offset != null) ? offset.GetOffset(renderFlags.FlagSet(PawnRenderFlags.Portrait), pawn.story.bodyType, pawn.story.headType) : Vector3.zero;
|
||||||
AlienPartGenerator.RotationOffset offset2 = ba.offsets.GetOffset((ba.drawnInBed && !forceDrawForBody) || ba.alignWithHead ? pawnAnimator.headFacing : pawnAnimator.bodyFacing);
|
AlienPartGenerator.RotationOffset offset2 = ba.offsets.GetOffset((ba.drawnInBed && !forceDrawForBody) || ba.alignWithHead ? pawnAnimator.headFacing : pawnAnimator.bodyFacing);
|
||||||
Vector3 vector2 = a + ((offset2 != null) ? offset2.GetOffset(renderFlags.FlagSet(PawnRenderFlags.Portrait), pawn.story.bodyType, comp.crownType) : Vector3.zero);
|
Vector3 vector2 = a + ((offset2 != null) ? offset2.GetOffset(renderFlags.FlagSet(PawnRenderFlags.Portrait), pawn.story.bodyType, pawn.story.headType) : Vector3.zero);
|
||||||
vector2.y = (ba.inFrontOfBody ? (0.3f + vector2.y) : (-0.3f - vector2.y));
|
vector2.y = (ba.inFrontOfBody ? (0.3f + vector2.y) : (-0.3f - vector2.y));
|
||||||
float num = ba.angle;
|
float num = ba.angle;
|
||||||
if (rotation == Rot4.North)
|
if (rotation == Rot4.North)
|
||||||
|
@ -93,7 +93,7 @@ namespace Rimworld_Animations {
|
||||||
}
|
}
|
||||||
Graphic addonGraphic = comp.addonGraphics[i];
|
Graphic addonGraphic = comp.addonGraphics[i];
|
||||||
|
|
||||||
addonGraphic.drawSize = ((renderFlags.FlagSet(PawnRenderFlags.Portrait) && ba.drawSizePortrait != Vector2.zero) ? ba.drawSizePortrait : ba.drawSize) * (ba.scaleWithPawnDrawsize ? (ba.alignWithHead ? (renderFlags.FlagSet(PawnRenderFlags.Portrait) ? comp.customPortraitHeadDrawSize : comp.customHeadDrawSize) : (renderFlags.FlagSet(PawnRenderFlags.Portrait) ? comp.customPortraitDrawSize : comp.customDrawSize)) : Vector2.one) * 1.5f;
|
addonGraphic.drawSize = ((flag && ba.drawSizePortrait != Vector2.zero) ? ba.drawSizePortrait : ba.drawSize) * (ba.scaleWithPawnDrawsize ? (ba.alignWithHead ? ((flag ? comp.customPortraitHeadDrawSize : comp.customHeadDrawSize) * (ModsConfig.BiotechActive ? (pawn.ageTracker.CurLifeStage.headSizeFactor ?? 1.5f) : 1.5f)) : ((flag ? comp.customPortraitDrawSize : comp.customDrawSize) * (ModsConfig.BiotechActive ? pawn.ageTracker.CurLifeStage.bodySizeFactor : 1f) * 1.5f)) : (Vector2.one * 1.5f));
|
||||||
|
|
||||||
Vector3 orassanv = Vector3.zero;
|
Vector3 orassanv = Vector3.zero;
|
||||||
bool orassan = false;
|
bool orassan = false;
|
||||||
|
@ -106,7 +106,7 @@ namespace Rimworld_Animations {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ba.bodyPart.Contains("ear"))
|
if (ba.bodyPart.defName.Contains("ear"))
|
||||||
|
|
||||||
{
|
{
|
||||||
orassan = true;
|
orassan = true;
|
||||||
|
@ -117,7 +117,7 @@ namespace Rimworld_Animations {
|
||||||
orassanv.z -= 0.1f;
|
orassanv.z -= 0.1f;
|
||||||
orassanv.y += 1f;
|
orassanv.y += 1f;
|
||||||
|
|
||||||
if (ba.bodyPart.Contains("left"))
|
if (ba.bodyPart.defName.Contains("left"))
|
||||||
{
|
{
|
||||||
orassanv.x += 0.03f;
|
orassanv.x += 0.03f;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ namespace Rimworld_Animations {
|
||||||
orassanv.z -= 0.1f;
|
orassanv.z -= 0.1f;
|
||||||
orassanv.y += 1f;
|
orassanv.y += 1f;
|
||||||
|
|
||||||
if (ba.bodyPart.Contains("right"))
|
if (ba.bodyPart.defName.Contains("right"))
|
||||||
{
|
{
|
||||||
//orassanv.x += 0.3f;
|
//orassanv.x += 0.3f;
|
||||||
}
|
}
|
||||||
|
@ -187,8 +187,6 @@ namespace Rimworld_Animations {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(typeof(PawnGraphicSet), "ResolveApparelGraphics")]
|
[HarmonyPatch(typeof(PawnGraphicSet), "ResolveApparelGraphics")]
|
||||||
|
|
|
@ -53,8 +53,8 @@ namespace Rimworld_Animations {
|
||||||
{
|
{
|
||||||
|
|
||||||
yield return new CodeInstruction(OpCodes.Ldloca, (object)0);
|
yield return new CodeInstruction(OpCodes.Ldloca, (object)0);
|
||||||
yield return new CodeInstruction(OpCodes.Ldloca, (object)7);
|
yield return new CodeInstruction(OpCodes.Ldloca, (object)9);
|
||||||
yield return new CodeInstruction(OpCodes.Ldloca, (object)6);
|
yield return new CodeInstruction(OpCodes.Ldloca, (object)8);
|
||||||
yield return new CodeInstruction(OpCodes.Ldarga, (object)2);
|
yield return new CodeInstruction(OpCodes.Ldarga, (object)2);
|
||||||
yield return new CodeInstruction(OpCodes.Ldarg_0);
|
yield return new CodeInstruction(OpCodes.Ldarg_0);
|
||||||
yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.DeclaredField(typeof(PawnRenderer), "pawn"));
|
yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.DeclaredField(typeof(PawnRenderer), "pawn"));
|
||||||
|
@ -63,17 +63,15 @@ namespace Rimworld_Animations {
|
||||||
yield return ins[i];
|
yield return ins[i];
|
||||||
//headFacing equals true
|
//headFacing equals true
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
// Fixes the offsets for eye implants and wounds on the head during animations
|
// Fixes the offsets for eye implants and wounds on the head during animations
|
||||||
else if (ins[i].opcode == OpCodes.Callvirt && ins[i].operand != null && ins[i].OperandIs(AccessTools.DeclaredMethod(typeof(PawnWoundDrawer), "RenderOverBody")))
|
else if (ins[i].opcode == OpCodes.Callvirt && ins[i].operand != null && ins[i].OperandIs(AccessTools.DeclaredMethod(typeof(PawnOverlayDrawer), "RenderPawnOverlay")))
|
||||||
{
|
{
|
||||||
// Pass some additional info to a new overload of RenderOverBody
|
// Pass some additional info to a new overload of RenderOverBody
|
||||||
yield return new CodeInstruction(OpCodes.Ldarg_0);
|
yield return new CodeInstruction(OpCodes.Ldarg_0);
|
||||||
yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.DeclaredField(typeof(PawnRenderer), "pawn"));
|
yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.DeclaredField(typeof(PawnRenderer), "pawn"));
|
||||||
yield return new CodeInstruction(OpCodes.Ldarg_S, (object)6); // renderer flags
|
yield return new CodeInstruction(OpCodes.Ldarg_S, (object)6); // renderer flags
|
||||||
yield return new CodeInstruction(OpCodes.Call, AccessTools.DeclaredMethod(typeof(PawnWoundDrawerExtension), "RenderOverBody"));
|
yield return new CodeInstruction(OpCodes.Call, AccessTools.DeclaredMethod(typeof(PawnWoundDrawerExtension), "RenderPawnOverlay"));
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
yield return ins[i];
|
yield return ins[i];
|
||||||
|
|
Binary file not shown.
Loading…
Reference in a new issue