clear redo list on world change

This commit is contained in:
NotAKidoS 2023-04-12 03:25:45 -05:00
parent 2c029b1452
commit 92a5991ff9
2 changed files with 19 additions and 9 deletions

View file

@ -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;