Decompiled source of EnhancedTweaks v1.0.4

EnhancedTweaks.dll

Decompiled 8 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EnhancedTweaks")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Enhanced tweaks for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EnhancedTweaks")]
[assembly: AssemblyTitle("EnhancedTweaks")]
[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 EnhancedTweaks
{
	internal enum HorizontalPositions
	{
		Left,
		Center,
		Right,
		CustomRelative,
		CustomAbsolute
	}
	internal enum VerticalPositions
	{
		Top,
		Center,
		Bottom,
		CustomRelative,
		CustomAbsolute
	}
	[BepInPlugin("EnhancedTweaks", "EnhancedTweaks", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		internal static Plugin Instance;

		private readonly Harmony _harmony = new Harmony("EnhancedTweaks");

		internal static ConfigEntry<int> newQuotaRackupDuration;

		internal static ConfigEntry<bool> showSeedNumber;

		internal static ConfigEntry<bool> showSeedNumberOnCompanyMoon;

		internal static ConfigEntry<float> seedNumberFontSize;

		internal static ConfigEntry<int> seedNumberColorRed;

		internal static ConfigEntry<int> seedNumberColorGreen;

		internal static ConfigEntry<int> seedNumberColorBlue;

		internal static ConfigEntry<int> seedNumberColorAlpha;

		internal static ConfigEntry<HorizontalPositions> seedNumberHorizontalPosition;

		internal static ConfigEntry<VerticalPositions> seedNumberVerticalPosition;

		internal static ConfigEntry<float> seedNumberCustomHorizontalPosition;

		internal static ConfigEntry<float> seedNumberCustomVerticalPosition;

		internal static ConfigEntry<bool> fixRotationExitingFire;

		internal static ConfigEntry<bool> helpResizeLightningWarningSlots;

		private void Awake()
		{
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected O, but got Unknown
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"Plugin EnhancedTweaks is loaded!");
			newQuotaRackupDuration = ((BaseUnityPlugin)this).Config.Bind<int>("Quota", "New quota rack up duration", 5, "Length of time in seconds of how long to rack up new quota. Set to zero for instantly racking up.");
			showSeedNumber = ((BaseUnityPlugin)this).Config.Bind<bool>("Seed Number", "Show seed number", true, "If enabled, will show the random map seed number at a position of your choice.");
			showSeedNumberOnCompanyMoon = ((BaseUnityPlugin)this).Config.Bind<bool>("Seed Number", "Show seed number on company moon", false, "If \"Show seed number\" is enabled, this option will show the random map seed number on the company moon in addition to the regular moons.");
			seedNumberFontSize = ((BaseUnityPlugin)this).Config.Bind<float>("Seed Number", "Seed number font size", 20f, "The point font size for the seed number relative to a 1080p resolution.");
			seedNumberColorRed = ((BaseUnityPlugin)this).Config.Bind<int>("Seed Number", "Red color component for seed number (0-255)", 0, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>()));
			seedNumberColorGreen = ((BaseUnityPlugin)this).Config.Bind<int>("Seed Number", "Green color component for seed number (0-255)", 0, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>()));
			seedNumberColorBlue = ((BaseUnityPlugin)this).Config.Bind<int>("Seed Number", "Blue color component for seed number (0-255)", 0, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>()));
			seedNumberColorAlpha = ((BaseUnityPlugin)this).Config.Bind<int>("Seed Number", "Alpha color component for seed number (0-255)", 192, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>()));
			seedNumberHorizontalPosition = ((BaseUnityPlugin)this).Config.Bind<HorizontalPositions>("Seed Number", "Horizontal position of seed number", HorizontalPositions.Left, "CustomRelative and CustomAbsolute will use the custom values configured below rather than the presets. CustomRelative means 0.0 will be the center of the screen, 1.0 will be the right edge of the screen, and -1.0 will be left edge of the screen.  CustomAbsolute position will be the position in screen pixels with the origin at the center and positive going to the right.");
			seedNumberVerticalPosition = ((BaseUnityPlugin)this).Config.Bind<VerticalPositions>("Seed Number", "Vertical position of seed number", VerticalPositions.Bottom, "CustomRelative and CustomAbsolute will use the custom values configured below rather than the presets. CustomRelative means 0.0 will be the center of the screen, 1.0 will be the top edge of the screen, and -1.0 will be the bottom edge of the screen.  CustomAbsolute position will be the position in screen pixels with the origin at the center and positive going to the top.");
			seedNumberCustomHorizontalPosition = ((BaseUnityPlugin)this).Config.Bind<float>("Seed Number", "Custom horizontal position of seed number", 0f, "This option is only used if \"Horizontal position of seed number\" option is set to CustomRelative or CustomAbsolute. The center of the seed number text container will be used as the pivot point, so if placing on the edge, adjustments may be needed to place the text fully within the viewable area.");
			seedNumberCustomVerticalPosition = ((BaseUnityPlugin)this).Config.Bind<float>("Seed Number", "Custom vertical position of seed number", 0f, "This option is only used if \"Vertical position of seed number\" option is set to CustomRelative or CustomAbsolute. The center of the seed number text container will be used as the pivot point, so if placing on the edge, adjustments may be needed to place the text fully within the viewable area.");
			helpResizeLightningWarningSlots = ((BaseUnityPlugin)this).Config.Bind<bool>("Helpers", "Fix lightning warnings", true, "If enabled, this will attempt to help GeneralImprovements' lightning warnings to work with custom hotbar sizes.  Without this, GeneralImprovements' lightning warning feature may not work beyond the vanilla 4 item slots provided by some mods.  This option will have no effect if you don't have GeneralImprovements installed.");
			fixRotationExitingFire = ((BaseUnityPlugin)this).Config.Bind<bool>("Fixes", "Fix rotation exiting fire", true, "Fixes the rotation of the player when exiting through a fire exit.  In vanilla, some fire exits rotate the player 90 degrees to the left, this option attempts to fix this.  The rotation value can be tweaked in the \"Fixes - Fire Exit Player Rotations\" section.  This does not fix the rotation when entering the facility through a fire exit.  Please use one of the many existing mods to fix the entering rotation. Note: The \"Fixes - Fire Exit Player Rotations\" config list is dynamically generated as you discover each fire exit, so it may not even get created until you go through your first fire exit, and will continue to grow as you go through more.");
			_harmony.PatchAll();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "EnhancedTweaks";

		public const string PLUGIN_NAME = "EnhancedTweaks";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace EnhancedTweaks.Patches
{
	[HarmonyPatch(typeof(EntranceTeleport))]
	internal class EntranceTeleportPatches
	{
		private static FieldInfo _exitPointField = typeof(EntranceTeleport).GetField("exitPoint", BindingFlags.Instance | BindingFlags.NonPublic);

		private static Dictionary<string, float> _defaultExitRotations = new Dictionary<string, float>
		{
			{ "41 Experimentation", 90f },
			{ "220 Assurance", 90f },
			{ "56 Vow", 0f },
			{ "21 Offense", 90f },
			{ "61 March", 90f },
			{ "85 Rend", 90f },
			{ "7 Dine", 90f },
			{ "8 Titan", 0f }
		};

		private static Dictionary<string, ConfigEntry<float>> _exitRotationConfigs = new Dictionary<string, ConfigEntry<float>>();

		[HarmonyPatch("TeleportPlayer")]
		[HarmonyPostfix]
		private static void TeleportPlayer(EntranceTeleport __instance)
		{
			if (Plugin.fixRotationExitingFire.Value && __instance.entranceId != 0 && !__instance.isEntranceToBuilding)
			{
				RotatePlayer(__instance, GameNetworkManager.Instance.localPlayerController, __instance.entranceId);
			}
		}

		[HarmonyPatch("TeleportPlayerClientRpc")]
		[HarmonyPostfix]
		private static void TeleportPlayerClientRpc(EntranceTeleport __instance, int playerObj)
		{
			if (Plugin.fixRotationExitingFire.Value && __instance.entranceId != 0 && !__instance.isEntranceToBuilding)
			{
				PlayerControllerB val = __instance.playersManager.allPlayerScripts[playerObj];
				if (!((NetworkBehaviour)val).IsOwner)
				{
					RotatePlayer(__instance, val, __instance.entranceId);
				}
			}
		}

		private static void RotatePlayer(EntranceTeleport instance, PlayerControllerB player, int entranceId)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			string planetName = StartOfRound.Instance.currentLevel.PlanetName;
			string text = $"{planetName} door #{entranceId}";
			float value = 0f;
			_defaultExitRotations.TryGetValue(planetName, out value);
			if (!_exitRotationConfigs.TryGetValue(text, out var value2))
			{
				value2 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<float>("Fixes - Fire Exit Player Rotations", text, value, (ConfigDescription)null);
				_exitRotationConfigs.Add(text, value2);
			}
			Vector3 eulerAngles = ((Transform)_exitPointField.GetValue(instance)).eulerAngles;
			((Component)player).transform.rotation = Quaternion.Euler(eulerAngles.x, eulerAngles.y + value2.Value, eulerAngles.z);
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDManagerPatches
	{
		internal const string GIPluginTypeName = "GeneralImprovements.Plugin";

		internal const string GIHUDManagerPatchTypeName = "GeneralImprovements.Patches.HUDManagerPatch";

		internal const string GIShowHitPointsFieldName = "ShowHitPoints";

		internal const string GIHUDManagerStartMethodName = "Start";

		internal static HUDManager _hudManager;

		internal static GameObject _seedScreenCanvas;

		internal static GameObject _seedUI;

		internal static TextMeshProUGUI _seedUIText;

		internal static Vector2 _prevDisplaySize;

		internal static int _vanillaItemSlotSize = -1;

		internal static bool _helpersInitialized = false;

		internal static bool _hasGeneralImprovements = false;

		internal static bool _lightningWarningSlotsResized = false;

		internal static PropertyInfo _giShowHitPoints;

		internal static MethodInfo _giHUDManagerStart;

		internal static int _prevItemSlotSize;

		internal static void InitializeHelpers()
		{
			if (_helpersInitialized)
			{
				return;
			}
			if (Plugin.helpResizeLightningWarningSlots.Value)
			{
				try
				{
					Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.FullName.Contains("GeneralImprovements,"));
					if (assembly != null)
					{
						Type type = assembly.GetType("GeneralImprovements.Plugin");
						Type? type2 = assembly.GetType("GeneralImprovements.Patches.HUDManagerPatch");
						if (type == null)
						{
							throw new Exception("Cannot find type GeneralImprovements.Plugin");
						}
						if (type2 == null)
						{
							throw new Exception("Cannot find type GeneralImprovements.Patches.HUDManagerPatch");
						}
						_giShowHitPoints = type.GetProperty("ShowHitPoints", BindingFlags.Static | BindingFlags.Public);
						_giHUDManagerStart = type2.GetMethod("Start", BindingFlags.Static | BindingFlags.NonPublic);
						if (_giShowHitPoints == null)
						{
							throw new Exception("Cannot find property GeneralImprovements.Plugin.ShowHitPoints");
						}
						if (_giHUDManagerStart == null)
						{
							throw new Exception("Cannot find method GeneralImprovements.Patches.HUDManagerPatch.Start");
						}
						Plugin.Log.LogInfo((object)"Found GeneralImprovements, lightning warning slots will be resized if needed");
						_hasGeneralImprovements = true;
					}
					else
					{
						_hasGeneralImprovements = false;
					}
				}
				catch (Exception arg)
				{
					Plugin.Log.LogWarning((object)$"Failed to initialize lightning warning helper: {arg}");
				}
			}
			_helpersInitialized = true;
		}

		public static void CreateSeedUI(HUDManager __instance)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.showSeedNumber.Value)
			{
				return;
			}
			if ((Object)(object)_seedScreenCanvas == (Object)null)
			{
				_seedScreenCanvas = new GameObject("SeedScreenCanvas");
				_seedScreenCanvas.transform.SetParent(((Component)((Graphic)__instance.playerScreenTexture).canvas).transform.parent, false);
				_seedScreenCanvas.AddComponent<Canvas>().renderMode = (RenderMode)0;
				_seedScreenCanvas.AddComponent<CanvasScaler>();
				_seedScreenCanvas.AddComponent<GraphicRaycaster>();
			}
			if ((Object)(object)_seedUI == (Object)null)
			{
				_seedUI = new GameObject("MySeedUI");
				_seedUI.transform.SetParent(_seedScreenCanvas.transform, false);
			}
			if ((Object)(object)_seedUIText == (Object)null)
			{
				_prevDisplaySize = ((Graphic)HUDManager.Instance.playerScreenTexture).canvas.renderingDisplaySize;
				float num = 1f;
				float num2 = 1.7777778f;
				num = ((!(_prevDisplaySize.x / _prevDisplaySize.y > num2)) ? (_prevDisplaySize.x / 1920f) : (_prevDisplaySize.y / 1080f));
				string text = "Seed: 99999999";
				_seedUIText = _seedUI.AddComponent<TextMeshProUGUI>();
				((TMP_Text)_seedUIText).enableWordWrapping = false;
				((TMP_Text)_seedUIText).autoSizeTextContainer = true;
				((TMP_Text)_seedUIText).font = ((TMP_Text)__instance.weightCounter).font;
				((TMP_Text)_seedUIText).faceColor = Color32.op_Implicit(new Color((float)Plugin.seedNumberColorRed.Value / 255f, (float)Plugin.seedNumberColorGreen.Value / 255f, (float)Plugin.seedNumberColorBlue.Value / 255f, (float)Plugin.seedNumberColorAlpha.Value / 255f));
				((TMP_Text)_seedUIText).fontSize = Plugin.seedNumberFontSize.Value * 1.3333334f * num;
				((TMP_Text)_seedUIText).alignment = (TextAlignmentOptions)514;
				((TMP_Text)_seedUIText).text = text;
				Vector2 preferredValues = ((TMP_Text)_seedUIText).GetPreferredValues(text);
				float num3 = 0f;
				float num4 = 0f;
				float num5 = _prevDisplaySize.x / 2f;
				float num6 = _prevDisplaySize.y / 2f;
				if (Plugin.seedNumberHorizontalPosition.Value == HorizontalPositions.Right)
				{
					num3 = num5;
					num3 -= preferredValues.x / 2f;
				}
				else if (Plugin.seedNumberHorizontalPosition.Value == HorizontalPositions.Left)
				{
					num3 = 0f - num5;
					num3 += preferredValues.x / 2f;
				}
				else if (Plugin.seedNumberHorizontalPosition.Value == HorizontalPositions.CustomRelative)
				{
					num3 = Plugin.seedNumberCustomHorizontalPosition.Value * num5;
				}
				else if (Plugin.seedNumberHorizontalPosition.Value == HorizontalPositions.CustomAbsolute)
				{
					num3 = Plugin.seedNumberCustomHorizontalPosition.Value;
				}
				if (Plugin.seedNumberVerticalPosition.Value == VerticalPositions.Top)
				{
					num4 = num6;
					num4 -= preferredValues.y / 2f;
				}
				else if (Plugin.seedNumberVerticalPosition.Value == VerticalPositions.Bottom)
				{
					num4 = 0f - num6;
					num4 += preferredValues.y / 2f;
				}
				else if (Plugin.seedNumberVerticalPosition.Value == VerticalPositions.CustomRelative)
				{
					num4 = Plugin.seedNumberCustomVerticalPosition.Value * num6;
				}
				else if (Plugin.seedNumberVerticalPosition.Value == VerticalPositions.CustomAbsolute)
				{
					num4 = Plugin.seedNumberCustomVerticalPosition.Value;
				}
				((TMP_Text)_seedUIText).transform.localPosition = new Vector3(num3, num4, 0f);
				if (StartOfRoundPatches._gameHasStarted && (Plugin.showSeedNumberOnCompanyMoon.Value || !StartOfRound.Instance.currentLevel.PlanetName.Equals("71 Gordion", StringComparison.CurrentCultureIgnoreCase)))
				{
					((TMP_Text)_seedUIText).text = $"Seed: {StartOfRound.Instance.randomMapSeed}";
					((Behaviour)_seedUIText).enabled = true;
				}
				else
				{
					((Behaviour)_seedUIText).enabled = false;
				}
			}
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch(HUDManager __instance)
		{
			_hudManager = __instance;
			InitializeHelpers();
			if (Plugin.showSeedNumber.Value)
			{
				CreateSeedUI(__instance);
				((Behaviour)_seedUIText).enabled = false;
			}
		}

		[HarmonyPatch("OpenMenu_performed")]
		[HarmonyPostfix]
		private static void OpenMenu_performedPatch()
		{
			StartOfRoundPatches.UpdateSeedUISize(StartOfRound.Instance);
		}

		[HarmonyPatch("PingScan_performed")]
		[HarmonyPostfix]
		private static void PingScan_performedPatch()
		{
			StartOfRoundPatches.UpdateSeedUISize(StartOfRound.Instance);
		}

		[HarmonyTranspiler]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static IEnumerable<CodeInstruction> rackUpNewQuotaTextMoveNext(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Expected O, but got Unknown
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Expected O, but got Unknown
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Expected O, but got Unknown
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Expected O, but got Unknown
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Expected O, but got Unknown
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Expected O, but got Unknown
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Expected O, but got Unknown
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Expected O, but got Unknown
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Expected O, but got Unknown
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Expected O, but got Unknown
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Expected O, but got Unknown
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Expected O, but got Unknown
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Expected O, but got Unknown
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Expected O, but got Unknown
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Expected O, but got Unknown
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Expected O, but got Unknown
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Expected O, but got Unknown
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Expected O, but got Unknown
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f6: Expected O, but got Unknown
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Expected O, but got Unknown
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Expected O, but got Unknown
			//IL_047d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0483: Expected O, but got Unknown
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a7: Expected O, but got Unknown
			//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: Expected O, but got Unknown
			//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04da: Expected O, but got Unknown
			//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f3: Expected O, but got Unknown
			//IL_050b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0511: Expected O, but got Unknown
			//IL_052b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0531: Expected O, but got Unknown
			//IL_0554: Unknown result type (might be due to invalid IL or missing references)
			//IL_055a: Expected O, but got Unknown
			//IL_057b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0581: Expected O, but got Unknown
			//IL_058f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0595: Expected O, but got Unknown
			//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c9: Expected O, but got Unknown
			//IL_05dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e2: Expected O, but got Unknown
			FieldInfo fieldInfo = null;
			foreach (CodeInstruction instruction in instructions)
			{
				FieldInfo obj = instruction.operand as FieldInfo;
				if ((object)obj != null && obj.Name?.Contains("<quotaTextAmount>") == true)
				{
					FieldInfo obj2 = instruction.operand as FieldInfo;
					if ((object)obj2 != null && obj2.ReflectedType?.Name.Contains("<rackUpNewQuotaText>") == true)
					{
						fieldInfo = instruction.operand as FieldInfo;
						break;
					}
				}
			}
			if (fieldInfo == null)
			{
				Plugin.Log.LogWarning((object)"Did vanilla code change?  Unable to find field quotaTextAmount in rackUpNewQuotaText enumerator");
				return instructions;
			}
			float num = 2.1474836E+09f;
			if (Plugin.newQuotaRackupDuration.Value > 0)
			{
				num = 100f / (float)Plugin.newQuotaRackupDuration.Value;
			}
			IEnumerable<CodeInstruction> result = instructions;
			try
			{
				result = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
				{
					new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)250f, (string)null),
					new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null)
				}).ThrowIfNotMatch("250f quota inrement amount not found", Array.Empty<CodeMatch>()).SetOperandAndAdvance((object)num)
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Mul, (object)null)
					})
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(TimeOfDay), "get_Instance", (Type[])null, (Type[])null))
					})
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(TimeOfDay), "profitQuota"))
					})
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Conv_R4, (object)null)
					})
					.Advance(1)
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Ldc_R4, (object)1f)
					})
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Mathf), "Max", new Type[2]
						{
							typeof(float),
							typeof(float)
						}, (Type[])null))
					})
					.MatchForward(false, (CodeMatch[])(object)new CodeMatch[5]
					{
						new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
						new CodeMatch((OpCode?)OpCodes.Ldfld, (object)fieldInfo, (string)null),
						new CodeMatch((OpCode?)OpCodes.Ldc_I4_3, (object)null, (string)null),
						new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null),
						new CodeMatch((OpCode?)OpCodes.Conv_R4, (object)null, (string)null)
					})
					.ThrowIfNotMatch("(quotaTextAmount + 3) instructions not found", Array.Empty<CodeMatch>())
					.RemoveInstructions(5)
					.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
					{
						new CodeMatch((OpCode?)OpCodes.Ldc_I4_S, (object)(sbyte)10, (string)null),
						new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null),
						new CodeMatch((OpCode?)OpCodes.Conv_R4, (object)null, (string)null),
						new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Mathf), "Clamp", new Type[3]
						{
							typeof(float),
							typeof(float),
							typeof(float)
						}, (Type[])null), (string)null)
					})
					.ThrowIfNotMatch("Exact Mathf.Clamp instruction not found", Array.Empty<CodeMatch>())
					.Advance(3)
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Ldc_R4, (object)100f)
					})
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Mul, (object)null)
					})
					.SetInstructionAndAdvance(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Mathf), "Min", new Type[2]
					{
						typeof(float),
						typeof(float)
					}, (Type[])null)))
					.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
					{
						new CodeMatch((OpCode?)OpCodes.Ldflda, (object)fieldInfo, (string)null),
						new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(int), "ToString", (Type[])null, (Type[])null), (string)null)
					})
					.ThrowIfNotMatch("Exact quotaTextAmount.ToString() not found", Array.Empty<CodeMatch>())
					.SetInstructionAndAdvance(new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo))
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Ldc_I4, (object)100)
					})
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Div, (object)null)
					})
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Stloc_0, (object)null)
					})
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Ldloca_S, (object)0)
					})
					.MatchForward(false, (CodeMatch[])(object)new CodeMatch[4]
					{
						new CodeMatch((OpCode?)OpCodes.Ldfld, (object)fieldInfo, (string)null),
						new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(TimeOfDay), "get_Instance", (Type[])null, (Type[])null), (string)null),
						new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(TimeOfDay), "profitQuota"), (string)null),
						new CodeMatch((OpCode?)OpCodes.Blt, (object)null, (string)null)
					})
					.ThrowIfNotMatch("Exact quotaTextAmount < TimeOfDay.Instance.profitQuota compare not found", Array.Empty<CodeMatch>())
					.Advance(3)
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Ldc_I4, (object)100)
					})
					.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1]
					{
						new CodeInstruction(OpCodes.Mul, (object)null)
					})
					.InstructionEnumeration();
			}
			catch (Exception arg)
			{
				Plugin.Log.LogWarning((object)$"Did vanilla code change?  Unable to patch rackUpNewQuotaText enumerator. Exception: {arg}");
			}
			return result;
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		[HarmonyPriority(800)]
		private static void InitVanillaValues(HUDManager __instance)
		{
			if (_vanillaItemSlotSize == -1)
			{
				_vanillaItemSlotSize = __instance.itemSlotIconFrames.Length;
				_prevItemSlotSize = _vanillaItemSlotSize;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void ResizeSlotsOnConnectClientToPlayerObject()
		{
			_lightningWarningSlotsResized = false;
			_prevItemSlotSize = _vanillaItemSlotSize;
			ResizeLightningWarningSlots();
		}

		[HarmonyPatch(typeof(StartOfRound), "openingDoorsSequence")]
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void ResizeSlotsOnOpeningDoorsSequence()
		{
			ResizeLightningWarningSlots();
		}

		[HarmonyPatch(typeof(QuickMenuManager), "CloseQuickMenu")]
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void ResizeSlotsOnCloseQuickMenu()
		{
			ResizeLightningWarningSlots();
		}

		private static void ResizeLightningWarningSlots()
		{
			if ((_vanillaItemSlotSize == _hudManager.itemSlotIconFrames.Length || _lightningWarningSlotsResized) && _prevItemSlotSize == _hudManager.itemSlotIconFrames.Length)
			{
				return;
			}
			if (_hasGeneralImprovements && Plugin.helpResizeLightningWarningSlots.Value)
			{
				try
				{
					Plugin.Log.LogInfo((object)"Resizing lightning warning slots in GeneralImprovements");
					ConfigEntry<bool> val = (ConfigEntry<bool>)_giShowHitPoints.GetValue(null);
					bool value = val.Value;
					val.Value = false;
					_giHUDManagerStart.Invoke(null, new object[1] { _hudManager });
					val.Value = value;
				}
				catch (Exception arg)
				{
					Plugin.Log.LogWarning((object)$"Failed to adjust lightning warnings in GeneralImprovements: {arg}");
				}
			}
			_lightningWarningSlotsResized = true;
			_prevItemSlotSize = _hudManager.itemSlotIconFrames.Length;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatches
	{
		internal static bool _gameHasStarted;

		internal static void UpdateSeedUISize(StartOfRound __instance)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.showSeedNumber.Value)
			{
				return;
			}
			_ = HUDManagerPatches._prevDisplaySize;
			if (HUDManagerPatches._prevDisplaySize != ((Graphic)HUDManager.Instance.playerScreenTexture).canvas.renderingDisplaySize)
			{
				if ((Object)(object)HUDManagerPatches._seedScreenCanvas != (Object)null && (Object)(object)HUDManagerPatches._seedUI != (Object)null)
				{
					HUDManagerPatches._seedScreenCanvas.transform.DetachChildren();
					Object.Destroy((Object)(object)HUDManagerPatches._seedUIText);
					Object.Destroy((Object)(object)HUDManagerPatches._seedUI);
					HUDManagerPatches._seedUI = null;
					HUDManagerPatches._seedUIText = null;
				}
				HUDManagerPatches.CreateSeedUI(HUDManager.Instance);
			}
		}

		[HarmonyPatch("openingDoorsSequence")]
		[HarmonyPostfix]
		private static void UpdateSeedUI(StartOfRound __instance)
		{
			_gameHasStarted = true;
			if (Plugin.showSeedNumber.Value)
			{
				UpdateSeedUISize(__instance);
				if ((Object)(object)HUDManagerPatches._seedUIText != (Object)null && (Plugin.showSeedNumberOnCompanyMoon.Value || !StartOfRound.Instance.currentLevel.PlanetName.Equals("71 Gordion", StringComparison.CurrentCultureIgnoreCase)))
				{
					string text = $"Seed: {__instance.randomMapSeed}";
					((TMP_Text)HUDManagerPatches._seedUIText).text = text;
					((Behaviour)HUDManagerPatches._seedUIText).enabled = true;
				}
			}
		}

		[HarmonyPatch("EndOfGame")]
		[HarmonyPostfix]
		private static void EndOfGame(StartOfRound __instance)
		{
			_gameHasStarted = false;
			if (Plugin.showSeedNumber.Value && (Object)(object)HUDManagerPatches._seedUIText != (Object)null)
			{
				((Behaviour)HUDManagerPatches._seedUIText).enabled = false;
			}
		}
	}
}