Skip to content

Commit

Permalink
Mute Lobby BGM
Browse files Browse the repository at this point in the history
  • Loading branch information
mxyx0412 committed Sep 17, 2024
1 parent fab1af5 commit 87a6b78
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 7 deletions.
2 changes: 1 addition & 1 deletion TheOtherRoles/CustomOptionHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ public static void Load()

if (Utilities.EventUtility.canBeEnabled) enableEventMode = Create(3, Types.General, cs(Color.green, "Enable Special Mode"), true, null, true);

anyPlayerCanStopStart = Create(2, Types.General, cs(new Color32(204, 204, 0, 255), "Any Player Can Stop The Start"), false, null, false);
// Using new id's for the options to not break compatibilty with older versions
neutralRolesCountMin = Create(8, Types.General, cs(new Color32(204, 204, 0, 255), "Minimum Neutral Roles"), 15f, 0f, 15f, 1f, heading: "Min/Max Roles");
neutralRolesCountMax = Create(9, Types.General, cs(new Color32(204, 204, 0, 255), "Maximum Neutral Roles"), 15f, 0f, 15f, 1f);
Expand All @@ -619,7 +620,6 @@ public static void Load()


maxNumberOfMeetings = Create(3, Types.General, "Number Of Meetings (excluding Mayor meeting)", 10, 0, 15, 1, null, true, heading: "Gameplay Settings");
anyPlayerCanStopStart = Create(2, Types.General, cs(new Color(204f / 255f, 204f / 255f, 0, 1f), "Any Player Can Stop The Start"), false, null, false);
resteButtonCooldown = Create(20, Types.General, "Game Start CoolDown", 10f, 2.5f, 30f, 2.5f);
blockSkippingInEmergencyMeetings = Create(22, Types.General, "Block Skipping In Emergency Meetings", false);
noVoteIsSelfVote = Create(23, Types.General, "No Vote Is Self Vote", false, blockSkippingInEmergencyMeetings);
Expand Down
5 changes: 5 additions & 0 deletions TheOtherRoles/Helper/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,11 @@ public static bool Contains<T, TKey>(this IEnumerable<T> list, T item, Func<T, T
return list.Any(x => keySelector(x).Equals(keySelector(item)));
}

public static T Find<T>(this Il2CppSystem.Collections.Generic.List<T> data, Predicate<T> match)
{
return data.ToList().Find(match);
}

