2022-09-10 01:22:08 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using HarmonyLib;
|
|
|
|
|
using RimWorld;
|
|
|
|
|
using Verse;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Reflection.Emit;
|
|
|
|
|
using Rimworld_Animations;
|
|
|
|
|
using rjw;
|
|
|
|
|
|
|
|
|
|
namespace Rimworld_Animations_Patch
|
|
|
|
|
{
|
2022-10-02 02:14:35 +00:00
|
|
|
|
/*[StaticConstructorOnStartup]
|
2022-09-10 01:22:08 +00:00
|
|
|
|
[HarmonyPatch(typeof(PawnRenderer), "RenderPawnInternal", new Type[]
|
|
|
|
|
{
|
|
|
|
|
typeof(Vector3),
|
|
|
|
|
typeof(float),
|
|
|
|
|
typeof(bool),
|
|
|
|
|
typeof(Rot4),
|
|
|
|
|
typeof(RotDrawMode),
|
|
|
|
|
typeof(PawnRenderFlags)
|
|
|
|
|
}
|
|
|
|
|
)]
|
|
|
|
|
public static class HarmonyPatch_PawnRenderer_RenderPawnInternal
|
|
|
|
|
{
|
|
|
|
|
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
|
|
|
|
|
{
|
|
|
|
|
List<CodeInstruction> ins = instructions.ToList();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < instructions.Count(); i++)
|
|
|
|
|
{
|
|
|
|
|
bool runIns = true;
|
|
|
|
|
|
|
|
|
|
// Replaces the rotation that gets passed to DrawHeadHair with one that is based the current 'true' head orientation
|
|
|
|
|
if (i + 8 < instructions.Count() && ins[i + 8].opcode == OpCodes.Call && ins[i + 8].operand != null && ins[i + 8].OperandIs(AccessTools.DeclaredMethod(typeof(PawnRenderer), "DrawHeadHair")))
|
|
|
|
|
{
|
|
|
|
|
// Get the true head rotation
|
|
|
|
|
yield return new CodeInstruction(OpCodes.Ldarg_0);
|
|
|
|
|
yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.DeclaredField(typeof(PawnRenderer), "pawn"));
|
|
|
|
|
yield return new CodeInstruction(OpCodes.Ldloc, (object)7); // local body facing
|
|
|
|
|
yield return new CodeInstruction(OpCodes.Ldarg_S, (object)6); // renderer flags
|
|
|
|
|
yield return new CodeInstruction(OpCodes.Call, AccessTools.DeclaredMethod(typeof(AnimationPatchUtility), "PawnHeadRotInAnimation"));
|
|
|
|
|
yield return new CodeInstruction(OpCodes.Stloc_S, (object)7); // set local body facing to true head facing
|
|
|
|
|
|
|
|
|
|
// Pass this head rotation to a new DrawHeadHair call
|
|
|
|
|
yield return new CodeInstruction(OpCodes.Ldarg_0);
|
|
|
|
|
yield return new CodeInstruction(OpCodes.Ldarg_1);
|
|
|
|
|
yield return new CodeInstruction(OpCodes.Ldloc_S, (object)6);
|
|
|
|
|
yield return new CodeInstruction(OpCodes.Ldarg_2);
|
|
|
|
|
yield return new CodeInstruction(OpCodes.Ldloc_S, (object)7); // local true head facing
|
|
|
|
|
yield return new CodeInstruction(OpCodes.Ldloc_S, (object)7); // local true head facing
|
|
|
|
|
yield return new CodeInstruction(OpCodes.Ldarg_S, (object)5); // bodyDrawType
|
|
|
|
|
yield return new CodeInstruction(OpCodes.Ldarg_S, (object)6); // renderer flags
|
|
|
|
|
yield return new CodeInstruction(OpCodes.Call, AccessTools.DeclaredMethod(typeof(PawnRenderer), "DrawHeadHair"));
|
|
|
|
|
|
|
|
|
|
// Skip the original call to DrawHeadHair
|
|
|
|
|
i = i + 8;
|
|
|
|
|
|
|
|
|
|
runIns = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (runIns)
|
|
|
|
|
{
|
|
|
|
|
yield return ins[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-02 02:14:35 +00:00
|
|
|
|
}*/
|
2022-09-10 01:22:08 +00:00
|
|
|
|
|
|
|
|
|
[StaticConstructorOnStartup]
|
|
|
|
|
[HarmonyPatch(typeof(PawnGraphicSet), "ResolveAllGraphics")]
|
|
|
|
|
public static class HarmonyPatch_PawnGraphicSet_ResolveAllGraphics
|
|
|
|
|
{
|
|
|
|
|
public static void Postfix(PawnGraphicSet __instance)
|
|
|
|
|
{
|
|
|
|
|
if (__instance?.pawn?.apparel == null)
|
|
|
|
|
{ return; }
|
|
|
|
|
|
|
|
|
|
if (__instance.pawn.GetAnimationData() != null)
|
|
|
|
|
{ return; }
|
|
|
|
|
|
|
|
|
|
if (__instance.pawn.apparel.WornApparel.NullOrEmpty() == false)
|
|
|
|
|
{
|
2022-09-11 06:05:16 +00:00
|
|
|
|
foreach (Apparel apparel in __instance.pawn.apparel.WornApparel)
|
2022-09-10 01:22:08 +00:00
|
|
|
|
{
|
|
|
|
|
CompApparelVisibility comp = apparel.TryGetComp<CompApparelVisibility>();
|
|
|
|
|
|
|
|
|
|
if (comp != null)
|
2022-09-11 06:05:16 +00:00
|
|
|
|
{
|
2022-09-30 23:34:08 +00:00
|
|
|
|
comp.isBeingWorn = null;
|
2022-09-11 06:05:16 +00:00
|
|
|
|
comp.rimNudeDataStatus = RimNudeDataStatus.NotLoaded;
|
|
|
|
|
}
|
2022-09-10 01:22:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-01 03:51:09 +00:00
|
|
|
|
|
|
|
|
|
__instance.pawn.TryGetComp<CompPawnSexData>()?.UpdateBodyAddonVisibility();
|
2022-09-10 01:22:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|