using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BaseVoiceoverLib; using BepInEx; using BepInEx.Configuration; using KirbyVoiceMod.Components; using KirbyVoiceMod.Modules; using Microsoft.CodeAnalysis; using R2API; using RoR2; using RoR2.ContentManagement; 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("KirbyVoiceMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("KirbyVoiceMod")] [assembly: AssemblyTitle("KirbyVoiceMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace KirbyVoiceMod { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.Dannyduartemgs.KirbyVoiceMod", "KirbyVoiceMod", "1.0.0")] public class KirbyVoiceMod : BaseUnityPlugin { public class NSEInfo { public NetworkSoundEventDef nse; public uint akId; public string eventName = string.Empty; public NSEInfo(NetworkSoundEventDef source) { nse = source; akId = source.akId; eventName = source.eventName; } private void DisableSound() { nse.akId = 0u; nse.eventName = string.Empty; } private void EnableSound() { nse.akId = akId; nse.eventName = eventName; } public void ValidateParams() { if (akId == 0) { akId = nse.akId; } if (eventName == string.Empty) { eventName = nse.eventName; } if (!enableVoicelines.Value) { DisableSound(); } else { EnableSound(); } } } public static ConfigEntry enableVoicelines; public static bool playedSeasonalVoiceline = false; public static AssetBundle assetBundle; public static List nseList = new List(); public void Awake() { //IL_004b: 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_0066: Expected O, but got Unknown //IL_0066: Expected O, but got Unknown Files.PluginInfo = ((BaseUnityPlugin)this).Info; RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnLoad)); new Content().Initialize(); InitNSE(); enableVoicelines = ((BaseUnityPlugin)this).Config.Bind(new ConfigDefinition("Settings", "Enable Voicelines"), true, new ConfigDescription("Enable Kirby voicelines when using the skin.", (AcceptableValueBase)null, Array.Empty())); enableVoicelines.SettingChanged += EnableVoicelines_SettingChanged; } private void EnableVoicelines_SettingChanged(object sender, EventArgs e) { RefreshNSE(); } private void OnLoad() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_0092: Expected O, but got Unknown BodyIndex val = BodyCatalog.FindBodyIndex("DrifterBody"); SkinDef val2 = null; if ((int)val != -1) { SkinDef[] array = SkinCatalog.FindSkinsForBody(val); foreach (SkinDef val3 in array) { if (((Object)val3).name == "KirbySkin") { val2 = val3; break; } } } if (!Object.op_Implicit((Object)(object)val2)) { ((BaseUnityPlugin)this).Logger.LogError((object)"[KirbyVoiceMod] ❌ SkinDef not found. Voicelines will not work!"); return; } VoiceoverInfo val4 = new VoiceoverInfo(typeof(KirbyVoiceoverComponent), val2, "DrifterBody"); val4.selectActions = (LobbySelectActions)Delegate.Combine((Delegate?)(object)val4.selectActions, (Delegate?)new LobbySelectActions(OnSkinSelect)); RefreshNSE(); } private void OnSkinSelect(GameObject mannequinObject) { if (!enableVoicelines.Value) { return; } bool flag = false; if (!playedSeasonalVoiceline) { if (DateTime.Today.Month == 1 && DateTime.Today.Day == 1) { Util.PlaySound("Play_Kirby_NewYear", mannequinObject); flag = true; } else if (DateTime.Today.Month == 12 && (DateTime.Today.Day == 24 || DateTime.Today.Day == 25)) { Util.PlaySound("Play_Kirby_Xmas", mannequinObject); flag = true; } if (flag) { playedSeasonalVoiceline = true; } } if (!flag) { if (Util.CheckRoll(10f, 0f, (CharacterMaster)null)) { Util.PlaySound("Play_Kirby_select2", mannequinObject); } else { Util.PlaySound("Play_Kirby_select", mannequinObject); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"[KirbyVoiceMod] Played skin select voiceline."); } } private void InitNSE() { KirbyVoiceoverComponent.nseSpecial = RegisterNSE("Play_Kirby_special"); KirbyVoiceoverComponent.nseBlock = RegisterNSE("Play_Kirby_Blocked"); KirbyVoiceoverComponent.nseShrineFail = RegisterNSE("Play_Kirby_fail"); KirbyVoiceoverComponent.nseShout = RegisterNSE("Play_Kirby_secondary"); KirbyVoiceoverComponent.nseTitle = RegisterNSE("Play_Kirby_TitleDrop"); KirbyVoiceoverComponent.nseIntro = RegisterNSE("Play_Kirby_Intro"); KirbyVoiceoverComponent.nseHurt = RegisterNSE("Play_Kirby_hurt"); KirbyVoiceoverComponent.nseKanpeki = RegisterNSE("Play_Kirby_Kanpeki"); KirbyVoiceoverComponent.nseSmart = RegisterNSE("Play_Kirby_Smart"); KirbyVoiceoverComponent.nseLogic = RegisterNSE("Play_Kirby_Logic"); KirbyVoiceoverComponent.nseFactor = RegisterNSE("Play_Kirby_secondary"); KirbyVoiceoverComponent.nseThanks = RegisterNSE("Play_Kirby_Thanks"); KirbyVoiceoverComponent.nseIku = RegisterNSE("Play_Kirby_jump"); KirbyVoiceoverComponent.nseMathTruth = RegisterNSE("Play_Kirby_MathTruth"); } private NetworkSoundEventDef RegisterNSE(string eventName) { NetworkSoundEventDef val = ScriptableObject.CreateInstance(); val.eventName = eventName; Content.networkSoundEventDefs.Add(val); nseList.Add(new NSEInfo(val)); return val; } public void RefreshNSE() { foreach (NSEInfo nse in nseList) { nse.ValidateParams(); } } } } namespace KirbyVoiceMod.Modules { public class Content : IContentPackProvider { [CompilerGenerated] private sealed class d__8 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public FinalizeAsyncArgs args; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>1__state = -1; args.ReportProgress(1f); 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 d__7 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Content <>4__this; public GetContentPackAsyncArgs args; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; Content content = <>4__this; if (num != 0) { return false; } <>1__state = -1; ContentPack.Copy(content.contentPack, args.output); args.ReportProgress(1f); 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 d__6 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Content <>4__this; public LoadStaticContentAsyncArgs args; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; Content content = <>4__this; if (num != 0) { return false; } <>1__state = -1; content.contentPack.identifier = content.identifier; content.contentPack.networkSoundEventDefs.Add(networkSoundEventDefs.ToArray()); args.ReportProgress(1f); 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 ContentPack contentPack = new ContentPack(); public static List networkSoundEventDefs = new List(); public string identifier => "com.Dannyduartemgs.KirbyVoiceMod"; public void Initialize() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(AddContentPackProvider); } private void AddContentPackProvider(AddContentPackProviderDelegate addContentPackProvider) { addContentPackProvider.Invoke((IContentPackProvider)(object)this); } [IteratorStateMachine(typeof(d__6))] public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__6(0) { <>4__this = this, args = args }; } [IteratorStateMachine(typeof(d__7))] public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__7(0) { <>4__this = this, args = args }; } [IteratorStateMachine(typeof(d__8))] public IEnumerator FinalizeAsync(FinalizeAsyncArgs args) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__8(0) { args = args }; } internal static NetworkSoundEventDef CreateNetworkSoundEventDef(string eventName) { NetworkSoundEventDef val = ScriptableObject.CreateInstance(); val.akId = AkSoundEngine.GetIDFromString(eventName); val.eventName = eventName; networkSoundEventDefs.Add(val); return val; } } public static class Files { public static PluginInfo PluginInfo; public static string assemblyDir => Path.GetDirectoryName(PluginInfo.Location); } public static class SoundBanks { private static bool initialized; public static string SoundBankDirectory => Files.assemblyDir; public static void Init() { if (!initialized) { initialized = true; string text = Path.Combine(SoundBankDirectory, "KirbySoundbank.sound"); if (!File.Exists(text)) { Debug.LogError((object)("[KirbyVoiceMod] ❌ Soundbank not found: " + text)); return; } SoundBanks.Add(File.ReadAllBytes(text)); Debug.Log((object)("[KirbyVoiceMod] ✅ Loaded soundbank: " + text)); } } } } namespace KirbyVoiceMod.Components { public class KirbyVoiceoverComponent : BaseVoiceoverComponent { public static NetworkSoundEventDef nseShout; public static NetworkSoundEventDef nseSpecial; public static NetworkSoundEventDef nseBlock; public static NetworkSoundEventDef nseShrineFail; public static NetworkSoundEventDef nseTitle; public static NetworkSoundEventDef nseIntro; public static NetworkSoundEventDef nseHurt; public static NetworkSoundEventDef nseKanpeki; public static NetworkSoundEventDef nseSmart; public static NetworkSoundEventDef nseLogic; public static NetworkSoundEventDef nseFactor; public static NetworkSoundEventDef nseThanks; public static NetworkSoundEventDef nseIku; public static NetworkSoundEventDef nseMathTruth; private float lowHealthCooldown; private float blockedCooldown; private float specialCooldown; private float utilityCooldown; private float levelCooldown; private float shrineOfChanceFailCooldown; private float secondaryCooldown; protected override void Start() { ((BaseVoiceoverComponent)this).Start(); } protected override void FixedUpdate() { ((BaseVoiceoverComponent)this).FixedUpdate(); if (lowHealthCooldown > 0f) { lowHealthCooldown -= Time.fixedDeltaTime; } if (blockedCooldown > 0f) { blockedCooldown -= Time.fixedDeltaTime; } if (specialCooldown > 0f) { specialCooldown -= Time.fixedDeltaTime; } if (utilityCooldown > 0f) { utilityCooldown -= Time.fixedDeltaTime; } if (levelCooldown > 0f) { levelCooldown -= Time.fixedDeltaTime; } if (shrineOfChanceFailCooldown > 0f) { levelCooldown -= Time.fixedDeltaTime; } if (secondaryCooldown > 0f) { secondaryCooldown -= Time.fixedDeltaTime; } } public override void PlaySpawn() { ((BaseVoiceoverComponent)this).TryPlaySound("Play_Kirby_spawn", 1f, false); } public override void PlayJump() { ((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseIku, 0f, false); } public override void PlayDeath() { ((BaseVoiceoverComponent)this).TryPlaySound("Play_Kirby_death", 1.5f, true); } public override void PlayHurt(float percentHPLost) { if (percentHPLost >= 0.1f) { ((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseHurt, 0f, false); } } public override void PlaySecondaryAuthority(GenericSkill skill) { if (!(secondaryCooldown > 0f) && ((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseShout, 0f, false)) { secondaryCooldown = 6.5f; } } public override void PlayTeleporterStart() { ((BaseVoiceoverComponent)this).TryPlaySound("Play_Kirby_tpstart", 3f, false); } public override void PlayTeleporterFinish() { ((BaseVoiceoverComponent)this).TryPlaySound("Play_Kirby_tpend", 3.8f, false); } public override void PlayVictory() { ((BaseVoiceoverComponent)this).TryPlaySound("Play_Kirby_tpend", 3.8f, true); } public override void PlayLevelUp() { if (!(levelCooldown > 0f) && ((BaseVoiceoverComponent)this).TryPlaySound("Play_Kirby_levelup", 3f, false)) { levelCooldown = 60f; } } public override void PlayLowHealth() { if (!(lowHealthCooldown > 0f) && ((BaseVoiceoverComponent)this).TryPlaySound("Play_Kirby_lowhealth", 1f, false)) { lowHealthCooldown = 45f; } } public override void PlayUtilityAuthority(GenericSkill skill) { if (!(utilityCooldown > 0f) && ((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseFactor, 0f, false)) { utilityCooldown = 10f; } } public override void PlaySpecialAuthority(GenericSkill skill) { if (!(specialCooldown > 0f) && ((BaseVoiceoverComponent)this).TryPlayNetworkSound(nseSpecial, 0f, false)) { specialCooldown = 15f; } } public void PlayAcquireLegendary() { ((BaseVoiceoverComponent)this).TryPlaySound("Play_Kirby_yay", 5.75f, false); } public override void PlayShrineOfChanceFailServer() { if (NetworkServer.active && !(shrineOfChanceFailCooldown > 0f) && ((BaseVoiceoverComponent)this).TryPlaySound("Play_Kirby_fail", 1f, false)) { shrineOfChanceFailCooldown = 60f; } } public override bool ComponentEnableVoicelines() { return KirbyVoiceMod.enableVoicelines.Value; } } }