|
5 | 5 | using VRC.SDKBase;
|
6 | 6 | using VRC.Udon.Wrapper.Modules;
|
7 | 7 |
|
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")] |
9 | 9 | [assembly: MelonGame("VRChat", "VRChat")]
|
10 | 10 | [assembly: MelonColor(ConsoleColor.DarkMagenta)]
|
11 | 11 |
|
12 | 12 | namespace Astrum
|
13 | 13 | {
|
14 | 14 | public class AstralPickups : MelonMod
|
15 | 15 | {
|
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; |
19 | 17 |
|
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(); |
31 | 20 |
|
32 |
| - //https://docs.vrchat.com/docs/players#enablepickups |
33 |
| - private static void EnablePickupsPatch(ref bool enable) |
| 21 | + public override void OnApplicationStart() |
34 | 22 | {
|
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); |
36 | 27 | }
|
37 | 28 |
|
| 29 | + private static bool HookNoOp() => false; |
38 | 30 | private static void HookAwake(ref VRC_Pickup __instance)
|
39 | 31 | {
|
40 | 32 | __instance.DisallowTheft = false;
|
41 | 33 | __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 |
44 | 36 | }
|
45 |
| - |
46 |
| - private static bool HookNoOp() => false; |
47 | 37 | }
|
48 | 38 | }
|
0 commit comments