Decompiled source of WindowsXPFaint v1.0.1

plugins/com.Witherstyle.peak.WindowsXPFaint.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.Witherstyle.peak.WindowsXPFaint")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+6f12d922fe372cd375ea52619b7c2c3161f85636")]
[assembly: AssemblyProduct("com.Witherstyle.peak.WindowsXPFaint")]
[assembly: AssemblyTitle("WindowsXPFaint")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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.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;
		}
	}
	[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace WindowsXPFaint
{
	[BepInPlugin("com.Witherstyle.peak.WindowsXPFaint", "WindowsXPFaint", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Character), "RPCA_PassOut")]
		private static class CharacterRPCA_PassOut
		{
			[HarmonyPostfix]
			private static void PlayPassoutSFX(Character __instance)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				passoutSFX.Play(__instance.Center + Vector3.up * 0.2f + Vector3.forward * 0.1f);
			}
		}

		[HarmonyPatch(typeof(Character), "RPCA_UnPassOut")]
		private static class CharacterRPCA_UnPassOut
		{
			[HarmonyPostfix]
			private static void PlayUnPassoutSFX(Character __instance)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				unpassoutSFX.Play(__instance.Center + Vector3.up * 0.2f + Vector3.forward * 0.1f);
			}
		}

		internal static List<AudioClip> customAudio = new List<AudioClip>();

		internal static SFX_Instance passoutSFX = ScriptableObject.CreateInstance<SFX_Instance>();

		internal static SFX_Instance unpassoutSFX = ScriptableObject.CreateInstance<SFX_Instance>();

		public const string Id = "com.Witherstyle.peak.WindowsXPFaint";

		internal static ManualLogSource Log { get; private set; } = null;


		public static string Name => "WindowsXPFaint";

		public static string Version => "1.0.1";

		private void Awake()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			if (LoadCustomAudio())
			{
				Harmony val = new Harmony(Name ?? "");
				val.PatchAll();
				Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
			}
		}

		private bool LoadCustomAudio()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			Log.LogInfo((object)("Looking for .ogg in: " + directoryName));
			string text = directoryName + "\\passout.ogg";
			string text2 = directoryName + "\\unpassout.ogg";
			if (File.Exists(text) && File.Exists(text2))
			{
				((MonoBehaviour)this).StartCoroutine(LoadAudio(new string[2] { text, text2 }));
				return true;
			}
			return false;
		}

		private IEnumerator LoadAudio(string[] fileNames)
		{
			foreach (string fileName in fileNames)
			{
				string text = "file://" + fileName;
				UnityWebRequest webRequest = UnityWebRequestMultimedia.GetAudioClip(text, (AudioType)14);
				try
				{
					yield return webRequest.SendWebRequest();
					if ((int)webRequest.result == 2 || (int)webRequest.result == 3)
					{
						Log.LogInfo((object)("Failed to load .ogg file: " + webRequest.error));
						continue;
					}
					customAudio.Add(DownloadHandlerAudioClip.GetContent(webRequest));
					Log.LogInfo((object)("Loaded .ogg file: " + fileName));
				}
				finally
				{
					((IDisposable)webRequest)?.Dispose();
				}
			}
			InitializeSFX();
		}

		private void InitializeSFX()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			passoutSFX.clips = (AudioClip[])(object)new AudioClip[1] { customAudio[0] };
			passoutSFX.settings = new SFX_Settings
			{
				range = 150f,
				volume_Variation = 0f,
				pitch_Variation = 0f
			};
			unpassoutSFX.clips = (AudioClip[])(object)new AudioClip[1] { customAudio[1] };
			unpassoutSFX.settings = new SFX_Settings
			{
				range = 150f,
				volume_Variation = 0f,
				pitch_Variation = 0f
			};
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}