Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Commit

Permalink
IKT: fix for build 1078 of VRChat
Browse files Browse the repository at this point in the history
  • Loading branch information
knah committed Apr 19, 2021
1 parent 333a140 commit 2c0d2e4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
29 changes: 26 additions & 3 deletions IKTweaks/FullBodyHandling.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Harmony;
Expand All @@ -13,8 +14,30 @@

namespace IKTweaks
{
public class FullBodyHandling
public static class FullBodyHandling
{
private static T MinBy<T>(this IEnumerable<T> src, Func<T, int> selector)
{
var seenElement = false;
var minValue = int.MaxValue;
T best = default;
foreach (var x in src)
{
seenElement = true;
var current = selector(x);
if (current < minValue)
{
minValue = current;
best = x;
}
}

if (!seenElement)
throw new ArgumentException("Sequence is empty");

return best;
}

internal static VRCFbbIkController LastInitializedController;
internal static VRIK_New LastInitializedVRIK;

Expand Down Expand Up @@ -440,9 +463,9 @@ internal static void HookFullBodyController(HarmonyInstance harmony)
new HarmonyMethod(typeof(FullBodyHandling), nameof(IsCalibratedForAvatarPrefix)));

var userOfHfts = typeof(VRCFbbIkController)
.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).Single(it =>
.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).Where(it =>
XrefScanner.XrefScan(it).Any(jt => jt.Type == XrefType.Global && jt.ReadAsObject()?.ToString() ==
"Hip+Feet Tracking: 3 trackers found, tracking enabled."));
"Hip+Feet Tracking: 3 trackers found, tracking enabled.")).MinBy(it => XrefScanner.XrefScan(it).Count());
var hipAndFeetTrackingSupportedCandidates = XrefScanner.XrefScan(userOfHfts).Where(it =>
{
if (it.Type != XrefType.Method) return false;
Expand Down
2 changes: 1 addition & 1 deletion IKTweaks/IKTweaks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<VrcReferences>true</VrcReferences>
<AssemblyVersion>1.0.8</AssemblyVersion>
<AssemblyVersion>1.0.9</AssemblyVersion>
</PropertyGroup>
<ItemGroup>
<None Remove="iktweaks" />
Expand Down
2 changes: 1 addition & 1 deletion IKTweaks/IKTweaksMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
using Delegate = Il2CppSystem.Delegate;
using Object = UnityEngine.Object;

[assembly:MelonInfo(typeof(IKTweaksMod), "IKTweaks", "1.0.8", "knah", "https://github.com/knah/VRCMods")]
[assembly:MelonInfo(typeof(IKTweaksMod), "IKTweaks", "1.0.9", "knah", "https://github.com/knah/VRCMods")]
[assembly:MelonGame("VRChat", "VRChat")]
[assembly:MelonOptionalDependencies("UIExpansionKit")]

Expand Down

0 comments on commit 2c0d2e4

Please sign in to comment.