Skip to content
This repository was archived by the owner on Jul 27, 2022. It is now read-only.

Commit 4146f9e

Browse files
committed
convert hk enable pickups to nop and bump ver
1 parent 6d351e4 commit 4146f9e

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

AstralPickups.cs

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,34 @@
55
using VRC.SDKBase;
66
using VRC.Udon.Wrapper.Modules;
77

8-
[assembly: MelonInfo(typeof(Astrum.AstralPickups), "AstralPickups", "0.1.0", downloadLink: "github.com/Astrum-Project/AstralPickups")]
8+
[assembly: MelonInfo(typeof(Astrum.AstralPickups), "AstralPickups", "0.2.0", downloadLink: "github.com/Astrum-Project/AstralPickups")]
99
[assembly: MelonGame("VRChat", "VRChat")]
1010
[assembly: MelonColor(ConsoleColor.DarkMagenta)]
1111

1212
namespace Astrum
1313
{
1414
public class AstralPickups : MelonMod
1515
{
16-
public override void OnApplicationStart()
17-
{
18-
var nop = new HarmonyMethod(typeof(AstralPickups).GetMethod(nameof(HookNoOp), BindingFlags.NonPublic | BindingFlags.Static));
16+
const BindingFlags PrivateStatic = BindingFlags.NonPublic | BindingFlags.Static;
1917

20-
HarmonyInstance.Patch(
21-
typeof(VRC_Pickup).GetMethod(nameof(VRC_Pickup.Awake)),
22-
null,
23-
new HarmonyMethod(typeof(AstralPickups).GetMethod(nameof(HookAwake), BindingFlags.NonPublic | BindingFlags.Static))
24-
);
25-
26-
HarmonyInstance.Patch(typeof(ExternVRCSDK3ComponentsVRCPickup).GetMethod(nameof(ExternVRCSDK3ComponentsVRCPickup.__set_DisallowTheft__SystemBoolean)), nop);
27-
HarmonyInstance.Patch(typeof(ExternVRCSDK3ComponentsVRCPickup).GetMethod(nameof(ExternVRCSDK3ComponentsVRCPickup.__set_pickupable__SystemBoolean)), nop);
28-
HarmonyInstance.Patch(typeof(VRCPlayerApi).GetMethod(nameof(VRCPlayerApi.EnablePickups)), postfix: typeof(AstralPickups).GetMethod(nameof(EnablePickupsPatch), BindingFlags.NonPublic | BindingFlags.Static)
29-
?.ToNewHarmonyMethod());
30-
}
18+
public static HarmonyMethod hkNoOp = new HarmonyMethod(typeof(AstralPickups).GetMethod(nameof(HookNoOp), BindingFlags.NonPublic | BindingFlags.Static));//
19+
public static HarmonyMethod hkAwake = typeof(AstralPickups).GetMethod(nameof(HookAwake), PrivateStatic)?.ToNewHarmonyMethod();
3120

32-
//https://docs.vrchat.com/docs/players#enablepickups
33-
private static void EnablePickupsPatch(ref bool enable)
21+
public override void OnApplicationStart()
3422
{
35-
enable = true;
23+
HarmonyInstance.Patch(typeof(VRC_Pickup).GetMethod(nameof(VRC_Pickup.Awake)), null, hkAwake); // https://docs.unity3d.com/ScriptReference/MonoBehaviour.Awake.html
24+
HarmonyInstance.Patch(typeof(VRCPlayerApi).GetMethod(nameof(VRCPlayerApi.EnablePickups)), null, hkNoOp); // https://docs.vrchat.com/docs/players#enablepickups
25+
HarmonyInstance.Patch(typeof(ExternVRCSDK3ComponentsVRCPickup).GetMethod(nameof(ExternVRCSDK3ComponentsVRCPickup.__set_DisallowTheft__SystemBoolean)), hkNoOp);
26+
HarmonyInstance.Patch(typeof(ExternVRCSDK3ComponentsVRCPickup).GetMethod(nameof(ExternVRCSDK3ComponentsVRCPickup.__set_pickupable__SystemBoolean)), hkNoOp);
3627
}
3728

29+
private static bool HookNoOp() => false;
3830
private static void HookAwake(ref VRC_Pickup __instance)
3931
{
4032
__instance.DisallowTheft = false;
4133
__instance.pickupable = true;
42-
__instance.allowManipulationWhenEquipped = true;
43-
__instance.proximity = float.MaxValue;
34+
__instance.allowManipulationWhenEquipped = true; // TODO: write a hook to prevent this from being set
35+
__instance.proximity = float.MaxValue; // TODO: write a hook to prevent this from being set
4436
}
45-
46-
private static bool HookNoOp() => false;
4737
}
4838
}

0 commit comments

Comments
 (0)