From 431780461cbfc8cd42755e351e5ad47fbd9a9c96 Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com> Date: Tue, 4 Jun 2024 13:06:36 -0500 Subject: [PATCH] [LazyPrune] Fixed binding flags --- LazyPrune/Main.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/LazyPrune/Main.cs b/LazyPrune/Main.cs index 47d3d26..6667dda 100644 --- a/LazyPrune/Main.cs +++ b/LazyPrune/Main.cs @@ -30,28 +30,31 @@ public class LazyPrune : MelonMod // listen for local avatar load/clear events HarmonyInstance.Patch( - typeof(CVRAvatar).GetMethod(nameof(CVRAvatar.Awake)), // earliest callback + typeof(CVRAvatar).GetMethod(nameof(CVRAvatar.Awake), + BindingFlags.NonPublic | BindingFlags.Instance), // earliest callback prefix: new HarmonyMethod(typeof(LazyPrune).GetMethod(nameof(OnObjectCreated), BindingFlags.NonPublic | BindingFlags.Static)) ); HarmonyInstance.Patch( - typeof(CVRAvatar).GetMethod(nameof(CVRAvatar.OnDestroy)), + typeof(CVRAvatar).GetMethod(nameof(CVRAvatar.OnDestroy), + BindingFlags.NonPublic | BindingFlags.Instance), // earliest callback prefix: new HarmonyMethod(typeof(LazyPrune).GetMethod(nameof(OnObjectDestroyed), BindingFlags.NonPublic | BindingFlags.Static)) ); // listen for prop load/clear events HarmonyInstance.Patch( - typeof(CVRSpawnable).GetMethod(nameof(CVRSpawnable.OnEnable)), // earliest callback + typeof(CVRSpawnable).GetMethod(nameof(CVRSpawnable.OnEnable), + BindingFlags.NonPublic | BindingFlags.Instance), // earliest callback prefix: new HarmonyMethod(typeof(LazyPrune).GetMethod(nameof(OnObjectCreated), BindingFlags.NonPublic | BindingFlags.Static)) ); HarmonyInstance.Patch( - typeof(CVRSpawnable).GetMethod(nameof(CVRSpawnable.OnDestroy)), + typeof(CVRSpawnable).GetMethod(nameof(CVRSpawnable.OnDestroy), + BindingFlags.Public | BindingFlags.Instance), // earliest callback (why is this public?) prefix: new HarmonyMethod(typeof(LazyPrune).GetMethod(nameof(OnObjectDestroyed), BindingFlags.NonPublic | BindingFlags.Static)) ); - } #region Game Events @@ -61,6 +64,7 @@ public class LazyPrune : MelonMod if (_lastLoadedWorld != guid) ForcePrunePendingObjects(); + // did you know worlds can spam OnEnabled :) _lastLoadedWorld = guid; }