Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Voicelines v1.2.0
Voicelines.dll
Decompiled 6 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; 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.Configuration; using GlobalEnums; using HarmonyLib; using HutongGames.PlayMaker.Actions; using Microsoft.CodeAnalysis; using Silksong.FsmUtil; using UnityEngine; using UnityEngine.Networking; [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("Voicelines")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.2.0.0")] [assembly: AssemblyInformationalVersion("1.2.0+e76383dfe444495319a2691a8820620fd151f8f8")] [assembly: AssemblyProduct("Voicelines")] [assembly: AssemblyTitle("Voicelines")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.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; } } } internal sealed class ConfigurationManagerAttributes { public delegate void CustomHotkeyDrawerFunc(ConfigEntryBase setting, ref bool isCurrentlyAcceptingInput); public bool? ShowRangeAsPercent; public Action<ConfigEntryBase> CustomDrawer; public CustomHotkeyDrawerFunc CustomHotkeyDrawer; public bool? Browsable; public string Category; public object DefaultValue; public bool? HideDefaultButton; public bool? HideSettingName; public string Description; public string DispName; public int? Order; public bool? ReadOnly; public bool? IsAdvanced; public Func<object, string> ObjToStr; public Func<string, object> StrToObj; } namespace Voicelines { public class AcceptableCSV<T> : AcceptableValueList<T> where T : IEquatable<T> { public AcceptableCSV(params T[] acceptableValues) : base(acceptableValues) { } public override bool IsValid(object value) { if (value == null) { return false; } string text = value.ToString(); if (string.IsNullOrWhiteSpace(text)) { return false; } if ((from s in text.Split(',') select s.Trim() into s where !string.IsNullOrEmpty(s) select s).ToArray().Length == 0) { return false; } return true; } public override object Clamp(object value) { if (((AcceptableValueBase)this).IsValid(value)) { return value; } return "None"; } } public static class MultiselectDrawer { private static readonly Dictionary<string, Dictionary<string, bool>> multiSelectionStates = new Dictionary<string, Dictionary<string, bool>>(); private static readonly Dictionary<string, Vector2> scrollPositions = new Dictionary<string, Vector2>(); private static string? currentlyExpanded = null; public static void Draw(ConfigEntryBase entry, string[] soundOptions) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) string key = entry.Definition.Key; if (!multiSelectionStates.ContainsKey(key)) { multiSelectionStates[key] = new Dictionary<string, bool>(); scrollPositions[key] = Vector2.zero; string[] array = soundOptions; foreach (string key2 in array) { multiSelectionStates[key][key2] = false; } } string[] array2 = (from s in entry.BoxedValue.ToString().Split(',') select s.Trim() into s where !string.IsNullOrEmpty(s) select s).ToArray(); GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); string text = string.Join(", ", array2); GUIStyle val = ((currentlyExpanded == key) ? GUI.skin.textArea : GUI.skin.button); if (GUILayout.Button(text, val, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.MaxWidth(300f), GUILayout.ExpandWidth(true) })) { if (currentlyExpanded == key) { currentlyExpanded = null; } else { currentlyExpanded = key; string[] array = soundOptions; foreach (string text2 in array) { multiSelectionStates[key][text2] = array2.Contains(text2); } } } if (currentlyExpanded == key) { _ = soundOptions.Length; float num = 20f; float num2 = (float)soundOptions.Length * num; float num3 = 150f; scrollPositions[key] = GUILayout.BeginScrollView(scrollPositions[key], false, num2 > num3, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, GUI.skin.box, (GUILayoutOption[])(object)new GUILayoutOption[3] { GUILayout.Height(num3), GUILayout.MaxWidth(300f), GUILayout.ExpandWidth(true) }); string[] array = soundOptions; foreach (string text3 in array) { bool flag = multiSelectionStates[key][text3]; bool flag2 = GUILayout.Toggle(flag, text3, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (flag2 == flag) { continue; } multiSelectionStates[key][text3] = flag2; if (flag2 && text3 == "None") { foreach (string item in soundOptions.Where((string s) => s != "None")) { multiSelectionStates[key][item] = false; } } else if (flag2 && text3 != "None") { multiSelectionStates[key]["None"] = false; } string[] array3 = (from kvp in multiSelectionStates[key] where kvp.Value select kvp.Key).ToArray(); string boxedValue = ((array3.Length == 0) ? "None" : string.Join(", ", array3)); entry.BoxedValue = boxedValue; } GUILayout.EndScrollView(); if (GUILayout.Button("Clear All", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.MaxWidth(300f), GUILayout.ExpandWidth(true) })) { array = soundOptions; foreach (string key3 in array) { multiSelectionStates[key][key3] = false; } multiSelectionStates[key]["None"] = true; entry.BoxedValue = "None"; } } GUILayout.EndVertical(); } } [BepInPlugin("bergbok.voicelines", "Voicelines", "1.2.0")] [BepInProcess("Hollow Knight Silksong")] public class Voicelines : BaseUnityPlugin { private class BlockEntry { public string ID; public string Pattern; public float ExpiryTime; } [HarmonyPatch(typeof(HeroController), "Attack")] private static class HeroController_Attack_Patch { [HarmonyPrefix] private static void Prefix(HeroController __instance, ref AttackDirection attackDir) { PlayAudio("Attack", AttackSound.Value, "^a"); } } [HarmonyPatch(typeof(HeroController), "Die")] private static class HeroController_Die_Patch { [HarmonyPrefix] private static void Prefix(HeroController __instance, ref bool nonLethal, ref bool frostDeath) { PlayAudio("Death", DeathSound.Value, "^hero_damage"); } } [HarmonyPatch(typeof(HeroController), "DoDoubleJump")] private static class HeroController_DoDoubleJump_Patch { [HarmonyPrefix] private static void Prefix(HeroController __instance) { PlayAudio("Faydown Cloak", FaydownCloakSound.Value, "^g"); } } [HarmonyPatch(typeof(HeroController), "HeroDamaged")] private static class HeroController_HeroDamaged_Patch { [HarmonyPrefix] private static void Prefix(HeroController __instance) { PlayAudio("Hurt", HurtSound.Value, "^hero_damage"); } } [HarmonyPatch(typeof(HeroController), "HeroDash")] private static class HeroController_HeroDash_Patch { [HarmonyPrefix] private static void Prefix(HeroController __instance, ref bool startAlreadyDashing) { PlayAudio("Swift Step", SwiftStepSound.Value, "^g"); } } [HarmonyPatch(typeof(HeroController), "OnHeroJumped")] private static class HeroController_OnHeroJumped_Patch { [HarmonyPrefix] private static void Prefix(HeroController __instance) { PlayAudio("Jump", JumpSound.Value, "^g"); } } [HarmonyPatch(typeof(HeroController), "Start")] private static class HeroController_Start_Patch { [HarmonyPostfix] private static void Postfix(HeroController __instance) { Instance.playerAudioSource = ((Component)__instance).GetComponent<AudioSource>(); if ((Object)(object)Instance.playerAudioSource == (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogError((object)"Could not find player AudioSource, audio will not play."); } } } [HarmonyPatch(typeof(HeroController), "UseLavaBell")] private static class HeroController_UseLavaBell_Patch { [HarmonyPrefix] private static void Prefix(HeroController __instance) { PlayAudio("Lava Bell Hit", LavaBellHitSound.Value); } } [HarmonyPatch(typeof(PlayMakerFSM), "SendEvent")] private static class PlayMakerFSM_SendEvent_Patch { [HarmonyPrefix] private static void Prefix(PlayMakerFSM __instance, ref string eventName) { switch (__instance.FsmName) { case "Control": if (eventName == "HIT") { PlayAudio("Warding Bell Hit", WardingBellHitSound.Value, "hornet_warding_bell_bind_break"); } break; case "Harpoon Dash": if (eventName == "DO MOVE") { PlayAudio("Clawline", ClawlineSound.Value, "^a|^g"); } break; case "Silk Specials": switch (eventName) { case "NEEDLE THROW": PlayAudio("Silkspear", SilkspearSound.Value, "^Hornet_attack_large"); break; case "PARRY": PlayAudio("Cross Stitch", CrossStitchSound.Value, "^a"); break; case "SILK CHARGE": PlayAudio("Sharpdart", SharpdartSound.Value, "^Hornet_attack_large"); break; case "SILK BOMB": PlayAudio("Rune Rage", RuneRageSound.Value, "^Hornet_attack_large"); break; case "BOSS NEEDLE": PlayAudio("Pale Nails", PaleNailsSound.Value); break; case "THREAD SPHERE": PlayAudio("Thread Storm", ThreadStormSound.Value, "^Hornet_attack_large"); break; } break; case "Superjump": if (eventName == "DO MOVE") { PlayAudio("Silk Soar", SilkSoarSound.Value, "hornet_superjump_pt_1_into_position"); } break; case "Umbrella Float": if (eventName == "FLOAT" && __instance.ActiveStateName != "Cooldown") { PlayAudio("Drifter's Cloak", DrifersCloakSound.Value, "hornet_umbrella_open"); } break; } } } [HarmonyPatch(typeof(PlayMakerFSM), "Start")] private static class PlayMakerFSM_Start_Patch { [HarmonyPostfix] public static void Postfix(PlayMakerFSM __instance) { if (__instance != null && ((Object)__instance).name == "Hero_Hornet(Clone)" && __instance.FsmName == "Silk Specials") { RunFSM action = FsmUtil.GetAction<RunFSM>(__instance.Fsm, "Needolin Sub", 2); FsmUtil.AddLambdaMethod(((action != null) ? action.fsmTemplateControl.RunFsm : null).GetState("Start Needolin"), (Action<Action>)delegate { PlayAudio("Needolin", NeedolinSound.Value, "^g"); }); } } } [HarmonyPatch(typeof(RandomAudioClipTable), "CanPlay")] private static class RandomAudioClipTable_CanPlay_Patch { [HarmonyPrefix] private static void Prefix(RandomAudioClipTable __instance) { switch (((Object)__instance).name) { case "Attack Heavy Hornet Voice": PlayAudio("Dash Attack", DashAttackSound.Value, "^a"); break; case "Attack Needle Art Hornet Voice": PlayAudio("Nail Art", NailArtSound.Value, "^a"); break; case "Bind Hornet Voice": PlayAudio("Bind", BindSound.Value, "^bind|^hornet_bind"); break; case "Hornet_poshanka": PlayAudio("Ring Taunt", RingTauntSound.Value, "^Hornet_poshanka"); break; case "Taunt Hornet Voice": PlayAudio("Taunt", TauntSound.Value, "^t"); break; } } } [HarmonyPatch(typeof(AudioSource), "PlayOneShot", new Type[] { typeof(AudioClip), typeof(float) })] private static class AudioSource_PlayOneShot_Patch { private static bool Prefix(AudioSource __instance, AudioClip clip) { AudioClip clip2 = clip; string name = ((Object)__instance).GetName(); if (!(name == "Audio Player Actor(Clone)") && !(name == "Audio Player Actor 2D(Clone)") && !name.EndsWith("Voice")) { return true; } if (!PluginEnabled.Value || !ReplaceGameSounds.Value || ClipsToBlock.Count == 0) { return true; } ClipsToBlock.RemoveAll((BlockEntry entry) => Time.time > entry.ExpiryTime); List<BlockEntry> list = ClipsToBlock.Where((BlockEntry entry) => Regex.IsMatch(((Object)clip2).name, entry.Pattern)).ToList(); if (list.Any()) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)("Suppressing clip: " + ((Object)clip2).name + " (matched patterns: " + string.Join(", ", list.Select((BlockEntry e) => e.Pattern)) + ")")); foreach (BlockEntry item in list) { ClipsToBlock.Remove(item); } return false; } return true; } } [CompilerGenerated] private sealed class <>c__DisplayClass38_0 { public string blockID; internal bool <CleanupBlockEntry>b__0(BlockEntry e) { return e.ID == blockID; } } [CompilerGenerated] private sealed class <CleanupBlockEntry>d__38 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string blockID; public float delay; private <>c__DisplayClass38_0 <>8__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <CleanupBlockEntry>d__38(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass38_0(); <>8__1.blockID = blockID; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: { <>1__state = -1; BlockEntry blockEntry = ClipsToBlock.FirstOrDefault((BlockEntry e) => e.ID == <>8__1.blockID); if (blockEntry != null) { ClipsToBlock.Remove(blockEntry); } return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <LoadAudioClip>d__36 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string filePath; public Voicelines <>4__this; public string clipName; private UnityWebRequest <www>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadAudioClip>d__36(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <www>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Invalid comparison between Unknown and I4 int num = <>1__state; Voicelines voicelines = <>4__this; switch (num) { default: return false; case 0: { <>1__state = -1; string text = "file:///" + filePath.Replace("\\", "/").Replace(" ", "%20"); ((BaseUnityPlugin)voicelines).Logger.LogInfo((object)("Loading audio: " + clipName + " from " + text)); <www>5__2 = UnityWebRequestMultimedia.GetAudioClip(text, (AudioType)0); <>2__current = <www>5__2.SendWebRequest(); <>1__state = 1; return true; } case 1: <>1__state = -1; if ((int)<www>5__2.result == 1) { AudioClip content = DownloadHandlerAudioClip.GetContent(<www>5__2); ((Object)content).name = clipName; voicelines.audioClips.Add(clipName, content); ((BaseUnityPlugin)voicelines).Logger.LogInfo((object)("Successfully loaded audio clip: " + clipName)); } else { ((BaseUnityPlugin)voicelines).Logger.LogError((object)("Failed to load audio clip " + clipName + ": " + <www>5__2.error)); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal static Voicelines Instance; internal static ConfigEntry<bool> PluginEnabled; internal static ConfigEntry<bool> ReplaceGameSounds; internal static ConfigEntry<bool> UseGameVolume; internal static ConfigEntry<float> AudioVolume; internal static ConfigEntry<float> TriggerChance; internal static ConfigEntry<string> AttackSound; internal static ConfigEntry<string> BindSound; internal static ConfigEntry<string> WardingBellHitSound; internal static ConfigEntry<string> CrossStitchSound; internal static ConfigEntry<string> DashAttackSound; internal static ConfigEntry<string> DeathSound; internal static ConfigEntry<string> FaydownCloakSound; internal static ConfigEntry<string> SwiftStepSound; internal static ConfigEntry<string> DrifersCloakSound; internal static ConfigEntry<string> HurtSound; internal static ConfigEntry<string> JumpSound; internal static ConfigEntry<string> ClawlineSound; internal static ConfigEntry<string> LavaBellHitSound; internal static ConfigEntry<string> NailArtSound; internal static ConfigEntry<string> NeedolinSound; internal static ConfigEntry<string> PaleNailsSound; internal static ConfigEntry<string> RingTauntSound; internal static ConfigEntry<string> RuneRageSound; internal static ConfigEntry<string> SharpdartSound; internal static ConfigEntry<string> SilkspearSound; internal static ConfigEntry<string> SilkSoarSound; internal static ConfigEntry<string> TauntSound; internal static ConfigEntry<string> ThreadStormSound; private AudioSource playerAudioSource; private readonly List<string> audioList = new List<string>(); private readonly Dictionary<string, AudioClip> audioClips = new Dictionary<string, AudioClip>(); private static readonly List<BlockEntry> ClipsToBlock = new List<BlockEntry>(); private void Awake() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Expected O, but got Unknown //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Expected O, but got Unknown //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Expected O, but got Unknown //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Expected O, but got Unknown //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Expected O, but got Unknown //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Expected O, but got Unknown //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Expected O, but got Unknown //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Expected O, but got Unknown //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Expected O, but got Unknown //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Expected O, but got Unknown //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04a5: Expected O, but got Unknown //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Expected O, but got Unknown //IL_052f: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Expected O, but got Unknown //IL_0579: Unknown result type (might be due to invalid IL or missing references) //IL_0583: Expected O, but got Unknown //IL_05c3: Unknown result type (might be due to invalid IL or missing references) //IL_05cd: Expected O, but got Unknown //IL_060d: Unknown result type (might be due to invalid IL or missing references) //IL_0617: Expected O, but got Unknown //IL_0657: Unknown result type (might be due to invalid IL or missing references) //IL_0661: Expected O, but got Unknown //IL_06a1: Unknown result type (might be due to invalid IL or missing references) //IL_06ab: Expected O, but got Unknown //IL_06eb: Unknown result type (might be due to invalid IL or missing references) //IL_06f5: Expected O, but got Unknown //IL_0735: Unknown result type (might be due to invalid IL or missing references) //IL_073f: Expected O, but got Unknown //IL_077f: Unknown result type (might be due to invalid IL or missing references) //IL_0789: Expected O, but got Unknown //IL_07c9: Unknown result type (might be due to invalid IL or missing references) //IL_07d3: Expected O, but got Unknown //IL_0813: Unknown result type (might be due to invalid IL or missing references) //IL_081d: Expected O, but got Unknown //IL_085d: Unknown result type (might be due to invalid IL or missing references) //IL_0867: Expected O, but got Unknown //IL_0871: Unknown result type (might be due to invalid IL or missing references) Instance = this; LoadAudioClips(); string[] soundList = new string[2] { "None", "Random" }.Concat(audioList).ToArray(); AcceptableCSV<string> acceptableCSV = new AcceptableCSV<string>(soundList); PluginEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, new ConfigDescription("", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 5 } })); ReplaceGameSounds = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Replace Game Sounds", true, new ConfigDescription("", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 4 } })); UseGameVolume = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Use Game Volume", true, new ConfigDescription("", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 3 } })); AudioVolume = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Custom Volume", 0.125f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[1] { new ConfigurationManagerAttributes { Order = 2, ShowRangeAsPercent = true } })); TriggerChance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Trigger Chance", 1f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[1] { new ConfigurationManagerAttributes { Order = 1, ShowRangeAsPercent = true } })); AttackSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Attack", "None", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); BindSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Bind", "None", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); ClawlineSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Clawline", "None", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); CrossStitchSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Cross Stitch", "None", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); DashAttackSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Dash Attack", "None", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); DeathSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Death", "None", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); DrifersCloakSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Drifters Cloak", "None", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); FaydownCloakSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Faydown Cloak", "None", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); HurtSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Hurt", "None", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); JumpSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Jump", "Jump", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); LavaBellHitSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Lava Bell Hit", "None", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); NailArtSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Nail Art", "None", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); NeedolinSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Needolin", "None", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); PaleNailsSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Pale Nails", "None", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); RingTauntSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Ring Taunt", "None", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); RuneRageSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Rune Rage", "None", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); SharpdartSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Sharpdart", "None", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); SilkSoarSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Silk Soar", "None", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); SilkspearSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Silkspear", "ADEENO", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); SwiftStepSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Swift Step", "None", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); TauntSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Taunt", "None", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); ThreadStormSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Thread Storm", "SHAW", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); WardingBellHitSound = ((BaseUnityPlugin)this).Config.Bind<string>("Sound Bindings", "Warding Bell Hit", "None", new ConfigDescription("", (AcceptableValueBase)(object)acceptableCSV, new object[1] { new ConfigurationManagerAttributes { CustomDrawer = delegate(ConfigEntryBase entry) { MultiselectDrawer.Draw(entry, soundList); } } })); new Harmony("bergbok.voicelines").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin loaded and initialized."); } private void LoadAudioClips() { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "SFX"); if (!Directory.Exists(text)) { ((BaseUnityPlugin)this).Logger.LogError((object)("SFX directory not found at: " + text)); return; } string[] files = Directory.GetFiles(text, "*"); foreach (string text2 in files) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text2); ((MonoBehaviour)this).StartCoroutine(LoadAudioClip(text2, fileNameWithoutExtension)); audioList.Add(fileNameWithoutExtension); } } [IteratorStateMachine(typeof(<LoadAudioClip>d__36))] private IEnumerator LoadAudioClip(string filePath, string clipName) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadAudioClip>d__36(0) { <>4__this = this, filePath = filePath, clipName = clipName }; } public static void PlayAudio(string action, string clipName, string blockPattern = "") { if (!PluginEnabled.Value || clipName == "None" || (Object)(object)Instance == (Object)null) { return; } if (Random.value > TriggerChance.Value) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)("Skipping sound for action: " + action + " due to trigger chance")); return; } string[] array = (from s in clipName.Split(',') select s.Trim() into s where !string.IsNullOrEmpty(s) select s).ToArray(); if (array.Length == 0) { return; } string text; if (!array.Contains("Random")) { text = ((array.Length != 1) ? array[Random.Range(0, array.Length)] : array[0]); } else { string[] array2 = Instance.audioList.Where((string sound) => sound != "None").ToArray(); if (array2.Length == 0) { ((BaseUnityPlugin)Instance).Logger.LogError((object)"No sounds available for random selection"); return; } text = array2[Random.Range(0, array2.Length)]; } ((BaseUnityPlugin)Instance).Logger.LogInfo((object)("Playing sound: " + text + " for action: " + action)); if (Instance.audioClips.TryGetValue(text, out AudioClip value)) { if (!string.IsNullOrEmpty(blockPattern) && ReplaceGameSounds.Value) { string text2 = Guid.NewGuid().ToString(); BlockEntry item = new BlockEntry { ID = text2, Pattern = blockPattern, ExpiryTime = Time.time + value.length + 0.2f }; ClipsToBlock.Add(item); ((MonoBehaviour)Instance).StartCoroutine(CleanupBlockEntry(text2, value.length + 0.2f)); } if ((Object)(object)Instance.playerAudioSource != (Object)null) { if (UseGameVolume.Value) { Instance.playerAudioSource.PlayOneShot(value); } else { Instance.playerAudioSource.PlayOneShot(value, AudioVolume.Value); } } } else { ((BaseUnityPlugin)Instance).Logger.LogError((object)("Could not play " + text + " - clip not available")); } } [IteratorStateMachine(typeof(<CleanupBlockEntry>d__38))] private static IEnumerator CleanupBlockEntry(string blockID, float delay) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <CleanupBlockEntry>d__38(0) { blockID = blockID, delay = delay }; } } public static class PluginInfo { public const string PLUGIN_GUID = "bergbok.voicelines"; public const string PLUGIN_NAME = "Voicelines"; public const string PLUGIN_VERSION = "1.2.0"; } }