public static bool IsAlive(this PlayerControl player)
{
return player != null && !player.Data.Disconnected && !player.Data.IsDead;
Expand Down
6 changes: 3 additions & 3 deletions TheOtherRoles/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ public class TheOtherRolesPlugin : BasePlugin
public static ConfigEntry<bool> GhostsSeeRoles { get; set; }
public static ConfigEntry<bool> GhostsSeeModifier { get; set; }
public static ConfigEntry<bool> GhostsSeeVotes { get; set; }
public static ConfigEntry<bool> ShowRoleSummary { get; set; }
public static ConfigEntry<bool> ShowLighterDarker { get; set; }
public static ConfigEntry<bool> EnableSoundEffects { get; set; }
public static ConfigEntry<bool> ShowChatNotifications { get; set; }
public static ConfigEntry<bool> ShowFPS { get; set; }
public static ConfigEntry<bool> MuteLobbyBGM { get; set; }
public static ConfigEntry<bool> ShowChatNotifications { get; set; }
public static ConfigEntry<bool> EnableHorseMode { get; set; }
public static ConfigEntry<bool> ToggleCursor { get; set; }
public static ConfigEntry<string> Ip { get; set; }
Expand Down Expand Up @@ -99,13 +99,13 @@ public override void Load()
GhostsSeeRoles = Config.Bind("Custom", "Ghosts See Roles", true);
GhostsSeeModifier = Config.Bind("Custom", "Ghosts See Modifier", true);
GhostsSeeVotes = Config.Bind("Custom", "Ghosts See Votes", true);
ShowRoleSummary = Config.Bind("Custom", "Show Role Summary", true);
ShowLighterDarker = Config.Bind("Custom", "Show Lighter / Darker", true);
ToggleCursor = Config.Bind("Custom", "Better Cursor", true);
EnableSoundEffects = Config.Bind("Custom", "Enable Sound Effects", true);
EnableHorseMode = Config.Bind("Custom", "Enable Horse Mode", false);
ShowPopUpVersion = Config.Bind("Custom", "Show PopUp", "0");
ShowFPS = Config.Bind("Custom", "Show FPS", true);
MuteLobbyBGM = Config.Bind("Custom", "Mute Lobby BGM", true);
ShowChatNotifications = Config.Bind("Custom", "Show Chat Notifications", true);

Ip = Config.Bind("Custom", "Custom Server IP", "127.0.0.1");
Expand Down
3 changes: 2 additions & 1 deletion TheOtherRoles/MapOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ static class TORMapOptions
public static bool ShowVentsOnMap;
public static bool ShowVentsOnMeetingMap = true;
public static bool ShowChatNotifications = true;
public static bool muteLobbyBGM = true;
public static bool showFPS;
public static bool disableMedscanWalking;
public static int restrictDevices;
Expand Down Expand Up @@ -99,13 +100,13 @@ public static void reloadPluginOptions()
ghostsSeeModifier = Main.GhostsSeeModifier.Value;
ghostsSeeInformation = Main.GhostsSeeInformation.Value;
ghostsSeeVotes = Main.GhostsSeeVotes.Value;
showRoleSummary = Main.ShowRoleSummary.Value;
showLighterDarker = Main.ShowLighterDarker.Value;
toggleCursor = Main.ToggleCursor.Value;
enableSoundEffects = Main.EnableSoundEffects.Value;
enableHorseMode = Main.EnableHorseMode.Value;
showFPS = Main.ShowFPS.Value;
ShowChatNotifications = Main.ShowChatNotifications.Value;
muteLobbyBGM = Main.MuteLobbyBGM.Value;

//Patches.ShouldAlwaysHorseAround.isHorseMode = Main.EnableHorseMode.Value;
}
Expand Down
4 changes: 2 additions & 2 deletions TheOtherRoles/Patches/ClientOptionsPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public static class ClientOptionsPatch
TORMapOptions.ghostsSeeRoles = Main.GhostsSeeRoles.Value = !Main.GhostsSeeRoles.Value, Main.GhostsSeeRoles.Value),
new("Ghosts Can Additionally See Modifier", () =>
TORMapOptions.ghostsSeeModifier = Main.GhostsSeeModifier.Value = !Main.GhostsSeeModifier.Value, Main.GhostsSeeModifier.Value),
new("Show Role Summary", () =>
TORMapOptions.showRoleSummary = Main.ShowRoleSummary.Value = !Main.ShowRoleSummary.Value, Main.ShowRoleSummary.Value),
new("Show Lighter / Darker", () =>
TORMapOptions.showLighterDarker = Main.ShowLighterDarker.Value = !Main.ShowLighterDarker.Value, Main.ShowLighterDarker.Value),
new("Better Cursor", () =>
Expand All @@ -33,6 +31,8 @@ public static class ClientOptionsPatch
TORMapOptions.showFPS = Main.ShowFPS.Value = !Main.ShowFPS.Value, Main.ShowFPS.Value),
new("Show Chat Notifications", () =>
TORMapOptions.ShowChatNotifications = Main.ShowChatNotifications.Value = !Main.ShowChatNotifications.Value, Main.ShowChatNotifications.Value),
new ("Mute Lobby BGM", () =>
TORMapOptions.muteLobbyBGM = Main.MuteLobbyBGM.Value = !Main.MuteLobbyBGM.Value, Main.MuteLobbyBGM.Value),
];

private static GameObject popUp;
Expand Down
27 changes: 27 additions & 0 deletions TheOtherRoles/Patches/LobbyBehaviourPatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace TheOtherRoles.Patches;

[HarmonyPatch(typeof(LobbyBehaviour))]
public class LobbyBehaviourPatch
{
public static int Frame = 0;

[HarmonyPatch(nameof(LobbyBehaviour.FixedUpdate)), HarmonyPostfix]
public static void UpdatePostfix(LobbyBehaviour __instance)
{
if (--Frame <= 0)
{
ISoundPlayer MapThemeSound = SoundManager.Instance.soundPlayers.Find(x => x.Name.Equals("MapTheme"));
if (Main.MuteLobbyBGM.Value)
{
if (MapThemeSound == null) return;
SoundManager.Instance.StopNamedSound("MapTheme");
}
else
{
if (MapThemeSound != null) return;
SoundManager.Instance.CrossFadeSound("MapTheme", __instance.MapTheme, 0.5f);
}
Frame = 15;
}
}
}

0 comments on commit 87a6b78

Please sign in to comment.