Decompiled source of RadxFlipnote Jingle v1.0.0

RadXFlipNote Jingle/RadXFlipNoteJingle.dll

Decompiled a month ago
using 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 HarmonyLib;
using Microsoft.CodeAnalysis;
using Panik;
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: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("CloverPitExampleMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CloverPitExampleMod")]
[assembly: AssemblyTitle("CloverPitExampleMod")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CloverPitExampleMod
{
	public static class Logging
	{
		public static ManualLogSource Logger => Plugin.Log;

		public static void Log(LogLevel level, object message)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Logger.Log(level, message);
		}

		public static void LogInfo(object message)
		{
			Logger.LogInfo(message);
		}

		public static void LogDebug(object message)
		{
			Logger.LogDebug(message);
		}

		public static void LogWarning(object message)
		{
			Logger.LogWarning(message);
		}

		public static void LogError(object message)
		{
			Logger.LogError(message);
		}

		public static void LogFatal(object message)
		{
			Logger.LogFatal(message);
		}
	}
	[BepInPlugin("IngoH.cloverpit.CloverPitExampleMod", "CloverPit Example Mod", "1.0.0")]
	[HarmonyPatch]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "IngoH.cloverpit.CloverPitExampleMod";

		public const string PluginName = "CloverPit Example Mod";

		public const string PluginVer = "1.0.0";

		internal static ManualLogSource Log;

		internal static readonly Harmony Harmony = new Harmony("IngoH.cloverpit.CloverPitExampleMod");

		internal static string PluginPath;

		internal const string MainContentFolder = "Radxflipnote Jingle";

		internal ConfigEntry<bool> SomeConfigOption;

		private static AudioClip _customSound;

		public static string DataPath { get; private set; }

		public static string ImagePath { get; private set; }

		internal static AudioClip CustomSound
		{
			get
			{
				if ((Object)(object)_customSound == (Object)null)
				{
					_customSound = LoadCustomSound();
				}
				return _customSound;
			}
		}

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			PluginPath = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			DataPath = Path.Combine(PluginPath, "Radxflipnote Jingle", "Data");
			ImagePath = Path.Combine(PluginPath, "Radxflipnote Jingle", "Images");
		}

		private void MakeConfig()
		{
			SomeConfigOption = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "SomeConfigOption", true, "An example config option.");
		}

		private void OnEnable()
		{
			Harmony.PatchAll();
			Logging.LogInfo("Loaded CloverPit Example Mod!");
		}

		private void OnDisable()
		{
			Harmony.UnpatchSelf();
			Logging.LogInfo("Unloaded CloverPit Example Mod!");
		}

		private void Update()
		{
		}

		private static AudioClip LoadCustomSound()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Invalid comparison between Unknown and I4
			string text = Path.Combine(DataPath, "SoundSlotStartupJingle(radx).ogg");
			if (File.Exists(text))
			{
				UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip("file://" + text, (AudioType)0);
				audioClip.SendWebRequest();
				while (!audioClip.isDone)
				{
				}
				if ((int)audioClip.result == 1)
				{
					AudioClip content = DownloadHandlerAudioClip.GetContent(audioClip);
					audioClip.Dispose();
					return content;
				}
				Log.LogWarning((object)("Error loading custom sound file: " + audioClip.error));
				return null;
			}
			Log.LogWarning((object)("Custom sound file not found at path: " + text));
			return null;
		}

		[HarmonyPatch(typeof(Sound), "_Play")]
		[HarmonyPrefix]
		internal static void _Play_Prefix(ref AudioClip sound)
		{
			if (((Object)sound).name == "SoundSlotMachineStartupJingle")
			{
				sound = CustomSound ?? sound;
			}
		}
	}
}