Decompiled source of QualityOfLifePack v1.0.1

BepInEx/plugins/FlipMods-FasterItemDropship-1.2.1/FasterItemDropship.dll

Decompiled 9 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FasterItemDropship")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("Mod made by flipf17")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FasterItemDropship")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a5a250fd-b706-48b9-9be9-da360fd939dc")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace FasterItemDropship
{
	public static class ConfigSettings
	{
		public static ConfigEntry<int> dropshipDeliveryTime;

		public static ConfigEntry<int> dropshipMaxStayDuration;

		public static ConfigEntry<int> dropshipLeaveAfterSecondsOpenDoors;

		public static void BindConfigSettings()
		{
			Plugin.Log("BindingConfigs");
			dropshipDeliveryTime = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("FasterItemDropship", "DeliveryTime", 10, "How long it takes (in seconds) for the item dropship to arrive.");
			dropshipMaxStayDuration = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("FasterItemDropship", "MaxLandDuration", 40, "The max duration (in seconds) the item dropship will stay.");
			dropshipLeaveAfterSecondsOpenDoors = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("FasterItemDropship", "LeaveAfterSecondsOpenDoors", 3, "How long (in seconds) the item dropship will stay for after opening its doors.");
		}
	}
	[BepInPlugin("FlipMods.FasterItemDropship", "FasterItemDropship", "1.2.1")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony _harmony;

		public static Plugin instance;

		private void Awake()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			instance = this;
			ConfigSettings.BindConfigSettings();
			_harmony = new Harmony("FasterItemDropship");
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"FasterItemDropship loaded");
		}

		public static void Log(string message)
		{
			((BaseUnityPlugin)instance).Logger.LogInfo((object)message);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "FlipMods.FasterItemDropship";

		public const string PLUGIN_NAME = "FasterItemDropship";

		public const string PLUGIN_VERSION = "1.2.1";
	}
}
namespace FasterItemDropship.Patches
{
	[HarmonyPatch]
	internal class FasterItemDropshipPatcher
	{
		private static Terminal terminalScript;

		private static StartOfRound playersManager;

		private static List<int> itemsToDeliver;

		private static List<int> orderedItemsFromTerminal;

		[HarmonyPatch(typeof(ItemDropship), "Start")]
		[HarmonyPrefix]
		public static void InitializeDropship(ItemDropship __instance)
		{
			playersManager = Object.FindObjectOfType<StartOfRound>();
			terminalScript = Object.FindObjectOfType<Terminal>();
			itemsToDeliver = (List<int>)Traverse.Create((object)__instance).Field("itemsToDeliver").GetValue();
		}

		[HarmonyPatch(typeof(Terminal), "Start")]
		[HarmonyPrefix]
		public static void InitializeTerminal(Terminal __instance)
		{
			orderedItemsFromTerminal = __instance.orderedItemsFromTerminal;
		}

		[HarmonyPatch(typeof(ItemDropship), "Update")]
		[HarmonyPrefix]
		public static void DropshipUpdate(ItemDropship __instance)
		{
			if (((NetworkBehaviour)__instance).IsServer && !__instance.deliveringOrder && terminalScript.orderedItemsFromTerminal.Count > 0 && !playersManager.shipHasLanded)
			{
				__instance.shipTimer += Time.deltaTime;
			}
		}

		[HarmonyPatch(typeof(ItemDropship), "Update")]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldc_R4)
				{
					if ((float)list[i].operand == 20f)
					{
						list[i].operand = (float)ConfigSettings.dropshipMaxStayDuration.Value;
					}
					else if ((float)list[i].operand == 40f)
					{
						list[i].operand = (float)(ConfigSettings.dropshipMaxStayDuration.Value + ConfigSettings.dropshipDeliveryTime.Value);
					}
					else if ((float)list[i].operand == 30f)
					{
						list[i].operand = (float)ConfigSettings.dropshipMaxStayDuration.Value;
						break;
					}
				}
			}
			return list.AsEnumerable();
		}

		[HarmonyPatch(typeof(ItemDropship), "OpenShipDoorsOnServer")]
		[HarmonyPostfix]
		public static void OnOpenShipDoors(ItemDropship __instance)
		{
			if (((NetworkBehaviour)__instance).IsServer)
			{
				__instance.shipTimer = Mathf.Max(__instance.shipTimer, (float)(ConfigSettings.dropshipMaxStayDuration.Value - ConfigSettings.dropshipLeaveAfterSecondsOpenDoors.Value));
			}
		}

		[HarmonyPatch(typeof(ItemDropship), "ShipLandedAnimationEvent")]
		[HarmonyPrefix]
		public static void AddLateItemsServer(ItemDropship __instance)
		{
			if (((NetworkBehaviour)__instance).IsServer && !__instance.shipLanded && !__instance.shipDoorsOpened)
			{
				while (orderedItemsFromTerminal.Count > 0 && itemsToDeliver.Count < 12)
				{
					itemsToDeliver.Add(orderedItemsFromTerminal[0]);
					orderedItemsFromTerminal.RemoveAt(0);
				}
			}
		}
	}
}

BepInEx/plugins/Drakorle-MoreItems-1.0.2/BepInEx/plugins/MoreItems.dll

Decompiled 9 months 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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MoreItems.Patches;

[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("MoreItems")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("MoreItems")]
[assembly: AssemblyTitle("MoreItems")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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 MoreItems
{
	[BepInPlugin("MoreItems", "MoreItems", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("MoreItems");

		private void Awake()
		{
			try
			{
				harmony.PatchAll(typeof(GameNetworkManagerPatch));
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MoreItems is loaded!");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin MoreItems failed to load and threw an exception:\n" + ex.Message));
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "MoreItems";

		public const string PLUGIN_NAME = "MoreItems";

		public const string PLUGIN_VERSION = "1.0.2";
	}
}
namespace MoreItems.Patches
{
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class GameNetworkManagerPatch
	{
		private const int newMaxItemCapacity = 999;

		[HarmonyPatch("SaveItemsInShip")]
		[HarmonyPrefix]
		private static void IncreaseShipItemCapacity()
		{
			StartOfRound.Instance.maxShipItemCapacity = 999;
			Logger.CreateLogSource("MoreItems").LogInfo((object)$"Maximum amount of items that can be saved set to {999} just before saving.");
		}
	}
}

BepInEx/plugins/FlipMods-BetterStamina-1.3.2/BetterStamina.dll

Decompiled 9 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BetterStamina.Config;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BetterStamina")]
[assembly: AssemblyDescription("Mod made by flipf17")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BetterStamina")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1c42022e-b386-4342-baf0-67de1b7529e2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BetterStamina
{
	[BepInPlugin("FlipMods.BetterStamina", "BetterStamina", "1.3.2")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony _harmony;

		public static Plugin instance;

		private void Awake()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			instance = this;
			ConfigSettings.BindConfigSettings();
			_harmony = new Harmony("BetterStamina");
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"BetterStamina loaded");
		}

		public static void Log(string message)
		{
			((BaseUnityPlugin)instance).Logger.LogInfo((object)message);
		}

		public static void LogError(string message)
		{
			((BaseUnityPlugin)instance).Logger.LogError((object)message);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "FlipMods.BetterStamina";

		public const string PLUGIN_NAME = "BetterStamina";

		public const string PLUGIN_VERSION = "1.3.2";
	}
}
namespace BetterStamina.Patches
{
	[HarmonyPatch]
	public class PlayerPatcher
	{
		private static float currentSprintMeter;

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPrefix]
		public static void UpdateStaminaPrefix(PlayerControllerB __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled)
			{
				currentSprintMeter = __instance.sprintMeter;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPostfix]
		public static void UpdateStaminaPostfix(PlayerControllerB __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled)
			{
				float num = __instance.sprintMeter - currentSprintMeter;
				if (num < 0f)
				{
					__instance.sprintMeter = Mathf.Max(currentSprintMeter + num * ConfigSync.instance.staminaConsumptionMultiplier, 0f);
				}
				else if (num > 0f)
				{
					__instance.sprintMeter = Mathf.Min(currentSprintMeter + num * ConfigSync.instance.staminaRegenMultiplier, 1f);
				}
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
		[HarmonyPrefix]
		public static void LateUpdatePrefix(PlayerControllerB __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled)
			{
				currentSprintMeter = __instance.sprintMeter;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
		[HarmonyPostfix]
		public static void LateUpdateStaminaPostfix(PlayerControllerB __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled)
			{
				float num = __instance.sprintMeter - currentSprintMeter;
				if (num < 0f)
				{
					__instance.sprintMeter = Mathf.Max(currentSprintMeter + num * ConfigSync.instance.staminaConsumptionMultiplier, 0f);
				}
				else if (num > 0f)
				{
					__instance.sprintMeter = Mathf.Min(currentSprintMeter + num * ConfigSync.instance.staminaRegenMultiplier, 1f);
				}
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Jump_performed")]
		[HarmonyPrefix]
		public static void JumpPerformedPrefix(PlayerControllerB __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled)
			{
				currentSprintMeter = __instance.sprintMeter;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Jump_performed")]
		[HarmonyPostfix]
		public static void JumpPerformedPostfix(PlayerControllerB __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled)
			{
				float num = __instance.sprintMeter - currentSprintMeter;
				if (num < 0f)
				{
					__instance.sprintMeter = Mathf.Max(new float[1] { currentSprintMeter + num * ConfigSync.instance.jumpStaminaConsumptionMultiplier });
				}
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyTranspiler]
		public static IEnumerable<CodeInstruction> SpoofWeightValuesUpdate(IEnumerable<CodeInstruction> instructions)
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			FieldInfo field = typeof(PlayerControllerB).GetField("carryWeight", BindingFlags.Instance | BindingFlags.Public);
			MethodInfo method = typeof(PlayerPatcher).GetMethod("GetAdjustedWeight", BindingFlags.Static | BindingFlags.Public);
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldfld && (FieldInfo)list[i].operand == field)
				{
					list[i] = new CodeInstruction(OpCodes.Call, (object)method);
					list.RemoveAt(i - 1);
				}
			}
			return list.AsEnumerable();
		}

		[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
		[HarmonyTranspiler]
		public static IEnumerable<CodeInstruction> SpoofWeightValuesLateUpdate(IEnumerable<CodeInstruction> instructions)
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			FieldInfo field = typeof(PlayerControllerB).GetField("carryWeight", BindingFlags.Instance | BindingFlags.Public);
			MethodInfo method = typeof(PlayerPatcher).GetMethod("GetAdjustedWeight", BindingFlags.Static | BindingFlags.Public);
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldfld && (FieldInfo)list[i].operand == field)
				{
					list[i] = new CodeInstruction(OpCodes.Call, (object)method);
					list.RemoveAt(i - 1);
				}
			}
			return list.AsEnumerable();
		}

		public static float GetAdjustedWeight()
		{
			return Mathf.Max(((Object)(object)StartOfRound.Instance.localPlayerController != (Object)null) ? (StartOfRound.Instance.localPlayerController.carryWeight * ConfigSync.instance.carryWeightPenaltyMultiplier) : 1f, 1f);
		}
	}
}
namespace BetterStamina.Config
{
	[Serializable]
	public static class ConfigSettings
	{
		public static ConfigEntry<float> staminaRegenMultiplierConfig;

		public static ConfigEntry<float> staminaConsumptionMultiplierConfig;

		public static ConfigEntry<float> jumpStaminaConsumptionMultiplierConfig;

		public static ConfigEntry<float> carryWeightPenaltyMultiplierConfig;

		public static ConfigEntry<float> movementSpeedMultiplierConfig;

		public static void BindConfigSettings()
		{
			Plugin.Log("BindingConfigs");
			staminaRegenMultiplierConfig = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("BetterStamina", "StaminaRegenMultiplier", 1.5f, "Multiplier for how fast your stamina regens.");
			staminaConsumptionMultiplierConfig = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("BetterStamina", "StaminaConsumptionMultiplier", 0.75f, "Multiplier for how much stamina drains while sprinting.");
			jumpStaminaConsumptionMultiplierConfig = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("BetterStamina", "JumpStaminaConsumptionMultiplier", 0.75f, "Multiplier for how much stamina jumping consumes.");
			carryWeightPenaltyMultiplierConfig = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("BetterStamina", "CarryWeightPenaltyMultiplier", 0.5f, "Multiplier for how much your speed/stamina consumption are affected by weight.");
			movementSpeedMultiplierConfig = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("BetterStamina", "MovementSpeedMultiplier", 1f, "Player movement speed multiplier.");
		}
	}
	[Serializable]
	[HarmonyPatch]
	public class ConfigSync
	{
		public static ConfigSync defaultConfig;

		public static ConfigSync instance;

		public static PlayerControllerB localPlayerController;

		public static bool isSynced = false;

		private static float defaultMovementSpeed = 4.6f;

		public float staminaRegenMultiplier = 1f;

		public float staminaConsumptionMultiplier = 1f;

		public float jumpStaminaConsumptionMultiplier = 1f;

		public float carryWeightPenaltyMultiplier = 1f;

		public float movementSpeedMultiplier = 1f;

		public static void BuildDefaultConfigSync()
		{
			instance = new ConfigSync();
		}

		public static void BuildServerConfigSync()
		{
			if (defaultConfig == null)
			{
				defaultConfig = new ConfigSync();
				defaultConfig.staminaRegenMultiplier = ConfigSettings.staminaRegenMultiplierConfig.Value;
				defaultConfig.staminaConsumptionMultiplier = ConfigSettings.staminaConsumptionMultiplierConfig.Value;
				defaultConfig.jumpStaminaConsumptionMultiplier = ConfigSettings.jumpStaminaConsumptionMultiplierConfig.Value;
				defaultConfig.carryWeightPenaltyMultiplier = ConfigSettings.carryWeightPenaltyMultiplierConfig.Value;
				defaultConfig.movementSpeedMultiplier = ConfigSettings.movementSpeedMultiplierConfig.Value;
				instance = defaultConfig;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		public static void InitializeLocalPlayer(PlayerControllerB __instance)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			localPlayerController = __instance;
			if (NetworkManager.Singleton.IsServer)
			{
				BuildServerConfigSync();
				NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("BetterStamina-OnRequestConfigSync", new HandleNamedMessageDelegate(OnReceiveConfigSyncRequest));
				OnLocalClientConfigSync();
			}
			else
			{
				isSynced = false;
				BuildDefaultConfigSync();
				NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("BetterStamina-OnReceiveConfigSync", new HandleNamedMessageDelegate(OnReceiveConfigSync));
				RequestConfigSync();
			}
		}

		public static void RequestConfigSync()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsClient)
			{
				Plugin.Log("Sending config sync request to server.");
				FastBufferWriter val = default(FastBufferWriter);
				((FastBufferWriter)(ref val))..ctor(4, (Allocator)2, -1);
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("BetterStamina-OnRequestConfigSync", 0uL, val, (NetworkDelivery)3);
			}
			else
			{
				Plugin.LogError("Failed to send config sync request.");
			}
		}

