using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LethalSettings.UI;
using LethalSettings.UI.Components;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Kesomannen")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Volume tuning mod for Lethal Company")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: AssemblyInformationalVersion("1.4.0+e7f0f8f8d8f26615fe9cd3f0ce7fdb9716a69851")]
[assembly: AssemblyProduct("KeepItDown")]
[assembly: AssemblyTitle("KeepItDown")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace KeepItDown
{
internal static class AudioPatches
{
private static string GetFormattedName(Object gameObject)
{
return gameObject.name.Replace("(Clone)", "").Replace("Item", "");
}
[HarmonyPostfix]
[HarmonyPatch(typeof(NoisemakerProp), "Start")]
private static void NoiseMakerProp_Start_Postfix(NoisemakerProp __instance)
{
GameObject gameObject = ((Component)__instance).gameObject;
string formattedName = GetFormattedName((Object)(object)gameObject);
KeepItDownPlugin.Instance.Bind(formattedName, gameObject, __instance.maxLoudness, delegate(float v)
{
__instance.maxLoudness = v;
});
KeepItDownPlugin.Instance.Bind(formattedName, gameObject, __instance.minLoudness, delegate(float v)
{
__instance.minLoudness = v;
});
}
[HarmonyPostfix]
[HarmonyPatch(typeof(AnimatedItem), "Start")]
private static void AnimatedItem_Start_Postfix(AnimatedItem __instance)
{
string formattedName = GetFormattedName((Object)(object)((Component)__instance).gameObject);
KeepItDownPlugin.Instance.BindAudioSource(formattedName, __instance.itemAudio);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(RadarBoosterItem), "Start")]
private static void RadarBoosterItem_Start_Postfix(RadarBoosterItem __instance)
{
KeepItDownPlugin.Instance.BindAudioSource("RadarBoosterPing", __instance.pingAudio);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(ShipAlarmCord), "Start")]
private static void ShipAlarmCord_Start_Postfix(ShipAlarmCord __instance)
{
KeepItDownPlugin.Instance.BindAudioSources("ShipAlarm", __instance.hornClose, __instance.hornFar);
KeepItDownPlugin.Instance.BindAudioSource("ShipAlarmCord", __instance.cordAudio);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(BoomboxItem), "Start")]
private static void BoomboxItem_Start_Postfix(BoomboxItem __instance)
{
KeepItDownPlugin.Instance.BindAudioSource("Boombox", __instance.boomboxAudio);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(WalkieTalkie), "Start")]
private static void WalkieTalkie_Start_Postfix(WalkieTalkie __instance)
{
KeepItDownPlugin.Instance.BindAudioSource("Walkie-talkie", __instance.thisAudio);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(FlashlightItem), "Start")]
private static void FlashlightItem_Start_Postfix(FlashlightItem __instance)
{
KeepItDownPlugin.Instance.BindAudioSource("Flashlight", __instance.flashlightAudio);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(SprayPaintItem), "Start")]
private static void SprayPaintItem_Start_Postfix(SprayPaintItem __instance)
{
KeepItDownPlugin.Instance.BindAudioSource("Spraycan", __instance.sprayAudio);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Landmine), "Start")]
private static void Landmine_Start_Postfix(Landmine __instance)
{
KeepItDownPlugin.Instance.BindAudioSource("Landmine", __instance.mineAudio);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(SpikeRoofTrap), "Start")]
private static void SpikeRoofTrap_Start_Postfix(SpikeRoofTrap __instance)
{
KeepItDownPlugin.Instance.BindAudioSource("SpikeTrap", __instance.spikeTrapAudio);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Turret), "Start")]
private static void Turret_Start_Postfix(Turret __instance)
{
KeepItDownPlugin.Instance.BindAudioSources("Turret", __instance.mainAudio, __instance.berserkAudio, __instance.farAudio);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(JesterAI), "Start")]
private static void JesterAI_Start_Postfix(JesterAI __instance)
{
KeepItDownPlugin.Instance.BindAudioSource("Jester", __instance.farAudio);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(RadMechAI), "Start")]
private static void JesterAI_Start_Postfix(RadMechAI __instance)
{
KeepItDownPlugin.Instance.BindAudioSources("OldBird", __instance.blowtorchAudio, __instance.explosionAudio, __instance.LocalLRADAudio, __instance.LocalLRADAudio2, __instance.chargeForwardAudio, __instance.flyingDistantAudio, __instance.spotlightOnAudio);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(TVScript), "OnEnable")]
private static void TVScript_OnEnable_Postfix(TVScript __instance)
{
KeepItDownPlugin.Instance.BindAudioSource("TV", __instance.tvSFX);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(TVScript), "OnDisable")]
private static void TVScript_OnDisable_Postfix(TVScript __instance)
{
KeepItDownPlugin.Instance.RemoveBindings("TV", ((Component)__instance.tvSFX).gameObject);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(StormyWeather), "OnEnable")]
private static void StormyWeather_OnEnable_Postfix(StormyWeather __instance)
{
KeepItDownPlugin.Instance.BindAudioSources("Thunder", __instance.randomStrikeAudio, __instance.randomStrikeAudioB, __instance.targetedStrikeAudio);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(StormyWeather), "OnDisable")]
private static void StormyWeather_OnDisable_Postfix(StormyWeather __instance)
{
KeepItDownPlugin.Instance.RemoveBindings("Thunder", ((Component)__instance).gameObject);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(GrabbableObject), "Start")]
private static void GrabbableObject_Start_Postfix(GrabbableObject __instance)
{
RemoteProp val = (RemoteProp)(object)((__instance is RemoteProp) ? __instance : null);
if (val == null)
{
JetpackItem val2 = (JetpackItem)(object)((__instance is JetpackItem) ? __instance : null);
if (val2 == null)
{
Shovel val3 = (Shovel)(object)((__instance is Shovel) ? __instance : null);
if (val3 == null)
{
WhoopieCushionItem val4 = (WhoopieCushionItem)(object)((__instance is WhoopieCushionItem) ? __instance : null);
if (val4 == null)
{
ExtensionLadderItem val5 = (ExtensionLadderItem)(object)((__instance is ExtensionLadderItem) ? __instance : null);
if (val5 == null)
{
StunGrenadeItem val6 = (StunGrenadeItem)(object)((__instance is StunGrenadeItem) ? __instance : null);
if (val6 != null)
{
string key = (((Object)val6).name.Contains("Egg") ? "EasterEgg" : "StunGrenade");
KeepItDownPlugin.Instance.BindAudioSource(key, val6.itemAudio);
}
}
else
{
KeepItDownPlugin.Instance.BindAudioSource("ExtensionLadder", val5.ladderAudio);
}
}
else
{
KeepItDownPlugin.Instance.BindAudioSource("WhoopieCushion", val4.whoopieCushionAudio);
}
}
else
{
KeepItDownPlugin.Instance.BindAudioSource("Shovel", val3.shovelAudio);
}
}
else
{
KeepItDownPlugin.Instance.BindAudioSource("Jetpack", val2.jetpackAudio);
}
}
else
{
KeepItDownPlugin.Instance.BindAudioSource("Remote", val.remoteAudio);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(NetworkBehaviour), "OnNetworkSpawn")]
private static void NetworkBehaviour_OnNetworkSpawn_Postfix(NetworkBehaviour __instance)
{
ItemCharger val = (ItemCharger)(object)((__instance is ItemCharger) ? __instance : null);
if (val != null)
{
KeepItDownPlugin.Instance.BindAudioSource("ItemCharger", val.zapAudio);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(HUDManager), "OnEnable")]
private static void HUDManager_OnEnable_Postfix(HUDManager __instance)
{
KeepItDownPlugin.Instance.BindAudioSource("Scan", __instance.UIAudio);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(HUDManager), "OnDisable")]
private static void HUDManager_OnDisable_Postfix(HUDManager __instance)
{
KeepItDownPlugin.Instance.RemoveBindings("Scan", ((Component)__instance.UIAudio).gameObject);
}
}
public class KeepItDownConfig
{
private readonly Dictionary<string, VolumeConfig> _volumes = new Dictionary<string, VolumeConfig>();
private readonly ConfigFile _mainCfg;
public IReadOnlyDictionary<string, VolumeConfig> Volumes => _volumes;
internal KeepItDownConfig(ConfigFile mainCfg)
{
_mainCfg = mainCfg;
}
private static VolumeConfig CreateVolumeConfig(ConfigFile cfg, string key, string section)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
return new VolumeConfig(key, cfg.Bind<float>(section, key + "Volume", 50f, new ConfigDescription("Volume of " + key, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>())));
}
public bool AddVolumeConfig(string key, string section, ConfigFile cfg = null)
{
if (_volumes.ContainsKey(key))
{
KeepItDownPlugin.Instance.Log.LogWarning((object)("Volume config for " + key + " already exists!"));
return false;
}
_volumes[key] = CreateVolumeConfig(cfg ?? _mainCfg, key, section);
KeepItDownPlugin.Instance.Log.LogDebug((object)("Registered " + key));
return true;
}
public bool AddVolumeConfigs(IEnumerable<string> keys, string section, ConfigFile cfg = null)
{
return keys.Select((string key) => AddVolumeConfig(key, section, cfg)).All((bool x) => x);
}
}
public class VolumeConfig : IDisposable
{
public delegate void ChangedEventHandler(VolumeConfig config, float rawValue, float normalizedValue);
public struct Binding
{
public GameObject GameObject { get; }
public float BaseVolume { get; }
public Action<float> Setter { get; }
public Binding(GameObject gameObject, float baseVolume, Action<float> setter)
{
GameObject = gameObject;
BaseVolume = baseVolume;
Setter = setter;
}
}
private readonly List<Binding> _bindings = new List<Binding>();
private bool _isDisposed;
public ConfigEntry<float> ConfigEntry { get; }
public float NormalizedValue
{
get
{
return RawValue / 100f * 2f;
}
set
{
RawValue = value * 100f / 2f;
}
}
public float RawValue
{
get
{
return ConfigEntry.Value;
}
set
{
ConfigEntry.Value = value;
}
}
public string Key { get; }
public string Section => ((ConfigEntryBase)ConfigEntry).Definition.Section;
public event ChangedEventHandler OnChanged;
internal VolumeConfig(string key, ConfigEntry<float> configEntry)
{
Key = key;
ConfigEntry = configEntry;
ConfigEntry.SettingChanged += SettingChangedEventHandler;
}
~VolumeConfig()
{
Dispose();
}
public void Dispose()
{
if (!_isDisposed)
{
_isDisposed = true;
ConfigEntry.SettingChanged -= SettingChangedEventHandler;
}
}
private void SettingChangedEventHandler(object sender, EventArgs e)
{
for (int i = 0; i < _bindings.Count; i++)
{
Binding binding = _bindings[i];
if ((Object)(object)binding.GameObject == (Object)null)
{
_bindings.RemoveAt(i--);
}
else
{
ActivateBinding(in binding);
}
}
this.OnChanged?.Invoke(this, RawValue, NormalizedValue);
}
public void AddBinding(Binding binding)
{
_bindings.Add(binding);
ActivateBinding(in binding);
}
public void RemoveBindings(GameObject gameObject)
{
for (int i = 0; i < _bindings.Count; i++)
{
if ((Object)(object)_bindings[i].GameObject == (Object)(object)gameObject)
{
_bindings.RemoveAt(i--);
}
}
}
private void ActivateBinding(in Binding binding)
{
binding.Setter(NormalizedValue * binding.BaseVolume);
}
}
public static class KeepItDownInfo
{
public const string Guid = "KeepItDown";
public const string Name = "KeepItDown";
public const string Version = "1.4.0";
}
[BepInPlugin("KeepItDown", "KeepItDown", "1.4.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class KeepItDownPlugin : BaseUnityPlugin
{
private const string LethalSettingsGuid = "com.willis.lc.lethalsettings";
private const string LethalConfigGuid = "ainavt.lc.lethalconfig";
public static KeepItDownPlugin Instance { get; private set; }
internal ManualLogSource Log => ((BaseUnityPlugin)this).Logger;
internal KeepItDownConfig Config { get; private set; }
private void Awake()
{
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
Config = new KeepItDownConfig(((BaseUnityPlugin)this).Config);
AddConfigs(new string[31]
{
"Airhorn", "Boombox", "CashRegister", "Remote", "Flashlight", "Walkie-talkie", "Scan", "Spraycan", "Dentures", "RobotToy",
"Hairdryer", "Jetpack", "RadarBoosterPing", "ShipAlarm", "ShipAlarmCord", "ItemCharger", "Shovel", "RubberDucky", "Landmine", "Jester",
"Thunder", "WhoopieCushion", "ExtensionLadder", "Turret", "TV", "Clownhorn", "OldPhone", "StunGrenade", "OldBird", "EasterEgg",
"SpikeTrap"
}, "Vanilla");
new Harmony("KeepItDown").PatchAll(typeof(AudioPatches));
bool num = Chainloader.PluginInfos.ContainsKey("com.willis.lc.lethalsettings");
if (num)
{
Log.LogInfo((object)"LethalSettings found, initializing UI...");
LethalSettingsUI.Init();
}
bool flag = Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig");
if (flag)
{
Log.LogInfo((object)"LethalConfig found, initializing UI...");
LethalConfigUI.Init();
}
if (!num && !flag)
{
Log.LogWarning((object)"Neither LethalSettings nor LethalConfig found, no UI will be available");
}
Log.LogInfo((object)"KeepItDown is loaded!");
}
internal bool AddConfig(string key, string section, ConfigFile cfg = null)
{
return Config.AddVolumeConfig(key, section, cfg);
}
internal bool AddConfigs(IEnumerable<string> keys, string section, ConfigFile cfg = null)
{
return Config.AddVolumeConfigs(keys, section, cfg);
}
internal bool TryGetConfig(string key, out VolumeConfig config)
{
return Config.Volumes.TryGetValue(key, out config);
}
internal bool Bind(string key, GameObject gameObject, float baseVolume, Action<float> volumeSetter)
{
if (!TryGetConfig(key, out var config))
{
Log.LogWarning((object)("Trying to bind volume config for " + key + ", but it doesn't exist"));
return false;
}
config.AddBinding(new VolumeConfig.Binding(gameObject, baseVolume, volumeSetter));
return true;
}
internal bool BindAudioSource(string key, AudioSource audioSource)
{
return Bind(key, ((Component)audioSource).gameObject, audioSource.volume, delegate(float v)
{
audioSource.volume = v;
});
}
internal bool BindAudioSources(string key, params AudioSource[] audioSources)
{
return audioSources.All((AudioSource audioSource) => BindAudioSource(key, audioSource));
}
internal bool RemoveBindings(string key, GameObject gameObject)
{
if (!TryGetConfig(key, out var config))
{
Log.LogWarning((object)("Trying to remove volume config bindings for " + key + ", but it doesn't exist"));
return false;
}
config.RemoveBindings(gameObject);
return true;
}
}
internal static class LethalConfigUI
{
internal static void Init()
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Expected O, but got Unknown
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
//IL_0098: Expected O, but got Unknown
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Expected O, but got Unknown
LethalConfigManager.SkipAutoGen();
LethalConfigManager.SetModDescription("Volume control for various sounds in the game.");
foreach (KeyValuePair<string, VolumeConfig> item in KeepItDownPlugin.Instance.Config.Volumes.OrderBy((KeyValuePair<string, VolumeConfig> kvp) => kvp.Key))
{
item.Deconstruct(out var _, out var value);
VolumeConfig volumeConfig = value;
ConfigEntry<float> configEntry = volumeConfig.ConfigEntry;
FloatStepSliderOptions val = new FloatStepSliderOptions
{
Name = SharedUI.GetDisplayName(volumeConfig),
RequiresRestart = false
};
((BaseRangeOptions<float>)val).Min = 0f;
((BaseRangeOptions<float>)val).Max = 100f;
LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(configEntry, (FloatSliderOptions)val));
}
}
}
internal static class LethalSettingsUI
{
internal static void Init()
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Expected O, but got Unknown
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Expected O, but got Unknown
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Expected O, but got Unknown
SliderComponent[] _sliders = null;
Dictionary<SliderComponent, string> _sliderToConfigKey = new Dictionary<SliderComponent, string>();
KeepItDownConfig config2 = KeepItDownPlugin.Instance.Config;
_sliders = ((IEnumerable<KeyValuePair<string, VolumeConfig>>)config2.Volumes).Select((Func<KeyValuePair<string, VolumeConfig>, SliderComponent>)delegate(KeyValuePair<string, VolumeConfig> kvp)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
kvp.Value.OnChanged += OnConfigChangedHandler;
return new SliderComponent
{
MinValue = 0f,
MaxValue = 100f,
OnValueChanged = OnSliderValueChanged
};
}).ToArray();
RefreshOrder();
ButtonComponent item = new ButtonComponent
{
Text = "Reset",
OnClick = OnResetClicked
};
InputComponent item2 = new InputComponent
{
Placeholder = "Search...",
OnValueChanged = delegate(InputComponent _, string text)
{
RefreshOrder(text);
}
};
List<MenuComponent> list = new List<MenuComponent>
{
(MenuComponent)(object)item,
(MenuComponent)(object)item2
};
list.AddRange((IEnumerable<MenuComponent>)(object)_sliders);
ModMenu.RegisterMod(new ModSettingsConfig
{
Name = "Keep It Down!",
Id = "KeepItDown",
Version = "1.4.0",
Description = "Volume control for various sounds in the game.",
MenuComponents = list.ToArray()
}, true, true);
void OnConfigChangedHandler(VolumeConfig config, float rawValue, float normalizedValue)
{
SliderComponent val2 = ((IEnumerable<SliderComponent>)_sliders).FirstOrDefault((Func<SliderComponent, bool>)((SliderComponent s) => _sliderToConfigKey[s] == config.Key));
if (val2 != null && !Mathf.Approximately(val2.Value, rawValue))
{
val2.Value = rawValue;
}
}
static void OnResetClicked(ButtonComponent instance)
{
SharedUI.ResetAllVolumes();
}
void OnSliderValueChanged(SliderComponent slider, float value)
{
if (_sliderToConfigKey.TryGetValue(slider, out var value2) && KeepItDownPlugin.Instance.TryGetConfig(value2, out var config4))
{
config4.RawValue = value;
}
}
void RefreshOrder(string searchTerm = null)
{
KeepItDownConfig config3 = KeepItDownPlugin.Instance.Config;
IEnumerable<string> enumerable;
if (searchTerm == null)
{
enumerable = config3.Volumes.Keys.OrderBy((string k) => k);
}
else
{
string lowerSearchTerm = searchTerm.ToLower();
enumerable = config3.Volumes.Keys.OrderBy((string k) => (!k.ToLower().Contains(lowerSearchTerm)) ? 1 : 0);
}
_sliderToConfigKey.Clear();
int num = 0;
foreach (string item3 in enumerable)
{
SliderComponent val = _sliders[num++];
VolumeConfig volumeConfig = config3.Volumes[item3];
val.Text = SharedUI.GetDisplayName(volumeConfig);
val.Value = volumeConfig.RawValue;
_sliderToConfigKey[val] = item3;
}
}
}
}
public static class SharedUI
{
public const string Name = "Keep It Down!";
public const string Guid = "KeepItDown";
public const string Version = "1.4.0";
public const string Description = "Volume control for various sounds in the game.";
private static readonly Regex _nicifyRegex = new Regex("(?<=[a-z])([A-Z])", RegexOptions.Compiled);
public static string GetDisplayName(VolumeConfig volumeConfig)
{
string text = _nicifyRegex.Replace(volumeConfig.Key, " $1");
if (volumeConfig.Section != "Vanilla")
{
text = text + " (" + volumeConfig.Section + ")";
}
return text;
}
public static void ResetAllVolumes()
{
foreach (VolumeConfig value in KeepItDownPlugin.Instance.Config.Volumes.Values)
{
value.NormalizedValue = 1f;
}
}
}
}