Skip to content

Commit 9b4e748

Browse files
committed
Merge branch 'master' of https://github.com/knah/VRCMods
2 parents 071965b + 72bd9f0 commit 9b4e748

17 files changed

+183
-125
lines changed

AdvancedSafety/AdvancedSafety.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<VrcReferences>true</VrcReferences>
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
77
<LangVersion>latest</LangVersion>
8-
<Version>1.6.1.0</Version>
8+
<Version>1.6.2.0</Version>
99
<UsesNativePatches>true</UsesNativePatches>
1010
</PropertyGroup>
1111

AdvancedSafety/AdvancedSafetyMod.cs

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
using Object = UnityEngine.Object;
2020

2121
[assembly:MelonGame("VRChat", "VRChat")]
22-
[assembly:MelonInfo(typeof(AdvancedSafetyMod), "Advanced Safety", "1.6.1", "knah, Requi, Ben", "https://github.com/xAstroBoy/VRCMods-Unchained")]
22+
[assembly:MelonInfo(typeof(AdvancedSafetyMod), "Advanced Safety", "1.6.2", "knah, Requi, Ben", "https://github.com/knah/VRCMods")]
2323
[assembly:MelonOptionalDependencies("UIExpansionKit")]
2424

2525
namespace AdvancedSafety
@@ -31,31 +31,10 @@ internal partial class AdvancedSafetyMod : MelonMod
3131

3232
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
3333
private delegate void VoidDelegate(IntPtr thisPtr, IntPtr nativeMethodInfo);
34-
private static readonly Func<VRCUiManager> ourGetUiManager;
35-
36-
static AdvancedSafetyMod()
37-
{
38-
ourGetUiManager = (Func<VRCUiManager>)Delegate.CreateDelegate(typeof(Func<VRCUiManager>), typeof(VRCUiManager)
39-
.GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.DeclaredOnly)
40-
.First(it => it.PropertyType == typeof(VRCUiManager)).GetMethod);
41-
}
42-
43-
internal static VRCUiManager GetUiManager() => ourGetUiManager();
44-
45-
private static void DoAfterUiManagerInit(Action code)
46-
{
47-
MelonCoroutines.Start(OnUiManagerInitCoro(code));
48-
}
49-
50-
private static IEnumerator OnUiManagerInitCoro(Action code)
51-
{
52-
while (GetUiManager() == null)
53-
yield return null;
54-
code();
55-
}
5634

5735
public override void OnApplicationStart()
5836
{
37+
if (!CheckWasSuccessful || !MustStayTrue || MustStayFalse) return;
5938

6039
AdvancedSafetySettings.RegisterSettings();
6140
ClassInjector.RegisterTypeInIl2Cpp<SortingOrderHammerer>();
883 KB
Binary file not shown.

AdvancedSafety/BundleVerifier/BundleVerifierMod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ private static IEnumerator CheckInstanceType()
9393
MelonDebug.Msg($"Got instance, intercept state: {BundleDlInterceptor.ShouldIntercept}");
9494
}
9595

96-
private const string VerifierVersion = "1.2-2019.4.31";
96+
private const string VerifierVersion = "1.4-2019.4.31";
9797
internal const string SettingsCategory = "ASBundleVerifier";
9898

9999
private static void PrepareVerifierDir()

FavCat/FavCat.csproj

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<VrcReferences>true</VrcReferences>
4-
<TargetFramework>net48</TargetFramework>
4+
<TargetFramework>net472</TargetFramework>
55
<LangVersion>latest</LangVersion>
66
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
77
<Nullable>enable</Nullable>
88
<ClearOutputDirectory>False</ClearOutputDirectory>
9-
<AssemblyVersion>1.1.15.0</AssemblyVersion>
10-
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
11-
<ClearOutputDirectory>False</ClearOutputDirectory>
12-
<VRChatFolder>D:\SteamLibrary\steamapps\common\VRChat</VRChatFolder>
13-
<MelonManaged>$(VRChatFolder)\MelonLoader\Managed</MelonManaged>
14-
<MelonLoader>$(VRChatFolder)\MelonLoader</MelonLoader>
9+
<AssemblyVersion>1.1.16.0</AssemblyVersion>
1510
<UsesNativePatches>true</UsesNativePatches>
1611
</PropertyGroup>
1712
<ItemGroup>
@@ -41,8 +36,7 @@
4136
<InputAssemblies Include="$(OutputPath)/System.Runtime.CompilerServices.Unsafe.dll" />
4237

4338
<IlRepackLibs Include="$(OutputPath)" />
44-
<IlRepackLibs Include="$(MelonManaged)" />
45-
<IlRepackLibs Include="$(MelonLoader)" />
39+
<IlRepackLibs Include="$(MsBuildThisFileDirectory)/../Libs" />
4640
</ItemGroup>
4741
<Message Text="MERGING: @(InputAssemblies->'%(Filename)') into $(OutputAssembly)" Importance="High" />
4842
<ILRepack Internalize="true" LibraryPath="@(IlRepackLibs)" OutputFile="$(OutputPath)/$(AssemblyName)-merged.dll" InputAssemblies="@(InputAssemblies)" />