		public static void OnReceiveConfigSyncRequest(ulong clientId, FastBufferReader reader)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsServer)
			{
				Plugin.Log("Receiving config sync request from client with id: " + clientId + ". Sending config sync to client.");
				byte[] array = SerializeConfigToByteArray(instance);
				FastBufferWriter val = default(FastBufferWriter);
				((FastBufferWriter)(ref val))..ctor(array.Length + 4, (Allocator)2, -1);
				int num = array.Length;
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0);
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("BetterStamina-OnReceiveConfigSync", clientId, val, (NetworkDelivery)3);
			}
		}

		public static void OnReceiveConfigSync(ulong clientId, FastBufferReader reader)
		{
			//IL_0014: 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)
			if (((FastBufferReader)(ref reader)).TryBeginRead(4))
			{
				int num = default(int);
				((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
				if (((FastBufferReader)(ref reader)).TryBeginRead(num))
				{
					Plugin.Log("Receiving config sync from server.");
					byte[] data = new byte[num];
					((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0);
					instance = DeserializeFromByteArray(data);
					OnLocalClientConfigSync();
				}
				else
				{
					Plugin.LogError("Error receiving sync from server.");
				}
			}
			else
			{
				Plugin.LogError("Error receiving bytes length.");
			}
		}

		public static void OnLocalClientConfigSync()
		{
			localPlayerController.movementSpeed = defaultMovementSpeed * instance.movementSpeedMultiplier;
			isSynced = true;
		}

		public static byte[] SerializeConfigToByteArray(ConfigSync config)
		{
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			MemoryStream memoryStream = new MemoryStream();
			binaryFormatter.Serialize(memoryStream, config);
			return memoryStream.ToArray();
		}

		public static ConfigSync DeserializeFromByteArray(byte[] data)
		{
			MemoryStream serializationStream = new MemoryStream(data);
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			return (ConfigSync)binaryFormatter.Deserialize(serializationStream);
		}
	}
}

BepInEx/plugins/Zaggy1024-NutcrackerFixes-1.2.2/BepInEx/plugins/NutcrackerFixes.dll

Decompiled 9 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.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using NutcrackerFixes.Patches;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("NutcrackerFixes")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NutcrackerFixes")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d01d5a17-8806-47da-aff3-70fb6669aff2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace NutcrackerFixes
{
	[BepInPlugin("Zaggy1024.NutcrackerFixes", "NutcrackerFixes", "1.2.2")]
	public class Plugin : BaseUnityPlugin
	{
		private const string MOD_NAME = "NutcrackerFixes";

		private const string MOD_UNIQUE_NAME = "Zaggy1024.NutcrackerFixes";

		private const string MOD_VERSION = "1.2.2";

		private readonly Harmony harmony = new Harmony("Zaggy1024.NutcrackerFixes");

		public static ConfigEntry<bool> Shotgun_SynchronizeShellsAndSafety;

		public static Plugin Instance { get; private set; }

		public ManualLogSource Logger => ((BaseUnityPlugin)this).Logger;

		private void Awake()
		{
			Instance = this;
			Shotgun_SynchronizeShellsAndSafety = ((BaseUnityPlugin)this).Config.Bind<bool>("Shotgun", "SynchronizeShellsAndSafety", true, "Synchronize the shotgun shell count and safety setting upon picking up the shotgun. This feature must be installed and enabled for everyone, or the safety will not function as expected. Fixes an issue where too many items on the ship would cause the number of loaded shells as well as the safety to be desynced between the server and clients.");
			harmony.PatchAll(typeof(PatchNutcrackerEnemyAI));
			harmony.PatchAll(typeof(PatchShotgunItem));
			harmony.PatchAll(typeof(PatchBlobAI));
			harmony.PatchAll(typeof(PatchSandSpiderAI));
		}
	}
}
namespace NutcrackerFixes.Patches
{
	public class SequenceMatch
	{
		public int Start;

		public int End;

		public int Size => End - Start;

		public SequenceMatch(int start, int end)
		{
			Start = start;
			End = end;
		}
	}
	public static class Common
	{
		public static readonly MethodInfo m_Debug_Log = typeof(Debug).GetMethod("Log", new Type[1] { typeof(object) });

		public static MethodInfo GetGenericMethod(Type type, string name, Type[] parameters, Type[] genericArguments)
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			MethodInfo[] methods = type.GetMethods();
			foreach (MethodInfo methodInfo in methods)
			{
				if (methodInfo.Name != name)
				{
					continue;
				}
				MethodInfo methodInfo2 = methodInfo;
				if (genericArguments.Length != 0)
				{
					try
					{
						methodInfo2 = methodInfo2.MakeGenericMethod(genericArguments);
					}
					catch
					{
					}
				}
				ParameterInfo[] parameters2 = methodInfo2.GetParameters();
				if (parameters2.Length != parameters.Length)
				{
					continue;
				}
				for (int j = 0; j < parameters.Length; j++)
				{
					if (parameters2[j].ParameterType != parameters[j])
					{
						methodInfo2 = null;
						break;
					}
				}
				if (methodInfo2 != null)
				{
					return methodInfo2;
				}
			}
			throw new MemberNotFoundException("Could not find method " + type.Name + "::" + name);
		}

		public static SequenceMatch FindIndexOfSequence<T>(this List<T> list, int startIndex, int count, IEnumerable<Predicate<T>> predicates)
		{
			int num;
			for (num = startIndex; num < list.Count(); num++)
			{
				IEnumerator<Predicate<T>> enumerator = predicates.GetEnumerator();
				if (!enumerator.MoveNext())
				{
					return null;
				}
				num = list.FindIndex(num, enumerator.Current);
				if (num < 0)
				{
					break;
				}
				bool flag = true;
				int num2 = 1;
				while (enumerator.MoveNext())
				{
					if (num2 >= list.Count() - num || !enumerator.Current(list[num + num2]))
					{
						flag = false;
						break;
					}
					num2++;
				}
				if (flag)
				{
					return new SequenceMatch(num, num + predicates.Count());
				}
			}
			return null;
		}

		public static SequenceMatch FindIndexOfSequence<T>(this List<T> list, int startIndex, IEnumerable<Predicate<T>> predicates)
		{
			return list.FindIndexOfSequence(startIndex, -1, predicates);
		}

		public static SequenceMatch FindIndexOfSequence<T>(this List<T> list, IEnumerable<Predicate<T>> predicates)
		{
			return list.FindIndexOfSequence(0, -1, predicates);
		}
	}
	[HarmonyPatch(typeof(BlobAI))]
	internal class PatchBlobAI
	{
		private static readonly MethodInfo m_Component_get_transform = AccessTools.Method(typeof(Component), "get_transform", new Type[0], (Type[])null);

		private static readonly MethodInfo m_Transform_get_position = AccessTools.Method(typeof(Transform), "get_position", new Type[0], (Type[])null);

		private static readonly MethodInfo m_Transform_set_position = AccessTools.Method(typeof(Transform), "set_position", new Type[1] { typeof(Vector3) }, (Type[])null);

		private static readonly FieldInfo f_PlayerControllerB_gameplayCamera = typeof(PlayerControllerB).GetField("gameplayCamera");

		[HarmonyTranspiler]
		[HarmonyPatch("HitEnemy")]
		private static IEnumerable<CodeInstruction> DoHitEnemyTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Expected O, but got Unknown
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Expected O, but got Unknown
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Expected O, but got Unknown
			List<CodeInstruction> list = instructions.ToList();
			SequenceMatch sequenceMatch = list.FindIndexOfSequence(new Predicate<CodeInstruction>[2]
			{
				(CodeInstruction insn) => CodeInstructionExtensions.IsLdarg(insn, (int?)2),
				(CodeInstruction insn) => CodeInstructionExtensions.LoadsField(insn, f_PlayerControllerB_gameplayCamera, false)
			});
			CodeInstruction val = list[sequenceMatch.Start];
			Label label = generator.DefineLabel();
			list[sequenceMatch.Start].labels.Add(label);
			Label label2 = generator.DefineLabel();
			int index = list.FindIndex(sequenceMatch.End, (CodeInstruction insn) => CodeInstructionExtensions.Calls(insn, m_Transform_set_position));
			list[index].labels.Add(label2);
			list.InsertRange(sequenceMatch.Start, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[6]
			{
				new CodeInstruction(val.opcode, val.operand),
				new CodeInstruction(OpCodes.Brtrue_S, (object)label),
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Call, (object)m_Component_get_transform),
				new CodeInstruction(OpCodes.Call, (object)m_Transform_get_position),
				new CodeInstruction(OpCodes.Br, (object)label2)
			});
			return list;
		}
	}
	[HarmonyPatch(typeof(NutcrackerEnemyAI))]
	internal class PatchNutcrackerEnemyAI
	{
		[HarmonyTranspiler]
		[HarmonyPatch("TurnTorsoToTargetDegrees")]
		private static IEnumerable<CodeInstruction> TurnTorsoToTargetDegreesTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			foreach (CodeInstruction instruction in instructions)
			{
				if (CodeInstructionExtensions.Calls(instruction, Common.m_Debug_Log))
				{
					yield return new CodeInstruction(OpCodes.Pop, (object)null);
				}
				else
				{
					yield return instruction;
				}
			}
		}
	}
	[HarmonyPatch(typeof(SandSpiderAI))]
	internal class PatchSandSpiderAI
	{
		private static readonly MethodInfo m_NetworkBehavior_get_IsOwner = typeof(NetworkBehaviour).GetMethod("get_IsOwner");

		private static readonly MethodInfo m_SandSpiderAI_TriggerChaseWithPlayer = typeof(SandSpiderAI).GetMethod("TriggerChaseWithPlayer");

		[HarmonyTranspiler]
		[HarmonyPatch("HitEnemy")]
		private static IEnumerable<CodeInstruction> DoHitEnemyTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected O, but got Unknown
			List<CodeInstruction> list = instructions.ToList();
			Label? label2 = default(Label?);
			SequenceMatch sequenceMatch = list.FindIndexOfSequence(new Predicate<CodeInstruction>[6]
			{
				(CodeInstruction insn) => CodeInstructionExtensions.IsLdarg(insn, (int?)0),
				(CodeInstruction insn) => CodeInstructionExtensions.Calls(insn, m_NetworkBehavior_get_IsOwner),
				(CodeInstruction insn) => CodeInstructionExtensions.Branches(insn, ref label2),
				(CodeInstruction insn) => CodeInstructionExtensions.IsLdarg(insn, (int?)0),
				(CodeInstruction insn) => CodeInstructionExtensions.IsLdarg(insn, (int?)null),
				(CodeInstruction insn) => CodeInstructionExtensions.Calls(insn, m_SandSpiderAI_TriggerChaseWithPlayer)
			});
			Label label = (Label)list[sequenceMatch.Start + 2].operand;
			list.InsertRange(sequenceMatch.Start + 3, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[2]
			{
				new CodeInstruction(list[sequenceMatch.End - 2]),
				new CodeInstruction(OpCodes.Brfalse_S, (object)label)
			});
			return list;
		}
	}
	[HarmonyPatch(typeof(ShotgunItem))]
	internal class PatchShotgunItem
	{
		private static readonly MethodInfo m_PatchShotgunItem_SetSafetyServerRpc = typeof(PatchShotgunItem).GetMethod("SetSafetyServerRpc", new Type[2]
		{
			typeof(ShotgunItem),
			typeof(bool)
		});

		private static readonly FieldInfo f_ShotgunItem_enemyColliders = AccessTools.Field(typeof(ShotgunItem), "enemyColliders");

		private static readonly FieldInfo f_ShotgunItem_safetyOn = typeof(ShotgunItem).GetField("safetyOn");

		private static readonly MethodInfo m_ShotgunItem_SetSafetyControlTip = AccessTools.Method(typeof(ShotgunItem), "SetSafetyControlTip", new Type[0], (Type[])null);

		private static readonly MethodInfo m_Physics_SphereCastNonAlloc = AccessTools.Method(typeof(Physics), "SphereCastNonAlloc", new Type[6]
		{
			typeof(Ray),
			typeof(float),
			typeof(RaycastHit[]),
			typeof(float),
			typeof(int),
			typeof(QueryTriggerInteraction)
		}, (Type[])null);

		private static readonly ConstructorInfo m_HashSet_EnemyAI_Constructor = typeof(HashSet<EnemyAI>).GetConstructor(new Type[0]);

		private static readonly MethodInfo m_HashSet_EnemyAI_Contains = typeof(HashSet<EnemyAI>).GetMethod("Contains", new Type[1] { typeof(EnemyAI) });

		private static readonly MethodInfo m_HashSet_EnemyAI_Add = typeof(HashSet<EnemyAI>).GetMethod("Add", new Type[1] { typeof(EnemyAI) });

		private static readonly MethodInfo m_Component_GetComponent_EnemyAICollisionDetect = Common.GetGenericMethod(typeof(Component), "GetComponent", new Type[0], new Type[1] { typeof(EnemyAICollisionDetect) });

		private static readonly MethodInfo m_Component_TryGetComponent_IHittable = Common.GetGenericMethod(typeof(Component), "TryGetComponent", new Type[1] { typeof(IHittable).MakeByRefType() }, new Type[1] { typeof(IHittable) });

		private static readonly MethodInfo m_UnityEngine_Object_op_Implicit = typeof(Object).GetMethod("op_Implicit", new Type[1] { typeof(Object) });

		private static readonly FieldInfo f_EnemyAICollisionDetect_onlyCollideWhenGrounded = typeof(EnemyAICollisionDetect).GetField("onlyCollideWhenGrounded");

		private static readonly FieldInfo f_EnemyAICollisionDetect_mainScript = typeof(EnemyAICollisionDetect).GetField("mainScript");

		private static readonly MethodInfo m_RaycastHit_get_transform = AccessTools.Method(typeof(RaycastHit), "get_transform", new Type[0], (Type[])null);

		private const uint SET_SAFETY_SERVER_RPC = 391u;

		private const uint SET_SAFETY_CLIENT_RPC = 392u;

		private const uint SYNCHRONIZE_CLIENT_RPC = 393u;

		private const uint SYNCHRONIZE_SERVER_RPC = 394u;

		[HarmonyTranspiler]
		[HarmonyPatch("ShootGun")]
		private static IEnumerable<CodeInstruction> ShootGunTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Expected O, but got Unknown
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Expected O, but got Unknown
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Expected O, but got Unknown
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Expected O, but got Unknown
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Expected O, but got Unknown
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Expected O, but got Unknown
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Expected O, but got Unknown
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Expected O, but got Unknown
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Expected O, but got Unknown
			//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cc: Expected O, but got Unknown
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Expected O, but got Unknown
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Expected O, but got Unknown
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Expected O, but got Unknown
			//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c6: Expected O, but got Unknown
			//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d8: Expected O, but got Unknown
			//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e7: Expected O, but got Unknown
			//IL_0615: Unknown result type (might be due to invalid IL or missing references)
			//IL_061b: Expected O, but got Unknown
			//IL_0624: Unknown result type (might be due to invalid IL or missing references)
			//IL_062a: Expected O, but got Unknown
			//IL_0636: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Expected O, but got Unknown
			//IL_064a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0650: Expected O, but got Unknown
			//IL_0659: Unknown result type (might be due to invalid IL or missing references)
			//IL_065f: Expected O, but got Unknown
			//IL_0668: Unknown result type (might be due to invalid IL or missing references)
			//IL_066e: Expected O, but got Unknown
			//IL_067a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0680: Expected O, but got Unknown
			//IL_0688: Unknown result type (might be due to invalid IL or missing references)
			//IL_068e: Expected O, but got Unknown
			//IL_0777: Unknown result type (might be due to invalid IL or missing references)
			//IL_0781: Expected O, but got Unknown
			//IL_07cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d7: Expected O, but got Unknown
			List<CodeInstruction> list = instructions.ToList();
			int num = list.FindIndex((CodeInstruction insn) => insn.opcode == OpCodes.Newarr && insn.operand as Type == typeof(RaycastHit));
			list[num - 1].operand = 50;
			SequenceMatch sequenceMatch = list.FindIndexOfSequence(new Predicate<CodeInstruction>[2]
			{
				(CodeInstruction insn) => CodeInstructionExtensions.Calls(insn, m_Physics_SphereCastNonAlloc),
				(CodeInstruction insn) => CodeInstructionExtensions.IsStloc(insn, (LocalBuilder)null)
			});
			LocalBuilder localBuilder = generator.DeclareLocal(typeof(HashSet<EnemyAI>));
			CodeInstruction[] array = (CodeInstruction[])(object)new CodeInstruction[2]
			{
				new CodeInstruction(OpCodes.Newobj, (object)m_HashSet_EnemyAI_Constructor),
				new CodeInstruction(OpCodes.Stloc, (object)localBuilder)
			};
			list.InsertRange(sequenceMatch.End, array);
			sequenceMatch.End += array.Length;
			Label? label4 = default(Label?);
			SequenceMatch sequenceMatch2 = list.FindIndexOfSequence(sequenceMatch.End, new Predicate<CodeInstruction>[3]
			{
				(CodeInstruction insn) => CodeInstructionExtensions.LoadsConstant(insn, 0L),
				(CodeInstruction insn) => CodeInstructionExtensions.IsStloc(insn, (LocalBuilder)null),
				(CodeInstruction insn) => CodeInstructionExtensions.Branches(insn, ref label4)
			});
			LocalBuilder hitEnemyIndexVar = (LocalBuilder)list[sequenceMatch2.Start + 1].operand;
			Label label = generator.DefineLabel();
			Predicate<CodeInstruction>[] first = new Predicate<CodeInstruction>[6]
			{
				(CodeInstruction insn) => CodeInstructionExtensions.IsLdarg(insn, (int?)0),
				(CodeInstruction insn) => CodeInstructionExtensions.LoadsField(insn, f_ShotgunItem_enemyColliders, false),
				(CodeInstruction insn) => CodeInstructionExtensions.IsLdloc(insn, hitEnemyIndexVar),
				(CodeInstruction insn) => insn.opcode == OpCodes.Ldelema,
				(CodeInstruction insn) => CodeInstructionExtensions.Calls(insn, m_RaycastHit_get_transform),
				(CodeInstruction insn) => CodeInstructionExtensions.Calls(insn, m_Component_GetComponent_EnemyAICollisionDetect)
			};
			Label? label3 = default(Label?);
			SequenceMatch sequenceMatch3 = list.FindIndexOfSequence(sequenceMatch2.End, first.Concat(new Predicate<CodeInstruction>[3]
			{
				(CodeInstruction insn) => CodeInstructionExtensions.Calls(insn, m_UnityEngine_Object_op_Implicit),
				(CodeInstruction insn) => CodeInstructionExtensions.Branches(insn, ref label3),
				(CodeInstruction insn) => insn.opcode == OpCodes.Ret
			}));
			list.RemoveRange(sequenceMatch3.Start, sequenceMatch3.Size);
			sequenceMatch3.End -= sequenceMatch3.Size;
			LocalBuilder localBuilder2 = generator.DeclareLocal(typeof(EnemyAICollisionDetect));
			CodeInstruction[] array2 = (CodeInstruction[])(object)new CodeInstruction[13]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldfld, (object)f_ShotgunItem_enemyColliders),
				new CodeInstruction(OpCodes.Ldloc, (object)hitEnemyIndexVar),
				new CodeInstruction(OpCodes.Ldelema, (object)typeof(RaycastHit)),
				new CodeInstruction(OpCodes.Call, (object)m_RaycastHit_get_transform),
				new CodeInstruction(OpCodes.Call, (object)m_Component_GetComponent_EnemyAICollisionDetect),
				new CodeInstruction(OpCodes.Stloc, (object)localBuilder2),
				new CodeInstruction(OpCodes.Ldloc, (object)localBuilder2),
				new CodeInstruction(OpCodes.Call, (object)m_UnityEngine_Object_op_Implicit),
				new CodeInstruction(OpCodes.Brfalse_S, (object)label),
				new CodeInstruction(OpCodes.Ldloc, (object)localBuilder2),
				new CodeInstruction(OpCodes.Ldfld, (object)f_EnemyAICollisionDetect_onlyCollideWhenGrounded),
				new CodeInstruction(OpCodes.Brtrue_S, (object)label)
			};
			list.InsertRange(sequenceMatch3.Start, array2);
			SequenceMatch sequenceMatch4 = list.FindIndexOfSequence(sequenceMatch3.Start + array2.Length, first.Concat(new Predicate<CodeInstruction>[2]
			{
				(CodeInstruction insn) => CodeInstructionExtensions.LoadsField(insn, f_EnemyAICollisionDetect_mainScript, false),
				(CodeInstruction insn) => CodeInstructionExtensions.IsStloc(insn, (LocalBuilder)null)
			}));
			LocalBuilder localBuilder3 = (LocalBuilder)list[sequenceMatch4.End - 1].operand;
			list.RemoveRange(sequenceMatch4.Start, sequenceMatch4.Size);
			list.InsertRange(sequenceMatch4.Start, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[3]
			{
				new CodeInstruction(OpCodes.Ldloc, (object)localBuilder2),
				new CodeInstruction(OpCodes.Ldfld, (object)f_EnemyAICollisionDetect_mainScript),
				new CodeInstruction(OpCodes.Stloc, (object)localBuilder3)
			});
			Label? label2 = default(Label?);
			SequenceMatch sequenceMatch5 = list.FindIndexOfSequence(sequenceMatch2.End, new Predicate<CodeInstruction>[8]
			{
				(CodeInstruction insn) => CodeInstructionExtensions.IsLdarg(insn, (int?)0),
				(CodeInstruction insn) => CodeInstructionExtensions.LoadsField(insn, f_ShotgunItem_enemyColliders, false),
				(CodeInstruction insn) => CodeInstructionExtensions.IsLdloc(insn, hitEnemyIndexVar),
				(CodeInstruction insn) => insn.opcode == OpCodes.Ldelema,
				(CodeInstruction insn) => CodeInstructionExtensions.Calls(insn, m_RaycastHit_get_transform),
				(CodeInstruction insn) => insn.opcode == OpCodes.Ldloca_S,
				(CodeInstruction insn) => CodeInstructionExtensions.Calls(insn, m_Component_TryGetComponent_IHittable),
				(CodeInstruction insn) => CodeInstructionExtensions.Branches(insn, ref label2)
			});
			list.InsertRange(sequenceMatch5.End, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[8]
			{
				new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder),
				new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder3),
				new CodeInstruction(OpCodes.Call, (object)m_HashSet_EnemyAI_Contains),
				new CodeInstruction(OpCodes.Brtrue_S, (object)label),
				new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder),
				new CodeInstruction(OpCodes.Ldloc_S, (object)localBuilder3),
				new CodeInstruction(OpCodes.Call, (object)m_HashSet_EnemyAI_Add),
				new CodeInstruction(OpCodes.Pop, (object)null)
			});
			SequenceMatch sequenceMatch6 = list.FindIndexOfSequence(sequenceMatch2.End, new Predicate<CodeInstruction>[3]
			{
				(CodeInstruction insn) => CodeInstructionExtensions.IsLdloc(insn, (LocalBuilder)null),
				(CodeInstruction insn) => CodeInstructionExtensions.LoadsConstant(insn, 1L),
				(CodeInstruction insn) => insn.opcode == OpCodes.Add
			});
			list[sequenceMatch6.Start].labels.Add(label);
			int num2 = sequenceMatch2.End;
			while (true)
			{
				num2 = list.FindIndex(num2, sequenceMatch6.Start - num2, (CodeInstruction insn) => insn.opcode == OpCodes.Ret);
				if (num2 < 0)
				{
					break;
				}
				list[num2] = new CodeInstruction(OpCodes.Br_S, (object)label);
			}
			num2 = sequenceMatch2.End;
			while (true)
			{
				num2 = list.FindIndex(num2, sequenceMatch6.Start - num2, (CodeInstruction insn) => CodeInstructionExtensions.Calls(insn, Common.m_Debug_Log));
				if (num2 < 0)
				{
					break;
				}
				list[num2] = new CodeInstruction(OpCodes.Pop, (object)null);
			}
			return list;
		}

		[HarmonyPostfix]
		[HarmonyPatch("EquipItem")]
		private static void EquipItemPostfix(ShotgunItem __instance)
		{
			if (Plugin.Shotgun_SynchronizeShellsAndSafety.Value)
			{
				SynchronizeServerRpc(__instance);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("LoadItemSaveData")]
		private static void LoadItemSaveDataPostfix(ShotgunItem __instance)
		{
			if (Plugin.Shotgun_SynchronizeShellsAndSafety.Value)
			{
				SetSafetyServerRpc(__instance, __instance.safetyOn);
			}
		}

		[HarmonyTranspiler]
		[HarmonyPatch("ItemInteractLeftRight")]
		private static IEnumerable<CodeInstruction> ItemInteractLeftRightTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Expected O, but got Unknown
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Expected O, but got Unknown
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			List<CodeInstruction> list = instructions.ToList();
			SequenceMatch sequenceMatch = list.FindIndexOfSequence(new Predicate<CodeInstruction>[2]
			{
				(CodeInstruction insn) => CodeInstructionExtensions.IsLdarg(insn, (int?)1),
				(CodeInstruction insn) => insn.opcode == OpCodes.Brtrue || insn.opcode == OpCodes.Brtrue_S
			});
			Label isLeftInteractEndLabel = (Label)list[sequenceMatch.End - 1].operand;
			int num = list.FindIndex((CodeInstruction insn) => insn.labels.Contains(isLeftInteractEndLabel));
			Label label = generator.DefineLabel();
			list[sequenceMatch.End].labels.Add(label);
			CodeInstruction[] array = (CodeInstruction[])(object)new CodeInstruction[4]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Call, (object)Reflection.m_NetworkBehaviour_get_IsOwner),
				new CodeInstruction(OpCodes.Brtrue_S, (object)label),
				new CodeInstruction(OpCodes.Ret, (object)null)
			};
			list.InsertRange(sequenceMatch.End, array);
			CodeInstruction[] collection = (CodeInstruction[])(object)new CodeInstruction[4]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldfld, (object)f_ShotgunItem_safetyOn),
				new CodeInstruction(OpCodes.Call, (object)m_PatchShotgunItem_SetSafetyServerRpc)
			};
			list.InsertRange(num - 1 + array.Length, collection);
			return list;
		}

		public static void SetSafetyServerRpc(ShotgunItem shotgun, bool safetyOn)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)shotgun).IsOwner && !((NetworkBehaviour)shotgun).IsHost && !((NetworkBehaviour)shotgun).IsServer)
			{
				return;
			}
			NetworkManager networkManager = ((NetworkBehaviour)shotgun).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if (((NetworkBehaviour)shotgun).IsHost || ((NetworkBehaviour)shotgun).IsServer)
				{
					SetSafetyClientRpc(shotgun, safetyOn);
				}
				else if (((NetworkBehaviour)shotgun).IsClient)
				{
					ServerRpcParams rpcParams = default(ServerRpcParams);
					FastBufferWriter buffer = Reflection.BeginSendServerRPC((NetworkBehaviour)(object)shotgun, 391u, rpcParams, (RpcDelivery)0);
					((FastBufferWriter)(ref buffer)).WriteValueSafe<bool>(ref safetyOn, default(ForPrimitives));
					Reflection.EndSendServerRPC((NetworkBehaviour)(object)shotgun, ref buffer, 391u, rpcParams, (RpcDelivery)0);
				}
			}
		}

		public static void SetSafetyClientRpc(ShotgunItem shotgun, bool safetyOn)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)shotgun).IsOwner || ((NetworkBehaviour)shotgun).IsHost || ((NetworkBehaviour)shotgun).IsServer)
			{
				NetworkManager networkManager = ((NetworkBehaviour)shotgun).NetworkManager;
				if (networkManager != null && networkManager.IsListening && (((NetworkBehaviour)shotgun).IsHost || ((NetworkBehaviour)shotgun).IsServer))
				{
					ClientRpcParams rpcParams = default(ClientRpcParams);
					FastBufferWriter buffer = Reflection.BeginSendClientRPC((NetworkBehaviour)(object)shotgun, 392u, rpcParams, (RpcDelivery)0);
					((FastBufferWriter)(ref buffer)).WriteValueSafe<bool>(ref safetyOn, default(ForPrimitives));
					Reflection.EndSendClientRPC((NetworkBehaviour)(object)shotgun, ref buffer, 392u, rpcParams, (RpcDelivery)0);
				}
			}
		}

		private static void RPCHandlerSetSafetyServer(NetworkBehaviour target, FastBufferReader reader, __RpcParams parameters)
		{
			//IL_0019: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool safetyOn = default(bool);
				((FastBufferReader)(ref reader)).ReadValue<bool>(ref safetyOn, default(ForPrimitives));
				SetSafetyClientRpc((ShotgunItem)target, safetyOn);
			}
		}

		private static void RPCHandlerSetSafetyClient(NetworkBehaviour target, FastBufferReader reader, __RpcParams parameters)
		{
			//IL_0019: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool safetyOn = default(bool);
				((FastBufferReader)(ref reader)).ReadValue<bool>(ref safetyOn, default(ForPrimitives));
				SetSafety((ShotgunItem)target, safetyOn);
			}
		}

		private static void SetSafety(ShotgunItem shotgun, bool safetyOn)
		{
			shotgun.safetyOn = safetyOn;
			m_ShotgunItem_SetSafetyControlTip.Invoke(shotgun, new object[0]);
		}

		public static void SynchronizeServerRpc(ShotgunItem shotgun)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)shotgun).IsOwner || ((NetworkBehaviour)shotgun).IsHost || ((NetworkBehaviour)shotgun).IsServer)
			{
				return;
			}
			NetworkManager networkManager = ((NetworkBehaviour)shotgun).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if (((NetworkBehaviour)shotgun).IsHost || ((NetworkBehaviour)shotgun).IsServer)
				{
					SynchronizeClientRpc(shotgun);
				}
				else if (((NetworkBehaviour)shotgun).IsClient)
				{
					ServerRpcParams rpcParams = default(ServerRpcParams);
					FastBufferWriter buffer = Reflection.BeginSendServerRPC((NetworkBehaviour)(object)shotgun, 394u, rpcParams, (RpcDelivery)0);
					Reflection.EndSendServerRPC((NetworkBehaviour)(object)shotgun, ref buffer, 394u, rpcParams, (RpcDelivery)0);
				}
			}
		}

		public static void SynchronizeClientRpc(ShotgunItem shotgun)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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)
			if (((NetworkBehaviour)shotgun).IsHost || ((NetworkBehaviour)shotgun).IsServer)
			{
				NetworkManager networkManager = ((NetworkBehaviour)shotgun).NetworkManager;
				if (networkManager != null && networkManager.IsListening && (((NetworkBehaviour)shotgun).IsHost || ((NetworkBehaviour)shotgun).IsServer))
				{
					ClientRpcParams rpcParams = default(ClientRpcParams);
					FastBufferWriter buffer = Reflection.BeginSendClientRPC((NetworkBehaviour)(object)shotgun, 393u, rpcParams, (RpcDelivery)0);
					((FastBufferWriter)(ref buffer)).WriteValueSafe<int>(ref shotgun.shellsLoaded, default(ForPrimitives));
					((FastBufferWriter)(ref buffer)).WriteValueSafe<bool>(ref shotgun.safetyOn, default(ForPrimitives));
					Reflection.EndSendClientRPC((NetworkBehaviour)(object)shotgun, ref buffer, 393u, rpcParams, (RpcDelivery)0);
				}
			}
		}

		private static void RPCHandlerSynchronizeServer(NetworkBehaviour target, FastBufferReader reader, __RpcParams parameters)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				SynchronizeClientRpc((ShotgunItem)target);
			}
		}

		private static void RPCHandlerSynchronizeClient(NetworkBehaviour target, FastBufferReader reader, __RpcParams parameters)
		{
			//IL_0019: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int shellsLoaded = default(int);
				((FastBufferReader)(ref reader)).ReadValue<int>(ref shellsLoaded, default(ForPrimitives));
				bool safetyOn = default(bool);
				((FastBufferReader)(ref reader)).ReadValue<bool>(ref safetyOn, default(ForPrimitives));
				Synchronize((ShotgunItem)target, shellsLoaded, safetyOn);
			}
		}

		private static void Synchronize(ShotgunItem shotgun, int shellsLoaded, bool safetyOn)
		{
			shotgun.shellsLoaded = shellsLoaded;
			((Renderer)shotgun.shotgunShellLeft).enabled = shellsLoaded >= 1;
			((Renderer)shotgun.shotgunShellRight).enabled = shellsLoaded >= 2;
			shotgun.safetyOn = safetyOn;
			m_ShotgunItem_SetSafetyControlTip.Invoke(shotgun, new object[0]);
		}

		[HarmonyPostfix]
		[HarmonyPatch("InitializeRPCS_ShotgunItem")]
		private static void InitializeRPCS_ShotgunItemPostfix()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(391u, new RpcReceiveHandler(RPCHandlerSetSafetyServer));
			NetworkManager.__rpc_func_table.Add(392u, new RpcReceiveHandler(RPCHandlerSetSafetyClient));
			NetworkManager.__rpc_func_table.Add(394u, new RpcReceiveHandler(RPCHandlerSynchronizeServer));
			NetworkManager.__rpc_func_table.Add(393u, new RpcReceiveHandler(RPCHandlerSynchronizeClient));
		}
	}
	public static class Reflection
	{
		public static readonly MethodInfo m_Debug_Log = typeof(Debug).GetMethod("Log", new Type[1] { typeof(object) });

		public static readonly MethodInfo m_NetworkBehaviour_get_IsOwner = typeof(NetworkBehaviour).GetMethod("get_IsOwner", new Type[0]);

		public static readonly MethodInfo m_NetworkBehaviour_beginSendServerRpc = AccessTools.Method(typeof(NetworkBehaviour), "__beginSendServerRpc", new Type[3]
		{
			typeof(uint),
			typeof(ServerRpcParams),
			typeof(RpcDelivery)
		}, (Type[])null);

		public static readonly MethodInfo m_NetworkBehaviour_endSendServerRpc = AccessTools.Method(typeof(NetworkBehaviour), "__endSendServerRpc", new Type[4]
		{
			typeof(FastBufferWriter).MakeByRefType(),
			typeof(uint),
			typeof(ServerRpcParams),
			typeof(RpcDelivery)
		}, (Type[])null);

		public static readonly MethodInfo m_NetworkBehaviour_beginSendClientRpc = AccessTools.Method(typeof(NetworkBehaviour), "__beginSendClientRpc", new Type[3]
		{
			typeof(uint),
			typeof(ClientRpcParams),
			typeof(RpcDelivery)
		}, (Type[])null);

		public static readonly MethodInfo m_NetworkBehaviour_endSendClientRpc = AccessTools.Method(typeof(NetworkBehaviour), "__endSendClientRpc", new Type[4]
		{
			typeof(FastBufferWriter).MakeByRefType(),
			typeof(uint),
			typeof(ClientRpcParams),
			typeof(RpcDelivery)
		}, (Type[])null);

		public static FastBufferWriter BeginSendServerRPC(NetworkBehaviour behaviour, uint rpcID, ServerRpcParams rpcParams, RpcDelivery delivery)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			return (FastBufferWriter)m_NetworkBehaviour_beginSendServerRpc.Invoke(behaviour, new object[3] { rpcID, rpcParams, delivery });
		}

		public static void EndSendServerRPC(NetworkBehaviour behaviour, ref FastBufferWriter buffer, uint rpcID, ServerRpcParams rpcParams, RpcDelivery delivery)
		{
			//IL_0009: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			object[] array = new object[4] { buffer, rpcID, rpcParams, delivery };
			m_NetworkBehaviour_endSendServerRpc.Invoke(behaviour, array);
			buffer = (FastBufferWriter)array[0];
		}

		public static FastBufferWriter BeginSendClientRPC(NetworkBehaviour behaviour, uint rpcID, ClientRpcParams rpcParams, RpcDelivery delivery)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			return (FastBufferWriter)m_NetworkBehaviour_beginSendClientRpc.Invoke(behaviour, new object[3] { rpcID, rpcParams, delivery });
		}

		public static void EndSendClientRPC(NetworkBehaviour behaviour, ref FastBufferWriter buffer, uint rpcID, ClientRpcParams rpcParams, RpcDelivery delivery)
		{
			//IL_0009: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			object[] array = new object[4] { buffer, rpcID, rpcParams, delivery };
			m_NetworkBehaviour_endSendClientRpc.Invoke(behaviour, array);
			buffer = (FastBufferWriter)array[0];
		}
	}
}

