From b1749af6ca0387ffdfd1900b62b3c40ec93cb7fe Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com> Date: Thu, 13 Apr 2023 18:32:21 -0500 Subject: [PATCH] fixed warn/deny sound usage, enabled sfx by default again --- PropUndoButton/Main.cs | 27 +++++++++++++-------------- PropUndoButton/format.json | 2 +- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/PropUndoButton/Main.cs b/PropUndoButton/Main.cs index 5ab8ddc..33c3b0b 100644 --- a/PropUndoButton/Main.cs +++ b/PropUndoButton/Main.cs @@ -23,7 +23,7 @@ public class PropUndoButton : MelonMod Category.CreateEntry("Enabled", true, description: "Toggle Undo Prop Button."); public static readonly MelonPreferences_Entry EntryUseSFX = - Category.CreateEntry("Use SFX", false, description: "Toggle audio queues for prop spawn, undo, redo, or warning."); + Category.CreateEntry("Use SFX", true, description: "Toggle audio queues for prop spawn, undo, redo, and warning."); // audio clip names, InterfaceAudio adds "PropUndo_" prefix public const string sfx_spawn = "PropUndo_sfx_spawn"; @@ -123,7 +123,7 @@ public class PropUndoButton : MelonMod if (!IsPropSpawnAllowed() || IsAtPropLimit()) { - PlayAudioModule(sfx_warn); + PlayAudioModule(sfx_deny); return; } @@ -187,32 +187,32 @@ public class PropUndoButton : MelonMod public static void RedoProp() { int index = deletedProps.Count - 1; - if (index < 0 || index >= deletedProps.Count || IsAtPropLimit()) + if (index < 0) { PlayAudioModule(sfx_warn); return; } + if (!IsPropSpawnAllowed() || IsAtPropLimit()) + { + PlayAudioModule(sfx_deny); + return; + } + // only allow redo of prop spawned in last minute DeletedProp deletedProp = deletedProps[index]; if (Time.time - deletedProp.timeDeleted <= redoTimeoutLimit) { - if (AttemptRedoProp(deletedProp.propGuid, deletedProp.position, deletedProp.rotation)) - { - deletedProps.RemoveAt(index); - PlayAudioModule(sfx_redo); - return; - } + SendRedoProp(deletedProp.propGuid, deletedProp.position, deletedProp.rotation); + PlayAudioModule(sfx_redo); } - PlayAudioModule(sfx_warn); + deletedProps.RemoveAt(index); } // original spawn prop method does not let you specify rotation - public static bool AttemptRedoProp(string propGuid, Vector3 position, Vector3 rotation) + public static void SendRedoProp(string propGuid, Vector3 position, Vector3 rotation) { - if (!IsPropSpawnAllowed()) return false; - using (DarkRiftWriter darkRiftWriter = DarkRiftWriter.Create()) { darkRiftWriter.Write(propGuid); @@ -231,7 +231,6 @@ public class PropUndoButton : MelonMod NetworkManager.Instance.GameNetwork.SendMessage(message, SendMode.Reliable); } } - return true; } public static void PlayAudioModule(string module) diff --git a/PropUndoButton/format.json b/PropUndoButton/format.json index 244b981..02d3b81 100644 --- a/PropUndoButton/format.json +++ b/PropUndoButton/format.json @@ -18,6 +18,6 @@ ], "downloadlink": "https://github.com/NotAKidOnSteam/PropUndoButton/releases/download/v1.0.1/PropUndoButton.dll", "sourcelink": "https://github.com/NotAKidOnSteam/PropUndoButton/", - "changelog": "- Initial Release\n- Added redo button.\n- Disabled SFX by default.\n- Lowered SFX volume to match existing UI sounds.", + "changelog": "- Initial Release\n- Added redo button.\n- Mitigated issue of props getting stuck locally if deleting them before they fully spawn.\n- Lowered SFX volume to match existing UI sounds.", "embedcolor": "#00FFFF" } \ No newline at end of file