Skip to content

Commit

Permalink
Merge pull request #14 from Kokaiinum/master
Browse files Browse the repository at this point in the history
Marco's hair fix
  • Loading branch information
DeathWeasel1337 authored Apr 25, 2019
2 parents 788f02a + f3ee310 commit 31160d3
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion KK_ForceHighPoly/KK_ForceHighPoly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,34 @@ public static void LoadAssetPrefix(ref string assetName)
}

[HarmonyPrefix]
[HarmonyBefore(new string[] { "com.bepis.bepinex.resourceredirector" })]
[HarmonyBefore(new string[] { "com.bepis.bepinex.resourceredirector" })]
[HarmonyPatch(typeof(AssetBundleManager), nameof(AssetBundleManager.LoadAssetAsync), new[] { typeof(string), typeof(string), typeof(Type), typeof(string) })]
public static void LoadAssetAsyncPrefix(ref string assetName)
{
if (Enabled.Value && assetName.EndsWith("_low"))
assetName = assetName.Substring(0, assetName.Length - 4);
}

[HarmonyPostfix]
[HarmonyPatch(typeof(ChaControl), "ChangeHairAsync", new Type[] { typeof(int), typeof(int), typeof(bool), typeof(bool) })]
public static void ChangeHairAsyncPostHook(ChaControl __instance, int kind, ref IEnumerator __result)
{
var orig = __result;
__result = new IEnumerator[] { orig, ChangeHairAsyncPostfix(__instance, kind) }.GetEnumerator();
}

private static IEnumerator ChangeHairAsyncPostfix(ChaControl instance, int kind)
{
var hairObject = instance.objHair[kind];
if (hairObject != null)
{
var componentsInChildren = hairObject.GetComponentsInChildren<DynamicBone>(true);
foreach (var dynamicBone in componentsInChildren)
{
dynamicBone.enabled = true;
}
}
yield break;
}
}
}

0 comments on commit 31160d3

Please sign in to comment.