BepInEx/plugins/Thorlar-HealthStation-1.0.1/OctolarFirstMod.dll

Decompiled 9 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using OctolarFirstMod.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("OctolarFirstMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OctolarFirstMod")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a761e7d0-2e73-4d38-b7ad-3010bdcd4702")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace OctolarFirstMod
{
	[BepInPlugin("Octolar.Healthstation", "Health Station mod", "1.0.0.1")]
	public class OctolarFirstMod : BaseUnityPlugin
	{
		private const string modGUID = "Octolar.Healthstation";

		private const string modName = "Health Station mod";

		private const string modVersion = "1.0.0.1";

		private readonly Harmony harmony = new Harmony("Octolar.Healthstation");

		private static OctolarFirstMod Instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Octolar.Healthstation");
			mls.LogInfo((object)"Octolar HealthStation mod is now active");
			harmony.PatchAll(typeof(OctolarFirstMod));
			harmony.PatchAll(typeof(ItemChargerPatch));
		}
	}
}
namespace OctolarFirstMod.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	[HarmonyPatch(typeof(ItemCharger))]
	internal class ItemChargerPatch
	{
		[HarmonyPatch("ChargeItem")]
		[HarmonyPostfix]
		private static void ChargerHealsPatch()
		{
			//IL_0014: 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)
			GameNetworkManager.Instance.localPlayerController.DamagePlayer(-100, false, true, (CauseOfDeath)0, 0, false, default(Vector3));
			if (GameNetworkManager.Instance.localPlayerController.health >= 10 && GameNetworkManager.Instance.localPlayerController.criticallyInjured)
			{
				GameNetworkManager.Instance.localPlayerController.MakeCriticallyInjured(false);
			}
		}
	}
}

BepInEx/plugins/ThePotato-scanForItemsFix-1.0.4/BepInEx/plugins/ThePotato-scanFixForItemsFix.dll

