Decompiled source of CoilHeadScatman v1.0.0

CoilHeadScatman.dll

Decompiled 11 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using CoilHeadScatman.AssetManager;
using CoilHeadScatman.Patches;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("CoilHeadScatman")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CoilHeadScatman")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9923b217-aff7-49c4-bbc1-fb398718f54b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CoilHeadScatman
{
	[BepInPlugin("CoilHeadScatman", "CoilHeadScatman", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public Harmony harmony;

		private static Plugin Instance;

		internal static ManualLogSource mls;

		private void Awake()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("CoilHeadScatman");
			mls.LogInfo((object)"CoilHeadScatman has awakened");
			harmony = new Harmony("CoilHeadScatman");
			harmony.PatchAll(typeof(Plugin));
			Assets.LoadAssets();
			harmony.PatchAll(typeof(SoundPatches));
			mls.LogInfo((object)"patched soundpatches");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "CoilHeadScatman";

		public const string PLUGIN_NAME = "CoilHeadScatman";

		public const string PLUGIN_VERSION = "1.0.0";

		public const string ASSET_BUNDLE_NAME = "coilheadscatman";
	}
}
namespace CoilHeadScatman.Patches
{
	[HarmonyPatch]
	internal class SoundPatches
	{
		private static ManualLogSource mls33;

		[HarmonyPatch(typeof(EnemyAI), "Start")]
		[HarmonyPostfix]
		public static void ReplaceMusic(EnemyAI __instance)
		{
			SpringManAI val = (SpringManAI)(object)((__instance is SpringManAI) ? __instance : null);
			if (val != null)
			{
				mls33 = Plugin.mls;
				mls33.LogInfo((object)"Replacing audio");
				mls33.LogInfo((object)"Trying to find animcontainer");
				Transform val2 = ((Component)((Component)val).transform.Find("SpringManModel")).transform.Find("AnimContainer");
				PlayAudioAnimationEvent component = ((Component)val2).GetComponent<PlayAudioAnimationEvent>();
				component.randomClips = Assets.ReplacementAudio.ToArray();
				mls33.LogInfo((object)"Crashed?");
			}
		}
	}
}
namespace CoilHeadScatman.AssetManager
{
	public static class Assets
	{
		public static List<AudioClip> ReplacementAudio = new List<AudioClip>();

		public static List<string> FileNames = new List<string>();

		private static ManualLogSource mls33;

		public static AssetBundle AssetBundle { get; private set; }

		public static void LoadAssets()
		{
			mls33 = Plugin.mls;
			mls33.LogInfo((object)"Attempting to start importing assetbundle");
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "coilheadscatman");
			mls33.LogInfo((object)("Loading AssetBundle " + text));
			AssetBundle = AssetBundle.LoadFromFile(text);
			mls33.LogInfo((object)"Starting to load scatman sounds");
			for (int i = 1; i <= 11; i++)
			{
				mls33.LogInfo((object)("Loading with i " + i));
				FileNames.Add("Assets/AudioClip/scatman/scat" + i + ".wav");
			}
			mls33.LogInfo((object)"Crashed?");
			mls33.LogInfo((object)("Loaded " + ReplacementAudio.Count));
			foreach (string fileName in FileNames)
			{
				mls33.LogInfo((object)("Trying to load " + fileName));
				ReplacementAudio.Add(AssetBundle.LoadAsset<AudioClip>(fileName));
			}
			mls33.LogInfo((object)"Crashed?");
		}
	}
}