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 TomatoSounds v2.1.5
Tomatobird.TomatoSounds.dll
Decompiled a month agousing 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 BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using TomatoSounds.Patches; 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("Tomatobird.TomatoSounds")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.2.3.0")] [assembly: AssemblyInformationalVersion("1.2.3+5ec8656ca434cafa6ec71ec4aa4a8ac03c8407ba")] [assembly: AssemblyProduct("TomatoSounds")] [assembly: AssemblyTitle("Tomatobird.TomatoSounds")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.3.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 TomatoSounds { [BepInPlugin("Tomatobird.TomatoSounds", "TomatoSounds", "1.2.3")] public class TomatoSounds : BaseUnityPlugin { internal static Dictionary<string, int> audioRarities = new Dictionary<string, int> { { "c20", 7 }, { "c21", 8 }, { "c22", 5 }, { "f1", 8 }, { "f2", 5 }, { "DropKeyReverb", 3 }, { "Hey", 1 }, { "Fireball", 1 }, { "Chicken", 1 }, { "pissed_myself_reverb", 1 }, { "FishReverb", 1 }, { "spider", 3 }, { "MaskLaugh1Left", 6 }, { "crunch", 6 }, { "yes_reverb", 2 }, { "bbot67", 1 } }; internal static string[] ambientClipNames = new string[8] { "b1", "b2", "b3", "b4", "d1", "d2", "e1", "e2" }; internal static List<AudioClip>? audioClips; internal static List<AudioClip>? ambientAudioClips; internal static List<RandomAudioClip>? randomInsanityAudioClips; internal static AssetBundle? bundle; internal static List<string> levelAmbienceNames = new List<string>(); internal static bool playerSpecificRarityAdjustment; internal static bool playerSpecificAdjustmentsDone = false; internal static bool playFireball; internal static float fireballVolume = 0.95f; public static TomatoSounds Instance { get; private set; } = null; internal static ManualLogSource Logger { get; private set; } = null; internal static Harmony? Harmony { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; bundle = AssetBundle.LoadFromFile(((BaseUnityPlugin)Instance).Info.Location.TrimEnd("Tomatobird.TomatoSounds.dll".ToCharArray()) + "insanitysounds"); if ((Object)(object)bundle != (Object)null) { audioClips = bundle.LoadAllAssets<AudioClip>().ToList(); randomInsanityAudioClips = ClipToRandom(audioClips.ToArray(), audioRarities).ToList(); ambientAudioClips = ClipToList(audioClips.ToArray(), ambientClipNames).ToList(); playerSpecificRarityAdjustment = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PlayerSpecificAmbientRarityAdjustments", true, "Should player specific insanity audio ajustments be applied?").Value; playFireball = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PlayFireball", true, "Should Fireball soundclip be played when player ragdoll spawns?").Value; fireballVolume = ((BaseUnityPlugin)this).Config.Bind<float>("General", "FireballVolume", 0.95f, "Volume of Fireball on player ragdoll").Value; Patch(); Logger.LogInfo((object)"Tomatobird.TomatoSounds v1.2.3 has loaded successfully!"); } else { Logger.LogError((object)"Tomatobird.TomatoSounds v1.2.3 failed to load!"); } } internal static AudioClip[] ClipToList(AudioClip[] audioClipArray, string[] names) { List<AudioClip> list = new List<AudioClip>(); List<string> list2 = names.ToList(); foreach (AudioClip val in audioClipArray) { if (list2.Contains(((Object)val).name)) { list.Add(val); } } return list.ToArray(); } internal static RandomAudioClip[] ClipToRandom(AudioClip[] audioClipArray, Dictionary<string, int> rarities) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown List<RandomAudioClip> list = new List<RandomAudioClip>(); foreach (AudioClip val in audioClipArray) { if (rarities.ContainsKey(((Object)val).name)) { RandomAudioClip item = new RandomAudioClip { audioClip = val, chance = rarities[((Object)val).name] }; list.Add(item); } } return list.ToArray(); } internal static void Patch() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("Tomatobird.TomatoSounds"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(typeof(InsanityAmbiencePatch)); if (playFireball) { Harmony.PatchAll(typeof(RagdollPatch)); } Logger.LogDebug((object)"Finished patching!"); } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "Tomatobird.TomatoSounds"; public const string PLUGIN_NAME = "TomatoSounds"; public const string PLUGIN_VERSION = "1.2.3"; } } namespace TomatoSounds.Patches { [HarmonyPatch(typeof(RoundManager))] internal class InsanityAmbiencePatch { [HarmonyPatch("GenerateNewFloor")] [HarmonyPostfix] private static void AddAudio() { if (TomatoSounds.randomInsanityAudioClips == null) { return; } LevelAmbienceLibrary currentLevelAmbience = SoundManager.Instance.currentLevelAmbience; if (!TomatoSounds.levelAmbienceNames.Contains(((Object)currentLevelAmbience).name)) { if (TomatoSounds.playerSpecificRarityAdjustment && !TomatoSounds.playerSpecificAdjustmentsDone) { PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)(object)val) { continue; } if (val.playerUsername.ToLower().Contains("cutedogdude")) { foreach (RandomAudioClip randomInsanityAudioClip in TomatoSounds.randomInsanityAudioClips) { if (((Object)randomInsanityAudioClip.audioClip).name == "Fireball") { randomInsanityAudioClip.chance = 10; } if (((Object)randomInsanityAudioClip.audioClip).name == "DropKeyReverb") { randomInsanityAudioClip.chance = 20; } if (((Object)randomInsanityAudioClip.audioClip).name == "Hey") { randomInsanityAudioClip.chance = 4; } if (((Object)randomInsanityAudioClip.audioClip).name == "Chicken") { randomInsanityAudioClip.chance = 8; } if (((Object)randomInsanityAudioClip.audioClip).name == "pissed_myself_reverb") { randomInsanityAudioClip.chance = 2; } if (((Object)randomInsanityAudioClip.audioClip).name == "spider") { randomInsanityAudioClip.chance = 1; } if (((Object)randomInsanityAudioClip.audioClip).name == "MaskLaugh1Left") { randomInsanityAudioClip.chance = 15; } if (((Object)randomInsanityAudioClip.audioClip).name == "bbot67") { randomInsanityAudioClip.chance = 10; } } break; } if (val.playerUsername.ToLower().Contains("gmd")) { foreach (RandomAudioClip randomInsanityAudioClip2 in TomatoSounds.randomInsanityAudioClips) { if (((Object)randomInsanityAudioClip2.audioClip).name == "Fireball") { randomInsanityAudioClip2.chance = 10; } if (((Object)randomInsanityAudioClip2.audioClip).name == "Chicken") { randomInsanityAudioClip2.chance = 8; } if (((Object)randomInsanityAudioClip2.audioClip).name == "pissed_myself_reverb") { randomInsanityAudioClip2.chance = 5; } if (((Object)randomInsanityAudioClip2.audioClip).name == "yes_reverb") { randomInsanityAudioClip2.chance = 18; } if (((Object)randomInsanityAudioClip2.audioClip).name == "bbot67") { randomInsanityAudioClip2.chance = 6; } } } if (val.playerUsername.ToLower().Contains("gian") || val.playerUsername.ToLower().Contains("gren") || val.playerUsername.ToLower().Contains("yoshistar")) { foreach (RandomAudioClip randomInsanityAudioClip3 in TomatoSounds.randomInsanityAudioClips) { if (((Object)randomInsanityAudioClip3.audioClip).name == "Chicken") { randomInsanityAudioClip3.chance = 15; } if (((Object)randomInsanityAudioClip3.audioClip).name == "DropKeyReverb") { randomInsanityAudioClip3.chance = 4; } if (((Object)randomInsanityAudioClip3.audioClip).name == "pissed_myself_reverb") { randomInsanityAudioClip3.chance = 2; } if (((Object)randomInsanityAudioClip3.audioClip).name == "spider") { randomInsanityAudioClip3.chance = 6; } if (((Object)randomInsanityAudioClip3.audioClip).name == "yes_reverb") { randomInsanityAudioClip3.chance = 9; } } } if (val.playerUsername.ToLower().Contains("kacie")) { foreach (RandomAudioClip randomInsanityAudioClip4 in TomatoSounds.randomInsanityAudioClips) { if (((Object)randomInsanityAudioClip4.audioClip).name == "pissed_myself_reverb") { randomInsanityAudioClip4.chance = 15; } } } if (val.playerUsername.ToLower().Contains("peps")) { foreach (RandomAudioClip randomInsanityAudioClip5 in TomatoSounds.randomInsanityAudioClips) { if (((Object)randomInsanityAudioClip5.audioClip).name == "spider") { randomInsanityAudioClip5.chance = 8; } } } if (val.playerUsername.ToLower().Contains("sabuh")) { foreach (RandomAudioClip randomInsanityAudioClip6 in TomatoSounds.randomInsanityAudioClips) { if (((Object)randomInsanityAudioClip6.audioClip).name == "crunch") { randomInsanityAudioClip6.chance = 18; } } } if (val.playerUsername.ToLower().Contains("malaren")) { foreach (RandomAudioClip randomInsanityAudioClip7 in TomatoSounds.randomInsanityAudioClips) { if (((Object)randomInsanityAudioClip7.audioClip).name == "FishReverb") { randomInsanityAudioClip7.chance = 22; } if (((Object)randomInsanityAudioClip7.audioClip).name == "bbot67") { randomInsanityAudioClip7.chance = 16; } } } if (!val.playerUsername.ToLower().Contains("bbot")) { continue; } foreach (RandomAudioClip randomInsanityAudioClip8 in TomatoSounds.randomInsanityAudioClips) { if (((Object)randomInsanityAudioClip8.audioClip).name == "bbot67") { randomInsanityAudioClip8.chance = 10; } } } TomatoSounds.playerSpecificAdjustmentsDone = true; } TomatoSounds.Logger.LogDebug((object)"LevelAmbienceLibrary name was not found in internal list. Adding new ambient sounds..."); TomatoSounds.levelAmbienceNames.Add(((Object)currentLevelAmbience).name); List<RandomAudioClip> list = currentLevelAmbience.insideAmbienceInsanity.ToList(); list.AddRange(TomatoSounds.randomInsanityAudioClips); currentLevelAmbience.insideAmbienceInsanity = list.ToArray(); List<AudioClip> list2 = currentLevelAmbience.insideAmbience.ToList(); list2.AddRange(TomatoSounds.ambientAudioClips); currentLevelAmbience.insideAmbience = list2.ToArray(); TomatoSounds.Logger.LogDebug((object)"New ambient sounds added!"); } else { TomatoSounds.Logger.LogDebug((object)"LevelAmbienceLibrary name was found in internal list. Skipping..."); } } } [HarmonyPatch(typeof(RagdollGrabbableObject))] public class RagdollPatch { [HarmonyPatch("Start")] [HarmonyPostfix] public static void StartPatch(RagdollGrabbableObject __instance) { if (TomatoSounds.audioClips == null) { return; } AudioSource val = ((Component)__instance).gameObject.AddComponent<AudioSource>(); foreach (AudioClip audioClip in TomatoSounds.audioClips) { if (((Object)audioClip).name == "Fireball") { val.clip = audioClip; break; } } val.playOnAwake = false; val.loop = false; val.volume = TomatoSounds.fireballVolume; val.spatialBlend = 1f; val.maxDistance = 20f; val.minDistance = 5f; val.rolloffMode = (AudioRolloffMode)1; val.Play(); } } }