Decompiled 9 months ago
using System;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("ThePotato-scanFixForItemsFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Fixes an error that occurs when scanning for scrap")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.4")]
[assembly: AssemblyProduct("ThePotato-scanFixForItemsFix")]
[assembly: AssemblyTitle("ThePotato-scanFixForItemsFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.4.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 ScanFix
{
	[BepInPlugin("ThePotato-scanFixForItemsFix", "ThePotato-scanFixForItemsFix", "1.0.4")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Terminal), "TextPostProcess")]
		internal class TextProcessPatch
		{
			private static bool Prefix(ref string modifiedDisplayText, TerminalNode node)
			{
				if (modifiedDisplayText.Contains("[scanForItems]"))
				{
					try
					{
						Random random = new Random(StartOfRound.Instance.randomMapSeed + 91);
						int num = 0;
						int num2 = 0;
						foreach (var item in Object.FindObjectsOfType<GrabbableObject>().Select((GrabbableObject grabbable, int index) => new { grabbable, index }))
						{
							GrabbableObject grabbable2 = item.grabbable;
							int index2 = item.index;
							Item itemProperties = grabbable2.itemProperties;
							if (grabbable2 != null && !grabbable2.isInShipRoom && !grabbable2.isInElevator && itemProperties != null && itemProperties.minValue > 0 && itemProperties.maxValue > 0 && itemProperties.isScrap)
							{
								int minValue = Mathf.Min(itemProperties.minValue, itemProperties.maxValue);
								int maxValue = Mathf.Max(itemProperties.minValue, itemProperties.maxValue);
								int num3 = Mathf.Clamp(random.Next(minValue, maxValue), grabbable2.scrapValue - 6 * index2, grabbable2.scrapValue + 9 * index2);
								num2 += num3;
								num++;
							}
						}
						modifiedDisplayText = modifiedDisplayText.Replace("[scanForItems]", $"There are {num} objects outside the ship, totalling at an approximate value of ${num2}.");
					}
					catch
					{
						modifiedDisplayText = modifiedDisplayText.Replace("[scanForItems]", "FAILED TO SCAN FOR ITEMS");
					}
				}
				return true;
			}
		}

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin ThePotato-scanFixForItemsFix is loaded!");
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin ThePotato-scanFixForItemsFix is patched!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ThePotato-scanFixForItemsFix";

		public const string PLUGIN_NAME = "ThePotato-scanFixForItemsFix";

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

BepInEx/plugins/Zaggy1024-PathfindingLagFix-1.2.1/BepInEx/plugins/PathfindingLagFix.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using PathfindingLagFix.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("PathfindingLagFix")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PathfindingLagFix")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("fedb984b-16ae-458c-b2cc-19590627c578")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace PathfindingLagFix
{
	[BepInPlugin("Zaggy1024.PathfindingLagFix", "PathfindingLagFix", "1.2.1")]
	public class Plugin : BaseUnityPlugin
	{
		private const string MOD_NAME = "PathfindingLagFix";

		private const string MOD_UNIQUE_NAME = "Zaggy1024.PathfindingLagFix";

		private const string MOD_VERSION = "1.2.1";

		private readonly Harmony harmony = new Harmony("Zaggy1024.PathfindingLagFix");

		public static Plugin Instance { get; private set; }

		public ManualLogSource Logger => ((BaseUnityPlugin)this).Logger;

		public void Awake()
		{
			Instance = this;
			harmony.PatchAll(typeof(PatchFlowermanAI));
			harmony.PatchAll(typeof(PatchCopyVanillaFlowermanCode));
			harmony.PatchAll(typeof(PatchPufferAI));
			harmony.PatchAll(typeof(PatchCopyVanillaPufferCode));
			harmony.PatchAll(typeof(PatchCentipedeAI));
			harmony.PatchAll(typeof(PatchCopyVanillaCentipedeCode));
		}
	}
}
namespace PathfindingLagFix.Patches
{
	public class SequenceMatch
	{
		public int Start;

		public int End;

		public SequenceMatch(int start, int end)
		{
			Start = start;
			End = end;
		}
	}
	public static class Common
	{
		public static SequenceMatch FindIndexOfSequence<T>(this List<T> list, int startIndex, int count, IEnumerable<Predicate<T>> predicates)
		{
			int num;
			for (num = startIndex; num < list.Count(); num++)
			{
				IEnumerator<Predicate<T>> enumerator = predicates.GetEnumerator();
				if (!enumerator.MoveNext())
				{
					return null;
				}
				num = list.FindIndex(num, enumerator.Current);
				if (num < 0)
				{
					break;
				}
				bool flag = true;
				int num2 = 1;
				while (enumerator.MoveNext())
				{
					if (num2 >= list.Count() - num || !enumerator.Current(list[num + num2]))
					{
						flag = false;
						break;
					}
					num2++;
				}
				if (flag)
				{
					return new SequenceMatch(num, num + predicates.Count());
				}
			}
			return null;
		}

		public static SequenceMatch FindIndexOfSequence<T>(this List<T> list, int startIndex, IEnumerable<Predicate<T>> predicates)
		{
			return list.FindIndexOfSequence(startIndex, -1, predicates);
		}

		public static SequenceMatch FindIndexOfSequence<T>(this List<T> list, IEnumerable<Predicate<T>> predicates)
		{
			return list.FindIndexOfSequence(0, -1, predicates);
		}

		public static IEnumerable<T> IndexRangeView<T>(this List<T> list, int start, int end)
		{
			for (int i = start; i < end; i++)
			{
				yield return list[i];
			}
		}

		public static IEnumerable<T> IndexRangeView<T>(this List<T> list, SequenceMatch range)
		{
			return list.IndexRangeView(range.Start, range.End);
		}

		public static void RemoveIndexRange<T>(this List<T> list, int start, int end)
		{
			list.RemoveRange(start, end - start);
		}

		public static void RemoveIndicesRange<T>(this List<T> list, SequenceMatch range)
		{
			list.RemoveIndexRange(range.Start, range.End);
		}

		public static void TransferLabelsAndVariables(this IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			Dictionary<LocalBuilder, LocalBuilder> localDict = new Dictionary<LocalBuilder, LocalBuilder>();
			Dictionary<Label, Label> labelDict = new Dictionary<Label, Label>();
			foreach (CodeInstruction instruction in instructions)
			{
				if (instruction.operand is LocalBuilder local2)
				{
					instruction.operand = GetLocal(local2);
				}
				for (int i = 0; i < instruction.labels.Count(); i++)
				{
					instruction.labels[i] = GetLabel(instruction.labels[i]);
				}
				if (instruction.operand is Label label2)
				{
					instruction.operand = GetLabel(label2);
				}
			}
			Label GetLabel(Label label)
			{
				if (!labelDict.ContainsKey(label))
				{
					labelDict[label] = generator.DefineLabel();
				}
				return labelDict[label];
			}
			LocalBuilder GetLocal(LocalBuilder local)
			{
				if (!localDict.ContainsKey(local))
				{
					localDict[local] = generator.DeclareLocal(local.LocalType);
				}
				return localDict[local];
			}
		}

		public static int GetLocalIndex(this CodeInstruction instruction)
		{
			if (instruction.opcode == OpCodes.Ldloc_0 || instruction.opcode == OpCodes.Stloc_0)
			{
				return 0;
			}
			if (instruction.opcode == OpCodes.Ldloc_1 || instruction.opcode == OpCodes.Stloc_1)
			{
				return 1;
			}
			if (instruction.opcode == OpCodes.Ldloc_2 || instruction.opcode == OpCodes.Stloc_2)
			{
				return 2;
			}
			if (instruction.opcode == OpCodes.Ldloc_3 || instruction.opcode == OpCodes.Stloc_3)
			{
				return 3;
			}
			if (instruction.opcode != OpCodes.Ldloc || instruction.opcode != OpCodes.Ldloc_S || instruction.opcode != OpCodes.Ldloca || instruction.opcode != OpCodes.Ldloca_S || instruction.opcode != OpCodes.Stloc || instruction.opcode != OpCodes.Stloc_S)
			{
				return -1;
			}
			return ((LocalBuilder)instruction.operand).LocalIndex;
		}

		public static int PopCount(this CodeInstruction instruction)
		{
			if (instruction.opcode == OpCodes.Call || instruction.opcode == OpCodes.Callvirt)
			{
				return ((MethodInfo)instruction.operand).GetParameters().Length;
			}
			return instruction.opcode.StackBehaviourPop switch
			{
				StackBehaviour.Pop0 => 0, 
				StackBehaviour.Pop1 => 1, 
				StackBehaviour.Pop1_pop1 => 2, 
				StackBehaviour.Popi => 1, 
				StackBehaviour.Popi_pop1 => 2, 
				StackBehaviour.Popi_popi => 2, 
				StackBehaviour.Popi_popi8 => 2, 
				StackBehaviour.Popi_popi_popi => 3, 
				StackBehaviour.Popi_popr4 => 2, 
				StackBehaviour.Popi_popr8 => 2, 
				StackBehaviour.Popref => 1, 
				StackBehaviour.Popref_pop1 => 2, 
				StackBehaviour.Popref_popi => 2, 
				StackBehaviour.Popref_popi_popi => 3, 
				StackBehaviour.Popref_popi_popi8 => 3, 
				StackBehaviour.Popref_popi_popr4 => 3, 
				StackBehaviour.Popref_popi_popr8 => 3, 
				StackBehaviour.Popref_popi_popref => 3, 
				StackBehaviour.Varpop => throw new NotImplementedException("Variable pop on non-call instruction"), 
				StackBehaviour.Popref_popi_pop1 => 3, 
				_ => throw new NotSupportedException($"StackBehaviourPop of {instruction.opcode.StackBehaviourPop} was not a pop for instruction '{instruction}'"), 
			};
		}

		public static int PushCount(this CodeInstruction instruction)
		{
			if (instruction.opcode == OpCodes.Call || instruction.opcode == OpCodes.Callvirt)
			{
				return 1;
			}
			return instruction.opcode.StackBehaviourPush switch
			{
				StackBehaviour.Push0 => 1, 
				StackBehaviour.Push1 => 1, 
				StackBehaviour.Push1_push1 => 2, 
				StackBehaviour.Pushi => 1, 
				StackBehaviour.Pushi8 => 1, 
				StackBehaviour.Pushr4 => 1, 
				StackBehaviour.Pushr8 => 1, 
				StackBehaviour.Pushref => 1, 
				StackBehaviour.Varpush => throw new NotImplementedException("Variable push on non-call instruction"), 
				_ => throw new NotSupportedException($"StackBehaviourPush of {instruction.opcode.StackBehaviourPush} was not a push for instruction '{instruction}'"), 
			};
		}

		public static SequenceMatch InstructionRangeForStackItems(this List<CodeInstruction> instructions, int instructionIndex, int startIndex, int endIndex)
		{
			int num = -1;
			int num2 = -1;
			instructionIndex--;
			int num3 = 0;
			while (instructionIndex >= 0)
			{
				CodeInstruction instruction = instructions[instructionIndex];
				int num4 = instruction.PushCount();
				if (num2 == -1 && num3 == startIndex && num4 > 0)
				{
					num2 = instructionIndex + 1;
				}
				num3 += instruction.PushCount();
				num3 -= instruction.PopCount();
				if (num3 > endIndex)
				{
					num = instructionIndex;
					break;
				}
				instructionIndex--;
			}
			if (num == -1 || num2 == -1)
			{
				return null;
			}
			return new SequenceMatch(num, num2);
		}

		public static Exception PatchError(string message, string patchName)
		{
			return new Exception(message + ", " + patchName + " may not be supported on this game version");
		}

		public static Exception StubError(string name, string patchName)
		{
			return new NotSupportedException(name + " stub was called, " + patchName + " may not be supported on this game version");
		}
	}
	public static class Coroutines
	{
		public static IEnumerator<Transform> ChooseFarthestNodeFromPosition(EnemyAI enemy, Vector3 pos, bool avoidLineOfSight = false, int offset = 0)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			GameObject[] candidateNodes = enemy.allAINodes.OrderByDescending((GameObject node) => Vector3.Distance(pos, node.transform.position)).ToArray();
			yield return null;
			Transform firstAccessibleNode = null;
			int pathsRemaining = offset;
			for (int i = 0; i < candidateNodes.Length; i++)
			{
				Transform transform = candidateNodes[i].transform;
				Vector3 position = transform.position;
				if (!enemy.agent.CalculatePath(position, enemy.path1))
				{
					yield return null;
					continue;
				}
				if ((Object)(object)firstAccessibleNode == (Object)null)
				{
					firstAccessibleNode = transform;
				}
				if (Vector3.Distance(enemy.path1.corners[enemy.path1.corners.Length - 1], RoundManager.Instance.GetNavMeshPosition(position, RoundManager.Instance.navHit, 2.7f, -1)) > 1.5f)
				{
					yield return null;
					continue;
				}
				if (avoidLineOfSight)
				{
					bool flag = false;
					for (int j = 1; j < enemy.path1.corners.Length; j++)
					{
						if (flag)
						{
							break;
						}
						flag = Physics.Linecast(enemy.path1.corners[j - 1], enemy.path1.corners[j], 262144);
					}
					if (flag)
					{
						yield return null;
						continue;
					}
				}
				enemy.mostOptimalDistance = Vector3.Distance(pos, transform.position);
				yield return transform;
				if (pathsRemaining == 0)
				{
					yield break;
				}
				pathsRemaining--;
			}
			if (avoidLineOfSight)
			{
				yield return firstAccessibleNode;
			}
		}
	}
	[HarmonyPatch(typeof(CentipedeAI))]
	public class PatchCentipedeAI
	{
		private static readonly FieldInfo f_CentipedeAI_mainEntrancePosition = AccessTools.Field(typeof(CentipedeAI), "mainEntrancePosition");

		private static readonly FieldInfo f_CentipedeAI_choseHidingSpotNoPlayersNearby = AccessTools.Field(typeof(CentipedeAI), "choseHidingSpotNoPlayersNearby");

		public const string PATCH_NAME = "Snare Flea lag patch";

		public static int NoPlayerToTargetNodeVar = -1;

		public static List<CodeInstruction> NoPlayerToTargetInstructions = null;

		public static void FinishChoosingFarthestNodeFromEntrance(CentipedeAI centipede, Transform node)
		{
			throw Common.StubError("FinishChoosingFarthestNodeFromEntrance", "Snare Flea lag patch");
		}

		private static IEnumerator ChooseFarthestNodeFromEntrance(CentipedeAI centipede, Vector3 position, bool avoidLineOfSight, int offset)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			IEnumerator<Transform> farthestNodeCoroutine = Coroutines.ChooseFarthestNodeFromPosition((EnemyAI)(object)centipede, position, avoidLineOfSight, offset);
			Transform lastTransform = null;
			while (farthestNodeCoroutine.MoveNext())
			{
				if ((Object)(object)farthestNodeCoroutine.Current != (Object)null)
				{
					lastTransform = farthestNodeCoroutine.Current;
				}
				yield return null;
			}
			((EnemyAI)centipede).searchCoroutine = null;
			if (!((Object)(object)farthestNodeCoroutine.Current == (Object)null))
			{
				FinishChoosingFarthestNodeFromEntrance(centipede, lastTransform);
			}
		}

		[HarmonyPatch("DoAIInterval")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> DoAIIntervalTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Expected O, but got Unknown
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Expected O, but got Unknown
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Expected O, but got Unknown
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Expected O, but got Unknown
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Expected O, but got Unknown
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Expected O, but got Unknown
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Expected O, but got Unknown
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Expected O, but got Unknown
			List<CodeInstruction> list = instructions.ToList();
			list.FindIndexOfSequence(new Predicate<CodeInstruction>[2]
			{
				(CodeInstruction insn) => CodeInstructionExtensions.Calls(insn, Reflection.m_EnemyAI_TargetClosestPlayer),
				(CodeInstruction insn) => insn.opcode == OpCodes.Brtrue || insn.opcode == OpCodes.Brtrue_S
			});
			SequenceMatch sequenceMatch = list.FindIndexOfSequence(new Predicate<CodeInstruction>[3]
			{
				(CodeInstruction insn) => CodeInstructionExtensions.IsLdarg(insn, (int?)0),
				(CodeInstruction insn) => CodeInstructionExtensions.LoadsField(insn, f_CentipedeAI_choseHidingSpotNoPlayersNearby, false),
				(CodeInstruction insn) => insn.opcode == OpCodes.Brtrue || insn.opcode == OpCodes.Brtrue_S
			});
			Label hasChosenHidingSpotLabel = (Label)list[sequenceMatch.End - 1].operand;
			int num = list.FindIndex(sequenceMatch.End, (CodeInstruction insn) => insn.labels.Contains(hasChosenHidingSpotLabel)) - 1;
			int num2 = list.FindIndex(sequenceMatch.End, (CodeInstruction insn) => CodeInstructionExtensions.Calls(insn, Reflection.m_EnemyAI_ChooseFarthestNodeFromPosition));
			if (num2 >= num)
			{
				throw new Exception("Unexpected ordering of instructions in CentipedeAI.DoAIInterval().");
			}
			SequenceMatch sequenceMatch2 = list.InstructionRangeForStackItems(num2, 1, 4);
			NoPlayerToTargetInstructions = list.IndexRangeView(sequenceMatch.End, sequenceMatch2.Start).Append(new CodeInstruction(OpCodes.Ldarg_1, (object)null)).Concat(list.IndexRangeView(num2 + 1, num))
				.ToList();
			List<CodeInstruction> second = list.IndexRangeView(sequenceMatch2.Start, sequenceMatch2.End).ToList();
			list.RemoveIndexRange(sequenceMatch.End, num);
			IEnumerable<CodeInstruction> collection = ((IEnumerable<CodeInstruction>)(object)new CodeInstruction[5]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldfld, (object)Reflection.f_EnemyAI_searchCoroutine),
				new CodeInstruction(OpCodes.Brtrue_S, (object)hasChosenHidingSpotLabel),
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldarg_0, (object)null)
			}).Concat(second).Concat((IEnumerable<CodeInstruction>)(object)new CodeInstruction[3]
			{
				CodeInstruction.Call(typeof(PatchCentipedeAI), "ChooseFarthestNodeFromEntrance", new Type[4]
				{
					typeof(CentipedeAI),
					typeof(Vector3),
					typeof(bool),
					typeof(int)
				}, (Type[])null),
				new CodeInstruction(OpCodes.Call, (object)Reflection.m_MonoBehaviour_StartCoroutine),
				new CodeInstruction(OpCodes.Stfld, (object)Reflection.f_EnemyAI_searchCoroutine)
			});
			list.InsertRange(sequenceMatch.End, collection);
			return list;
		}
	}
	[HarmonyPatch(typeof(PatchCentipedeAI))]
	internal class PatchCopyVanillaCentipedeCode
	{
		[HarmonyPatch("FinishChoosingFarthestNodeFromEntrance")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> PatchCentipedeAI_FinishChoosingFarthestNodeFromEntranceTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			List<CodeInstruction> noPlayerToTargetInstructions = PatchCentipedeAI.NoPlayerToTargetInstructions;
			noPlayerToTargetInstructions.TransferLabelsAndVariables(generator);
			return noPlayerToTargetInstructions.Append(new CodeInstruction(OpCodes.Ret, (object)null));
		}
	}
	[HarmonyPatch(typeof(FlowermanAI))]
	public class PatchFlowermanAI
	{
		private static readonly FieldInfo f_FlowermanAI_mainEntrancePosition = AccessTools.Field(typeof(FlowermanAI), "mainEntrancePosition");

		public const string PATCH_NAME = "Bracken lag patch";

		public static int NoPlayerToTargetNodeVar = -1;

		public static List<CodeInstruction> NoPlayerToTargetInstructions = null;

		public static List<CodeInstruction> AvoidClosestPlayerInstructions = null;

		public static void FinishChoosingFarthestNodeFromEntrance(FlowermanAI flowerman, Transform node)
		{
			throw Common.StubError("FinishChoosingFarthestNodeFromEntrance", "Bracken lag patch");
		}

		private static IEnumerator ChooseFarthestNodeFromEntrance(FlowermanAI flowerman, Vector3 mainEntrancePosition)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			IEnumerator<Transform> farthestNodeCoroutine = Coroutines.ChooseFarthestNodeFromPosition((EnemyAI)(object)flowerman, mainEntrancePosition);
			Transform lastTransform = null;
			while (farthestNodeCoroutine.MoveNext())
			{
				if ((Object)(object)farthestNodeCoroutine.Current != (Object)null)
				{
					lastTransform = farthestNodeCoroutine.Current;
				}
				yield return null;
			}
			((EnemyAI)flowerman).searchCoroutine = null;
			if (!((Object)(object)farthestNodeCoroutine.Current == (Object)null))
			{
				FinishChoosingFarthestNodeFromEntrance(flowerman, lastTransform);
			}
		}

		[HarmonyPatch("DoAIInterval")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> DoAIIntervalTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Expected O, but got Unknown
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Expected O, but got Unknown
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Expected O, but got Unknown
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Expected O, but got Unknown
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Expected O, but got Unknown
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Expected O, but got Unknown
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Expected O, but got Unknown
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Expected O, but got Unknown
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Expected O, but got Unknown
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Expected O, but got Unknown
			List<CodeInstruction> list = instructions.ToList();
			Label? noPlayerTargetLabel = null;
			list.FindIndexOfSequence(new Predicate<CodeInstruction>[2]
			{
				(CodeInstruction insn) => CodeInstructionExtensions.Calls(insn, Reflection.m_EnemyAI_TargetClosestPlayer),
				(CodeInstruction insn) => CodeInstructionExtensions.Branches(insn, ref noPlayerTargetLabel)
			});
			int num = list.FindIndex((CodeInstruction insn) => insn.labels.Contains(noPlayerTargetLabel.Value));
			Label afterNoPlayerTargetLabel = (Label)list[num - 1].operand;
			int end = list.FindIndex(num, (CodeInstruction insn) => insn.labels.Contains(afterNoPlayerTargetLabel));
			SequenceMatch sequenceMatch = list.FindIndexOfSequence(num, new Predicate<CodeInstruction>[8]
			{
				(CodeInstruction insn) => CodeInstructionExtensions.IsLdarg(insn, (int?)0),
				(CodeInstruction insn) => CodeInstructionExtensions.IsLdarg(insn, (int?)0),
				(CodeInstruction insn) => CodeInstructionExtensions.LoadsField(insn, f_FlowermanAI_mainEntrancePosition, false),
				(CodeInstruction insn) => CodeInstructionExtensions.LoadsConstant(insn, 0L),
				(CodeInstruction insn) => CodeInstructionExtensions.LoadsConstant(insn, 0L),
				(CodeInstruction insn) => CodeInstructionExtensions.LoadsConstant(insn, 0L),
				(CodeInstruction insn) => CodeInstructionExtensions.Calls(insn, Reflection.m_EnemyAI_ChooseFarthestNodeFromPosition),
				(CodeInstruction insn) => CodeInstructionExtensions.IsStloc(insn, (LocalBuilder)null)
			});
			NoPlayerToTargetNodeVar = list[sequenceMatch.End - 1].GetLocalIndex();
			NoPlayerToTargetInstructions = list.IndexRangeView(sequenceMatch.End, end).ToList();
			Label[] array = list[sequenceMatch.Start].labels.ToArray();
			list.RemoveIndexRange(sequenceMatch.Start, end);
			Label label = generator.DefineLabel();
			list[sequenceMatch.Start].labels.Add(label);
			list.InsertRange(sequenceMatch.Start, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[11]
			{
				CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldarg_0, (object)null), array),
				new CodeInstruction(OpCodes.Ldfld, (object)Reflection.f_EnemyAI_searchCoroutine),
				new CodeInstruction(OpCodes.Brtrue_S, (object)label),
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldfld, (object)f_FlowermanAI_mainEntrancePosition),
				CodeInstruction.Call(typeof(PatchFlowermanAI), "ChooseFarthestNodeFromEntrance", new Type[2]
				{
					typeof(FlowermanAI),
					typeof(Vector3)
				}, (Type[])null),
				new CodeInstruction(OpCodes.Callvirt, (object)Reflection.m_MonoBehaviour_StartCoroutine),
				new CodeInstruction(OpCodes.Stfld, (object)Reflection.f_EnemyAI_searchCoroutine)
			});
			return list;
		}

		public static void FinishChoosingPlayerEvasionLocation(FlowermanAI flowerman, Transform node)
		{
			throw Common.StubError("FinishChoosingPlayerEvasionLocation", "Bracken lag patch");
		}

		public static IEnumerator ChoosePlayerEvasionLocation(FlowermanAI flowerman)
		{
			IEnumerator<Transform> farthestNodeCoroutine = Coroutines.ChooseFarthestNodeFromPosition((EnemyAI)(object)flowerman, ((Component)((EnemyAI)flowerman).targetPlayer).transform.position, avoidLineOfSight: true);
			Transform lastTransform = null;
			while (farthestNodeCoroutine.MoveNext())
			{
				if ((Object)(object)farthestNodeCoroutine.Current != (Object)null)
				{
					lastTransform = farthestNodeCoroutine.Current;
				}
				yield return null;
			}
			((EnemyAI)flowerman).searchCoroutine = null;
			if ((Object)(object)farthestNodeCoroutine.Current == (Object)null)
			{
				Plugin.Instance.Logger.LogWarning((object)"Failed to find avoid player target.");
			}
			else
			{
				FinishChoosingPlayerEvasionLocation(flowerman, lastTransform);
			}
		}

		[HarmonyPatch("AvoidClosestPlayer")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> DoAvoidClosestPlayerTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Expected O, but got Unknown
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Expected O, but got Unknown
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Expected O, but got Unknown
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Expected O, but got Unknown
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Expected O, but got Unknown
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Expected O, but got Unknown
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Expected O, but got Unknown
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Expected O, but got Unknown
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Expected O, but got Unknown
			List<CodeInstruction> list = instructions.ToList();
			SequenceMatch sequenceMatch = list.FindIndexOfSequence(new Predicate<CodeInstruction>[10]
			{
				(CodeInstruction insn) => CodeInstructionExtensions.IsLdarg(insn, (int?)0),
				(CodeInstruction insn) => CodeInstructionExtensions.IsLdarg(insn, (int?)0),
				(CodeInstruction insn) => CodeInstructionExtensions.LoadsField(insn, Reflection.f_EnemyAI_targetPlayer, false),
				(CodeInstruction insn) => CodeInstructionExtensions.Calls(insn, Reflection.m_Component_get_transform),
				(CodeInstruction insn) => CodeInstructionExtensions.Calls(insn, Reflection.m_Transform_get_position),
				(CodeInstruction insn) => CodeInstructionExtensions.LoadsConstant(insn, 1L),
				(CodeInstruction insn) => CodeInstructionExtensions.LoadsConstant(insn, 0L),
				(CodeInstruction insn) => CodeInstructionExtensions.LoadsConstant(insn, 1L),
				(CodeInstruction insn) => CodeInstructionExtensions.Calls(insn, Reflection.m_EnemyAI_ChooseFarthestNodeFromPosition),
				(CodeInstruction insn) => CodeInstructionExtensions.IsStloc(insn, (LocalBuilder)null)
			});
			int end = list.FindLastIndex((CodeInstruction insn) => insn.opcode == OpCodes.Ret);
			AvoidClosestPlayerInstructions = list.IndexRangeView(sequenceMatch.End, end).ToList();
			Label label = generator.DefineLabel();
			return (IEnumerable<CodeInstruction>)(object)new CodeInstruction[10]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldfld, (object)Reflection.f_EnemyAI_searchCoroutine),
				new CodeInstruction(OpCodes.Brtrue_S, (object)label),
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				CodeInstruction.Call(typeof(PatchFlowermanAI), "ChoosePlayerEvasionLocation", new Type[1] { typeof(FlowermanAI) }, (Type[])null),
				new CodeInstruction(OpCodes.Callvirt, (object)Reflection.m_MonoBehaviour_StartCoroutine),
				new CodeInstruction(OpCodes.Stfld, (object)Reflection.f_EnemyAI_searchCoroutine),
				CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ret, (object)null), new Label[1] { label })
			};
		}
	}
	[HarmonyPatch(typeof(PatchFlowermanAI))]
	internal class PatchCopyVanillaFlowermanCode
	{
		[HarmonyPatch("FinishChoosingPlayerEvasionLocation")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> PatchFlowermanAI_FinishChoosingPlayerEvasionLocationTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			if (PatchFlowermanAI.AvoidClosestPlayerInstructions == null)
			{
				throw Common.PatchError("Code was not copied from FlowermanAI.AvoidPlayerTarget()", "Bracken lag patch");
			}
			CodeInstruction[] array = PatchFlowermanAI.AvoidClosestPlayerInstructions.ToArray();
			if (!CodeInstructionExtensions.IsLdloc(array[0], (LocalBuilder)null))
			{
				throw Common.PatchError("Copied code from FlowermanAI.AvoidPlayerTarget() does not begin with an ldloc", "Bracken lag patch");
			}
			LocalBuilder localBuilder = (LocalBuilder)array[0].operand;
			for (int i = 0; i < array.Length; i++)
			{
				CodeInstruction val = array[i];
				if (CodeInstructionExtensions.IsLdloc(val, localBuilder))
				{
					array[i] = CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldarg_1, (object)null), (IEnumerable<Label>)val.labels);
				}
			}
			array.TransferLabelsAndVariables(generator);
			return array.Append(new CodeInstruction(OpCodes.Ret, (object)null));
		}

		[HarmonyPatch("FinishChoosingFarthestNodeFromEntrance")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> PatchFlowermanAI_FinishChoosingFarthestNodeFromEntranceTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			if (PatchFlowermanAI.NoPlayerToTargetNodeVar == -1)
			{
				throw Common.PatchError("Target node variable was not found in DoAIInterval()", "Bracken lag patch");
			}
			if (PatchFlowermanAI.NoPlayerToTargetInstructions == null)
			{
				throw Common.PatchError("Code was not copied from DoAIInterval()", "Bracken lag patch");
			}
			List<CodeInstruction> noPlayerToTargetInstructions = PatchFlowermanAI.NoPlayerToTargetInstructions;
			int noPlayerToTargetNodeVar = PatchFlowermanAI.NoPlayerToTargetNodeVar;
			PatchFlowermanAI.NoPlayerToTargetInstructions = null;
			PatchFlowermanAI.NoPlayerToTargetNodeVar = -1;
			for (int i = 0; i < noPlayerToTargetInstructions.Count(); i++)
			{
				CodeInstruction val = noPlayerToTargetInstructions[i];
				if (CodeInstructionExtensions.IsLdloc(val, (LocalBuilder)null) && val.GetLocalIndex() == noPlayerToTargetNodeVar)
				{
					noPlayerToTargetInstructions[i] = CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldarg_1, (object)null), (IEnumerable<Label>)val.labels);
				}
			}
			noPlayerToTargetInstructions.TransferLabelsAndVariables(generator);
			return noPlayerToTargetInstructions.Append(new CodeInstruction(OpCodes.Ret, (object)null));
		}
	}
	[HarmonyPatch(typeof(PufferAI))]
	public class PatchPufferAI
	{
		private static readonly FieldInfo f_PufferAI_closestSeenPlayer = AccessTools.Field(typeof(PufferAI), "closestSeenPlayer");

		public const string PATCH_NAME = "Spore Lizard lag patch";

		public static List<CodeInstruction> AvoidClosestPlayerInstructions = null;

		public static void FinishChoosingPlayerEvasionLocation(PufferAI puffer, Transform node)
		{
			throw Common.StubError("FinishChoosingPlayerEvasionLocation stub was called", "Spore Lizard lag patch");
		}

		public static IEnumerator ChoosePlayerEvasionLocation(PufferAI puffer, Vector3 origin)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			IEnumerator<Transform> farthestNodeCoroutine = Coroutines.ChooseFarthestNodeFromPosition((EnemyAI)(object)puffer, origin, avoidLineOfSight: true);
			Transform lastTransform = null;
			while (farthestNodeCoroutine.MoveNext())
			{
				if ((Object)(object)farthestNodeCoroutine.Current != (Object)null)
				{
					lastTransform = farthestNodeCoroutine.Current;
				}
				yield return null;
			}
			((EnemyAI)puffer).currentSearch = puffer.roamMap;
			if ((Object)(object)farthestNodeCoroutine.Current == (Object)null)
			{
				Plugin.Instance.Logger.LogWarning((object)"Failed to find avoid player target.");
			}
			else
			{
				FinishChoosingPlayerEvasionLocation(puffer, lastTransform);
			}
		}

		[HarmonyPatch("AvoidClosestPlayer")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> DoAvoidClosestPlayerTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Expected O, but got Unknown
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Expected O, but got Unknown
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Expected O, but got Unknown
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Expected O, but got Unknown
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Expected O, but got Unknown
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Expected O, but got Unknown
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Expected O, but got Unknown
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Expected O, but got Unknown
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Expected O, but got Unknown
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Expected O, but got Unknown
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Expected O, but got Unknown
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Expected O, but got Unknown
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Expected O, but got Unknown
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Expected O, but got Unknown
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Expected O, but got Unknown
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Expected O, but got Unknown
			List<CodeInstruction> list = instructions.ToList();
			SequenceMatch sequenceMatch = list.FindIndexOfSequence(new Predicate<CodeInstruction>[10]
			{
				(CodeInstruction insn) => CodeInstructionExtensions.IsLdarg(insn, (int?)0),
				(CodeInstruction insn) => CodeInstructionExtensions.IsLdarg(insn, (int?)0),
				(CodeInstruction insn) => CodeInstructionExtensions.LoadsField(insn, f_PufferAI_closestSeenPlayer, false),
				(CodeInstruction insn) => CodeInstructionExtensions.Calls(insn, Reflection.m_Component_get_transform),
				(CodeInstruction insn) => CodeInstructionExtensions.Calls(insn, Reflection.m_Transform_get_position),
				(CodeInstruction insn) => CodeInstructionExtensions.LoadsConstant(insn, 1L),
				(CodeInstruction insn) => CodeInstructionExtensions.LoadsConstant(insn, 0L),
				(CodeInstruction insn) => CodeInstructionExtensions.LoadsConstant(insn, 0L),
				(CodeInstruction insn) => CodeInstructionExtensions.Calls(insn, Reflection.m_EnemyAI_ChooseFarthestNodeFromPosition),
				(CodeInstruction insn) => CodeInstructionExtensions.IsStloc(insn, (LocalBuilder)null)
			});
			AvoidClosestPlayerInstructions = list.IndexRangeView(sequenceMatch.End, list.Count()).ToList();
			Label label = generator.DefineLabel();
			Label label2 = generator.DefineLabel();
			return (IEnumerable<CodeInstruction>)(object)new CodeInstruction[17]
			{
				CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldarg_0, (object)null), new Label[1] { label }),
				new CodeInstruction(OpCodes.Ldfld, (object)Reflection.f_EnemyAI_currentSearch),
				new CodeInstruction(OpCodes.Brfalse_S, (object)label2),
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldfld, (object)f_PufferAI_closestSeenPlayer),
				new CodeInstruction(OpCodes.Call, (object)Reflection.m_Component_get_transform),
				new CodeInstruction(OpCodes.Call, (object)Reflection.m_Transform_get_position),
				CodeInstruction.Call(typeof(PatchPufferAI), "ChoosePlayerEvasionLocation", new Type[2]
				{
					typeof(PufferAI),
					typeof(Vector3)
				}, (Type[])null),
				new CodeInstruction(OpCodes.Callvirt, (object)Reflection.m_MonoBehaviour_StartCoroutine),
				new CodeInstruction(OpCodes.Stfld, (object)Reflection.f_EnemyAI_searchCoroutine),
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldnull, (object)null),
				new CodeInstruction(OpCodes.Stfld, (object)Reflection.f_EnemyAI_currentSearch),
				CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ret, (object)null), new Label[1] { label2 })
			};
		}
	}
	[HarmonyPatch(typeof(PatchPufferAI))]
	internal class PatchCopyVanillaPufferCode
	{
		[HarmonyPatch("FinishChoosingPlayerEvasionLocation")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> PatchPufferAI_FinishChoosingPlayerEvasionLocationTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			if (PatchPufferAI.AvoidClosestPlayerInstructions == null)
			{
				throw Common.PatchError("Code was not copied from PufferAI.AvoidPlayerTarget()", "Spore Lizard lag patch");
			}
			List<CodeInstruction> list = instructions.ToList();
			CodeInstruction[] array = PatchPufferAI.AvoidClosestPlayerInstructions.ToArray();
			if (!CodeInstructionExtensions.IsLdloc(array[0], (LocalBuilder)null))
			{
				throw Common.PatchError("Copied code from PufferAI.AvoidPlayerTarget() does not begin with an ldloc", "Spore Lizard lag patch");
			}
			LocalBuilder localBuilder = (LocalBuilder)array[0].operand;
			for (int i = 0; i < array.Length; i++)
			{
				CodeInstruction val = array[i];
				if (CodeInstructionExtensions.IsLdloc(val, localBuilder))
				{
					array[i] = CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldarg_1, (object)null), (IEnumerable<Label>)val.labels);
				}
			}
			array.TransferLabelsAndVariables(generator);
			list.FindIndex((CodeInstruction insn) => insn.opcode == OpCodes.Ret);
			return array.Append(new CodeInstruction(OpCodes.Ret, (object)null));
		}
	}
	public static class Reflection
	{
		public static readonly MethodInfo m_Debug_Log = typeof(Debug).GetMethod("Log", new Type[1] { typeof(object) });

		public static readonly MethodInfo m_EnemyAI_DoAIInterval = typeof(EnemyAI).GetMethod("DoAIInterval", new Type[0]);

		public static readonly MethodInfo m_EnemyAI_TargetClosestPlayer = typeof(EnemyAI).GetMethod("TargetClosestPlayer", new Type[3]
		{
			typeof(float),
			typeof(bool),
			typeof(float)
		});

		public static readonly MethodInfo m_EnemyAI_ChooseFarthestNodeFromPosition = typeof(EnemyAI).GetMethod("ChooseFarthestNodeFromPosition", new Type[4]
		{
			typeof(Vector3),
			typeof(bool),
			typeof(int),
			typeof(bool)
		});

		public static readonly MethodInfo m_EnemyAI_SetDestinationToPosition = typeof(EnemyAI).GetMethod("SetDestinationToPosition", new Type[2]
		{
			typeof(Vector3),
			typeof(bool)
		});

		public static readonly FieldInfo f_EnemyAI_targetNode = typeof(EnemyAI).GetField("targetNode");

		public static readonly FieldInfo f_EnemyAI_targetPlayer = typeof(EnemyAI).GetField("targetPlayer");

		public static readonly FieldInfo f_EnemyAI_favoriteSpot = typeof(EnemyAI).GetField("favoriteSpot");

		public static readonly FieldInfo f_EnemyAI_searchCoroutine = typeof(EnemyAI).GetField("searchCoroutine");

		public static readonly FieldInfo f_EnemyAI_currentSearch = typeof(EnemyAI).GetField("currentSearch");

		public static readonly MethodInfo m_MonoBehaviour_StartCoroutine = typeof(MonoBehaviour).GetMethod("StartCoroutine", new Type[1] { typeof(IEnumerator) });

		public static readonly MethodInfo m_MonoBehaviour_StopCoroutine = typeof(MonoBehaviour).GetMethod("StopCoroutine", new Type[1] { typeof(Coroutine) });

		public static readonly MethodInfo m_Component_get_transform = typeof(Component).GetMethod("get_transform", new Type[0]);

		public static readonly MethodInfo m_Transform_get_position = typeof(Transform).GetMethod("get_position", new Type[0]);

		public static readonly MethodInfo m_Object_op_Equality = typeof(Object).GetMethod("op_Equality", new Type[2]
		{
			typeof(Object),
			typeof(Object)
		});
	}
}

BepInEx/plugins/Rune580-LethalCompany_InputUtils-0.6.3/plugins/LethalCompanyInputUtils/LethalCompanyInputUtils.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using LethalCompanyInputUtils.Components;
using LethalCompanyInputUtils.Components.Section;
using LethalCompanyInputUtils.Data;
using LethalCompanyInputUtils.Glyphs;
using LethalCompanyInputUtils.Utils;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.SceneManagement;
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("LethalCompanyInputUtils")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+913017c58a6ad55b5050a44817920ad9c63ce200")]
[assembly: AssemblyProduct("LethalCompanyInputUtils")]
[assembly: AssemblyTitle("LethalCompanyInputUtils")]
[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.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 LethalCompanyInputUtils
{
	public static class LcInputActionApi
	{
		private static readonly Dictionary<string, LcInputActions> InputActionsMap = new Dictionary<string, LcInputActions>();

		internal static bool PrefabLoaded;

		internal static RemapContainerController? ContainerInstance;

		internal static IReadOnlyCollection<LcInputActions> InputActions => InputActionsMap.Values;

		internal static void LoadIntoUI(KepRemapPanel panel)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			AdjustSizeAndPos(panel);
			LayoutElement val = EnsureLayoutElement(panel);
			panel.LoadKeybindsUI();
			float horizontalOffset = panel.horizontalOffset;
			Rect rect = ((Component)((Transform)panel.keyRemapContainer).parent).GetComponent<RectTransform>().rect;
			float num = Mathf.Floor(((Rect)(ref rect)).width / horizontalOffset);
			int count = panel.keySlots.Count;
			int num2 = NumberOfActualKeys(panel.keySlots);
			int num3 = count - num2;
			panel.maxVertical = (float)num2 / num + (float)num3;
			if (ContainerInstance != null && ContainerInstance.legacyButton != null)
			{
				((TMP_Text)((Component)ContainerInstance.legacyButton).GetComponentInChildren<TextMeshProUGUI>()).SetText($"> Show Legacy Controls ({num2} present)", true);
			}
			if (count == 0)
			{
				return;
			}
			val.minHeight = (panel.maxVertical + 1f) * panel.verticalOffset;
			int num4 = 0;
			int num5 = 0;
			foreach (GameObject keySlot in panel.keySlots)
			{
				if ((float)num5 > num)
				{
					num4++;
					num5 = 0;
				}
				keySlot.GetComponent<RectTransform>().anchoredPosition = new Vector2((float)num5 * panel.horizontalOffset, (float)num4 * (0f - panel.verticalOffset));
				if (keySlot.GetComponentInChildren<SettingsOption>() == null)
				{
					num5 = 0;
					num4++;
				}
				else
				{
					num5++;
				}
			}
		}

		public static bool RemapContainerVisible()
		{
			if (ContainerInstance == null)
			{
				return false;
			}
			return ContainerInstance.LayerShown > 0;
		}

		private static int NumberOfActualKeys(List<GameObject> keySlots)
		{
			int num = 0;
			foreach (GameObject keySlot in keySlots)
			{
				if (keySlot.GetComponentInChildren<SettingsOption>() != null)
				{
					num++;
				}
			}
			return num;
		}

		internal static void CloseContainerLayer()
		{
			if (ContainerInstance != null)
			{
				ContainerInstance.HideHighestLayer();
			}
		}

		private static void AdjustSizeAndPos(KepRemapPanel panel)
		{
			GameObject gameObject = ((Component)((Transform)panel.keyRemapContainer).parent).gameObject;
			if (gameObject.GetComponent<ContentSizeFitter>() == null)
			{
				panel.keyRemapContainer.SetPivotY(1f);
				panel.keyRemapContainer.SetAnchorMinY(1f);
				panel.keyRemapContainer.SetAnchorMaxY(1f);
				panel.keyRemapContainer.SetAnchoredPosY(0f);
				panel.keyRemapContainer.SetLocalPosY(0f);
				ContentSizeFitter obj = gameObject.AddComponent<ContentSizeFitter>();
				obj.horizontalFit = (FitMode)0;
				obj.verticalFit = (FitMode)1;
			}
		}

		private static LayoutElement EnsureLayoutElement(KepRemapPanel panel)
		{
			GameObject gameObject = ((Component)((Transform)panel.keyRemapContainer).parent).gameObject;
			LayoutElement component = gameObject.GetComponent<LayoutElement>();
			if (component != null)
			{
				return component;
			}
			return gameObject.AddComponent<LayoutElement>();
		}

		internal static void CalculateVerticalMaxForGamepad(KepRemapPanel panel)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			int num = panel.remappableKeys.Count((RemappableKey key) => key.gamepadOnly);
			float horizontalOffset = panel.horizontalOffset;
			Rect rect = ((Component)((Transform)panel.keyRemapContainer).parent).GetComponent<RectTransform>().rect;
			float num2 = Mathf.Floor(((Rect)(ref rect)).width / horizontalOffset);
			panel.maxVertical = (float)num / num2;
			LayoutElement obj = EnsureLayoutElement(panel);
			obj.minHeight += (panel.maxVertical + 3f) * panel.verticalOffset;
		}

		internal static void ResetLoadedInputActions()
		{
			PrefabLoaded = false;
			foreach (LcInputActions inputAction in InputActions)
			{
				inputAction.Loaded = false;
			}
		}

		internal static void RegisterInputActions(LcInputActions lcInputActions, InputActionMapBuilder builder)
		{
			if (!InputActionsMap.TryAdd(lcInputActions.Id, lcInputActions))
			{
				Logging.Warn("The mod [" + lcInputActions.Plugin.GUID + "] instantiated an Actions class [" + lcInputActions.GetType().Name + "] more than once!\n\t These classes should be treated as singletons!, do not instantiate more than once!");
			}
			else
			{
				lcInputActions.CreateInputActions(in builder);
				InputActionSetupExtensions.AddActionMap(lcInputActions.GetAsset(), builder.Build());
				lcInputActions.GetAsset().Enable();
				lcInputActions.OnAssetLoaded();
				lcInputActions.Load();
				lcInputActions.BuildActionRefs();
			}
		}

		internal static void DisableForRebind()
		{
			foreach (LcInputActions inputAction in InputActions)
			{
				if (inputAction.Enabled)
				{
					inputAction.Disable();
				}
			}
		}

		internal static void ReEnableFromRebind()
		{
			foreach (LcInputActions inputAction in InputActions)
			{
				if (inputAction.WasEnabled)
				{
					inputAction.Enable();
				}
			}
		}

		internal static void SaveOverrides()
		{
			foreach (LcInputActions inputAction in InputActions)
			{
				inputAction.Save();
			}
		}

		internal static void LoadOverrides()
		{
			foreach (LcInputActions inputAction in InputActions)
			{
				inputAction.Load();
			}
		}
	}
	[BepInPlugin("com.rune580.LethalCompanyInputUtils", "Lethal Company Input Utils", "0.6.3")]
	public class LethalCompanyInputUtilsPlugin : BaseUnityPlugin
	{
		public const string ModId = "com.rune580.LethalCompanyInputUtils";

		public const string ModName = "Lethal Company Input Utils";

		public const string ModVersion = "0.6.3";

		private Harmony? _harmony;

		private void Awake()
		{
			Logging.SetLogSource(((BaseUnityPlugin)this).Logger);
			_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.rune580.LethalCompanyInputUtils");
			SceneManager.activeSceneChanged += OnSceneChanged;
			InputSystem.onDeviceChange += OnDeviceChanged;
			LoadAssetBundles();
			ControllerGlyph.LoadGlyphs();
			FsUtils.EnsureControlsDir();
			RegisterExtendedMouseLayout();
			Logging.Info("InputUtils 0.6.3 has finished loading!");
		}

		private void LoadAssetBundles()
		{
			Assets.AddBundle("ui-assets");
		}

		private static void OnSceneChanged(Scene current, Scene next)
		{
			LcInputActionApi.ResetLoadedInputActions();
			CameraUtils.ClearUiCameraReference();
			BindsListController.OffsetCompensation = ((((Scene)(ref next)).name != "MainMenu") ? 20 : 0);
		}

		private static void OnDeviceChanged(InputDevice device, InputDeviceChange state)
		{
			RebindButton.ReloadGlyphs();
		}

		private static void RegisterExtendedMouseLayout()
		{
			InputSystem.RegisterLayoutOverride("{\n   \"name\": \"InputUtilsExtendedMouse\",\n   \"extend\": \"Mouse\",\n   \"controls\": [\n       {\n           \"name\": \"scroll/up\",\n           \"layout\": \"Button\",\n           \"useStateFrom\": \"scroll/up\",\n           \"format\": \"BIT\",\n           \"synthetic\": true\n       },\n       {\n           \"name\": \"scroll/down\",\n           \"layout\": \"Button\",\n           \"useStateFrom\": \"scroll/down\",\n           \"format\": \"BIT\",\n           \"synthetic\": true\n       },\n       {\n           \"name\": \"scroll/left\",\n           \"layout\": \"Button\",\n           \"useStateFrom\": \"scroll/left\",\n           \"format\": \"BIT\",\n           \"synthetic\": true\n       },\n       {\n           \"name\": \"scroll/right\",\n           \"layout\": \"Button\",\n           \"useStateFrom\": \"scroll/right\",\n           \"format\": \"BIT\",\n           \"synthetic\": true\n       }\n   ]\n}", (string)null);
			Logging.Info("Registered InputUtilsExtendedMouse Layout Override!");
		}
	}
}
namespace LethalCompanyInputUtils.Utils
{
	internal static class AssemblyUtils
	{
		public static BepInPlugin? GetBepInPlugin(this Assembly assembly)
		{
			foreach (Type validType in assembly.GetValidTypes())
			{
				BepInPlugin customAttribute = ((MemberInfo)validType).GetCustomAttribute<BepInPlugin>();
				if (customAttribute != null)
				{
					return customAttribute;
				}
			}
			return null;
		}

		public static IEnumerable<Type> GetValidTypes(this Assembly assembly)
		{
			try
			{
				return assembly.GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				return ex.Types.Where((Type type) => (object)type != null);
			}
		}
	}
	internal static class Assets
	{
		private static readonly List<AssetBundle> AssetBundles = new List<AssetBundle>();

		private static readonly Dictionary<string, int> AssetIndices = new Dictionary<string, int>();

		public static void AddBundle(string bundleName)
		{
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(FsUtils.AssetBundlesDir, bundleName));
			int count = AssetBundles.Count;
			AssetBundles.Add(val);
			string[] allAssetNames = val.GetAllAssetNames();
			for (int i = 0; i < allAssetNames.Length; i++)
			{
				string text = allAssetNames[i].ToLowerInvariant();
				if (text.StartsWith("assets/"))
				{
					string text2 = text;
					int length = "assets/".Length;
					text = text2.Substring(length, text2.Length - length);
				}
				AssetIndices[text] = count;
			}
		}

		public static T? Load<T>(string assetName) where T : Object
		{
			try
			{
				assetName = assetName.ToLowerInvariant();
				if (assetName.StartsWith("assets/"))
				{
					string text = assetName;
					int length = "assets/".Length;
					assetName = text.Substring(length, text.Length - length);
				}
				int index = AssetIndices[assetName];
				return AssetBundles[index].LoadAsset<T>("assets/" + assetName);
			}
			catch (Exception arg)
			{
				Logging.Error($"Couldn't load asset [{assetName}] exception: {arg}");
				return default(T);
			}
		}
	}
	internal static class CameraUtils
	{
		private static Camera? _uiCamera;

		public static Camera GetBestUiCamera()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (_uiCamera != null && Object.op_Implicit((Object)(object)_uiCamera))
			{
				return _uiCamera;
			}
			_uiCamera = null;
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name == "MainMenu")
			{
				GameObject val = ((IEnumerable<GameObject>)((Scene)(ref activeScene)).GetRootGameObjects()).FirstOrDefault((Func<GameObject, bool>)((GameObject go) => ((Object)go).name == "UICamera"));
				if (val == null)
				{
					Logging.Warn("Failed to find UICamera at MainMenu, falling back to Camera.current!");
					return Camera.current;
				}
				Camera component = val.GetComponent<Camera>();
				if (component == null)
				{
					Logging.Warn("Failed to find Camera component on UICamera, falling back to Camera.current!");
					return Camera.current;
				}
				_uiCamera = component;
			}
			else
			{
				GameObject val2 = ((IEnumerable<GameObject>)((Scene)(ref activeScene)).GetRootGameObjects()).FirstOrDefault((Func<GameObject, bool>)((GameObject go) => ((Object)go).name == "Systems"));
				if (val2 == null)
				{
					Logging.Warn("Failed to find UICamera in active scene, falling back to Camera.current!");
					return Camera.current;
				}
				Transform val3 = val2.transform.Find("UI/UICamera");
				if (val3 == null)
				{
					Logging.Warn("Failed to find UICamera at MainMenu, falling back to Camera.current!");
					return Camera.current;
				}
				Camera component2 = ((Component)val3).GetComponent<Camera>();
				if (component2 == null)
				{
					Logging.Warn("Failed to find Camera component on UICamera, falling back to Camera.current!");
					return Camera.current;
				}
				_uiCamera = component2;
			}
			return _uiCamera;
		}

		public static void ClearUiCameraReference()
		{
			_uiCamera = null;
		}
	}
	internal static class DebugUtils
	{
		public static string ToPrettyString<TKey, TValue>(this IDictionary<TKey, TValue> dictionary)
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("{");
			using (IEnumerator<KeyValuePair<TKey, TValue>> enumerator = dictionary.GetEnumerator())
			{
				string[] obj;
				object obj3;
				for (; enumerator.MoveNext(); obj[3] = (string)obj3, obj[4] = "\",", stringBuilder.AppendLine(string.Concat(obj)))
				{
					enumerator.Current.Deconstruct(out var key, out var value);
					TKey val = key;
					TValue val2 = value;
					obj = new string[5] { "\t\"", null, null, null, null };
					ref TKey reference = ref val;
					key = default(TKey);
					object obj2;
					if (key == null)
					{
						key = reference;
						reference = ref key;
						if (key == null)
						{
							obj2 = null;
							goto IL_007c;
						}
					}
					obj2 = reference.ToString();
					goto IL_007c;
					IL_007c:
					obj[1] = (string)obj2;
					obj[2] = "\": \"";
					ref TValue reference2 = ref val2;
					value = default(TValue);
					if (value == null)
					{
						value = reference2;
						reference2 = ref value;
						if (value == null)
						{
							obj3 = null;
							continue;
						}
					}
					obj3 = reference2.ToString();
				}
			}
			stringBuilder.Remove(stringBuilder.Length - 1, 1);
			stringBuilder.AppendLine("}");
			return stringBuilder.ToString();
		}

		public static void DrawGizmoUiRectWorld(this RectTransform rectTransform)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			float z = ((Transform)rectTransform).position.z;
			Rect val = rectTransform.UiBoundsWorld();
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(((Rect)(ref val)).min.x, ((Rect)(ref val)).min.y, z);
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(((Rect)(ref val)).min.x, ((Rect)(ref val)).max.y, z);
			Vector3 val4 = default(Vector3);
			((Vector3)(ref val4))..ctor(((Rect)(ref val)).max.x, ((Rect)(ref val)).max.y, z);
			Vector3 val5 = default(Vector3);
			((Vector3)(ref val5))..ctor(((Rect)(ref val)).max.x, ((Rect)(ref val)).min.y, z);
			Gizmos.DrawLine(val2, val3);
			Gizmos.DrawLine(val3, val4);
			Gizmos.DrawLine(val4, val5);
			Gizmos.DrawLine(val5, val2);
		}

		public static void DrawGizmoUiRect(this RectTransform rectTransform, Vector3 position)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			float z = position.z;
			Rect val = rectTransform.UiBounds(position);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(((Rect)(ref val)).min.x, ((Rect)(ref val)).min.y, z);
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(((Rect)(ref val)).min.x, ((Rect)(ref val)).max.y, z);
			Vector3 val4 = default(Vector3);
			((Vector3)(ref val4))..ctor(((Rect)(ref val)).max.x, ((Rect)(ref val)).max.y, z);
			Vector3 val5 = default(Vector3);
			((Vector3)(ref val5))..ctor(((Rect)(ref val)).max.x, ((Rect)(ref val)).min.y, z);
			Gizmos.DrawLine(val2, val3);
			Gizmos.DrawLine(val3, val4);
			Gizmos.DrawLine(val4, val5);
			Gizmos.DrawLine(val5, val2);
		}

		public static void DrawGizmoRect(this Rect rect, Vector3 position)
		{
			//IL_0000: 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_001e: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			float z = position.z;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(((Rect)(ref rect)).min.x + position.x, ((Rect)(ref rect)).min.y + position.y, z);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(((Rect)(ref rect)).min.x + position.x, ((Rect)(ref rect)).max.y + position.y, z);
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(((Rect)(ref rect)).max.x + position.x, ((Rect)(ref rect)).max.y + position.y, z);
			Vector3 val4 = default(Vector3);
			((Vector3)(ref val4))..ctor(((Rect)(ref rect)).max.x + position.x, ((Rect)(ref rect)).min.y + position.y, z);
			Gizmos.DrawLine(val, val2);
			Gizmos.DrawLine(val2, val3);
			Gizmos.DrawLine(val3, val4);
			Gizmos.DrawLine(val4, val);
		}
	}
	internal static class DeconstructUtils
	{
		public static void Deconstruct(this Rect rect, out Vector2 min, out Vector2 max)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			min = new Vector2(((Rect)(ref rect)).xMin, ((Rect)(ref rect)).yMin);
			max = new Vector2(((Rect)(ref rect)).xMax, ((Rect)(ref rect)).yMax);
		}

		public static void Deconstruct(this Vector3 vector, out float x, out float y, out float z)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			x = vector.x;
			y = vector.y;
			z = vector.z;
		}
	}
	internal static class FsUtils
	{
		private static string? _assetBundlesDir;

		public static string SaveDir { get; } = GetSaveDir();


		public static string Pre041ControlsDir { get; } = Path.Combine(Paths.BepInExRootPath, "controls");


		public static string ControlsDir { get; } = Path.Combine(Paths.ConfigPath, "controls");


		public static string AssetBundlesDir
		{
			get
			{
				if (_assetBundlesDir == null)
				{
					_assetBundlesDir = GetAssetBundlesDir();
				}
				if (string.IsNullOrEmpty(_assetBundlesDir))
				{
					string text = Chainloader.PluginInfos.ToPrettyString();
					Logging.Warn("InputUtils is loading in an invalid state!\n\tOne of the following mods may be the culprit:\n" + text);
					return "";
				}
				return _assetBundlesDir;
			}
		}

		private static string GetSaveDir()
		{
			string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
			return Path.Combine(folderPath, "AppData", "LocalLow", "ZeekerssRBLX", "Lethal Company");
		}

		public static void EnsureControlsDir()
		{
			if (!Directory.Exists(ControlsDir))
			{
				Directory.CreateDirectory(ControlsDir);
			}
		}

		private static string? GetAssetBundlesDir()
		{
			if (!Chainloader.PluginInfos.TryGetValue("com.rune580.LethalCompanyInputUtils", out var value))
			{
				return null;
			}
			string text = Path.Combine((Directory.GetParent(value.Location) ?? throw new NotSupportedException(BadInstallError())).FullName, "AssetBundles");
			if (!Directory.Exists(text))
			{
				throw new NotSupportedException(BadInstallError());
			}
			return text;
			static string BadInstallError()
			{
				Logging.Error("InputUtils can't find it's required AssetBundles! This will cause many issues!\nThis either means your mod manager incorrectly installed InputUtilsor if you've manually installed InputUtils, you've done so incorrectly. If you manually installed don't bother reporting the issue, I only provide support to people who use mod managers.");
				return "InputUtils can't find it's required AssetBundles! This will cause many issues!\nThis either means your mod manager incorrectly installed InputUtilsor if you've manually installed InputUtils, you've done so incorrectly. If you manually installed don't bother reporting the issue, I only provide support to people who use mod managers.";
			}
		}
	}
	internal static class InputSystemUtils
	{
		public static bool IsGamepadOnly(this InputAction action)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return ((IEnumerable<InputBinding>)(object)action.bindings).All((InputBinding binding) => !binding.IsKbmBind());
		}

		public static bool IsKbmBind(this InputBinding binding)
		{
			string path = ((InputBinding)(ref binding)).path;
			if (string.Equals(path, "<InputUtils-Kbm-Not-Bound>"))
			{
				return true;
			}
			if (path.StartsWith("<Keyboard>", StringComparison.InvariantCultureIgnoreCase))
			{
				return true;
			}
			if (path.StartsWith("<Mouse>", StringComparison.InvariantCultureIgnoreCase))
			{
				return true;
			}
			return false;
		}
	}
	internal static class Logging
	{
		private static ManualLogSource? _logSource;

		internal static void SetLogSource(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		public static void Error(object data)
		{
			Error(data.ToString());
		}

		public static void Warn(object data)
		{
			Warn(data.ToString());
		}

		public static void Info(object data)
		{
			Info(data.ToString());
		}

		public static void Error(string msg)
		{
			if (_logSource == null)
			{
				Debug.LogError((object)("[Lethal Company Input Utils] [Error] " + msg));
			}
			else
			{
				_logSource.LogError((object)msg);
			}
		}

		public static void Warn(string msg)
		{
			if (_logSource == null)
			{
				Debug.LogWarning((object)("[Lethal Company Input Utils] [Warning] " + msg));
			}
			else
			{
				_logSource.LogWarning((object)msg);
			}
		}

		public static void Info(string msg)
		{
			if (_logSource == null)
			{
				Debug.Log((object)("[Lethal Company Input Utils] [Info] " + msg));
			}
			else
			{
				_logSource.LogInfo((object)msg);
			}
		}
	}
	internal static class RectTransformExtensions
	{
		public static void SetLocalPosX(this RectTransform rectTransform, float x)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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)
			Vector3 localPosition = ((Transform)rectTransform).localPosition;
			((Transform)rectTransform).localPosition = new Vector3(x, localPosition.y, localPosition.z);
		}

		public static void SetLocalPosY(this RectTransform rectTransform, float y)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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)
			Vector3 localPosition = ((Transform)rectTransform).localPosition;
			((Transform)rectTransform).localPosition = new Vector3(localPosition.x, y, localPosition.z);
		}

		public static void SetPivotY(this RectTransform rectTransform, float y)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.pivot = new Vector2(rectTransform.pivot.x, y);
		}

		public static void SetAnchorMinY(this RectTransform rectTransform, float y)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchorMin = new Vector2(rectTransform.anchorMin.x, y);
		}

		public static void SetAnchorMaxY(this RectTransform rectTransform, float y)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchorMax = new Vector2(rectTransform.anchorMax.x, y);
		}

		public static void SetAnchoredPosX(this RectTransform rectTransform, float x)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchoredPosition = new Vector2(x, rectTransform.anchoredPosition.y);
		}

		public static void SetAnchoredPosY(this RectTransform rectTransform, float y)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x, y);
		}

		public static void SetSizeDeltaX(this RectTransform rectTransform, float x)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.sizeDelta = new Vector2(x, rectTransform.sizeDelta.y);
		}

		public static Rect UiBoundsWorld(this RectTransform rectTransform)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Transform)rectTransform).position;
			Rect rect = rectTransform.rect;
			Vector3 lossyScale = ((Transform)rectTransform).lossyScale;
			return new Rect(((Rect)(ref rect)).x * lossyScale.x + position.x, ((Rect)(ref rect)).y * lossyScale.y + position.y, ((Rect)(ref rect)).width * lossyScale.x, ((Rect)(ref rect)).height * lossyScale.y);
		}

		[Obsolete("Use GetRelativeRect")]
		public static Rect UiBounds(this RectTransform rectTransform, Vector3 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = rectTransform.rect;
			Vector3 lossyScale = ((Transform)rectTransform).lossyScale;
			return new Rect(((Rect)(ref rect)).x * lossyScale.x + position.x, ((Rect)(ref rect)).y * lossyScale.y + position.y, ((Rect)(ref rect)).width * lossyScale.x, ((Rect)(ref rect)).height * lossyScale.y);
		}

		public static Rect GetRelativeRect(this RectTransform rectTransform, RectTransform worldRectTransform)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_009d: 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)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			Camera bestUiCamera = CameraUtils.GetBestUiCamera();
			Vector3[] array = (Vector3[])(object)new Vector3[4];
			worldRectTransform.GetWorldCorners(array);
			Vector2[] array2 = (Vector2[])(object)new Vector2[4];
			for (int i = 0; i < array.Length; i++)
			{
				array2[i] = RectTransformUtility.WorldToScreenPoint(bestUiCamera, array[i]);
			}
			Vector2[] array3 = (Vector2[])(object)new Vector2[4];
			for (int j = 0; j < array2.Length; j++)
			{
				RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, array2[j], bestUiCamera, ref array3[j]);
			}
			Vector2 val = array3[0];
			Vector2 val2 = array3[0];
			Vector2[] array4 = array3;
			foreach (Vector2 val3 in array4)
			{
				val = Vector2.Min(val, val3);
				val2 = Vector2.Max(val2, val3);
			}
			Vector2 val4 = val2 - val;
			return new Rect(val.x, val.y, val4.x, val4.y);
		}

		public static Vector2 WorldToLocalPoint(this RectTransform rectTransform, Vector3 worldPoint)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			Camera bestUiCamera = CameraUtils.GetBestUiCamera();
			Vector2 val = RectTransformUtility.WorldToScreenPoint(bestUiCamera, worldPoint);
			Vector2 result = default(Vector2);
			RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, val, bestUiCamera, ref result);
			return result;
		}

		public static Vector2 WorldToLocalPoint(this RectTransform rectTransform, RectTransform other)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return rectTransform.WorldToLocalPoint(((Transform)other).position);
		}

		public static float WorldMaxY(this RectTransform rectTransform)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			Rect val = rectTransform.UiBoundsWorld();
			return ((Rect)(ref val)).max.y;
		}

		public static float WorldMinY(this RectTransform rectTransform)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			Rect val = rectTransform.UiBoundsWorld();
			return ((Rect)(ref val)).min.y;
		}
	}
	internal static class RectUtils
	{
		public static Vector2 CenteredPos(this Rect rect)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			return ((Rect)(ref rect)).min + ((Rect)(ref rect)).size / 2f;
		}
	}
	internal static class RuntimeHelper
	{
		public static Vector3 LocalPositionRelativeTo(this Transform transform, Transform parent)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.zero;
			Transform val2 = transform;
			do
			{
				val += transform.localPosition;
				val2 = val2.parent;
			}
			while ((Object)(object)val2 != (Object)(object)parent);
			return val;
		}

		public static void DisableKeys(this IEnumerable<RemappableKey> keys)
		{
			foreach (RemappableKey key in keys)
			{
				key.currentInput.action.Disable();
			}
		}

		public static void EnableKeys(this IEnumerable<RemappableKey> keys)
		{
			foreach (RemappableKey key in keys)
			{
				key.currentInput.action.Enable();
			}
		}
	}
	internal static class VectorUtils
	{
		public static Vector3 Mul(this Vector3 left, Vector3 right)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(left.x * right.x, left.y * right.y, left.z * right.z);
		}
	}
}
namespace LethalCompanyInputUtils.Utils.Anim
{
	public interface ITweenValue
	{
		bool IgnoreTimeScale { get; }

		float Duration { get; }

		void TweenValue(float percentage);

		bool ValidTarget();
	}
	public class TweenRunner<T> where T : struct, ITweenValue
	{
		protected MonoBehaviour? CoroutineContainer;

		protected IEnumerator? Tween;

		private static IEnumerator Start(T tweenValue)
		{
			if (tweenValue.ValidTarget())
			{
				float elapsedTime = 0f;
				while (elapsedTime < tweenValue.Duration)
				{
					elapsedTime += (tweenValue.IgnoreTimeScale ? Time.unscaledDeltaTime : Time.deltaTime);
					float percentage = Mathf.Clamp01(elapsedTime / tweenValue.Duration);
					tweenValue.TweenValue(percentage);
					yield return null;
				}
				tweenValue.TweenValue(1f);
			}
		}

		public void Init(MonoBehaviour coroutineContainer)
		{
			CoroutineContainer = coroutineContainer;
		}

		public void StartTween(T tweenValue)
		{
			if (CoroutineContainer != null)
			{
				if (Tween != null)
				{
					CoroutineContainer.StopCoroutine(Tween);
					Tween = null;
				}
				if (!((Component)CoroutineContainer).gameObject.activeInHierarchy)
				{
					tweenValue.TweenValue(1f);
					return;
				}
				Tween = Start(tweenValue);
				CoroutineContainer.StartCoroutine(Tween);
			}
		}

		public void StopTween()
		{
			if (Tween != null && CoroutineContainer != null)
			{
				CoroutineContainer.StopCoroutine(Tween);
				Tween = null;
			}
		}
	}
}
namespace LethalCompanyInputUtils.Utils.Anim.TweenValues
{
	public struct Vector3Tween : ITweenValue
	{
		private class Vector3TweenCallback : UnityEvent<Vector3>
		{
		}

		private Vector3TweenCallback? _target;

		public float Duration { get; set; }

		public Vector3 StartValue { get; set; }

		public Vector3 TargetValue { get; set; }

		public bool IgnoreTimeScale { get; set; }

		public void TweenValue(float percentage)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (ValidTarget())
			{
				Vector3 val = Vector3.Lerp(StartValue, TargetValue, percentage);
				((UnityEvent<Vector3>)_target).Invoke(val);
			}
		}

		public void AddOnChangedCallback(UnityAction<Vector3> callback)
		{
			if (_target == null)
			{
				_target = new Vector3TweenCallback();
			}
			((UnityEvent<Vector3>)_target).AddListener(callback);
		}

		public bool ValidTarget()
		{
			return _target != null;
		}
	}
}
namespace LethalCompanyInputUtils.Patches
{
	public static class InGamePlayerSettingsPatches
	{
		[HarmonyPatch(typeof(IngamePlayerSettings), "SaveChangedSettings")]
		public static class SaveChangedSettingsPatch
		{
			public static void Prefix()
			{
				LcInputActionApi.SaveOverrides();
			}
		}

		[HarmonyPatch(typeof(IngamePlayerSettings), "DiscardChangedSettings")]
		public static class DiscardChangedSettingsPatch
		{
			public static void Prefix()
			{
				LcInputActionApi.LoadOverrides();
			}
		}
	}
	public static class InputControlPathPatches
	{
		[HarmonyPatch]
		public static class ToHumanReadableStringPatch
		{
			public static IEnumerable<MethodBase> TargetMethods()
			{
				return from method in AccessTools.GetDeclaredMethods(typeof(InputControlPath))
					where method.Name == "ToHumanReadableString" && method.ReturnType == typeof(string)
					select method;
			}

			public static void Postfix(ref string __result)
			{
				string text = __result;
				if ((text == "<InputUtils-Gamepad-Not-Bound>" || text == "<InputUtils-Kbm-Not-Bound>") ? true : false)
				{
					__result = "";
				}
			}
		}
	}
	public static class KeyRemapPanelPatches
	{
		[HarmonyPatch(typeof(KepRemapPanel), "OnEnable")]
		public static class LoadKeybindsUIPatch
		{
			[CompilerGenerated]
			private static class <>O
			{
				public static UnityAction <0>__CloseContainerLayer;
			}

			public static void Prefix(KepRemapPanel __instance)
			{
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Expected O, but got Unknown
				//IL_011f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0129: Expected O, but got Unknown
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				//IL_0147: Unknown result type (might be due to invalid IL or missing references)
				//IL_0182: Unknown result type (might be due to invalid IL or missing references)
				//IL_018c: Unknown result type (might be due to invalid IL or missing references)
				//IL_019f: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0202: Expected O, but got Unknown
				//IL_023b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0245: Expected O, but got Unknown
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f5: Expected O, but got Unknown
				LcInputActionApi.DisableForRebind();
				if (LcInputActionApi.PrefabLoaded && LcInputActionApi.ContainerInstance != null)
				{
					LcInputActionApi.ContainerInstance.baseGameKeys.DisableKeys();
					return;
				}
				GameObject val = Object.Instantiate<GameObject>(Assets.Load<GameObject>("Prefabs/InputUtilsRemapContainer.prefab"), ((Component)__instance).transform);
				GameObject val2 = Object.Instantiate<GameObject>(Assets.Load<GameObject>("Prefabs/Legacy Holder.prefab"), ((Component)__instance).transform);
				if (val == null || val2 == null)
				{
					return;
				}
				Transform val3 = ((Component)__instance).transform.Find("Scroll View");
				if (val3 != null)
				{
					val3.SetParent(val2.transform);
					List<RemappableKey> remappableKeys = __instance.remappableKeys;
					__instance.remappableKeys = new List<RemappableKey>();
					val2.SetActive(false);
					GameObject gameObject = ((Component)((Component)__instance).transform.Find("Back")).gameObject;
					Button component = gameObject.GetComponent<Button>();
					GameObject obj = Object.Instantiate<GameObject>(gameObject, val2.transform, true);
					Object.DestroyImmediate((Object)(object)obj.GetComponentInChildren<SettingsOption>());
					Button component2 = obj.GetComponent<Button>();
					component2.onClick = new ButtonClickedEvent();
					ButtonClickedEvent onClick = component2.onClick;
					object obj2 = <>O.<0>__CloseContainerLayer;
					if (obj2 == null)
					{
						UnityAction val4 = LcInputActionApi.CloseContainerLayer;
						<>O.<0>__CloseContainerLayer = val4;
						obj2 = (object)val4;
					}
					((UnityEvent)onClick).AddListener((UnityAction)obj2);
					GameObject obj3 = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent);
					Object.DestroyImmediate((Object)(object)obj3.GetComponentInChildren<SettingsOption>());
					Button component3 = obj3.GetComponent<Button>();
					component3.onClick = new ButtonClickedEvent();
					RectTransform component4 = obj3.GetComponent<RectTransform>();
					component4.SetAnchoredPosY(component4.anchoredPosition.y + 25f);
					component4.SetSizeDeltaX(component4.sizeDelta.x + 180f);
					RectTransform component5 = ((Component)((Transform)component4).Find("SelectionHighlight")).GetComponent<RectTransform>();
					component5.SetSizeDeltaX(410f);
					component5.offsetMax = new Vector2(410f, component5.offsetMax.y);
					component5.offsetMin = new Vector2(0f, component5.offsetMin.y);
					RemapContainerController component6 = val.GetComponent<RemapContainerController>();
					component6.baseGameKeys = remappableKeys;
					component6.backButton = component;
					component6.legacyButton = component3;
					component6.legacyHolder = val2;
					component6.baseGameKeys.DisableKeys();
					((UnityEvent)component3.onClick).AddListener(new UnityAction(component6.ShowLegacyUi));
					component6.LoadUi();
					Button component7 = ((Component)((Component)__instance).transform.Find("SetDefault")).gameObject.GetComponent<Button>();
					((UnityEventBase)component7.onClick).RemoveAllListeners();
					((UnityEvent)component7.onClick).AddListener(new UnityAction(component6.OnSetToDefault));
					val2.transform.SetAsLastSibling();
					LcInputActionApi.PrefabLoaded = true;
				}
			}