FavCat/FavCatMod.cs

Lines changed: 32 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections;
32
using System.IO;
43
using System.Linq;
54
using System.Reflection;
@@ -11,7 +10,6 @@
1110
using HarmonyLib;
1211
using MelonLoader;
1312
using UIExpansionKit.API;
14-
using UnhollowerBaseLib;
1513
using UnhollowerRuntimeLib;
1614
using UnityEngine;
1715
using UnityEngine.Networking;
@@ -20,7 +18,7 @@
2018
using ImageDownloaderClosure = ImageDownloader.__c__DisplayClass11_0;
2119
using Object = UnityEngine.Object;
2220

23-
[assembly:MelonInfo(typeof(FavCatMod), "FavCat Unchained", "1.1.15~unchained", "knah & xAstroBoy", "https://github.com/xAstroBoy/VRCMods-Unchained")]
21+
[assembly:MelonInfo(typeof(FavCatMod), "FavCat", "1.1.16", "knah", "https://github.com/knah/VRCMods")]
2422
[assembly:MelonGame("VRChat", "VRChat")]
2523

2624
namespace FavCat
@@ -35,32 +33,11 @@ internal partial class FavCatMod : MelonMod
3533
internal PlayersModule? PlayerModule;
3634

3735
internal static PageUserInfo PageUserInfo;
38-
private static readonly Func<VRCUiManager> ourGetUiManager;
39-
40-
static FavCatMod()
41-
{
42-
ourGetUiManager = (Func<VRCUiManager>)Delegate.CreateDelegate(typeof(Func<VRCUiManager>), typeof(VRCUiManager)
43-
.GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.DeclaredOnly)
44-
.First(it => it.PropertyType == typeof(VRCUiManager)).GetMethod);
45-
}
46-
47-
internal static VRCUiManager GetUiManager() => ourGetUiManager();
48-
49-
private static void DoAfterUiManagerInit(Action code)
50-
{
51-
MelonCoroutines.Start(OnUiManagerInitCoro(code));
52-
}
53-
54-
private static IEnumerator OnUiManagerInitCoro(Action code)
55-
{
56-
while (GetUiManager() == null)
57-
yield return null;
58-
code();
59-
}
60-
36+
6137
public override void OnApplicationStart()
6238
{
6339
Instance = this;
40+
if (!CheckWasSuccessful || !MustStayTrue || MustStayFalse) return;
6441

6542
Directory.CreateDirectory("./UserData/FavCatImport");
6643

@@ -164,6 +141,7 @@ public class ApiSnifferPatch
164141
private delegate void ImageDownloaderOnDoneDelegate(IntPtr thisPtr, IntPtr asyncOperationPtr, IntPtr methodInfo);
165142

166143
private static ApiPopulateDelegate ourOriginalApiPopulate = (_, _, _, _) => 0;
144+
private static ApiPopulateDelegate ourOriginalApiPopulateTokens = (_, _, _, _) => 0;
167145
private static ImageDownloaderOnDoneDelegate ourOriginalOnDone = (_, _, _) => { };
168146

169147
private static readonly Type ImageDownloaderClosureType;
@@ -183,24 +161,18 @@ static ApiSnifferPatch()
183161

184162
public static void DoPatch()
185163
{
186-
unsafe
187-
{
188-
var originalMethodPointer = *(IntPtr*)(IntPtr)UnhollowerUtils
189-
.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(
190-
typeof(ApiModel).GetMethods().Single(it =>
191-
it.Name == nameof(ApiModel.SetApiFieldsFromJson) && it.GetParameters().Length == 2 && it.GetParameters()[0].ParameterType.GenericTypeArguments[1] == typeof(Il2CppSystem.Object)))
192-
.GetValue(null);
193-
MelonUtils.NativeHookAttach((IntPtr)(&originalMethodPointer), typeof(ApiSnifferPatch).GetMethod(nameof(ApiSnifferStatic))!.MethodHandle.GetFunctionPointer());
194-
ourOriginalApiPopulate = Marshal.GetDelegateForFunctionPointer<ApiPopulateDelegate>(originalMethodPointer);
195-
}
196-
197-
unsafe
198-
{
199-
var originalMethodPointer = *(IntPtr*)(IntPtr)UnhollowerUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(ImageDownloaderClosureType.GetMethod(nameof(ImageDownloaderClosure._DownloadImageInternal_b__0))).GetValue(null);
200-
MelonUtils.NativeHookAttach((IntPtr)(&originalMethodPointer), typeof(ApiSnifferPatch).GetMethod(nameof(ImageSnifferPatch))!.MethodHandle.GetFunctionPointer());
201-
ourOriginalOnDone = Marshal.GetDelegateForFunctionPointer<ImageDownloaderOnDoneDelegate>(originalMethodPointer);
202-
}
164+
NativePatchUtils.NativePatch(typeof(ApiModel).GetMethods().Single(it =>
165+
it.Name == nameof(ApiModel.SetApiFieldsFromJson) && it.GetParameters().Length == 2 && it.GetParameters()[0].ParameterType.GenericTypeArguments[1] == typeof(Il2CppSystem.Object)),
166+
out ourOriginalApiPopulate, ApiSnifferStatic);
167+
168+
NativePatchUtils.NativePatch(typeof(ApiModel).GetMethods().Single(it =>
169+
it.Name == nameof(ApiModel.SetApiFieldsFromJson) && it.GetParameters().Length == 2 && it.GetParameters()[0].ParameterType.GenericTypeArguments[1] != typeof(Il2CppSystem.Object)),
170+
out ourOriginalApiPopulateTokens, ApiSnifferStaticTokens);
171+
172+
NativePatchUtils.NativePatch(ImageDownloaderClosureType.GetMethod(nameof(ImageDownloaderClosure
173+
._DownloadImageInternal_b__0))!, out ourOriginalOnDone, ImageSnifferPatch);
203174
}
175+
204176
private static readonly object[] EmptyObjectArray = new object[0];
205177

206178
public static void ImageSnifferPatch(IntPtr instancePtr, IntPtr asyncOperationPtr, IntPtr methodInfo)
@@ -238,10 +210,26 @@ public static byte ApiSnifferStatic(IntPtr @this, IntPtr dictionary, IntPtr some
238210
{
239211
var result = ourOriginalApiPopulate(@this, dictionary, someRef, methodInfo);
240212

213+
ApiSnifferBody(@this);
214+
215+
return result;
216+
}
217+
218+
public static byte ApiSnifferStaticTokens(IntPtr @this, IntPtr dictionary, IntPtr someRef, IntPtr methodInfo)
219+
{
220+
var result = ourOriginalApiPopulateTokens(@this, dictionary, someRef, methodInfo);
221+
222+
ApiSnifferBody(@this);
223+
224+
return result;
225+
}
226+
227+
private static void ApiSnifferBody(IntPtr @this)
228+
{
241229
try
242230
{
243231
var apiModel = new ApiModel(@this);
244-
if (!apiModel.Populated) return result;
232+
if (!apiModel.Populated) return;
245233

246234
var maybeUser = apiModel.TryCast<APIUser>();
247235
if (maybeUser != null) FavCatMod.Database?.UpdateStoredPlayer(maybeUser);
@@ -252,8 +240,6 @@ public static byte ApiSnifferStatic(IntPtr @this, IntPtr dictionary, IntPtr some
252240
{
253241
MelonLogger.Error($"Exception in API sniffer patch: {ex}");
254242
}
255-
256-
return result;
257243
}
258244
}
259245
}

IKTweaks/CachedSolver.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ public struct CachedSolver
1212
public readonly IKSolverVR.Arm RightArm;
1313
public readonly IKSolverVR.Locomotion Locomotion;
1414

15+
public readonly IKSolverVR.VirtualBone[] LeftLegBones;
16+
public readonly IKSolverVR.VirtualBone[] RightLegBones;
17+
1518
public CachedSolver(IKSolverVR solver)
1619
{
1720
Solver = solver;
@@ -21,6 +24,9 @@ public CachedSolver(IKSolverVR solver)
2124
RightArm = solver.rightArm;
2225
RightLeg = solver.rightLeg;
2326
Locomotion = solver.locomotion;
27+
28+
LeftLegBones = LeftLeg.bones;
29+
RightLegBones = RightLeg.bones;
2430
}
2531
}
2632
}

