Decompiled source of BeyondLimitsPatcher v3.0.1

plugins/Marioalexsan.BeyondLimitsPatcher.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Lilly_s_Beyond_Limits;
using Microsoft.CodeAnalysis;
using Nessie.ATLYSS.EasySettings;
using Nessie.ATLYSS.EasySettings.UIElements;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Lilly_s_Beyond_Limits")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Marioalexsan.BeyondLimitsPatcher")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("3.0.1.0")]
[assembly: AssemblyInformationalVersion("3.0.1+f31034548bd1950dfa5c6218dcab6f50758b9e97")]
[assembly: AssemblyProduct("BeyondLimitsPatcher")]
[assembly: AssemblyTitle("Marioalexsan.BeyondLimitsPatcher")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.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 Marioalexsan.BeyondLimitsPatcher
{
	[BepInPlugin("Marioalexsan.BeyondLimitsPatcher", "BeyondLimitsPatcher", "3.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BeyondLimitsPatcher : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__17_0;

			internal void <Awake>b__17_0()
			{
				EasySettings.AddHeader("BeyondLimitsPatcher");
				EasySettings.AddToggle("Disable Fog", DisableFog);
				EasySettings.AddToggle("Super Far Render Distance", SuperFarRenderDistance);
			}
		}

		private static BeyondLimitsPatcher? _plugin;

		private readonly Harmony _harmony = new Harmony("Marioalexsan.BeyondLimitsPatcher");

		public static BeyondLimitsPatcher Plugin => _plugin ?? throw new InvalidOperationException("BeyondLimitsPatcher hasn't been initialized yet. Either wait until initialization, or check via ChainLoader instead.");

		internal ManualLogSource Logger { get; private set; }

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

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

		public BeyondLimitsPatcher()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			_plugin = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			DisableFog = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableFog", true, "By default, BeyondLimits disables fog in-game. Set this to false if you want to restore the fog.");
			SuperFarRenderDistance = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "SuperFarRenderDistance", true, "By default, BeyondLimits forces the render distance to 10x the value of 'Very Far'. Set this to false if you want to keep vanilla behaviour.");
		}

		public void Awake()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			_harmony.PatchAll();
			if (!EasySettings.IsAvailable)
			{
				return;
			}
			UnityEvent onInitialized = EasySettings.OnInitialized;
			object obj = <>c.<>9__17_0;
			if (obj == null)
			{
				UnityAction val = delegate
				{
					EasySettings.AddHeader("BeyondLimitsPatcher");
					EasySettings.AddToggle("Disable Fog", DisableFog);
					EasySettings.AddToggle("Super Far Render Distance", SuperFarRenderDistance);
				};
				<>c.<>9__17_0 = val;
				obj = (object)val;
			}
			onInitialized.AddListener((UnityAction)obj);
			EasySettings.OnApplySettings.AddListener((UnityAction)delegate
			{
				((BaseUnityPlugin)this).Config.Save();
			});
		}
	}
	[HarmonyPatch(typeof(BeyondCore), "findPlayer")]
	internal static class DoNotPatchPlayerNames
	{
		private static bool Prefix()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(BeyondCore), "onMessage")]
	internal static class DoNotAcceptCustomNamesOverNetwork
	{
		private static bool Prefix()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(lillyCred), "Prefix")]
	internal static class DoNotSendCustomNamesOverNetwork
	{
		private static bool Prefix()
		{
			return false;
		}
	}
	internal static class ConfigureFog
	{
		[HarmonyPatch(typeof(cameraFog), "Prefix")]
		private static class NoMessingAround
		{
			private static bool Prefix(ref bool __result)
			{
				__result = true;
				return false;
			}
		}

		[HarmonyPatch(typeof(CameraFogDensity), "OnPreRender")]
		private static class Before
		{
			private static void Prefix(CameraFogDensity __instance)
			{
				if (BeyondLimitsPatcher.DisableFog.Value)
				{
					RenderSettings.fogDensity = 1E-06f;
					__instance.fogDensity = 1E-06f;
				}
			}
		}

		[HarmonyPatch(typeof(cameraHeight), "Prefix")]
		private static class DontChangeTheFarClipPlane
		{
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> code)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Expected O, but got Unknown
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Expected O, but got Unknown
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Expected O, but got Unknown
				CodeMatcher val = new CodeMatcher(code, (ILGenerator)null);
				val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction x) => CodeInstructionExtensions.Calls(x, AccessTools.PropertySetter(typeof(Camera), "farClipPlane"))), (string)null)
				});
				val.SetInstruction(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(DontChangeTheFarClipPlane), "ManipulateFarClipPlane", (Type[])null, (Type[])null)));
				return val.InstructionEnumeration();
			}

			private static void ManipulateFarClipPlane(float value)
			{
				if (BeyondLimitsPatcher.SuperFarRenderDistance.Value)
				{
					CameraFunction._current._mainCamera.farClipPlane = value;
				}
			}
		}
	}
	internal static class Logging
	{
		private static ManualLogSource InternalLogger => BeyondLimitsPatcher.Plugin.Logger;

		public static void LogFatal(object data, ConfigEntry<bool>? toggle = null)
		{
			Log(data, (LogLevel)1, toggle);
		}

		public static void LogError(object data, ConfigEntry<bool>? toggle = null)
		{
			Log(data, (LogLevel)2, toggle);
		}

		public static void LogWarning(object data, ConfigEntry<bool>? toggle = null)
		{
			Log(data, (LogLevel)4, toggle);
		}

		public static void LogMessage(object data, ConfigEntry<bool>? toggle = null)
		{
			Log(data, (LogLevel)8, toggle);
		}

		public static void LogInfo(object data, ConfigEntry<bool>? toggle = null)
		{
			Log(data, (LogLevel)16, toggle);
		}

		public static void LogDebug(object data, ConfigEntry<bool>? toggle = null)
		{
			Log(data, (LogLevel)32, toggle);
		}

		private static void Log(object data, LogLevel level = 16, ConfigEntry<bool>? toggle = null)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (toggle == null || toggle.Value)
			{
				ManualLogSource internalLogger = InternalLogger;
				if (internalLogger != null)
				{
					internalLogger.Log(level, data);
				}
			}
		}
	}
	public static class EasySettings
	{
		private const MethodImplOptions SoftDepend = MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization;

		public const string ModID = "EasySettings";

		public static readonly Version ExpectedVersion = new Version("1.2.0");

		private static BaseUnityPlugin? _plugin;

		private static bool _initialized;

		public static bool IsAvailable
		{
			get
			{
				if (!_initialized)
				{
					_plugin = (Chainloader.PluginInfos.TryGetValue("EasySettings", out var value) ? value.Instance : null);
					_initialized = true;
					if ((Object)(object)_plugin == (Object)null)
					{
						Logging.LogWarning("Soft dependency EasySettings was not found.");
					}
					else if (_plugin.Info.Metadata.Version != ExpectedVersion)
					{
						Logging.LogWarning(string.Format("Soft dependency {0} has a different version than expected (have: {1}, expect: {2}).", "EasySettings", _plugin.Info.Metadata.Version, ExpectedVersion));
					}
				}
				return (Object)(object)_plugin != (Object)null;
			}
		}

		public static UnityEvent OnInitialized
		{
			[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
			get
			{
				return Settings.OnInitialized;
			}
		}

		public static UnityEvent OnCancelSettings
		{
			[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
			get
			{
				return Settings.OnCancelSettings;
			}
		}

		public static UnityEvent OnApplySettings
		{
			[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
			get
			{
				return Settings.OnApplySettings;
			}
		}

		public static UnityEvent OnCloseSettings
		{
			[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
			get
			{
				return Settings.OnCloseSettings;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static GameObject AddSpace()
		{
			return ((Component)((BaseAtlyssElement)Settings.ModTab.AddSpace()).Root).gameObject;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static GameObject AddHeader(string label)
		{
			return ((Component)((BaseAtlyssElement)Settings.ModTab.AddHeader(label)).Root).gameObject;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static GameObject AddButton(string buttonLabel, UnityAction onClick)
		{
			return ((Component)((BaseAtlyssElement)Settings.ModTab.AddButton(buttonLabel, onClick)).Root).gameObject;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static GameObject AddToggle(string label, ConfigEntry<bool> config)
		{
			return ((Component)((BaseAtlyssElement)Settings.ModTab.AddToggle(label, config)).Root).gameObject;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static GameObject AddSlider(string label, ConfigEntry<float> config, bool wholeNumbers = false)
		{
			return ((Component)((BaseAtlyssElement)Settings.ModTab.AddSlider(label, config, wholeNumbers)).Root).gameObject;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static GameObject AddAdvancedSlider(string label, ConfigEntry<float> config, bool wholeNumbers = false)
		{
			return ((Component)((BaseAtlyssElement)Settings.ModTab.AddAdvancedSlider(label, config, wholeNumbers)).Root).gameObject;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static GameObject AddDropdown<T>(string label, ConfigEntry<T> config) where T : Enum
		{
			return ((Component)((BaseAtlyssElement)Settings.ModTab.AddDropdown<T>(label, config)).Root).gameObject;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static GameObject AddKeyButton(string label, ConfigEntry<KeyCode> config)
		{
			return ((Component)((BaseAtlyssElement)Settings.ModTab.AddKeyButton(label, config)).Root).gameObject;
		}
	}
	internal static class ModInfo
	{
		public const string GUID = "Marioalexsan.BeyondLimitsPatcher";

		public const string NAME = "BeyondLimitsPatcher";

		public const string VERSION = "3.0.1";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}