Decompiled source of AnotherChallenges v0.1.1

plugins/com.github.LengSword.AnotherChallenges.dll

Decompiled 6 days ago
using System;
using System.Diagnostics;
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 DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[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.github.LengSword.AnotherChallenges")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.1.0")]
[assembly: AssemblyInformationalVersion("0.1.1+48a14046d76130626c23a15e63f6e5aad51dc1dc")]
[assembly: AssemblyProduct("com.github.LengSword.AnotherChallenges")]
[assembly: AssemblyTitle("AnotherChallenges")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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 AnotherChallenges
{
	public static class BlindAnimatorManager
	{
		private static Sequence? _activeSequence;

		private static IllegalScreenEffect? _currentInstance;

		public static void EnsureAnimationRunning(IllegalScreenEffect instance)
		{
			IllegalScreenEffect instance2 = instance;
			if (_activeSequence != null && (Object)(object)_currentInstance == (Object)(object)instance2)
			{
				return;
			}
			StopAnimation();
			if (!((Object)(object)instance2?.mat == (Object)null))
			{
				_currentInstance = instance2;
				string paramName = instance2.shaderVarName;
				float value = PluginConfig.BlindStrengthConfig.Value;
				float value2 = PluginConfig.BlindCycleIntervalConfig.Value;
				float value3 = PluginConfig.BlindFadeDurationConfig.Value;
				float value4 = PluginConfig.BlindRestTimeConfig.Value;
				instance2.mat.SetFloat(paramName, value);
				_activeSequence = TweenSettingsExtensions.SetLink<Sequence>(TweenSettingsExtensions.SetLoops<Sequence>(TweenSettingsExtensions.Append(TweenSettingsExtensions.AppendInterval(TweenSettingsExtensions.Append(TweenSettingsExtensions.AppendInterval(DOTween.Sequence(), value2), (Tween)(object)TweenSettingsExtensions.SetEase<TweenerCore<float, float, FloatOptions>>(DOTween.To((DOGetter<float>)(() => instance2.mat.GetFloat(paramName)), (DOSetter<float>)delegate(float x)
				{
					instance2.mat.SetFloat(paramName, x);
				}, 0f, value3), (Ease)1)), value4), (Tween)(object)TweenSettingsExtensions.SetEase<TweenerCore<float, float, FloatOptions>>(DOTween.To((DOGetter<float>)(() => instance2.mat.GetFloat(paramName)), (DOSetter<float>)delegate(float x)
				{
					instance2.mat.SetFloat(paramName, x);
				}, value, value3), (Ease)1)), -1, (LoopType)0), ((Component)instance2).gameObject);
			}
		}

		public static void StopAnimation()
		{
			Sequence? activeSequence = _activeSequence;
			if (activeSequence != null)
			{
				TweenExtensions.Kill((Tween)(object)activeSequence, false);
			}
			_activeSequence = null;
			_currentInstance = null;
		}

		public static void Cleanup()
		{
			StopAnimation();
		}
	}
	[BepInPlugin("com.github.LengSword.AnotherChallenges", "AnotherChallenges", "0.1.1")]
	public class Plugin : BaseUnityPlugin
	{
		private static bool IsChallengeNumb;

		public const string Id = "com.github.LengSword.AnotherChallenges";

		internal static ManualLogSource Logger { get; private set; }

		public static string Name => "AnotherChallenges";

		public static string Version => "0.1.1";

		private void Awake()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)("Plugin " + Name + " is loaded!"));
			PluginConfig.Initialize(((BaseUnityPlugin)this).Config, Logger);
			Harmony val = new Harmony("com.github.LengSword.AnotherChallenges");
			val.PatchAll();
		}

		private void Update()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if (!PluginConfig.EnableChallengeConfig.Value)
			{
				if (IsChallengeNumb)
				{
					GUIManager.instance.StopNumb();
					IsChallengeNumb = false;
				}
			}
			else
			{
				if ((Object)(object)Character.localCharacter == (Object)null || Character.localCharacter.data.dead || (Object)(object)GUIManager.instance == (Object)null)
				{
					return;
				}
				Scene activeScene = SceneManager.GetActiveScene();
				if (!(((Scene)(ref activeScene)).name == "Airport"))
				{
					if (PluginConfig.NumbConfig.Value && !((Component)GUIManager.instance.mushroomsCanvasGroup).gameObject.activeSelf)
					{
						GUIManager.instance.StartNumb();
						IsChallengeNumb = true;
					}
					else if (!PluginConfig.NumbConfig.Value && IsChallengeNumb)
					{
						GUIManager.instance.StopNumb();
						IsChallengeNumb = false;
					}
				}
			}
		}
	}
	public static class PluginConfig
	{
		internal static ConfigEntry<bool> EnableChallengeConfig { get; private set; }

		internal static ConfigEntry<bool> BlindConfig { get; private set; }

		internal static ConfigEntry<float> BlindStrengthConfig { get; private set; }

		internal static ConfigEntry<float> BlindCycleIntervalConfig { get; private set; }

		internal static ConfigEntry<float> BlindFadeDurationConfig { get; private set; }

		internal static ConfigEntry<float> BlindRestTimeConfig { get; private set; }

		internal static ConfigEntry<bool> NumbConfig { get; private set; }

		public static void Initialize(ConfigFile config, ManualLogSource logger)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			EnableChallengeConfig = config.Bind<bool>("General", "EnableChallenge", true, "Enable challenges");
			BlindConfig = config.Bind<bool>("General", "Blind", true, "Enable permanent blind status");
			BlindStrengthConfig = config.Bind<float>("General", "BlindStrength", 1f, new ConfigDescription("Blind status strength", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			BlindCycleIntervalConfig = config.Bind<float>("General", "BlindCycleInterval", 20f, new ConfigDescription("Blind cycle interval", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 120f), Array.Empty<object>()));
			BlindFadeDurationConfig = config.Bind<float>("General", "BlindFadeDuration", 1f, new ConfigDescription("Blind fade duration", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 30f), Array.Empty<object>()));
			BlindRestTimeConfig = config.Bind<float>("General", "BlindRestTime", 5f, new ConfigDescription("Blind rest time", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 120f), Array.Empty<object>()));
			NumbConfig = config.Bind<bool>("General", "Numb", false, "Enable permanent numb status");
			logger.LogInfo((object)"Plugin Config Loaded.");
		}
	}
}
namespace AnotherChallenges.Patches
{
	[HarmonyWrapSafe]
	internal sealed class ScreenEffectPatches
	{
		[HarmonyPatch(typeof(IllegalScreenEffect), "Update")]
		[HarmonyPrefix]
		private static bool IllegalScreenEffectUpdatePatch(IllegalScreenEffect __instance)
		{
			if (!PluginConfig.EnableChallengeConfig.Value || !PluginConfig.BlindConfig.Value)
			{
				BlindAnimatorManager.StopAnimation();
				return true;
			}
			if (!Object.op_Implicit((Object)(object)__instance.character) || __instance.character.data.fullyPassedOut || __instance.character.data.dead)
			{
				BlindAnimatorManager.StopAnimation();
				return true;
			}
			BlindAnimatorManager.EnsureAnimationRunning(__instance);
			((Renderer)__instance.rend).enabled = true;
			__instance.character.data.isBlind = true;
			return false;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}