fixed warn/deny sound usage, enabled sfx by default again

This commit is contained in:
NotAKidoS 2023-04-13 18:32:21 -05:00
parent cbcbb9f288
commit b1749af6ca
2 changed files with 14 additions and 15 deletions

View file

@ -23,7 +23,7 @@ public class PropUndoButton : MelonMod
Category.CreateEntry("Enabled", true, description: "Toggle Undo Prop Button."); Category.CreateEntry("Enabled", true, description: "Toggle Undo Prop Button.");
public static readonly MelonPreferences_Entry<bool> EntryUseSFX = public static readonly MelonPreferences_Entry<bool> 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 // audio clip names, InterfaceAudio adds "PropUndo_" prefix
public const string sfx_spawn = "PropUndo_sfx_spawn"; public const string sfx_spawn = "PropUndo_sfx_spawn";
@ -123,7 +123,7 @@ public class PropUndoButton : MelonMod
if (!IsPropSpawnAllowed() || IsAtPropLimit()) if (!IsPropSpawnAllowed() || IsAtPropLimit())
{ {
PlayAudioModule(sfx_warn); PlayAudioModule(sfx_deny);
return; return;
} }
@ -187,32 +187,32 @@ public class PropUndoButton : MelonMod
public static void RedoProp() public static void RedoProp()
{ {
int index = deletedProps.Count - 1; int index = deletedProps.Count - 1;
if (index < 0 || index >= deletedProps.Count || IsAtPropLimit()) if (index < 0)
{ {
PlayAudioModule(sfx_warn); PlayAudioModule(sfx_warn);
return; return;
} }
if (!IsPropSpawnAllowed() || IsAtPropLimit())
{
PlayAudioModule(sfx_deny);
return;
}
// only allow redo of prop spawned in last minute // only allow redo of prop spawned in last minute
DeletedProp deletedProp = deletedProps[index]; DeletedProp deletedProp = deletedProps[index];
if (Time.time - deletedProp.timeDeleted <= redoTimeoutLimit) if (Time.time - deletedProp.timeDeleted <= redoTimeoutLimit)
{ {
if (AttemptRedoProp(deletedProp.propGuid, deletedProp.position, deletedProp.rotation)) SendRedoProp(deletedProp.propGuid, deletedProp.position, deletedProp.rotation);
{
deletedProps.RemoveAt(index);
PlayAudioModule(sfx_redo); PlayAudioModule(sfx_redo);
return;
}
} }
PlayAudioModule(sfx_warn); deletedProps.RemoveAt(index);
} }
// original spawn prop method does not let you specify rotation // 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()) using (DarkRiftWriter darkRiftWriter = DarkRiftWriter.Create())
{ {
darkRiftWriter.Write(propGuid); darkRiftWriter.Write(propGuid);
@ -231,7 +231,6 @@ public class PropUndoButton : MelonMod
NetworkManager.Instance.GameNetwork.SendMessage(message, SendMode.Reliable); NetworkManager.Instance.GameNetwork.SendMessage(message, SendMode.Reliable);
} }
} }
return true;
} }
public static void PlayAudioModule(string module) public static void PlayAudioModule(string module)

View file

@ -18,6 +18,6 @@
], ],
"downloadlink": "https://github.com/NotAKidOnSteam/PropUndoButton/releases/download/v1.0.1/PropUndoButton.dll", "downloadlink": "https://github.com/NotAKidOnSteam/PropUndoButton/releases/download/v1.0.1/PropUndoButton.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/PropUndoButton/", "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" "embedcolor": "#00FFFF"
} }