Decompiled source of RadMechSounds v1.1.1

RadMechSounds.dll

Decompiled 7 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Stux.patch;
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(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("RadMechSounds")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+14b4a9d6aeac819fc97ce2e3e776c4fc7bd5511b")]
[assembly: AssemblyProduct("RadMechSounds")]
[assembly: AssemblyTitle("RadMechSounds")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace Stux
{
	[BepInPlugin("stux.RadmechSounds", "RadmechSounds", "1.1.1")]
	public class RadMechSounds : BaseUnityPlugin
	{
		private const string modGUID = "stux.RadmechSounds";

		private const string modName = "RadmechSounds";

		private const string modVersion = "1.1.1";

		public static AudioClip[] brainwashSounds;

		private readonly Harmony _harmony = new Harmony("stux.RadmechSounds");

		public static RadMechSounds Instance { get; set; }

		public static ManualLogSource Log => ((BaseUnityPlugin)Instance).Logger;

		public RadMechSounds()
		{
			//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()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"stux.RadmechSounds is loading");
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			((BaseUnityPlugin)this).Logger.LogInfo((object)("dllPath: " + location));
			string[] array = location.Split('\\');
			array[^1] = "radmechsoundbundle";
			string text = string.Join("\\", array);
			brainwashSounds = (AudioClip[])(object)new AudioClip[5];
			AssetBundle val = AssetBundle.LoadFromFile(text);
			brainwashSounds[0] = val.LoadAsset<AudioClip>("assets/RadMechStomp1.ogg");
			brainwashSounds[1] = val.LoadAsset<AudioClip>("assets/RadMechStomp2.ogg");
			brainwashSounds[2] = val.LoadAsset<AudioClip>("assets/RadMechStomp3.ogg");
			brainwashSounds[3] = val.LoadAsset<AudioClip>("assets/RadMechStomp4.ogg");
			brainwashSounds[4] = val.LoadAsset<AudioClip>("assets/lyla_bark.ogg");
			if ((Object)(object)brainwashSounds[0] == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load audio assets!");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"stux.RadmechSounds is loaded");
			}
			Log.LogInfo((object)"Applying patches...");
			ApplyPluginPatch();
			Log.LogInfo((object)"Patches applied");
		}

		private void ApplyPluginPatch()
		{
			_harmony.PatchAll(typeof(RadMechBrainwashPatch));
		}
	}
}
namespace Stux.patch
{
	[HarmonyPatch(typeof(RadMechAI))]
	public class RadMechBrainwashPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void Postfix(ref RadMechAI __instance)
		{
			((EnemyAI)__instance).enemyType.audioClips = RadMechSounds.brainwashSounds;
		}
	}
}