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 CustomDeathAudio TankBurst v1.0.1
CustomDeathAudio.dll
Decompiled 2 years agousing System; 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 BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LCSoundTool; using Microsoft.CodeAnalysis; using Unity.Netcode; 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: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: AssemblyCompany("CustomDeathAudio")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Customise the death audio.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+e5d1a44f587956c2ceedd1dc598010ede7d9878b")] [assembly: AssemblyProduct("CustomDeathAudio")] [assembly: AssemblyTitle("CustomDeathAudio")] [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.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 CustomDeathAudio { [BepInPlugin("com.bean.CustomDeathAudio", "CustomDeathAudio", "1.3.0")] public class Plugin : BaseUnityPlugin { public static Plugin? Instance; internal static ManualLogSource? LogSource; private readonly Harmony _harmony = new Harmony("com.bean.CustomDeathAudio"); public AudioClip CustomSound = null; private readonly string _pluginPath = "BeanCan-CustomDeathAudio"; private const string OriginFileName = "DeathAudio"; internal static ConfigEntry<string> CustomRelativePath; internal static ConfigEntry<float> CustomVolume; internal static ConfigEntry<float> CustomPitch; public static PlayerControllerB? Player => GameNetworkManager.Instance?.localPlayerController; public static void AddLog(string str) { ManualLogSource? logSource = LogSource; if (logSource != null) { logSource.LogInfo((object)str); } } private void Awake() { if ((Object)(object)Instance != (Object)null) { throw new Exception("More than 1 plugin instance."); } Instance = this; LogSource = ((BaseUnityPlugin)this).Logger; CustomRelativePath = ((BaseUnityPlugin)this).Config.Bind<string>("General", "CustomRelatedPath", "./DeathAudio.wav", "Customize the path of your audio relative to the plugin's folder. \ne.g. \"../another-path/MyAudio.ogg\" \nIf no suffix is provided, \".wav\" will be considered as the default."); CustomVolume = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CustomVolum", 1f, "Customize the Volum of your audio. \nShould be a float number. (Default: 100%)"); CustomPitch = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CustomPitch", 1f, "Customize the pitch(playback speed) of your audio. \nShould be a float number. (Default: 100%)"); AddLog("Plugin CustomDeathAudio is loaded!"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); } internal void Start() { ProcessSoundFile(); } internal void OnDestroy() { ProcessSoundFile(); } private void ProcessSoundFile() { if (_pluginPath == null) { return; } string directoryName = Path.GetDirectoryName(CustomRelativePath.Value); string fileName = Path.GetFileName(CustomRelativePath.Value); try { AddLog("Loading " + _pluginPath + "/" + directoryName + "/" + fileName + "."); CustomSound = SoundTool.GetAudioClip(_pluginPath, directoryName, fileName); } catch { } if (!((Object)(object)CustomSound != (Object)null)) { try { AddLog("Loading " + _pluginPath + "/DeathAudio.wav."); CustomSound = SoundTool.GetAudioClip(_pluginPath, "DeathAudio.wav"); } catch { } if (!((Object)(object)CustomSound != (Object)null)) { AddLog("Failed to load the audio."); } } } } [HarmonyPatch(typeof(PlayerControllerB))] public class DeathPatches { [HarmonyPostfix] [HarmonyPatch("KillPlayer")] private static void KillPlayerPatch(PlayerControllerB __instance) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown Plugin.AddLog("Killing player."); if (((NetworkBehaviour)__instance).IsOwner && !((Object)(object)Plugin.Instance?.CustomSound == (Object)null)) { Plugin.AddLog("Playing death audio."); GameObject val = new GameObject("DeathAudioObject"); AudioSource val2 = val.AddComponent<AudioSource>(); val2.pitch = Plugin.CustomPitch.Value; val2.spatialBlend = 0f; val2.PlayOneShot(Plugin.Instance.CustomSound, Plugin.CustomVolume.Value); } } } public static class PluginInfo { public const string PLUGIN_GUID = "CustomDeathAudio"; public const string PLUGIN_NAME = "CustomDeathAudio"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace Instruments4Music { public static class MyPluginInfo { public const string PLUGIN_GUID = "com.bean.CustomDeathAudio"; public const string PLUGIN_NAME = "CustomDeathAudio"; public const string PLUGIN_VERSION = "1.3.0"; } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }