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 DileraHorn v1.0.2
DileraHorn.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.Logging; using DileraHorn.NetcodePatcher; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Networking; using radzki.DileraHornMod.patch; [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("Assembly-CSharp")] [assembly: AssemblyCompany("DileraHorn")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.0.0.0")] [assembly: AssemblyInformationalVersion("0.0.0-alpha.0.26+9a6eab898ecc45995f8c0ca9f3fd3ec535bbd2a6")] [assembly: AssemblyProduct("DileraHorn")] [assembly: AssemblyTitle("DileraHorn")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] internal class <Module> { static <Module>() { } } 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 radzki.DileraHornMod { [BepInPlugin("DileraHorn", "DileraHorn", "1.0.0")] public class Plugin : BaseUnityPlugin { private readonly Harmony _harmony = new Harmony("DileraHorn"); private static AssetBundle _bundle; public static Plugin Instance { get; set; } public static ManualLogSource Log => ((BaseUnityPlugin)Instance).Logger; public Plugin() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown Instance = this; } private void Awake() { Log.LogInfo((object)"Applying patches..."); ApplyPluginPatch(); Log.LogInfo((object)"Patches applied"); } private void ApplyPluginPatch() { _harmony.PatchAll(typeof(NoisemakerPropAirhornPatch)); } public AssetBundle GetBundle() { string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Instance).Info.Location), "dilerahorn"); _bundle = AssetBundle.LoadFromFile(text); return _bundle; } } public static class PluginInfo { public const string PLUGIN_GUID = "DileraHorn"; public const string PLUGIN_NAME = "DileraHorn"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace radzki.DileraHornMod.util { internal class AudioUtility { public static AudioClip LoadFromMemory(byte[] fileData, string clipName) { int channels = BitConverter.ToInt16(fileData, 22); int frequency = BitConverter.ToInt32(fileData, 24); int num = BitConverter.ToInt16(fileData, 34); byte[] array = new byte[fileData.Length - 44]; Array.Copy(fileData, 44, array, 0, array.Length); return ByteArrayToAudioClip(array, clipName, channels, frequency); } public static AudioClip ByteArrayToAudioClip(byte[] byteArray, string clipName, int channels, int frequency) { if (frequency < 1 || frequency > 48000) { frequency = 44100; } if (channels < 1 || channels > 2) { channels = 1; } int num = 16; int num2 = num / 8; AudioClip val = AudioClip.Create(clipName, byteArray.Length / num2, channels, frequency, false); val.SetData(ConvertByteArrayToFloatArray(byteArray), 0); return val; } private static float[] ConvertByteArrayToFloatArray(byte[] byteArray) { float[] array = new float[byteArray.Length / 2]; int num = 32767; for (int i = 0; i < array.Length; i++) { short num2 = BitConverter.ToInt16(byteArray, i * 2); array[i] = (float)num2 / (float)num; } return array; } public static AudioClip LoadFromDiskToAudioClip(string path, AudioType type) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 AudioClip result = null; UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path, type); try { audioClip.SendWebRequest(); try { while (!audioClip.isDone) { } if ((int)audioClip.result != 1) { Plugin.Log.LogError((object)("Failed to load WAV AudioClip from path: " + path + " Full error: " + audioClip.error)); } else { result = DownloadHandlerAudioClip.GetContent(audioClip); } } catch (Exception ex) { Plugin.Log.LogError((object)(ex.Message + ", " + ex.StackTrace)); } } finally { ((IDisposable)audioClip)?.Dispose(); } return result; } } } namespace radzki.DileraHornMod.patch { [HarmonyPatch(typeof(NoisemakerProp))] public class NoisemakerPropAirhornPatch { private static AssetBundle _bundle = Plugin.Instance.GetBundle(); private static AudioClip _sound = _bundle.LoadAsset<AudioClip>("buzina.wav"); private static AudioClip _soundFar = _bundle.LoadAsset<AudioClip>("buzinaFar.wav"); [HarmonyPatch("Start")] [HarmonyPostfix] private static void PatchAudioSource(ref NoisemakerProp __instance, object[] __args) { if (!(((GrabbableObject)__instance).itemProperties.itemName != "Airhorn")) { __instance.noiseSFX[0] = _sound; __instance.noiseSFXFar[0] = _soundFar; __instance.maxLoudness = 10f; __instance.minLoudness = 3f; } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace DileraHorn.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }