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 HarveysStuff v1.0.3
HarveysRepoMod.dll
Decompiled a month agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("HarveysRepoMod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("HarveysRepoMod")] [assembly: AssemblyTitle("HarveysRepoMod")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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; } } } namespace HarveysRepoMod { [BepInPlugin("com.HarvDallz.repo.HarveysRepoMod", "Harvey's Repo mod", "1.0.3")] public class Plugin : BaseUnityPlugin { public static Dictionary<string, AudioClip> soundMap = new Dictionary<string, AudioClip>(); internal static ManualLogSource Logger { get; private set; } public static AudioClip getRandomClip(AudioClip[] list) { return list[Random.Range(0, list.Length)]; } private void Awake() { //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); directoryName = Path.Combine(directoryName, "Audio Files"); if (Directory.Exists(directoryName)) { foreach (string item in Directory.EnumerateFiles(directoryName, "*.wav")) { string text = Path.Combine(directoryName, item); if (!File.Exists(text)) { Logger.LogError((object)("Could not find audio file at: " + text)); continue; } try { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(item); AudioClip value = CreateClipFromWav(text, fileNameWithoutExtension); Logger.LogInfo((object)("Successfully built " + fileNameWithoutExtension)); soundMap[fileNameWithoutExtension] = value; } catch (Exception ex) { Logger.LogError((object)("Failed to parse " + item + ": " + ex.Message)); } } } else { Console.WriteLine("The specified folder does not exist."); } Harmony val = new Harmony("com.HarvDallz.repo.HarveysRepoMod"); val.PatchAll(); Logger.LogInfo((object)"Harvey's Repo mod has loaded! Oh Yeah baby!"); } private AudioClip CreateClipFromWav(string filePath, string name) { byte[] array = File.ReadAllBytes(filePath); int num = array[22]; int num2 = BitConverter.ToInt32(array, 24); int num3 = 44; float[] array2 = new float[(array.Length - num3) / 2]; for (int i = 0; i < array2.Length; i++) { array2[i] = (float)BitConverter.ToInt16(array, num3 + i * 2) / 32768f; } AudioClip val = AudioClip.Create(name, array2.Length / num, num, num2, false); val.SetData(array2, 0); return val; } } [HarmonyPatch(typeof(PhoneValuable))] public class PhoneRingPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void SwapPhoneAudioArray(PhoneValuable __instance) { AudioClip[] array = (AudioClip[])(object)new AudioClip[5] { Plugin.soundMap["mus1"], Plugin.soundMap["mus5"], Plugin.soundMap["mus6"], Plugin.soundMap["mus7"], Plugin.soundMap["mus10"] }; if (__instance.ringTone != null && array != null) { __instance.ringTone.Sounds = array; __instance.ringTone.Source.clip = Plugin.getRandomClip(array); Plugin.Logger.LogInfo((object)"Phone tracks swapped!"); } } } [HarmonyPatch(typeof(TrapGramophone))] public class GramophonePatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void SwapGramophoneAudio(TrapGramophone __instance) { AudioClip[] array = (AudioClip[])(object)new AudioClip[3] { Plugin.soundMap["mus2"], Plugin.soundMap["mus4"], Plugin.soundMap["mus8"] }; if (__instance.GramophoneMusic != null && (Object)(object)__instance.GramophoneMusic.Source != (Object)null && array != null) { __instance.GramophoneMusic.Sounds = array; __instance.GramophoneMusic.Source.clip = Plugin.getRandomClip(array); Plugin.Logger.LogInfo((object)"Gramophone music successfully swapped!"); } } } [HarmonyPatch(typeof(ShopRadio))] public class ShopRadioPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void SwapShopRadioAudio(ShopRadio __instance) { List<AudioClip> shopMusicClips = new List<AudioClip> { Plugin.soundMap["mus1"], Plugin.soundMap["mus2"], Plugin.soundMap["mus3"], Plugin.soundMap["mus4"], Plugin.soundMap["mus5"], Plugin.soundMap["mus6"], Plugin.soundMap["mus7"], Plugin.soundMap["mus8"] }; if (__instance.shopMusic != null && (Object)(object)__instance.shopMusic.Source != (Object)null) { __instance.shopMusicClips = shopMusicClips; } Plugin.Logger.LogInfo((object)"Shop music successfully swapped!"); } } [HarmonyPatch(typeof(ValuableBoombox))] public class BoomboxPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void SwapBoomboxAudio(ValuableBoombox __instance) { AudioClip[] array = (AudioClip[])(object)new AudioClip[1] { Plugin.soundMap["mus9"] }; if (__instance.soundBoomboxMusic != null && (Object)(object)__instance.soundBoomboxMusic.Source != (Object)null && array != null) { __instance.soundBoomboxMusic.Sounds = array; __instance.soundBoomboxMusic.Source.clip = Plugin.getRandomClip(array); Plugin.Logger.LogInfo((object)"Boombox music successfully swapped!"); } } } [HarmonyPatch(typeof(TrapRadio))] public class HeadmanRadioPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void SwapHMRadioAudio(TrapRadio __instance) { AudioClip[] array = (AudioClip[])(object)new AudioClip[3] { Plugin.soundMap["mus2"], Plugin.soundMap["mus7"], Plugin.soundMap["mus8"] }; if (__instance.RadioLoop != null && (Object)(object)__instance.RadioLoop.Source != (Object)null && array != null) { __instance.RadioLoop.Sounds = array; __instance.RadioLoop.Source.clip = Plugin.getRandomClip(array); Plugin.Logger.LogInfo((object)"Radio music successfully swapped!"); } } } [HarmonyPatch(typeof(EnemyParent), "Awake")] public class MasterInstanceAudioPatch { [HarmonyPostfix] private static void OverwriteLiveEnemyInstanceSounds(EnemyParent __instance) { if ((Object)(object)__instance == (Object)null || (Object)(object)((Component)__instance).gameObject == (Object)null) { return; } EnemyTumblerAnim componentInChildren = ((Component)__instance).GetComponentInChildren<EnemyTumblerAnim>(); EnemyGnomeAnim componentInChildren2 = ((Component)__instance).GetComponentInChildren<EnemyGnomeAnim>(); EnemyGnome val = ((Component)__instance).GetComponentInParent<EnemyGnome>() ?? ((Component)__instance).GetComponent<EnemyGnome>(); EnemyBeamerAnim componentInChildren3 = ((Component)__instance).GetComponentInChildren<EnemyBeamerAnim>(); if ((Object)(object)componentInChildren != (Object)null) { if (componentInChildren.sfxJump != null && Plugin.soundMap.ContainsKey("FrogJump1")) { componentInChildren.sfxJump.Sounds = (AudioClip[])(object)new AudioClip[3] { Plugin.soundMap["FrogJump1"], Plugin.soundMap["FrogJump2"], Plugin.soundMap["FrogJump3"] }; } if (componentInChildren.sfxDeath != null && Plugin.soundMap.ContainsKey("FrogDeath")) { componentInChildren.sfxDeath.Sounds = (AudioClip[])(object)new AudioClip[1] { Plugin.soundMap["FrogDeath"] }; } if (componentInChildren.sfxNotice != null && Plugin.soundMap.ContainsKey("FrogSpawn")) { componentInChildren.sfxNotice.Sounds = (AudioClip[])(object)new AudioClip[1] { Plugin.soundMap["FrogSpawn"] }; } Plugin.Logger.LogInfo((object)"[HarveysRepoMod] Live Frog instance audio redirected successfully."); } if ((Object)(object)componentInChildren2 != (Object)null) { if (componentInChildren2.soundJump != null && Plugin.soundMap.ContainsKey("gnomejump")) { componentInChildren2.soundJump.Sounds = (AudioClip[])(object)new AudioClip[1] { Plugin.soundMap["gnomejump"] }; } if (componentInChildren2.soundNotice != null && Plugin.soundMap.ContainsKey("GnomeSpotted1")) { componentInChildren2.soundNotice.Sounds = (AudioClip[])(object)new AudioClip[1] { Plugin.soundMap["GnomeSpotted1"] }; } if (componentInChildren2.soundPickaxeTell != null && Plugin.soundMap.ContainsKey("gnomepickaxetell")) { componentInChildren2.soundPickaxeTell.Sounds = (AudioClip[])(object)new AudioClip[1] { Plugin.soundMap["gnomepickaxetell"] }; } Plugin.Logger.LogInfo((object)"[HarveysRepoMod] Live Gnome Anim instance audio redirected successfully."); } if ((Object)(object)val != (Object)null) { if (val.soundDeath != null && Plugin.soundMap.ContainsKey("gnomedeath")) { val.soundDeath.Sounds = (AudioClip[])(object)new AudioClip[1] { Plugin.soundMap["gnomedeath"] }; } if (val.soundHurt != null && Plugin.soundMap.ContainsKey("gnomehurt")) { val.soundHurt.Sounds = (AudioClip[])(object)new AudioClip[1] { Plugin.soundMap["gnomehurt"] }; } Plugin.Logger.LogInfo((object)"[HarveysRepoMod] Live Gnome Logic Root instance audio redirected successfully."); } if ((Object)(object)componentInChildren3 != (Object)null) { if (componentInChildren3.soundAttackIntro != null && Plugin.soundMap.ContainsKey("clowncharge")) { componentInChildren3.soundAttackIntro.Sounds = (AudioClip[])(object)new AudioClip[1] { Plugin.soundMap["clowncharge"] }; } Plugin.Logger.LogInfo((object)"[HarveysRepoMod] Live Clown instance audio redirected successfully."); } } } }