Decompiled source of RobotPractiseMusic v1.0.1

BepInEx/plugins/RobotPractiseMusic.dll

Decompiled 10 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using RobotPractiseMusic.Patches;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RobotPractiseMusic")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RobotPractiseMusic")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("08f45b92-1ebf-4c98-abc3-9c0d4b8d076d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RobotPractiseMusic
{
	[BepInPlugin("KamenVacuumCleaner.RobotPractiseMusic", "RobotPractiseMusic", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "KamenVacuumCleaner.RobotPractiseMusic";

		private const string NAME = "RobotPractiseMusic";

		private const string VERSION = "1.0.1";

		private readonly Harmony harmony = new Harmony("RobotPractiseMusic");

		public static Plugin instance;

		internal ManualLogSource mls;

		public static AudioClip practiseSong;

		private void Awake()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Invalid comparison between Unknown and I4
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			mls = Logger.CreateLogSource("KamenVacuumCleaner.RobotPractiseMusic");
			mls.LogInfo((object)"Loading RobotPractiseMusic...");
			string text = ((BaseUnityPlugin)this).Info.Location.TrimEnd("RobotPractiseMusic.dll".ToCharArray());
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip("File://" + text + "PractiseSong.mp3", (AudioType)13);
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			if ((int)audioClip.result == 1)
			{
				practiseSong = DownloadHandlerAudioClip.GetContent(audioClip);
				harmony.PatchAll(typeof(AnimatedItemPatch));
				mls.LogInfo((object)"RobotPractiseMusic v1.0.1 has been loaded up successfully!");
			}
			else
			{
				mls.LogError((object)"An error occured while trying to load!");
			}
		}
	}
}
namespace RobotPractiseMusic.Patches
{
	[HarmonyPatch(typeof(AnimatedItem))]
	internal class AnimatedItemPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch(AnimatedItem __instance)
		{
			if (((Object)__instance.grabAudio).name.Equals("RobotToyCheer"))
			{
				__instance.grabAudio = Plugin.practiseSong;
			}
		}
	}
}