Decompiled source of weirdroutejingleonerror v1.0.0

weirdOnError.dll

Decompiled 7 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using RoR2;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("weirdOnError")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+27fb22515e8ae61da518e8152d1e93e8c76e3ac2")]
[assembly: AssemblyProduct("weirdOnError")]
[assembly: AssemblyTitle("weirdOnError")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 weirdOnError
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("kina.weirdOnError", "weirdOnError", "1.0.0")]
	public class weirdOnError : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static LogCallback <0>__ApplicationOnlogMessageReceived;
		}

		private const string PluginGUID = "kina.weirdOnError";

		private const string PluginAuthor = "kina";

		private const string PluginName = "weirdOnError";

		private const string PluginVersion = "1.0.0";

		private static List<float> weirdStack = new List<float>();

		private static ConfigEntry<bool> useOnLog;

		private static ConfigEntry<bool> useOnWarning;

		private static ConfigEntry<bool> useOnError;

		private static ConfigEntry<bool> useOnException;

		private static ConfigEntry<int> weirdHell;

		private static ConfigEntry<int> weirdHellSuper;

		private static ConfigEntry<int> weirdHellSeconds;

		private static GameObject weirdSoundPlayer;

		public void Awake()
		{
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Expected O, but got Unknown
			useOnLog = ((BaseUnityPlugin)this).Config.Bind<bool>("weirdOnError", "jingle on log", false, "");
			useOnWarning = ((BaseUnityPlugin)this).Config.Bind<bool>("weirdOnError", "jingle on warning", false, "");
			useOnError = ((BaseUnityPlugin)this).Config.Bind<bool>("weirdOnError", "jingle on error", false, "");
			useOnException = ((BaseUnityPlugin)this).Config.Bind<bool>("weirdOnError", "jingle on exception", true, "");
			weirdHellSeconds = ((BaseUnityPlugin)this).Config.Bind<int>("weirdOnError", "amount of time multiple errors have to be within to start playing weird_hell and weird_hell_super ,..", 3, "");
			weirdHell = ((BaseUnityPlugin)this).Config.Bind<int>("weirdOnError", "amount of errors to start playing weird_hell in ,..", 15, "");
			weirdHellSuper = ((BaseUnityPlugin)this).Config.Bind<int>("weirdOnError", "amount of errors to start playing weird_hell_super in ,..", 50, "");
			RoR2Application.onLoadFinished = (Action)Delegate.Combine(RoR2Application.onLoadFinished, (Action)delegate
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				object obj = <>O.<0>__ApplicationOnlogMessageReceived;
				if (obj == null)
				{
					LogCallback val = ApplicationOnlogMessageReceived;
					<>O.<0>__ApplicationOnlogMessageReceived = val;
					obj = (object)val;
				}
				Application.logMessageReceived += (LogCallback)obj;
			});
			weirdSoundPlayer = new GameObject("weirdSoundPlayer");
			Object.DontDestroyOnLoad((Object)(object)weirdSoundPlayer);
		}

		private static void ApplicationOnlogMessageReceived(string condition, string stacktrace, LogType type)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Invalid comparison between Unknown and I4
			if (((int)type == 3 && useOnLog.Value) || ((int)type == 2 && useOnWarning.Value) || ((int)type == 0 && useOnError.Value) || ((int)type == 4 && useOnException.Value))
			{
				weirdStack = weirdStack.Where((float weird) => Time.time - weird < (float)weirdHellSeconds.Value).ToList();
				if (weirdStack.Count >= weirdHellSuper.Value)
				{
					AkSoundEngine.PostEvent(1445867670u, weirdSoundPlayer);
				}
				else if (weirdStack.Count >= weirdHell.Value)
				{
					AkSoundEngine.PostEvent(2889195838u, weirdSoundPlayer);
				}
				else
				{
					AkSoundEngine.PostEvent(1026216972u, weirdSoundPlayer);
				}
				weirdStack.Add(Time.time);
			}
		}
	}
}