			public static void Postfix(KepRemapPanel __instance)
			{
				LcInputActionApi.LoadIntoUI(__instance);
			}
		}

		[HarmonyPatch(typeof(KepRemapPanel), "OnDisable")]
		public static class UnloadKeybindsUIPatch
		{
			public static void Prefix()
			{
				if (LcInputActionApi.ContainerInstance != null)
				{
					LcInputActionApi.ContainerInstance.baseGameKeys.EnableKeys();
				}
			}
		}
	}
	public static class QuickMenuManagerPatches
	{
		[HarmonyPatch(typeof(QuickMenuManager), "CloseQuickMenu")]
		public static class OpenMenuPerformedPatch
		{
			public static bool Prefix(QuickMenuManager __instance)
			{
				if (LcInputActionApi.RemapContainerVisible() && __instance.isMenuOpen)
				{
					LcInputActionApi.CloseContainerLayer();
					return false;
				}
				return true;
			}
		}
	}
	public static class SettingsOptionPatches
	{
		[HarmonyPatch(typeof(SettingsOption), "SetBindingToCurrentSetting")]
		public static class SetBindingToCurrentSettingPatch
		{
			public static bool Prefix(SettingsOption __instance)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Invalid comparison between Unknown and I4
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//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_002d: Unknown result type (might be due to invalid IL or missing references)
				if ((int)__instance.optionType != 6)
				{
					return true;
				}
				Enumerator<InputBinding> enumerator = __instance.rebindableAction.action.bindings.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						InputBinding current = enumerator.Current;
						if (__instance.gamepadOnlyRebinding)
						{
							if (!string.Equals(((InputBinding)(ref current)).effectivePath, "<InputUtils-Gamepad-Not-Bound>"))
							{
								continue;
							}
						}
						else if (!string.Equals(((InputBinding)(ref current)).effectivePath, "<InputUtils-Kbm-Not-Bound>"))
						{
							continue;
						}
						((TMP_Text)__instance.currentlyUsedKeyText).SetText("", true);
						return false;
					}
				}
				finally
				{
					((IDisposable)enumerator).Dispose();
				}
				return true;
			}
		}
	}
}
namespace LethalCompanyInputUtils.Glyphs
{
	[CreateAssetMenu]
	public class ControllerGlyph : ScriptableObject
	{
		public List<string> validGamepadTypes = new List<string>();

		public List<GlyphDef> glyphSet = new List<GlyphDef>();

		private readonly Dictionary<string, Sprite?> _glyphLut = new Dictionary<string, Sprite>();

		private static readonly List<ControllerGlyph> Instances = new List<ControllerGlyph>();

		private static bool _loaded;

		public static ControllerGlyph? MouseGlyphs { get; private set; }

		public bool IsCurrent
		{
			get
			{
				Gamepad current = Gamepad.current;
				if (current == null)
				{
					return false;
				}
				return validGamepadTypes.Any((string gamepadTypeName) => string.Equals(gamepadTypeName, ((object)current).GetType().Name));
			}
		}

		public Sprite this[string controlPath]
		{
			get
			{
				if (_glyphLut.Count == 0)
				{
					UpdateLut();
				}
				return _glyphLut.GetValueOrDefault(controlPath, null);
			}
		}

		public static ControllerGlyph? GetBestMatching()
		{
			if (Instances.Count == 0)
			{
				return null;
			}
			foreach (ControllerGlyph instance in Instances)
			{
				if (instance.IsCurrent)
				{
					return instance;
				}
			}
			return Instances[0];
		}

		internal static void LoadGlyphs()
		{
			if (!_loaded)
			{
				Assets.Load<ControllerGlyph>("controller glyphs/xbox series x glyphs.asset");
				Assets.Load<ControllerGlyph>("controller glyphs/dualsense glyphs.asset");
				MouseGlyphs = Assets.Load<ControllerGlyph>("controller glyphs/mouse glyphs.asset");
				_loaded = true;
			}
		}

		private void Awake()
		{
			if (!Instances.Contains(this))
			{
				Instances.Add(this);
			}
		}

		private void UpdateLut()
		{
			foreach (GlyphDef item in glyphSet)
			{
				_glyphLut[item.controlPath] = item.glyphSprite;
			}
		}

		private void OnDestroy()
		{
			if (Instances.Contains(this))
			{
				Instances.Remove(this);
			}
		}
	}
	[CreateAssetMenu]
	public class GlyphDef : ScriptableObject
	{
		public string controlPath = "";

		public Sprite? glyphSprite;
	}
}
namespace LethalCompanyInputUtils.Data
{
	[Serializable]
	public struct BindingOverride
	{
		public string? action;

		public string? origPath;

		public string? path;
	}
	[Serializable]
	public class BindingOverrides
	{
		public List<BindingOverride> overrides;

		private BindingOverrides()
		{
			overrides = new List<BindingOverride>();
		}

		public BindingOverrides(IEnumerable<InputBinding> bindings)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			overrides = new List<BindingOverride>();
			foreach (InputBinding binding in bindings)
			{
				InputBinding current = binding;
				if (((InputBinding)(ref current)).hasOverrides)
				{
					BindingOverride item = new BindingOverride
					{
						action = ((InputBinding)(ref current)).action,
						origPath = ((InputBinding)(ref current)).path,
						path = ((InputBinding)(ref current)).overridePath
					};
					overrides.Add(item);
				}
			}
		}

		public void LoadInto(InputActionAsset asset)
		{
			foreach (BindingOverride @override in overrides)
			{
				InputAction obj = asset.FindAction(@override.action, false);
				if (obj != null)
				{
					InputActionRebindingExtensions.ApplyBindingOverride(obj, @override.path, (string)null, @override.origPath);
				}
			}
		}

		public static BindingOverrides FromJson(string json)
		{
			BindingOverrides bindingOverrides = new BindingOverrides();
			JToken value = JsonConvert.DeserializeObject<JObject>(json).GetValue("overrides");
			bindingOverrides.overrides = value.ToObject<List<BindingOverride>>();
			return bindingOverrides;
		}
	}
}
namespace LethalCompanyInputUtils.Components
{
	[RequireComponent(typeof(RectTransform))]
	public class BindsListController : MonoBehaviour
	{
		public GameObject? sectionHeaderPrefab;

		public GameObject? sectionAnchorPrefab;

		public GameObject? rebindItemPrefab;

		public GameObject? spacerPrefab;

		public ScrollRect? scrollRect;

		public RectTransform? headerContainer;

		public UnityEvent<int> OnSectionChanged = new UnityEvent<int>();

		public static float OffsetCompensation;

		private RectTransform? _rectTransform;

		private RectTransform? _scrollRectTransform;

		private RectTransform? _content;

		private VerticalLayoutGroup? _verticalLayoutGroup;

		private int _currentSection;

		private float _sectionHeight;

		private float _spacing;

		private readonly List<SectionHeaderAnchor> _anchors = new List<SectionHeaderAnchor>();

		private void Awake()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			if (_rectTransform == null)
			{
				_rectTransform = ((Component)this).GetComponent<RectTransform>();
			}
			if (scrollRect == null)
			{
				scrollRect = ((Component)this).GetComponentInChildren<ScrollRect>();
			}
			if (_verticalLayoutGroup == null)
			{
				_verticalLayoutGroup = ((Component)scrollRect.content).GetComponent<VerticalLayoutGroup>();
			}
			_spacing = ((HorizontalOrVerticalLayoutGroup)_verticalLayoutGroup).spacing;
			if (sectionAnchorPrefab != null && rebindItemPrefab != null && spacerPrefab != null)
			{
				_sectionHeight = sectionAnchorPrefab.GetComponent<RectTransform>().sizeDelta.y;
				_scrollRectTransform = ((Component)scrollRect).GetComponent<RectTransform>();
				_content = scrollRect.content;
				if (headerContainer != null)
				{
					headerContainer.drivenByObject = (Object)(object)this;
					headerContainer.drivenProperties = (DrivenTransformProperties)3840;
					headerContainer.anchorMin = new Vector2(0f, 1f);
					headerContainer.anchorMax = Vector2.one;
					((UnityEvent<Vector2>)(object)scrollRect.onValueChanged).AddListener((UnityAction<Vector2>)OnScroll);
					OnScroll(Vector2.zero);
				}
			}
		}

		private void Start()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			OnScroll(Vector2.zero);
		}

		private void OnEnable()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			OnScroll(Vector2.zero);
		}

		public void JumpTo(int sectionIndex)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			if (_content == null || scrollRect == null || _scrollRectTransform == null)
			{
				return;
			}
			int count = _anchors.Count;
			if (sectionIndex < count && sectionIndex >= 0)
			{
				Canvas.ForceUpdateCanvases();
				scrollRect.StopMovement();
				if (sectionIndex == 0)
				{
					scrollRect.verticalNormalizedPosition = 1f;
				}
				else
				{
					SectionHeaderAnchor sectionHeaderAnchor = _anchors[sectionIndex];
					float y = Vector2.op_Implicit(((Transform)_scrollRectTransform).InverseTransformPoint(((Transform)_content).position) - ((Transform)_scrollRectTransform).InverseTransformPoint(((Transform)sectionHeaderAnchor.RectTransform).position)).y + _sectionHeight / 2f - _spacing;
					_content.SetAnchoredPosY(y);
				}
				if (_currentSection != sectionIndex)
				{
					OnSectionChanged.Invoke(sectionIndex);
				}
				_currentSection = sectionIndex;
			}
		}

		public void AddSection(string sectionName)
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			if (((Behaviour)this).isActiveAndEnabled && sectionHeaderPrefab != null && sectionAnchorPrefab != null && scrollRect != null)
			{
				SectionHeaderAnchor component = Object.Instantiate<GameObject>(sectionAnchorPrefab, (Transform)(object)_content).GetComponent<SectionHeaderAnchor>();
				SectionHeader component2 = Object.Instantiate<GameObject>(sectionHeaderPrefab, (Transform)(object)headerContainer).GetComponent<SectionHeader>();
				RectTransform rectTransform = component2.RectTransform;
				rectTransform.drivenByObject = (Object)(object)this;
				rectTransform.drivenProperties = (DrivenTransformProperties)1286;
				rectTransform.anchorMin = new Vector2(0f, rectTransform.anchorMin.y);
				rectTransform.anchorMax = new Vector2(1f, rectTransform.anchorMax.y);
				component2.anchor = component;
				component.sectionHeader = component2;
				component2.SetText(sectionName);
				OnScroll(Vector2.zero);
				if (_anchors.Count == 0)
				{
					component.RectTransform.sizeDelta = default(Vector2);
				}
				_currentSection = _anchors.Count;
				_anchors.Add(component);
			}
		}

		public void AddBinds(RemappableKey? kbmKey, RemappableKey? gamepadKey, bool isBaseGame = false, string controlName = "")
		{
			if (((Behaviour)this).isActiveAndEnabled && rebindItemPrefab != null && scrollRect != null)
			{
				if (kbmKey != null && string.IsNullOrEmpty(controlName))
				{
					controlName = kbmKey.ControlName;
				}
				else if (gamepadKey != null && string.IsNullOrEmpty(controlName))
				{
					controlName = gamepadKey.ControlName;
				}
				Object.Instantiate<GameObject>(rebindItemPrefab, (Transform)(object)_content).GetComponent<RebindItem>().SetBind(controlName, kbmKey, gamepadKey, isBaseGame);
			}
		}

		public void AddFooter()
		{
			if (((Behaviour)this).isActiveAndEnabled && spacerPrefab != null)
			{
				Object.Instantiate<GameObject>(spacerPrefab, (Transform)(object)_content);
			}
		}

		private void OnScroll(Vector2 delta)
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			if (_scrollRectTransform == null || headerContainer == null || _rectTransform == null)
			{
				return;
			}
			float maxY = GetMaxY(headerContainer);
			int num = -1;
			for (int i = 0; i < _anchors.Count; i++)
			{
				SectionHeaderAnchor sectionHeaderAnchor = _anchors[i];
				SectionHeader sectionHeader = sectionHeaderAnchor.sectionHeader;
				if (i == 0)
				{
					sectionHeader.RectTransform.SetLocalPosY(maxY - (_sectionHeight / 2f - _spacing));
					num = i;
					continue;
				}
				SectionHeader sectionHeader2 = _anchors[i - 1].sectionHeader;
				float num2 = CalculateHeaderRawYPos(sectionHeaderAnchor);
				sectionHeader.RectTransform.SetLocalPosY(num2);
				float num3 = GetMaxY(sectionHeader.RectTransform) + ((Transform)sectionHeader.RectTransform).localPosition.y;
				float num4 = GetMinY(sectionHeader2.RectTransform) + ((Transform)sectionHeader2.RectTransform).localPosition.y;
				if (num3 + _sectionHeight / 2f + _spacing >= num4)
				{
					sectionHeader2.RectTransform.SetLocalPosY(num2 + _sectionHeight);
				}
				if (num3 + _spacing / 2f >= maxY - _sectionHeight / 2f)
				{
					num = i;
					sectionHeader.RectTransform.SetLocalPosY(maxY - (_sectionHeight / 2f - _spacing));
				}
			}
			if (_currentSection != num)
			{
				OnSectionChanged.Invoke(num);
			}
			_currentSection = num;
		}

		private float CalculateHeaderRawYPos(SectionHeaderAnchor anchor)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			if (_content == null || headerContainer == null || _scrollRectTransform == null)
			{
				return 0f;
			}
			float num = GetMaxY(headerContainer) - GetMaxY(_scrollRectTransform);
			num += _sectionHeight / 2f;
			num -= OffsetCompensation;
			return ((Transform)anchor.RectTransform).localPosition.y - (num + 50f) + ((Transform)_content).localPosition.y;
		}

		private void OnDrawGizmos()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (_rectTransform != null && headerContainer != null)
			{
				Color color = Gizmos.color;
				_rectTransform.DrawGizmoUiRectWorld();
				Gizmos.color = color;
			}
		}

		private float GetMaxY(RectTransform element)
		{
			//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_0022: Unknown result type (might be due to invalid IL or missing references)
			if (_rectTransform == null)
			{
				_rectTransform = ((Component)this).GetComponent<RectTransform>();
			}
			Rect val = element.UiBounds(Vector3.zero);
			return ((Rect)(ref val)).max.y;
		}

		private float GetMinY(RectTransform element)
		{
			//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_0022: Unknown result type (might be due to invalid IL or missing references)
			if (_rectTransform == null)
			{
				_rectTransform = ((Component)this).GetComponent<RectTransform>();
			}
			Rect val = element.UiBounds(Vector3.zero);
			return ((Rect)(ref val)).min.y;
		}
	}
	public class RebindButton : MonoBehaviour
	{
		public Selectable? button;

		public TextMeshProUGUI? bindLabel;

		public Image? glyphLabel;

		public Image? notSupportedImage;

		public RebindIndicator? rebindIndicator;

		public Button? resetButton;

		public Button? removeButton;

		public float timeout = 5f;

		private RemappableKey? _key;

		private bool _isBaseGame;

		private RebindingOperation? _rebindingOperation;

		private bool _rebinding;

		private float _timeoutTimer;

		private static MethodInfo? _setChangesNotAppliedMethodInfo;

		private static readonly List<RebindButton> Instances = new List<RebindButton>();

		public void SetKey(RemappableKey? key, bool isBaseGame)
		{
			_key = key;
			_isBaseGame = isBaseGame;
			UpdateState();
		}

		public void UpdateState()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			if (bindLabel == null || glyphLabel == null || button == null || notSupportedImage == null || resetButton == null || removeButton == null)
			{
				return;
			}
			if (_key == null)
			{
				SetAsUnsupported();
				return;
			}
			int rebindingIndex = GetRebindingIndex();
			InputAction action = _key.currentInput.action;
			if (rebindingIndex >= action.bindings.Count)
			{
				SetAsUnsupported();
				return;
			}
			GameObject gameObject = ((Component)resetButton).gameObject;
			InputBinding val = action.bindings[rebindingIndex];
			gameObject.SetActive(((InputBinding)(ref val)).hasOverrides);
			val = action.bindings[rebindingIndex];
			string effectivePath = ((InputBinding)(ref val)).effectivePath;
			string bindPath = InputControlPath.ToHumanReadableString(effectivePath, (HumanReadableStringOptions)2, (InputControl)null);
			if (_key.gamepadOnly)
			{
				((TMP_Text)bindLabel).SetText("", true);
				if (effectivePath == "<InputUtils-Gamepad-Not-Bound>")
				{
					((Component)removeButton).gameObject.SetActive(false);
					((Behaviour)glyphLabel).enabled = false;
					return;
				}
				((Component)removeButton).gameObject.SetActive(true);
				ControllerGlyph bestMatching = ControllerGlyph.GetBestMatching();
				if (bestMatching == null)
				{
					((TMP_Text)bindLabel).SetText(effectivePath, true);
					((Behaviour)glyphLabel).enabled = false;
					return;
				}
				Sprite val2 = bestMatching[effectivePath];
				if (val2 == null)
				{
					((TMP_Text)bindLabel).SetText(effectivePath, true);
					((Behaviour)glyphLabel).enabled = false;
				}
				else
				{
					glyphLabel.sprite = val2;
					((Behaviour)glyphLabel).enabled = true;
				}
			}
			else
			{
				((Component)removeButton).gameObject.SetActive(!string.Equals(effectivePath, "<InputUtils-Kbm-Not-Bound>"));
				HandleKbmGlyphOrLabel(effectivePath, bindPath);
			}
		}

		private void HandleKbmGlyphOrLabel(string effectivePath, string bindPath)
		{
			if (bindLabel == null || glyphLabel == null)
			{
				return;
			}
			if (ControllerGlyph.MouseGlyphs != null)
			{
				Sprite val = ControllerGlyph.MouseGlyphs[effectivePath];
				if (val != null)
				{
					((TMP_Text)bindLabel).SetText("", true);
					glyphLabel.sprite = val;
					((Behaviour)glyphLabel).enabled = true;
					return;
				}
			}
			((Behaviour)glyphLabel).enabled = false;
			((TMP_Text)bindLabel).SetText(bindPath, true);
		}

		private void SetAsUnsupported()
		{
			if (button != null && bindLabel != null && glyphLabel != null && notSupportedImage != null && resetButton != null && removeButton != null)
			{
				button.interactable = false;
				button.targetGraphic.raycastTarget = false;
				((Behaviour)button.targetGraphic).enabled = false;
				((TMP_Text)bindLabel).SetText("", true);
				((Behaviour)glyphLabel).enabled = false;
				((Component)notSupportedImage).gameObject.SetActive(true);
				((Component)resetButton).gameObject.SetActive(false);
				((Component)removeButton).gameObject.SetActive(false);
			}
		}

		private int GetRebindingIndex()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (_key == null)
			{
				return -1;
			}
			InputAction action = _key.currentInput.action;
			if (action.controls.Count == 0)
			{
				if (action.bindings.Count == 0)
				{
					return -1;
				}
				if (_key.gamepadOnly && action.bindings.Count > 1)
				{
					return 1;
				}
				return 0;
			}
			if (_key.rebindingIndex >= 0)
			{
				return _key.rebindingIndex;
			}
			return InputActionRebindingExtensions.GetBindingIndexForControl(action, action.controls[0]);
		}

		public void StartRebinding()
		{
			if (_key != null && bindLabel != null && glyphLabel != null && rebindIndicator != null && resetButton != null && removeButton != null)
			{
				int rebindingIndex = GetRebindingIndex();
				((Selectable)resetButton).interactable = false;
				((Selectable)removeButton).interactable = false;
				((Behaviour)glyphLabel).enabled = false;
				if (_key.gamepadOnly)
				{
					((Behaviour)rebindIndicator).enabled = true;
					RebindGamepad(_key.currentInput, rebindingIndex);
				}
				else
				{
					((TMP_Text)bindLabel).SetText("", true);
					((Behaviour)rebindIndicator).enabled = true;
					RebindKbm(_key.currentInput, rebindingIndex);
				}
				_timeoutTimer = timeout;
				_rebinding = true;
			}
		}

		private void FinishRebinding()
		{
			if (_key != null && rebindIndicator != null && resetButton != null && removeButton != null)
			{
				((Behaviour)rebindIndicator).enabled = false;
				_rebinding = false;
				if (_rebindingOperation != null)
				{
					_rebindingOperation = null;
				}
				((Selectable)resetButton).interactable = true;
				((Selectable)removeButton).interactable = true;
				UpdateState();
			}
		}

		public void ResetToDefault()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			FinishRebinding();
			if (_key == null)
			{
				return;
			}
			int rebindingIndex = GetRebindingIndex();
			InputAction action = _key.currentInput.action;
			InputBinding val = action.bindings[rebindingIndex];
			if (((InputBinding)(ref val)).hasOverrides)
			{
				InputActionRebindingExtensions.RemoveBindingOverride(action, rebindingIndex);
				if (_isBaseGame)
				{
					BaseGameUnsavedChanges();
				}
				MarkSettingsAsDirty();
				UpdateState();
			}
		}

		public void RemoveBind()
		{
			FinishRebinding();
			if (_key != null)
			{
				int rebindingIndex = GetRebindingIndex();
				InputActionRebindingExtensions.ApplyBindingOverride(_key.currentInput.action, rebindingIndex, _key.gamepadOnly ? "<InputUtils-Gamepad-Not-Bound>" : "<InputUtils-Kbm-Not-Bound>");
				if (_isBaseGame)
				{
					BaseGameUnsavedChanges();
				}
				MarkSettingsAsDirty();
				UpdateState();
			}
		}

		private void OnEnable()
		{
			Instances.Add(this);
			if (_key != null)
			{
				UpdateState();
			}
		}

		private void OnDisable()
		{
			FinishRebinding();
			Instances.Remove(this);
		}

		private void Update()
		{
			if (!_rebinding)
			{
				return;
			}
			_timeoutTimer -= Time.deltaTime;
			if (!(_timeoutTimer > 0f))
			{
				if (_rebindingOperation == null)
				{
					FinishRebinding();
					return;
				}
				_rebindingOperation.Cancel();
				FinishRebinding();
			}
		}

		private void RebindKbm(InputActionReference inputActionRef, int rebindIndex)
		{
			_rebindingOperation = InputActionRebindingExtensions.PerformInteractiveRebinding(inputActionRef.action, rebindIndex).OnMatchWaitForAnother(0.1f).WithControlsHavingToMatchPath("<Keyboard>")
				.WithControlsHavingToMatchPath("<Mouse>")
				.WithControlsHavingToMatchPath("<InputUtilsExtendedMouse>")
				.WithControlsExcluding("<Mouse>/scroll/y")
				.WithControlsExcluding("<Mouse>/scroll/x")
				.WithCancelingThrough("<Keyboard>/escape")
				.OnComplete((Action<RebindingOperation>)delegate(RebindingOperation operation)
				{
					OnRebindComplete(operation, this);
				})
				.OnCancel((Action<RebindingOperation>)delegate
				{
					FinishRebinding();
				})
				.Start();
		}

		private void RebindGamepad(InputActionReference inputActionRef, int rebindIndex)
		{
			_rebindingOperation = InputActionRebindingExtensions.PerformInteractiveRebinding(inputActionRef.action, rebindIndex).OnMatchWaitForAnother(0.1f).WithControlsHavingToMatchPath("<Gamepad>")
				.OnComplete((Action<RebindingOperation>)delegate(RebindingOperation operation)
				{
					OnRebindComplete(operation, this);
				})
				.Start();
		}

		private static void OnRebindComplete(RebindingOperation operation, RebindButton instance)
		{
			if (operation.completed)
			{
				if (instance._isBaseGame)
				{
					BaseGameUnsavedChanges();
				}
				MarkSettingsAsDirty();
				instance.FinishRebinding();
			}
		}

		private static void BaseGameUnsavedChanges()
		{
			IngamePlayerSettings.Instance.unsavedSettings.keyBindings = InputActionRebindingExtensions.SaveBindingOverridesAsJson((IInputActionCollection2)(object)IngamePlayerSettings.Instance.playerInput.actions);
		}

		private static void MarkSettingsAsDirty()
		{
			if ((object)_setChangesNotAppliedMethodInfo == null)
			{
				_setChangesNotAppliedMethodInfo = AccessTools.Method(typeof(IngamePlayerSettings), "SetChangesNotAppliedTextVisible", (Type[])null, (Type[])null);
			}
			_setChangesNotAppliedMethodInfo.Invoke(IngamePlayerSettings.Instance, new object[1] { true });
		}

		public static void ReloadGlyphs()
		{
			foreach (RebindButton instance in Instances)
			{
				instance.UpdateState();
			}
		}

		public static void ResetAllToDefaults()
		{
			foreach (RebindButton instance in Instances)
			{
				instance.ResetToDefault();
			}
		}
	}
	public class RebindIndicator : MonoBehaviour
	{
		public TextMeshProUGUI? label;

		public int maxTicks = 5;

		public float timeBetweenTicks = 1f;

		private int _ticks = 1;

		private float _timer;

		private void OnEnable()
		{
			_ticks = 1;
			_timer = timeBetweenTicks;
			((TMP_Text)label).SetText(GetText(), true);
		}

		private void OnDisable()
		{
			_ticks = 1;
			_timer = timeBetweenTicks;
			((TMP_Text)label).SetText("", true);
		}

		private void Update()
		{
			_timer -= Time.unscaledDeltaTime;
			if (!(_timer > 0f))
			{
				_ticks++;
				if (_ticks > maxTicks)
				{
					_ticks = 1;
				}
				((TMP_Text)label).SetText(GetText(), true);
				_timer = timeBetweenTicks;
			}
		}

		private string GetText()
		{
			string text = "";
			for (int i = 0; i < _ticks; i++)
			{
				text += ".";
			}
			return text;
		}
	}
	public class RebindItem : MonoBehaviour
	{
		public TextMeshProUGUI? controlNameLabel;

		public RebindButton? kbmButton;

		public RebindButton? gamepadButton;

		public void SetBind(string controlName, RemappableKey? kbmKey, RemappableKey? gamepadKey, bool isBaseGame = false)
		{
			if (controlNameLabel != null)
			{
				((TMP_Text)controlNameLabel).SetText(controlName, true);
				if (kbmButton != null)
				{
					kbmButton.SetKey(kbmKey, isBaseGame);
				}
				if (gamepadButton != null)
				{
					gamepadButton.SetKey(gamepadKey, isBaseGame);
				}
			}
		}
	}
	public class RemapContainerController : MonoBehaviour
	{
		public BindsListController? bindsList;

		public SectionListController? sectionList;

		public Button? backButton;

		public Button? legacyButton;

		public GameObject? legacyHolder;

		public List<RemappableKey> baseGameKeys = new List<RemappableKey>();

		internal int LayerShown;

		private void Awake()
		{
			if (bindsList == null)
			{
				bindsList = ((Component)this).GetComponentInChildren<BindsListController>();
			}
			if (sectionList == null)
			{
				sectionList = ((Component)this).GetComponentInChildren<SectionListController>();
			}
			bindsList.OnSectionChanged.AddListener((UnityAction<int>)HandleSectionChanged);
			LcInputActionApi.ContainerInstance = this;
		}

		public void JumpTo(int sectionIndex)
		{
			if (bindsList != null)
			{
				bindsList.JumpTo(sectionIndex);
			}
		}

		public void LoadUi()
		{
			GenerateBaseGameSection();
			GenerateApiSections();
			FinishUi();
		}

		private void GenerateBaseGameSection()
		{
			if (bindsList == null || sectionList == null)
			{
				return;
			}
			Dictionary<string, (RemappableKey, RemappableKey)> dictionary = new Dictionary<string, (RemappableKey, RemappableKey)>();
			string key;
			foreach (RemappableKey baseGameKey in baseGameKeys)
			{
				RemappableKey item = null;
				RemappableKey item2 = null;
				string text = baseGameKey.ControlName.ToLower();
				if (text.StartsWith("walk"))
				{
					key = text;
					text = "move" + key.Substring(4, key.Length - 4);
				}
				baseGameKey.ControlName = baseGameKey.ControlName.Replace("primary", "Primary");
				if (dictionary.TryGetValue(text, out var value))
				{
					if (baseGameKey.gamepadOnly)
					{
						(item, _) = value;
					}
					else
					{
						item2 = value.Item2;
					}
				}
				if (baseGameKey.gamepadOnly)
				{
					item2 = baseGameKey;
				}
				else
				{
					item = baseGameKey;
				}
				dictionary[text] = (item, item2);
			}
			bindsList.AddSection("Lethal Company");
			sectionList.AddSection("Lethal Company");
			foreach (KeyValuePair<string, (RemappableKey, RemappableKey)> item3 in dictionary)
			{
				item3.Deconstruct(out key, out var value2);
				var (kbmKey, gamepadKey) = value2;
				bindsList.AddBinds(kbmKey, gamepadKey, isBaseGame: true);
			}
		}

		public void OnSetToDefault()
		{
			RebindButton.ResetAllToDefaults();
		}

		public void HideHighestLayer()
		{
			if (backButton != null && legacyHolder != null)
			{
				if (LayerShown > 1)
				{
					legacyHolder.SetActive(false);
					LayerShown--;
				}
				else if (LayerShown > 0)
				{
					((UnityEvent)backButton.onClick).Invoke();
				}
			}
		}

		public void ShowLegacyUi()
		{
			if (((Behaviour)this).isActiveAndEnabled && legacyHolder != null)
			{
				legacyHolder.SetActive(true);
				LayerShown++;
			}
		}

		private void GenerateApiSections()
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected O, but got Unknown
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			if (bindsList == null || sectionList == null)
			{
				return;
			}
			foreach (IGrouping<string, LcInputActions> item in from lc in LcInputActionApi.InputActions
				group lc by lc.Plugin.Name)
			{
				bindsList.AddSection(item.Key);
				sectionList.AddSection(item.Key);
				foreach (LcInputActions item2 in item)
				{
					if (item2.Loaded)
					{
						continue;
					}
					foreach (InputActionReference actionRef in item2.ActionRefs)
					{
						InputAction action = actionRef.action;
						InputBinding val = ((IEnumerable<InputBinding>)(object)action.bindings).First();
						string name = ((InputBinding)(ref val)).name;
						RemappableKey kbmKey = new RemappableKey
						{
							ControlName = name,
							currentInput = actionRef,
							rebindingIndex = 0,
							gamepadOnly = false
						};
						RemappableKey val2 = new RemappableKey
						{
							ControlName = name,
							currentInput = actionRef,
							rebindingIndex = 1,
							gamepadOnly = true
						};
						if (action.IsGamepadOnly())
						{
							val2.rebindingIndex = 0;
							bindsList.AddBinds(null, val2);
						}
						else
						{
							bindsList.AddBinds(kbmKey, val2);
						}
					}
					item2.Loaded = true;
				}
			}
		}

		private void FinishUi()
		{
			if (bindsList != null)
			{
				bindsList.AddFooter();
				JumpTo(0);
			}
		}

		private void HandleSectionChanged(int sectionIndex)
		{
			if (sectionList != null && bindsList != null)
			{
				sectionList.SelectSection(sectionIndex);
			}
		}

		private void OnEnable()
		{
			JumpTo(0);
			LayerShown = 1;
		}

		private void OnDisable()
		{
			LcInputActionApi.ReEnableFromRebind();
			LayerShown = 0;
		}

		private void OnDestroy()
		{
			LcInputActionApi.ContainerInstance = null;
			LayerShown = 0;
		}
	}
}
namespace LethalCompanyInputUtils.Components.Section
{
	[RequireComponent(typeof(Button), typeof(RectTransform))]
	public class SectionEntry : MonoBehaviour
	{
		public TextMeshProUGUI? indicator;

