From 92a5991ff9011b4df3f4dcf6d4db5921cd821c40 Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com> Date: Wed, 12 Apr 2023 03:25:45 -0500 Subject: [PATCH] clear redo list on world change --- PropUndoButton/Main.cs | 14 ++++++++++++-- PropUndoButton/PropUndoButton.csproj | 14 +++++++------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/PropUndoButton/Main.cs b/PropUndoButton/Main.cs index 7dc2791..d3f1506 100644 --- a/PropUndoButton/Main.cs +++ b/PropUndoButton/Main.cs @@ -1,4 +1,5 @@ -using ABI_RC.Core.AudioEffects; +using ABI.CCK.Components; +using ABI_RC.Core.AudioEffects; using ABI_RC.Core.Networking; using ABI_RC.Core.Savior; using ABI_RC.Core.UI; @@ -37,7 +38,7 @@ public class PropUndoButton : MelonMod typeof(CVRSyncHelper).GetMethod(nameof(CVRSyncHelper.SpawnProp)), postfix: new HarmonyLib.HarmonyMethod(typeof(PropUndoButton).GetMethod(nameof(OnSpawnProp), BindingFlags.NonPublic | BindingFlags.Static)) ); - HarmonyInstance.Patch( // prop delete sfx + HarmonyInstance.Patch( // prop delete sfx, log for possible redo typeof(CVRSyncHelper).GetMethod(nameof(CVRSyncHelper.DeletePropByInstanceId)), postfix: new HarmonyLib.HarmonyMethod(typeof(PropUndoButton).GetMethod(nameof(OnDeletePropByInstanceId), BindingFlags.NonPublic | BindingFlags.Static)) ); @@ -45,6 +46,10 @@ public class PropUndoButton : MelonMod typeof(InputModuleMouseKeyboard).GetMethod(nameof(InputModuleMouseKeyboard.UpdateInput)), postfix: new HarmonyLib.HarmonyMethod(typeof(PropUndoButton).GetMethod(nameof(OnUpdateInput), BindingFlags.NonPublic | BindingFlags.Static)) ); + HarmonyInstance.Patch( // clear redo list on world change + typeof(CVRWorld).GetMethod(nameof(CVRWorld.ConfigureWorld)), + postfix: new HarmonyLib.HarmonyMethod(typeof(PropUndoButton).GetMethod(nameof(OnWorldLoad), BindingFlags.NonPublic | BindingFlags.Static)) + ); SetupDefaultAudioClips(); } @@ -135,6 +140,11 @@ public class PropUndoButton : MelonMod PlayAudioModule(sfx_undo); } + private static void OnWorldLoad() + { + deletedProps.Clear(); + } + private static void UndoProp() { if (!EntryEnabled.Value) return; diff --git a/PropUndoButton/PropUndoButton.csproj b/PropUndoButton/PropUndoButton.csproj index e6a31c9..3b1889c 100644 --- a/PropUndoButton/PropUndoButton.csproj +++ b/PropUndoButton/PropUndoButton.csproj @@ -25,25 +25,25 @@ - C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\0Harmony.dll + C:\Users\krist\Documents\GitHub\_ChilloutVR Modding\_ManagedLibs\0Harmony.dll - C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp.dll + C:\Users\krist\Documents\GitHub\_ChilloutVR Modding\_ManagedLibs\Assembly-CSharp.dll - C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp-firstpass.dll + C:\Users\krist\Documents\GitHub\_ChilloutVR Modding\_ManagedLibs\Assembly-CSharp-firstpass.dll - ..\..\..\_ManagedLibs\DarkRift.dll + C:\Users\krist\Documents\GitHub\_ChilloutVR Modding\_ManagedLibs\DarkRift.dll - C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\MelonLoader.dll + C:\Users\krist\Documents\GitHub\_ChilloutVR Modding\_ManagedLibs\MelonLoader.dll - C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.CoreModule.dll + C:\Users\krist\Documents\GitHub\_ChilloutVR Modding\_ManagedLibs\UnityEngine.CoreModule.dll - C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.InputLegacyModule.dll + C:\Users\krist\Documents\GitHub\_ChilloutVR Modding\_ManagedLibs\UnityEngine.InputLegacyModule.dll