IKTweaks/IKTweaks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
55
<LangVersion>latest</LangVersion>
66
<VrcReferences>true</VrcReferences>
7-
<AssemblyVersion>2.0.0</AssemblyVersion>
7+
<AssemblyVersion>2.1.0</AssemblyVersion>
88
<UsesNativePatches>true</UsesNativePatches>
99
</PropertyGroup>
1010
<ItemGroup>

IKTweaks/IKTweaksMod.cs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Diagnostics;
34
using System.Linq;
45
using System.Runtime.CompilerServices;
@@ -9,7 +10,7 @@
910
using UIExpansionKit.Components;
1011
using UnityEngine;
1112

12-
[assembly:MelonInfo(typeof(IKTweaksMod), "IKTweaks", "2.0.0", "knah", "https://github.com/xAstroBoy/VRCMods-Unchained")]
13+
[assembly:MelonInfo(typeof(IKTweaksMod), "IKTweaks", "2.1.0", "knah", "https://github.com/knah/VRCMods")]
1314
[assembly:MelonGame("VRChat", "VRChat")]
1415
[assembly:MelonOptionalDependencies("UIExpansionKit")]
1516

@@ -19,6 +20,8 @@ internal partial class IKTweaksMod : MelonMod
1920
{
2021
public override void OnApplicationStart()
2122
{
23+
if (!CheckWasSuccessful || !MustStayTrue || MustStayFalse) return;
24+
2225
IkTweaksSettings.RegisterSettings();
2326

2427
VrIkHandling.HookVrIkInit();
@@ -31,6 +34,32 @@ public override void OnApplicationStart()
3134
private static void AddUixActions()
3235
{
3336
ExpansionKitApi.GetExpandedMenu(ExpandedMenu.SettingsMenu).AddSimpleButton("More IKTweaks...", ShowIKTweaksMenu);
37+
38+
var settingNameList = new[]
39+
{
40+
nameof(IkTweaksSettings.StraightSpineAngle),
41+
nameof(IkTweaksSettings.StraightSpinePower),
42+
nameof(IkTweaksSettings.DoHipShifting),
43+
nameof(IkTweaksSettings.PreStraightenSpine),
44+
nameof(IkTweaksSettings.StraightenNeck),
45+
nameof(IkTweaksSettings.PinHipRotation),
46+
nameof(IkTweaksSettings.NeckPriority),
47+
nameof(IkTweaksSettings.SpineRelaxIterations),
48+
nameof(IkTweaksSettings.MaxNeckAngleBack),
49+
nameof(IkTweaksSettings.MaxNeckAngleFwd),
50+
nameof(IkTweaksSettings.MaxSpineAngleBack),
51+
nameof(IkTweaksSettings.MaxSpineAngleFwd),
52+
};
53+
var updateCallbacks = new List<Action>();
54+
55+
foreach (var s in settingNameList)
56+
updateCallbacks.Add(ExpansionKitApi.RegisterSettingsVisibilityCallback(
57+
IkTweaksSettings.IkTweaksCategory, s, () => IkTweaksSettings.FullBodyVrIk.Value));
58+
59+
IkTweaksSettings.FullBodyVrIk.OnValueChangedUntyped += () =>
60+
{
61+
foreach (var it in updateCallbacks) it();
62+
};
3463
}
3564

3665
private static void ShowIKTweaksMenu()
@@ -39,7 +68,7 @@ private static void ShowIKTweaksMenu()
3968

4069
menu.AddSpacer();
4170
menu.AddSpacer();
42-
menu.AddSimpleButton("Open documentation in browser", () => Process.Start("https://github.com/xAstroBoy/VRCMods-Unchained#iktweaks"));
71+
menu.AddSimpleButton("Open documentation in browser", () => Process.Start("https://github.com/knah/VRCMods#iktweaks"));
4372
menu.AddSpacer();
4473

4574
menu.AddSimpleButton("Adjust hand offsets",

IKTweaks/IkTweaksSettings.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ internal static void RegisterSettings()
4343
NoWallFreeze = category.CreateEntry(nameof(NoWallFreeze), true, "Don't freeze head/hands inside walls");
4444

4545
DisableElbowAvoidance = category.CreateEntry(nameof(DisableElbowAvoidance), false, "Disable IK2 elbow-chest avoidance");
46+
IktKneeMode = category.CreateEntry(nameof(IktKneeMode), KneeBendNormalMode.Natural, "Knee angle mode (with no trackers)");
4647

4748
ExperimentalSettingOne = category.CreateEntry(nameof(ExperimentalSettingOne), false, "Experimental setting", dont_save_default: true, is_hidden: true);
4849

@@ -73,6 +74,8 @@ internal static void RegisterSettings()
7374
public static MelonPreferences_Entry<bool> Unrestrict3PointHeadRotation;
7475
public static MelonPreferences_Entry<bool> NoWallFreeze;
7576
public static MelonPreferences_Entry<bool> DisableElbowAvoidance;
77+
public static MelonPreferences_Entry<KneeBendNormalMode> IktKneeMode;
78+
7679
public static MelonPreferences_Entry<bool> ExperimentalSettingOne;
7780

7881
public static MelonPreferences_Entry<Vector3> HandAngleOffset;
@@ -97,4 +100,14 @@ public enum IgnoreAnimationsMode
97100
[Description("Ignore all (always slide around)")]
98101
All = HandAndHead | Others
99102
}
103+
104+
public enum KneeBendNormalMode
105+
{
106+
[Description("IK2 Default")]
107+
Default,
108+
[Description("IKT Classic")]
109+
Classic,
110+
[Description("IKT Natural")]
111+
Natural
112+
}
100113
}

0 commit comments

Comments
 (0)