		public TextMeshProUGUI? label;

		public Button? button;

		public int sectionIndex;

		public UnityEvent<int> OnEntrySelected = new UnityEvent<int>();

		private RectTransform? _rectTransform;

		public RectTransform RectTransform
		{
			get
			{
				if (_rectTransform == null)
				{
					_rectTransform = ((Component)this).GetComponent<RectTransform>();
				}
				return _rectTransform;
			}
		}

		private void Awake()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			if (button == null)
			{
				button = ((Component)this).GetComponent<Button>();
			}
			((UnityEvent)button.onClick).AddListener(new UnityAction(SelectEntry));
		}

		public void SetText(string text)
		{
			if (label != null)
			{
				((TMP_Text)label).SetText(text, true);
			}
		}

		public void SetIndicator(bool indicated)
		{
			if (indicator != null)
			{
				((Behaviour)indicator).enabled = indicated;
			}
		}

		private void SelectEntry()
		{
			OnEntrySelected.Invoke(sectionIndex);
		}
	}
	[RequireComponent(typeof(RectTransform))]
	public class SectionHeader : MonoBehaviour
	{
		public SectionHeaderAnchor? anchor;

		public TextMeshProUGUI? label;

		private RectTransform? _rectTransform;

		public RectTransform RectTransform
		{
			get
			{
				if (_rectTransform == null)
				{
					_rectTransform = ((Component)this).GetComponent<RectTransform>();
				}
				return _rectTransform;
			}
		}

		public void SetText(string text)
		{
			if (label != null)
			{
				((TMP_Text)label).SetText(text, true);
			}
		}
	}
	[RequireComponent(typeof(RectTransform))]
	public class SectionHeaderAnchor : MonoBehaviour
	{
		public SectionHeader? sectionHeader;

		private RectTransform? _rectTransform;

		public RectTransform RectTransform
		{
			get
			{
				if (_rectTransform == null)
				{
					_rectTransform = ((Component)this).GetComponent<RectTransform>();
				}
				return _rectTransform;
			}
		}

		private void Awake()
		{
			if (_rectTransform == null)
			{
				_rectTransform = ((Component)this).GetComponent<RectTransform>();
			}
		}
	}
	public class SectionListController : MonoBehaviour
	{
		public GameObject? sectionEntryPrefab;

		public ScrollRect? scrollRect;

		public RemapContainerController? remapContainer;

		private RectTransform? _viewport;

		private RectTransform? _content;

		private readonly List<SectionEntry> _sectionEntries = new List<SectionEntry>();

		private void Awake()
		{
			if (remapContainer == null)
			{
				remapContainer = ((Component)this).GetComponentInParent<RemapContainerController>();
			}
			if (scrollRect == null)
			{
				scrollRect = ((Component)this).GetComponentInChildren<ScrollRect>();
			}
			_viewport = scrollRect.viewport;
			_content = scrollRect.content;
		}

		public void AddSection(string sectionName)
		{
			if (_content != null && sectionEntryPrefab != null)
			{
				SectionEntry component = Object.Instantiate<GameObject>(sectionEntryPrefab, (Transform)(object)_content).GetComponent<SectionEntry>();
				component.SetText(sectionName);
				component.sectionIndex = _sectionEntries.Count;
				component.OnEntrySelected.AddListener((UnityAction<int>)OnSectionEntryPressed);
				_sectionEntries.Add(component);
			}
		}

		public void SelectSection(int sectionIndex)
		{
			int count = _sectionEntries.Count;
			if (sectionIndex >= count || sectionIndex < 0)
			{
				return;
			}
			foreach (SectionEntry sectionEntry2 in _sectionEntries)
			{
				sectionEntry2.SetIndicator(indicated: false);
			}
			SectionEntry sectionEntry = _sectionEntries[sectionIndex];
			sectionEntry.SetIndicator(indicated: true);
			if (scrollRect != null)
			{
				UpdateScrollPosToFit(sectionEntry);
			}
		}

		private void UpdateScrollPosToFit(SectionEntry sectionEntry)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			if (_viewport == null || _content == null || scrollRect == null)
			{
				return;
			}
			RectTransform rectTransform = sectionEntry.RectTransform;
			float num = rectTransform.WorldMinY();
			float num2 = rectTransform.WorldMaxY();
			float num3 = _viewport.WorldMinY();
			float num4 = _viewport.WorldMaxY();
			if (!(num > num3) || !(num2 < num4))
			{
				scrollRect.StopMovement();
				float num5 = 0f;
				if (num2 > num4)
				{
					num5 = num4 - num2 - rectTransform.sizeDelta.y;
				}
				else if (num < num3)
				{
					num5 = num3 - num + rectTransform.sizeDelta.y;
				}
				float y = _content.anchoredPosition.y;
				_content.SetAnchoredPosY(y + num5);
			}
		}

		private void OnSectionEntryPressed(int sectionIndex)
		{
			if (remapContainer != null)
			{
				remapContainer.JumpTo(sectionIndex);
			}
		}
	}
}
namespace LethalCompanyInputUtils.Components.PopOvers
{
	[RequireComponent(typeof(RectTransform))]
	public class PopOver : MonoBehaviour
	{
		public enum Placement
		{
			Top,
			Bottom,
			Left,
			Right
		}

		public RectTransform? popOverLayer;

		public PopOverTextContainer? textContainer;

		public RectTransform? pivotPoint;

		public GameObject? background;

		public PopOverArrow? arrow;

		public CanvasGroup? canvasGroup;

		public float maxWidth = 300f;

		private RectTransform? _rectTransform;

		private RectTransform? _target;

		private Placement _placement;

		public void SetTarget(RectTransform target, Placement placement)
		{
			if (background != null && canvasGroup != null)
			{
				background.SetActive(true);
				_target = target;
				_placement = placement;
				SetPivot();
				SetArrow();
			}
		}

		public void ClearTarget()
		{
			if (background != null && canvasGroup != null)
			{
				canvasGroup.alpha = 0f;
				_target = null;
				background.SetActive(false);
			}
		}

		private void MoveTo(RectTransform target)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//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_002d: 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)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if (pivotPoint != null)
			{
				Vector3 val = Vector2.op_Implicit(GetTargetPosition(target));
				Vector3 val2 = Vector2.op_Implicit(GetTargetPivotOffset(target));
				Vector3 val3 = Vector2.op_Implicit(GetLabelPivotOffset());
				Vector3 targetPos = val + val2 + val3;
				MovePopOverToTarget(targetPos);
				AdjustArrowPosToTarget(target);
			}
		}

		private void SetPivot()
		{
			//IL_0039: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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)
			if (pivotPoint != null)
			{
				RectTransform val = pivotPoint;
				val.pivot = (Vector2)(_placement switch
				{
					Placement.Top => new Vector2(0.5f, 0f), 
					Placement.Bottom => new Vector2(0.5f, 1f), 
					Placement.Left => new Vector2(1f, 0.5f), 
					Placement.Right => new Vector2(0f, 0.5f), 
					_ => throw new ArgumentOutOfRangeException(), 
				});
			}
		}

		private void SetArrow()
		{
			if (arrow != null)
			{
				switch (_placement)
				{
				case Placement.Top:
					arrow.PointToBottom();
					break;
				case Placement.Bottom:
					arrow.PointToTop();
					break;
				case Placement.Left:
					arrow.PointToRight();
					break;
				case Placement.Right:
					arrow.PointToLeft();
					break;
				default:
					throw new ArgumentOutOfRangeException();
				}
			}
		}

		private Vector2 GetTargetPosition(RectTransform target)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (popOverLayer == null)
			{
				return Vector2.zero;
			}
			return popOverLayer.WorldToLocalPoint(target);
		}

		private Vector2 GetTargetPivotOffset(RectTransform target)
		{
			//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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			if (popOverLayer == null)
			{
				return Vector2.zero;
			}
			Rect relativeRect = popOverLayer.GetRelativeRect(target);
			return (Vector2)(_placement switch
			{
				Placement.Top => new Vector2(0f, 2f + ((Rect)(ref relativeRect)).height / 2f), 
				Placement.Bottom => new Vector2(0f, -2f + (0f - ((Rect)(ref relativeRect)).height) / 2f), 
				Placement.Left => new Vector2(-2f + (0f - ((Rect)(ref relativeRect)).width) / 2f, 0f), 
				Placement.Right => new Vector2(2f + ((Rect)(ref relativeRect)).width / 2f, 0f), 
				_ => throw new ArgumentOutOfRangeException(), 
			});
		}

		private Vector2 GetLabelPivotOffset()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			if (textContainer == null || textContainer.rectTransform == null || _rectTransform == null || popOverLayer == null)
			{
				return Vector2.zero;
			}
			Rect relativeRect = popOverLayer.GetRelativeRect(_rectTransform);
			Rect relativeRect2 = popOverLayer.GetRelativeRect(textContainer.rectTransform);
			return (Vector2)(_placement switch
			{
				Placement.Top => new Vector2(0f, 0f - (((Rect)(ref relativeRect)).height - ((Rect)(ref relativeRect2)).height) / 2f), 
				Placement.Bottom => new Vector2(0f, (((Rect)(ref relativeRect)).height - ((Rect)(ref relativeRect2)).height) / 2f), 
				Placement.Left => new Vector2((((Rect)(ref relativeRect)).width - ((Rect)(ref relativeRect2)).width) / 2f, 0f), 
				Placement.Right => new Vector2(0f - (((Rect)(ref relativeRect)).width - ((Rect)(ref relativeRect2)).width) / 2f, 0f), 
				_ => throw new ArgumentOutOfRangeException(), 
			});
		}

		private void MovePopOverToTarget(Vector3 targetPos)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid