Decompiled source of Remnants v1.3.8

Remnants.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Remnants.Behaviours;
using Remnants.Data;
using Remnants.Patches;
using Remnants.utilities;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Remnants")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP Inc.")]
[assembly: AssemblyProduct("Remnants")]
[assembly: AssemblyCopyright("Copyright © HP Inc. 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6c141570-800d-4365-af83-2d520645ce78")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace Remnants
{
	[BepInDependency("evaisa.lethallib", "0.16.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("KawaiiBone.Remnants", "Remnants", "1.3.8")]
	public class Remnants : BaseUnityPlugin
	{
		private const string modGUID = "KawaiiBone.Remnants";

		private const string modName = "Remnants";

		private const string modVersion = "1.3.8";

		public static Remnants Instance;

		private readonly Harmony _harmony = new Harmony("KawaiiBone.Remnants");

		internal ManualLogSource Mls;

		public RegisterBodiesSpawnBehaviour RegisterBodiesSpawn = new RegisterBodiesSpawnBehaviour();

		public Config RemnantsConfig = new Config();

		public RegisterBodySuitsBehaviour RegisterBodySuits = new RegisterBodySuitsBehaviour();

		public LoadAssetsBodies LoadBodyAssets = new LoadAssetsBodies();

		public SpawnBodiesBehaviour SpawningBodyBeh = new SpawnBodiesBehaviour();

		public RemnantItemsBehaviour RemnantItemsBeh = new RemnantItemsBehaviour();

		public RandomizeBatteriesBehaviour ItemsBatteriesBeh = new RandomizeBatteriesBehaviour();

		public RemnantItemsLocationsBehaviour RegisterItemLocationsBeh = new RemnantItemsLocationsBehaviour();

		public SpawnRemnantItemsBehaviour SpawnRemnantItemsBeh = new SpawnRemnantItemsBehaviour();

		private RegisterItemsBehaviour _registerItemsBehaviour = new RegisterItemsBehaviour();

		private string[] _riskLevelArray = new string[9] { "Safe", "D", "C", "B", "A", "S", "S+", "S++", "S+++" };

		public string[] RiskLevelArray => _riskLevelArray;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Mls = Logger.CreateLogSource("KawaiiBone.Remnants");
			Mls.LogInfo((object)"modGUID has started");
			RemnantsConfig.Initialize();
			_harmony.PatchAll(typeof(RemnantItemsPatch));
			_harmony.PatchAll(typeof(SpawnRemnantItemsPatch));
			_harmony.PatchAll(typeof(SpawnableScrapPatch));
			_harmony.PatchAll(typeof(DespawnRemnantsPatch));
			_harmony.PatchAll(typeof(BodySuitBehaviour));
			_harmony.PatchAll(typeof(RegisterSuitsPatch));
			_harmony.PatchAll(typeof(AddRemnantItemsToItemList));
			_harmony.PatchAll(typeof(TerminalScanItemsPatch));
			_harmony.PatchAll(typeof(BeltBagTranspiler));
			_harmony.PatchAll(typeof(SaveGameTranspiler));
			_harmony.PatchAll(typeof(Remnants));
			_registerItemsBehaviour.Initialize();
			RegisterBodiesSpawn.Initialize();
			LoadBodyAssets.Initialize();
			RegisterBodySuits.Initialize();
			SpawningBodyBeh.Initialize();
			ItemsBatteriesBeh.Initialize();
			RegisterItemLocationsBeh.Initialize();
			SpawnRemnantItemsBeh.Initialize();
			Mls.LogInfo((object)"modGUID has loaded");
		}
	}
}
namespace Remnants.utilities
{
	internal class CoroutineHelper : MonoBehaviour
	{
		public static CoroutineHelper Instance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
				Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			}
			else
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		public void ExecuteAfterDelay(Action action, float delay)
		{
			((MonoBehaviour)this).StartCoroutine(DelayedExecution(action, delay));
		}

		private IEnumerator DelayedExecution(Action action, float delay)
		{
			yield return (object)new WaitForSeconds(delay);
			action();
		}
	}
	public class RemnantData
	{
		public string RemnantItemName { get; set; }

		public int RarityInfo { get; set; }
	}
	public class SuitData
	{
		public string SuitName { get; set; }

		public bool UseSuit { get; set; }
	}
}
namespace Remnants.Patches
{
	internal class AddRemnantItemsToItemList
	{
		private static bool _hasAddedNetworkRemnantItems;

		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyPostfix]
		private static void AddNetworkRemnantToStartOfRoundList(StartOfRound __instance)
		{
			if (!_hasAddedNetworkRemnantItems)
			{
				_hasAddedNetworkRemnantItems = true;
				ManualLogSource mls = Remnants.Instance.Mls;
				mls.LogInfo((object)"Patch, adding network remnant items to startOfRound item list.");
				List<ScrapItem> networkRemnantItems = Remnants.Instance.RemnantItemsBeh.NetworkRemnantItems;
				for (int i = 0; i < networkRemnantItems.Count; i++)
				{
					__instance.allItemsList.itemsList.Add(networkRemnantItems[i].item);
				}
			}
		}
	}
	internal class BeltBagTranspiler
	{
		private static FieldInfo _itemIsScrapField = AccessTools.Field(typeof(GrabbableObject), "itemProperties");

		[HarmonyPatch(typeof(BeltBagItem), "ItemInteractLeftRight")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> SaveItemsInShipTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator il)
		{
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Expected O, but got Unknown
			ManualLogSource mls = Remnants.Instance.Mls;
			if (!Remnants.Instance.RemnantsConfig.UseBeltBagTranspiler.Value)
			{
				mls.LogWarning((object)"Beltbag feature disabled, beltbag can now not pickup remnant items.");
				return instructions;
			}
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			int num = -1;
			int num2 = -1;
			for (int i = 0; i < list.Count; i++)
			{
				if (num == -1 && CodeInstructionExtensions.LoadsField(list[i], _itemIsScrapField, false))
				{
					num = i;
				}
				else if (num > -1 && list[i].opcode == OpCodes.Brtrue)
				{
					num2 = i;
					break;
				}
			}
			if (num == -1 || num2 == -1)
			{
				mls.LogError((object)"Could not find place in if statement to edit, unable to use BeltBagItem with remnant items.");
				return list.AsEnumerable();
			}
			int num3 = num2 - num;
			for (int j = 0; j < num3; j++)
			{
				list[j + num].opcode = OpCodes.Nop;
			}
			list[num2].opcode = OpCodes.Brfalse_S;
			list.Insert(num, new CodeInstruction(OpCodes.Ldloc_1, (object)null));
			list.Insert(num + 1, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(BeltBagTranspiler), "CheckIsStoreOrRemnantItem", new Type[1] { typeof(GrabbableObject) }, (Type[])null)));
			mls.LogInfo((object)"Transpiler succes with function: ItemInteractLeftRight for BeltBagItem.");
			return list.AsEnumerable();
		}

		public bool CheckIsStoreOrRemnantItem(GrabbableObject grabbableObject)
		{
			if ((Object)(object)grabbableObject == (Object)null || (Object)(object)grabbableObject.itemProperties == (Object)null)
			{
				return false;
			}
			if (!grabbableObject.itemProperties.isScrap)
			{
				return true;
			}
			List<RemnantData> remnantItemList = Remnants.Instance.RemnantsConfig.GetRemnantItemList(reloadConfig: false);
			if (remnantItemList.FindIndex((RemnantData configEntry) => configEntry.RemnantItemName == grabbableObject.itemProperties.itemName || configEntry.RemnantItemName == ((Object)grabbableObject.itemProperties).name) != -1)
			{
				return true;
			}
			return false;
		}
	}
	internal class DespawnRemnantsPatch
	{
		private static MethodInfo _firstMethodToFind = SymbolExtensions.GetMethodInfo((Expression<Action>)(() => Object.FindObjectsOfType<GrabbableObject>()));

		private static bool _canUseTranspiler = true;

		private static void DespawnItems(GrabbableObject[] grabbableObjects, bool skipShipRoom, bool despawnALlItems, string placeOfDespawning)
		{
			ManualLogSource mls = Remnants.Instance.Mls;
			if (grabbableObjects == null || grabbableObjects.Length == 0)
			{
				mls.LogInfo((object)("Could not find grabbableObjects in: " + placeOfDespawning));
				return;
			}
			foreach (GrabbableObject val in grabbableObjects)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				NetworkObject component = ((Component)val).GetComponent<NetworkObject>();
				if ((Object)(object)component == (Object)null || !component.IsSpawned || (!despawnALlItems && skipShipRoom && val.isInShipRoom && val.isInElevator))
				{
					continue;
				}
				if (val.isHeld && (Object)(object)val.playerHeldBy != (Object)null)
				{
					if (despawnALlItems)
					{
						val.playerHeldBy.DropAllHeldItemsAndSync();
					}
					else
					{
						if (val.playerHeldBy.isInHangarShipRoom && val.playerHeldBy.isInElevator)
						{
							continue;
						}
						val.playerHeldBy.DropAllHeldItemsAndSync();
					}
				}
				mls.LogInfo((object)("Despawning " + val.itemProperties.itemName + " from " + placeOfDespawning + "."));
				component.Despawn(true);
			}
		}

		private static void DespawnRemnantItems(object[] __args)
		{
			ManualLogSource mls = Remnants.Instance.Mls;
			bool flag = (bool)__args[0];
			mls.LogInfo((object)"Patching Despawn Remnant Items AtEndOfRound.");
			StartOfRound instance = StartOfRound.Instance;
			if (!((Object)(object)instance == (Object)null) && NetworkManager.Singleton.IsServer)
			{
				if (Remnants.Instance.RemnantsConfig.ShouldAlwaysDespawnRemnantItems.Value)
				{
					flag = true;
				}
				RemnantItemsBehaviour remnantItemsBeh = Remnants.Instance.RemnantItemsBeh;
				RemnantItemsLocationsBehaviour registerItemLocationsBeh = Remnants.Instance.RegisterItemLocationsBeh;
				if (flag || (StartOfRound.Instance.allPlayersDead && Remnants.Instance.RemnantsConfig.ShouldDespawnRemnantItemsOnPartyWipe.Value))
				{
					DespawnItems(registerItemLocationsBeh.GetShipRemnantItems(), !registerItemLocationsBeh.ShipObjectLocation.IsShipRoom, flag, registerItemLocationsBeh.ShipObjectLocation.ObjectLocationsNames.Last());
				}
				DespawnItems(registerItemLocationsBeh.GetItemsInProps(), !registerItemLocationsBeh.PropObjectLocation.IsShipRoom, flag, registerItemLocationsBeh.PropObjectLocation.ObjectLocationsNames.Last());
				DespawnItems(registerItemLocationsBeh.GetItemsInRoot(), !registerItemLocationsBeh.RootObjectLocation.IsShipRoom, flag, "Root objects");
				remnantItemsBeh.RemoveDespawnedAndNullItems();
				GrabbableObject[] grabbableObjects = RemnantItemsBehaviour.FoundRemnantItems.ConvertAll((GameObject remnantOBJ) => remnantOBJ.GetComponent<GrabbableObject>()).ToArray();
				DespawnItems(grabbableObjects, skipShipRoom: true, flag, "Unknown place");
				remnantItemsBeh.RemoveDespawnedAndNullItems();
			}
		}

		[HarmonyPatch(typeof(RoundManager), "DespawnPropsAtEndOfRound")]
		[HarmonyPostfix]
		private static void DespawnRemnantItemsAtEndOfRoundPatch(object[] __args)
		{
			if (!_canUseTranspiler)
			{
				ManualLogSource mls = Remnants.Instance.Mls;
				mls.LogInfo((object)"Patching Despawn Remnant Items AtEndOfRound.");
				DespawnRemnantItems(__args);
			}
		}

		[HarmonyPatch(typeof(RoundManager), "DespawnPropsAtEndOfRound")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> DespawnPropsAtEndOfRoundTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			ManualLogSource mls = Remnants.Instance.Mls;
			if (!Remnants.Instance.RemnantsConfig.ShouldDespawnRemnantItemsOnPartyWipe.Value)
			{
				mls.LogWarning((object)"Using config feature: Do not despawn remnant items on party wipe. This will not use the transpiler for cleaning up items, and may cause issues.");
				_canUseTranspiler = false;
				return instructions;
			}
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			int num = -1;
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Call && CodeInstructionExtensions.Calls(list[i], _firstMethodToFind))
				{
					num = i;
					break;
				}
			}
			if (num == -1)
			{
				mls.LogError((object)"Could not find first call to edit, using old patching method to despawn remnant items.");
				_canUseTranspiler = false;
				return list.AsEnumerable();
			}
			MethodInfo method = typeof(RemnantItemsLocationsBehaviour).GetMethod("GetAllItems");
			list.Insert(num + 1, new CodeInstruction(OpCodes.Call, (object)method));
			mls.LogInfo((object)"Transpiler succes with function: Despawn Props At End Of Round.");
			return list.AsEnumerable();
		}

		[HarmonyPatch(typeof(GameNetworkManager), "Disconnect")]
		[HarmonyPostfix]
		public static void DespawnRemnantItemsOnDisconnect(GameNetworkManager __instance)
		{
			ManualLogSource mls = Remnants.Instance.Mls;
			mls.LogInfo((object)"Patching Despawn Remnant Items at disconnect.");
			if ((__instance.isDisconnecting || !((Object)(object)StartOfRound.Instance == (Object)null)) && __instance.isHostingGame)
			{
				object[] _args = new object[1] { true };
				DespawnRemnantItems(_args);
			}
		}

		[HarmonyPatch(typeof(GameNetworkManager), "DisconnectProcess")]
		[HarmonyPrefix]
		public static void DespawnRemnantItemsOnDisconnectProcess(GameNetworkManager __instance)
		{
			ManualLogSource mls = Remnants.Instance.Mls;
			mls.LogInfo((object)"Patching Despawn Remnant Items at disconnect process.");
			if (__instance.isHostingGame)
			{
				object[] _args = new object[1] { true };
				DespawnRemnantItems(_args);
			}
		}

		[HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")]
		[HarmonyPrefix]
		private static void DespawnRemnantItemsOnStartDisconnect()
		{
			ManualLogSource mls = Remnants.Instance.Mls;
			mls.LogInfo((object)"Patching ownership of Remnant Items at start disconnect.");
			RemnantItemsLocationsBehaviour registerItemLocationsBeh = Remnants.Instance.RegisterItemLocationsBeh;
			List<GrabbableObject> list = registerItemLocationsBeh.GetShipItems().ToList();
			list.AddRange(registerItemLocationsBeh.GetItemsInProps());
			list.AddRange(registerItemLocationsBeh.GetItemsInRoot());
			foreach (GrabbableObject item in list)
			{
				NetworkObject component = ((Component)item).GetComponent<NetworkObject>();
				if ((Object)(object)component != (Object)null)
				{
					component.DontDestroyWithOwner = false;
					mls.LogInfo((object)(((Object)item).name + " DontDestroyWithOwner to false"));
				}
			}
		}
	}
	internal class RegisterSuitsPatch
	{
		private static bool _hasRegistered;

		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		private static void RegisterBodySuitsPatch(StartOfRound __instance)
		{
			if (!_hasRegistered)
			{
				ManualLogSource mls = Remnants.Instance.Mls;
				mls.LogInfo((object)"Patching register body suits.");
				Remnants.Instance.RegisterBodySuits.RegisterSuitsDataToConfig(__instance.unlockablesList.unlockables);
				_hasRegistered = true;
			}
		}
	}
	internal class RemnantItemsPatch
	{
		[HarmonyPatch(typeof(RoundManager), "waitForScrapToSpawnToSync")]
		[HarmonyPostfix]
		private static void PatchRemnantItems(object[] __args)
		{
			ManualLogSource mls = Remnants.Instance.Mls;
			NetworkObjectReference[] array = (NetworkObjectReference[])__args[0];
			mls.LogInfo((object)"Patching remnant items.");
			if (array == null)
			{
				mls.LogWarning((object)"spawnedScrap IS NULL");
				return;
			}
			RemnantItemsBehaviour remnantItemsBeh = Remnants.Instance.RemnantItemsBeh;
			remnantItemsBeh.RemoveDespawnedAndNullItems();
			RandomizeBatteriesBehaviour itemsBatteriesBeh = Remnants.Instance.ItemsBatteriesBeh;
			SpawnBodiesBehaviour spawningBodyBeh = Remnants.Instance.SpawningBodyBeh;
			List<GameObject> list = new List<GameObject>();
			List<RemnantData> remnantItemList = Remnants.Instance.RemnantsConfig.GetRemnantItemList();
			List<string> overriddenScrapItems = Remnants.Instance.RemnantsConfig.GetOverriddenScrapItems();
			NetworkObject val = default(NetworkObject);
			for (int i = 0; i < array.Length; i++)
			{
				if (!((NetworkObjectReference)(ref array[i])).TryGet(ref val, (NetworkManager)null))
				{
					continue;
				}
				GrabbableObject grabbableObject = ((Component)val).GetComponent<GrabbableObject>();
				if (!((Object)(object)grabbableObject == (Object)null))
				{
					if (overriddenScrapItems.FindIndex((string scrapName) => scrapName == grabbableObject.itemProperties.itemName || scrapName == ((Object)grabbableObject.itemProperties).name) != -1)
					{
						list.Add(((Component)grabbableObject).gameObject);
					}
					else if (remnantItemList.FindIndex((RemnantData itemData) => itemData.RemnantItemName == grabbableObject.itemProperties.itemName || itemData.RemnantItemName == ((Object)grabbableObject.itemProperties).name) != -1)
					{
						remnantItemsBeh.AddFoundRemnantItemObject(((Component)grabbableObject).gameObject);
						list.Add(((Component)grabbableObject).gameObject);
					}
				}
			}
			itemsBatteriesBeh.RandomizeItemsBattery(list);
			spawningBodyBeh.SpawnBodiesOnItems(list);
		}
	}
	public class SaveGameTranspiler
	{
		private static MethodInfo _firstMethodToFind = SymbolExtensions.GetMethodInfo((Expression<Action>)(() => Object.FindObjectsByType<GrabbableObject>((FindObjectsInactive)0, (FindObjectsSortMode)0)));

		[HarmonyPatch(typeof(GameNetworkManager), "SaveItemsInShip")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> SaveItemsInShipTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			ManualLogSource mls = Remnants.Instance.Mls;
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			int num = -1;
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Call && CodeInstructionExtensions.Calls(list[i], _firstMethodToFind))
				{
					num = i;
					break;
				}
			}
			if (num == -1)
			{
				mls.LogError((object)"Could not find first call to edit, unable to save remnant items.");
				return list.AsEnumerable();
			}
			MethodInfo method = typeof(RemnantItemsLocationsBehaviour).GetMethod("GetItemsToSave");
			list.Insert(num + 1, new CodeInstruction(OpCodes.Call, (object)method));
			mls.LogInfo((object)"Transpiler succes with function: Save Items In Ship.");
			return list.AsEnumerable();
		}
	}
	internal class TerminalScanItemsPatch
	{
		private static MethodInfo _findFirstGrabbableObjectMethod = SymbolExtensions.GetMethodInfo((Expression<Action>)(() => Object.FindObjectsOfType<GrabbableObject>()));

		private static FieldInfo _itemIsScrapField = AccessTools.Field(typeof(GrabbableObject), "itemProperties");

		[HarmonyPatch(typeof(Terminal), "TextPostProcess")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> TerminalScanItemsTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator il)
		{
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			ManualLogSource mls = Remnants.Instance.Mls;
			if (!Remnants.Instance.RemnantsConfig.UseTerminalScanItemsTranspiler.Value)
			{
				mls.LogWarning((object)"Terminal scan items feature disabled, terminal can now not find remnant items when scanning.");
				return instructions;
			}
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			int num = -1;
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Call && CodeInstructionExtensions.Calls(list[i], _findFirstGrabbableObjectMethod))
				{
					num = i;
					break;
				}
			}
			if (num == -1)
			{
				mls.LogError((object)"Could not find place to edit, unable to use scan remnant items in the terminal.");
				return list.AsEnumerable();
			}
			list.Insert(num + 1, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(RemnantItemsLocationsBehaviour), "GetAllItems", (Type[])null, (Type[])null)));
			mls.LogInfo((object)"Transpiler succes with function: TextPostProcess for scanning remnant items via the terminal.");
			return list.AsEnumerable();
		}
	}
	internal class SpawnableScrapPatch
	{
		private static int _currentLevelMinScrap = 0;

		private static int _currentLevelMaxScrap = 0;

		private static List<SpawnableItemWithRarity> _removedSpawnableItems = new List<SpawnableItemWithRarity>();

		[HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")]
		[HarmonyPrefix]
		public static void SpawnScrapInLevelPatch(RoundManager __instance)
		{
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource mls = Remnants.Instance.Mls;
			mls.LogInfo((object)"Patching remnant items spawns.");
			List<SpawnableItemWithRarity> spawnableScrap = __instance.currentLevel.spawnableScrap;
			List<RemnantData> scrapItemDataList = Remnants.Instance.RemnantsConfig.GetRemnantItemList();
			_removedSpawnableItems = spawnableScrap.Where((SpawnableItemWithRarity spawnableItem) => scrapItemDataList.FindIndex((RemnantData itemData) => itemData.RarityInfo == 0 && itemData.RemnantItemName == spawnableItem.spawnableItem.itemName) != -1).ToList();
			spawnableScrap.RemoveAll((SpawnableItemWithRarity spawnableItem) => _removedSpawnableItems.Contains(spawnableItem));
			__instance.currentLevel.spawnableScrap = spawnableScrap;
			if (Remnants.Instance.RemnantsConfig.IncreasedScrapSpawnPool.Value <= 0 || !Remnants.Instance.RemnantsConfig.UseLegacySpawning.Value)
			{
				return;
			}
			_currentLevelMinScrap = __instance.currentLevel.minScrap;
			_currentLevelMaxScrap = __instance.currentLevel.maxScrap;
			float num = 1f;
			float num2 = 100f / (float)Remnants.Instance.RemnantsConfig.IncreasedScrapSpawnPool.Value;
			if (!Remnants.Instance.RemnantsConfig.UseSpecificLevelRarities.Value)
			{
				num = (float)Remnants.Instance.RemnantsConfig.MaxRemnantRarity.Value / num2;
			}
			else if (Remnants.Instance.RemnantsConfig.CustomLevelRarities.ContainsKey(__instance.currentLevel.PlanetName))
			{
				num = (float)Remnants.Instance.RemnantsConfig.CustomLevelRarities[__instance.currentLevel.PlanetName].Item2 / num2;
			}
			else
			{
				foreach (KeyValuePair<LevelTypes, Tuple<int, int>> levelRarity in Remnants.Instance.RemnantsConfig.LevelRarities)
				{
					string value = __instance.currentLevel.PlanetName.Split(new char[1] { ' ' }).Last();
					LevelTypes key = levelRarity.Key;
					if (((object)(LevelTypes)(ref key)).ToString().Contains(value))
					{
						num = (float)levelRarity.Value.Item2 / num2;
						break;
					}
				}
			}
			num = Mathf.Clamp(num, 1f, (float)Remnants.Instance.RemnantsConfig.IncreasedScrapSpawnPool.Value);
			SelectableLevel currentLevel = __instance.currentLevel;
			currentLevel.minScrap += (int)num;
			SelectableLevel currentLevel2 = __instance.currentLevel;
			currentLevel2.maxScrap += (int)num;
		}

		[HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")]
		[HarmonyPostfix]
		public static void SpawnScrapInLevelEndPatch(RoundManager __instance)
		{
			ManualLogSource mls = Remnants.Instance.Mls;
			mls.LogInfo((object)"Patching end of Spawn Scrap.");
			__instance.currentLevel.spawnableScrap.AddRange(_removedSpawnableItems);
			_removedSpawnableItems.Clear();
			if (Remnants.Instance.RemnantsConfig.IncreasedScrapSpawnPool.Value > 0 && Remnants.Instance.RemnantsConfig.UseLegacySpawning.Value)
			{
				__instance.currentLevel.minScrap = _currentLevelMinScrap;
				__instance.currentLevel.maxScrap = _currentLevelMaxScrap;
			}
		}
	}
	internal class SpawnRemnantItemsPatch
	{
		[HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")]
		[HarmonyPostfix]
		private static void PatchSpawnRemnantItems(RoundManager __instance)
		{
			if (!Remnants.Instance.RemnantsConfig.UseLegacySpawning.Value)
			{
				ManualLogSource mls = Remnants.Instance.Mls;
				mls.LogInfo((object)"Patching spawn remnant items.");
				Remnants.Instance.SpawnRemnantItemsBeh.SpawnRemnantItems(__instance);
				Remnants.Instance.SpawningBodyBeh.SpawnBodiesOnPositions(Remnants.Instance.SpawnRemnantItemsBeh.BodySpawnPositions, alwaysSpawn: true);
			}
		}
	}
}
namespace Remnants.Data
{
	public class Config
	{
		private struct ConfigData
		{
			public string Name;

			public string Discription;

			public string StringValue;

			public ConfigData(string name, string discription, string stringValue)
			{
				Name = name;
				Discription = discription;
				StringValue = stringValue;
			}
		}

		private struct ConfigDataValue<T> where T : struct
		{
			public string Name;

			public string Discription;

			public T Value;
		}

		public ConfigEntry<int> MinRemnantRarity;

		public ConfigEntry<int> MaxRemnantRarity;

		public ConfigEntry<int> MinRemnantBatteryCharge;

		public ConfigEntry<int> MaxRemnantBatteryCharge;

		public List<ConfigEntry<int>> ConfigScrapDataList;

		public List<ConfigEntry<bool>> ConfigSuitsDataList;

		public ConfigEntry<bool> UseSpecificLevelRarities;

		public ConfigEntry<float> MaxRemnantItemCost;

		public ConfigEntry<int> SpawnRarityOfBody;

		public ConfigEntry<float> BodySpawnModifierRiskLevel;

		public ConfigEntry<int> RemnantScrapMinCostPercentage;

		public ConfigEntry<int> RemnantScrapMaxCostPercentage;

		public ConfigEntry<bool> ShouldSaveRemnantItems;

		public ConfigEntry<bool> ShouldDespawnRemnantItemsOnPartyWipe;

		public ConfigEntry<bool> ShouldAlwaysDespawnRemnantItems;

		public ConfigEntry<bool> ShouldBodiesBeScrap;

		public ConfigEntry<int> MinBodyScrapValue;

		public ConfigEntry<int> MaxBodyScrapValue;

		public Dictionary<LevelTypes, Tuple<int, int>> LevelRarities = new Dictionary<LevelTypes, Tuple<int, int>>();

		public Dictionary<string, Tuple<int, int>> CustomLevelRarities = new Dictionary<string, Tuple<int, int>>();

		public ConfigEntry<int> IncreasedScrapSpawnPool;

		public ConfigEntry<bool> UseLegacySpawning;

		public ConfigEntry<int> MinRemnantItemsSpawning;

		public ConfigEntry<int> MaxRemnantItemsSpawning;

		public ConfigEntry<float> RemnantItemsSpawningModifier;

		public ConfigEntry<int> MaxDuplicatesRemnantItems;

		public ConfigEntry<int> MinItemsFoundOnBodies;

		public ConfigEntry<int> MaxItemsFoundOnBodies;

		public ConfigEntry<bool> UseBeltBagTranspiler;

		public ConfigEntry<bool> UseTerminalScanItemsTranspiler;

		private bool _hasInitialized = false;

		private List<ConfigEntry<int>> _minRemnantLevelRarities = new List<ConfigEntry<int>>();

		private List<ConfigEntry<int>> _maxRemnantLevelRarities = new List<ConfigEntry<int>>();

		private List<ConfigEntry<int>> _minRemnantCustomLevelRarities = new List<ConfigEntry<int>>();

		private List<ConfigEntry<int>> _maxRemnantCustomLevelRarities = new List<ConfigEntry<int>>();

		private List<ConfigDataValue<int>> _configRemnantDataPairList = new List<ConfigDataValue<int>>();

		private List<ConfigDataValue<int>> _configCustomLevelsRarities = new List<ConfigDataValue<int>>();

		private List<ConfigDataValue<bool>> _configSuitsDataList = new List<ConfigDataValue<bool>>();

		private ConfigEntry<string> _bannedNamesFromRegistering;

		private ConfigEntry<string> _overriddenScrapItems;

		private ConfigEntry<string> _bannedItemsFromSaving;

		private ConfigFile _configFile;

		private string _bannedPlanetName = "71 Gordion";

		private const string _LethalConfigName = "ainavt.lc.lethalconfig";

		private string _configFileName = "\\Remnants.cfg";

		private string _generalSection = "General";

		private string _generalBodySection = "GeneralBody";

		private string _levelsSection = "Levels";

		private string _customLevelsSection = "ModdedLevels";

		private string _otherSection = "Other";

		private string _remnantsSection = "Remnants";

		private string _spawningSection = "Spawning";

		private string _spawningLegacySection = "SpawningLegacy";

		private string _suitsSection = "Suits";

		private string _saveLoadSection = "Save/load";

		private const int _maxPercentage = 100;

		private const int _minPercentage = 1;

		private const int _maxRemnantItemsSpawned = 50;

		private const float _minItemCost = 5f;

		private const float _maxItemCost = 1000f;

		private const float _maxItemStoreCost = 10000f;

		private const float _maxModifierWithMoonThreath = 10f;

		private const int _maxDuplicatesOfARemnantItem = 15;

		private const int _maximumItemsFoundOnBody = 10;

		private const int _maximumScrapSpawnPoolIncrease = 30;

		private const int _defaultMinRarity = 1;

		private const int _defaultMaxRarity = 100;

		public void Initialize()
		{
			if (!_hasInitialized)
			{
				_hasInitialized = true;
				LoadConfig();
			}
		}

		private void LoadConfig()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_0657: Unknown result type (might be due to invalid IL or missing references)
			//IL_066f: Unknown result type (might be due to invalid IL or missing references)
			//IL_068b: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a7: Unknown result type (might be due to invalid IL or missing references)
			LoadConfigData();
			_configFile = new ConfigFile(Paths.ConfigPath + _configFileName, true);
			MinRemnantRarity = _configFile.Bind<int>(_generalSection, "Min remnant item rarity", 1, "Minimum chance of a remnant item spawning.");
			MinRemnantRarity.Value = Mathf.Clamp(MinRemnantRarity.Value, 1, 100);
			MaxRemnantRarity = _configFile.Bind<int>(_generalSection, "Max remnant item rarity", 100, "Maximum chance of a remnant item spawning.");
			MaxRemnantRarity.Value = Mathf.Clamp(MaxRemnantRarity.Value, MinRemnantRarity.Value, 100);
			MinRemnantBatteryCharge = _configFile.Bind<int>(_generalSection, "Min remnant battery charge", 20, "Minimum remnant item battery charge on first finding it.");
			MinRemnantBatteryCharge.Value = Mathf.Clamp(MinRemnantBatteryCharge.Value, 1, 100);
			MaxRemnantBatteryCharge = _configFile.Bind<int>(_generalSection, "Max remnant battery charge", 90, "Maximum remnant item battery charge on first finding it.");
			MaxRemnantBatteryCharge.Value = Mathf.Clamp(MaxRemnantBatteryCharge.Value, MinRemnantBatteryCharge.Value, 100);
			RemnantScrapMinCostPercentage = _configFile.Bind<int>(_generalSection, "Remnant item min scrap cost percentage", 5, "The min percentage of how much worth of scrap a remnant item is compared to its normal credit cost. \nFrom 0 percentage scrap cost to 1000 percentage.");
			RemnantScrapMinCostPercentage.Value = Mathf.Clamp(RemnantScrapMinCostPercentage.Value, 0, 1000);
			RemnantScrapMaxCostPercentage = _configFile.Bind<int>(_generalSection, "Remnant item max scrap cost percentage", 20, "The max percentage of how much worth of scrap a remnant item is compared to its normal credit cost. \nFrom 0 percentage scrap cost to 1000 percentage.");
			RemnantScrapMaxCostPercentage.Value = Mathf.Clamp(RemnantScrapMaxCostPercentage.Value, RemnantScrapMinCostPercentage.Value, 1000);
			ShouldBodiesBeScrap = _configFile.Bind<bool>(_generalBodySection, "Should bodies be scrap", true, "When the bodies are a scrap they can be grabbed, have a scrap value and can be sold. \nIf not then it becomes a prop and cannot be interacted with.");
			SpawnRarityOfBody = _configFile.Bind<int>(_generalBodySection, "Body spawn rarity", 2, "This number is the chance that a body spawns next to an remnant item.");
			SpawnRarityOfBody.Value = Mathf.Clamp(SpawnRarityOfBody.Value, 0, 100);
			BodySpawnModifierRiskLevel = _configFile.Bind<float>(_generalBodySection, "Body spawn modifier per moon risk level", 1.2f, "By increasing this modifier you will increase the spawnchance of the body per risk level moon.");
			BodySpawnModifierRiskLevel.Value = Mathf.Clamp(BodySpawnModifierRiskLevel.Value, 0f, 10f);
			MinBodyScrapValue = _configFile.Bind<int>(_generalBodySection, "Min scrap value of the bodies", 8, "The minimum scrap value of the bodies that this mod spawns. \nThis only works if the bodies are set to scrap.");
			MinBodyScrapValue.Value = Mathf.Clamp(MinBodyScrapValue.Value, 0, 1000);
			MaxBodyScrapValue = _configFile.Bind<int>(_generalBodySection, "Max scrap value of the bodies", 25, "The maximum scrap value of the bodies that this mod spawns. \nThis only works if the bodies are set to scrap.");
			MaxBodyScrapValue.Value = Mathf.Clamp(MaxBodyScrapValue.Value, MinBodyScrapValue.Value, 1000);
			MaxRemnantItemCost = _configFile.Bind<float>(_otherSection, "Max value to calculate rarity", 400f, "This value helps calculating the spawn rarity, the rarity is calculated by the credit cost of the shop item. \nThis caps the maximum cost of an item and setting it as min spawn rarity if it is the same or higher than this value. \nThe more an item cost, the less spawn chance/spawn rarity it has.");
			MaxRemnantItemCost.Value = Mathf.Clamp(MaxRemnantItemCost.Value, 5f, 10000f);
			_bannedNamesFromRegistering = _configFile.Bind<string>(_otherSection, "Item list banned from registering as scrap", "Clipboard,StickyNote,Binoculars,MapDevice,Key,Error", "List of items that are barred from registering as scrap/remnant item. \nThese default items are there to avoid adding scrap that are left out of the vanilla version, don't work, or cause crashes. \nTo add more names to the list, be sure to add a comma between names.");
			_overriddenScrapItems = _configFile.Bind<string>(_otherSection, "Scrap item list to be used as remnant items", "Example scrap,Scrap-example", "In here you can add scrap items to be treated as remnant items, to spawn bodies on and to randomize batteries. \nTo add more names to the list, be sure to add a comma between names.");
			UseBeltBagTranspiler = _configFile.Bind<bool>(_otherSection, "Beltbag can store remnant items", true, "Make the beltbag item able to store remnant items. You can disable this feature to make other mods for the beltbag item more compatible.");
			UseTerminalScanItemsTranspiler = _configFile.Bind<bool>(_otherSection, "Terminal can scan remnant items", true, "Make the Terminal able to  scan remnant items. You can disable this feature to make other mods that interact with the terminal more compatible.");
			MinRemnantItemsSpawning = _configFile.Bind<int>(_spawningSection, "Minimum remnant items spawned on a moon", 3, "The minimum remnant items that can spawn on a moon. \nThis value gets increased by the threat level a moon has, along the down below modifier.");
			MinRemnantItemsSpawning.Value = Mathf.Clamp(MinRemnantItemsSpawning.Value, 1, 50);
			MaxRemnantItemsSpawning = _configFile.Bind<int>(_spawningSection, "Maximum remnant items spawned on a moon", 8, "The maximum remnant items that can spawn on a moon. \nThis value gets increased by the threat level a moon has, along the down below modifier.");
			MaxRemnantItemsSpawning.Value = Mathf.Clamp(MaxRemnantItemsSpawning.Value, MinRemnantItemsSpawning.Value, 50);
			RemnantItemsSpawningModifier = _configFile.Bind<float>(_spawningSection, "Remnant items spawn modifier", 1f, "A modifier that increases the spawn pool of remnant items in relative to the moon threat level. \nPutting the value under zero, will disable this feature and will always use the normal spawn amount.");
			RemnantItemsSpawningModifier.Value = Mathf.Clamp(RemnantItemsSpawningModifier.Value, -1f, 10f);
			MaxDuplicatesRemnantItems = _configFile.Bind<int>(_spawningSection, "Maximum duplicates can spawn", 4, "The maximum duplicates of a remnant item that can spawn on a moon. \nDo note that the spawning of remnant items will stop when it has used up all maximum duplicates.");
			MaxDuplicatesRemnantItems.Value = Mathf.Clamp(MaxDuplicatesRemnantItems.Value, 1, 15);
			MinItemsFoundOnBodies = _configFile.Bind<int>(_spawningSection, "Minimum remnant items found on a body", 1, "The Minimum remnant items found on a body.");
			MinItemsFoundOnBodies.Value = Mathf.Clamp(MinItemsFoundOnBodies.Value, 1, 10);
			MaxItemsFoundOnBodies = _configFile.Bind<int>(_spawningSection, "Maximum remnant items found on a body", 4, "The maximum remnant items found on a body.");
			MaxItemsFoundOnBodies.Value = Mathf.Clamp(MaxItemsFoundOnBodies.Value, MinItemsFoundOnBodies.Value, 10);
			UseLegacySpawning = _configFile.Bind<bool>(_spawningLegacySection, "Use legacy spawning", false, "Chooses if you want to use the older version of spawning remnant items. \nThe older version spawns along the normal scrap, which can be in lockers. \nWhile this is active this means that the new version will be disabled.");
			IncreasedScrapSpawnPool = _configFile.Bind<int>(_spawningLegacySection, "Max increase scrap spawn pool", 15, "Increases the total scrap spawn pool to accommodate the remnant items spawning along the scrap items. \nThis is intended to make sure you get enough scrap value per moon.");
			IncreasedScrapSpawnPool.Value = Mathf.Clamp(IncreasedScrapSpawnPool.Value, 0, 30);
			_minRemnantLevelRarities = new List<ConfigEntry<int>>();
			_maxRemnantLevelRarities = new List<ConfigEntry<int>>();
			LevelRarities = new Dictionary<LevelTypes, Tuple<int, int>>();
			UseSpecificLevelRarities = _configFile.Bind<bool>(_levelsSection, "Use level specific rarities", false, (ConfigDescription)null);
			string[] names = Enum.GetNames(typeof(LevelTypes));
			foreach (string text in names)
			{
				LevelTypes val = (LevelTypes)(-1);
				if (text == ((object)(LevelTypes)(ref val)).ToString())
				{
					continue;
				}
				val = (LevelTypes)1;
				if (text == ((object)(LevelTypes)(ref val)).ToString())
				{
					continue;
				}
				val = (LevelTypes)15356;
				if (!(text == ((object)(LevelTypes)(ref val)).ToString()))
				{
					val = (LevelTypes)1024;
					if (!(text == ((object)(LevelTypes)(ref val)).ToString()))
					{
						_minRemnantLevelRarities.Add(_configFile.Bind<int>(_levelsSection, text + " min remnant rarity", 1, "Minimum chance of a remnant item spawning on moon: " + text + "."));
						_minRemnantLevelRarities.Last().Value = Mathf.Clamp(_minRemnantLevelRarities.Last().Value, 1, 100);
						_maxRemnantLevelRarities.Add(_configFile.Bind<int>(_levelsSection, text + " max remnant rarity", 100, "Maximum chance of a remnant item spawning on moon: " + text + "."));
						_maxRemnantLevelRarities.Last().Value = Mathf.Clamp(_maxRemnantLevelRarities.Last().Value, _minRemnantLevelRarities.Last().Value, 100);
						LevelRarities.Add((LevelTypes)Enum.Parse(typeof(LevelTypes), text), new Tuple<int, int>(_minRemnantLevelRarities.Last().Value, _maxRemnantLevelRarities.Last().Value));
					}
				}
			}
			ShouldSaveRemnantItems = _configFile.Bind<bool>(_saveLoadSection, "Save remnant items", true, "This ensures that the remnant items are saved in the ship when you reload the lobby.");
			ShouldDespawnRemnantItemsOnPartyWipe = _configFile.Bind<bool>(_saveLoadSection, "Despawn remnant items on party wipe", true, "On party wipe all items are despawned from the ship, this ensures that remnant items also are despawned. \nIf you use a mod that prevents items from being despawned, here you can edit it too for remnant items. \nThis will not use the transpiler for cleaning up items, and may cause issues.");
			ShouldAlwaysDespawnRemnantItems = _configFile.Bind<bool>(_saveLoadSection, "Always despawn remnant items", false, "Despawns all remnant items when going away from moons, even if it is in the shiproom and you are holding it.");
			_bannedItemsFromSaving = _configFile.Bind<string>(_saveLoadSection, "Item list banned from saving", "Clipboard,StickyNote,Binoculars,MapDevice,Error", "List of items that are barred saving on the ship. \nThese default items are there to avoid issues with saving items on the ship. \nTo add more names to the list, be sure to add a comma between names.");
			ConfigScrapDataList = _configRemnantDataPairList.ConvertAll((ConfigDataValue<int> itemData) => _configFile.Bind<int>(_remnantsSection, itemData.Name, -1, "Set here the spawn rarity.\n -1 is the default using its store credits cost to calculate the rarity.\n 0 Is preventing from spawning it, and 1 to 100 is its costum rarity to spawn."));
			for (int j = 0; j < ConfigScrapDataList.Count; j++)
			{
				ConfigScrapDataList[j].Value = Mathf.Clamp(ConfigScrapDataList[j].Value, -1, 100);
			}
			ConfigSuitsDataList = _configSuitsDataList.ConvertAll((ConfigDataValue<bool> itemData) => _configFile.Bind<bool>(_suitsSection, itemData.Name, true, itemData.Discription));
			_minRemnantCustomLevelRarities = new List<ConfigEntry<int>>();
			_maxRemnantCustomLevelRarities = new List<ConfigEntry<int>>();
			for (int k = 0; k < _configCustomLevelsRarities.Count; k += 2)
			{
				_minRemnantCustomLevelRarities.Add(_configFile.Bind<int>(_customLevelsSection, _configCustomLevelsRarities[k].Name, 1, _configCustomLevelsRarities[k].Discription));
				_minRemnantCustomLevelRarities.Last().Value = Mathf.Clamp(_minRemnantCustomLevelRarities.Last().Value, 1, 100);
				_maxRemnantCustomLevelRarities.Add(_configFile.Bind<int>(_customLevelsSection, _configCustomLevelsRarities[k + 1].Name, 100, _configCustomLevelsRarities[k + 1].Discription));
				_maxRemnantCustomLevelRarities.Last().Value = Mathf.Clamp(_maxRemnantCustomLevelRarities.Last().Value, _minRemnantCustomLevelRarities.Last().Value, 100);
				CustomLevelRarities.Add(RemoveEndSentence(_configCustomLevelsRarities[k].Name, " min remnant rarity"), new Tuple<int, int>(_minRemnantCustomLevelRarities.Last().Value, _maxRemnantCustomLevelRarities.Last().Value));
			}
			ManualLogSource mls = Remnants.Instance.Mls;
			if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"))
			{
				mls.LogInfo((object)"LethalConfig found, creating lethal config items");
				CreateLethalConfigItems();
			}
			else
			{
				mls.LogInfo((object)"LethalConfig not found");
			}
			_configFile.Save();
		}

		private void LoadConfigData()
		{
			List<ConfigData> configSectionData = GetConfigSectionData(_remnantsSection);
			if (configSectionData != null || configSectionData.Count > 0)
			{
				string value = "false";
				string value2 = "true";
				string stringValue = "-1";
				for (int i = 0; i < configSectionData.Count; i++)
				{
					if (configSectionData[i].StringValue.Contains(value2) || configSectionData[i].StringValue.Contains(value))
					{
						ConfigData value3 = configSectionData[i];
						value3.StringValue = stringValue;
						configSectionData[i] = value3;
					}
				}
				_configRemnantDataPairList = configSectionData.ConvertAll(delegate(ConfigData configData)
				{
					ConfigDataValue<int> result3 = default(ConfigDataValue<int>);
					result3.Name = configData.Name;
					result3.Discription = configData.Discription;
					result3.Value = Convert.ToInt32(configData.StringValue);
					return result3;
				});
			}
			List<ConfigData> configSectionData2 = GetConfigSectionData(_customLevelsSection);
			if (configSectionData2 != null || configSectionData2.Count > 0)
			{
				_configCustomLevelsRarities = configSectionData2.ConvertAll(delegate(ConfigData configDataInt)
				{
					ConfigDataValue<int> result2 = default(ConfigDataValue<int>);
					result2.Name = configDataInt.Name;
					result2.Discription = configDataInt.Discription;
					result2.Value = Convert.ToInt32(configDataInt.StringValue);
					return result2;
				});
			}
			List<ConfigData> configSectionData3 = GetConfigSectionData(_suitsSection);
			if (configSectionData3 != null || configSectionData3.Count > 0)
			{
				_configSuitsDataList = configSectionData3.ConvertAll(delegate(ConfigData configDataSuit)
				{
					ConfigDataValue<bool> result = default(ConfigDataValue<bool>);
					result.Name = configDataSuit.Name;
					result.Discription = configDataSuit.Discription;
					result.Value = Convert.ToBoolean(configDataSuit.StringValue);
					return result;
				});
			}
		}

		private void CreateLethalConfigItems()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0022: Expected O, but got Unknown
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_0055: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0063: 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_006f: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_007e: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//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)
			//IL_00a2: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00b1: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Expected O, but got Unknown
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Expected O, but got Unknown
			//IL_00dd: Expected O, but got Unknown
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			//IL_00ed: 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_0103: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_0115: Expected O, but got Unknown
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Expected O, but got Unknown
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Expected O, but got Unknown
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Expected O, but got Unknown
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Expected O, but got Unknown
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Expected O, but got Unknown
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Expected O, but got Unknown
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Expected O, but got Unknown
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Expected O, but got Unknown
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Expected O, but got Unknown
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Expected O, but got Unknown
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Expected O, but got Unknown
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Expected O, but got Unknown
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Expected O, but got Unknown
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Expected O, but got Unknown
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Expected O, but got Unknown
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Expected O, but got Unknown
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Expected O, but got Unknown
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Expected O, but got Unknown
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Expected O, but got Unknown
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Expected O, but got Unknown
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Expected O, but got Unknown
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Expected O, but got Unknown
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Expected O, but got Unknown
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Expected O, but got Unknown
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Expected O, but got Unknown
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Expected O, but got Unknown
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Expected O, but got Unknown
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Expected O, but got Unknown
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Expected O, but got Unknown
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Expected O, but got Unknown
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Expected O, but got Unknown
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Expected O, but got Unknown
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Expected O, but got Unknown
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Expected O, but got Unknown
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Expected O, but got Unknown
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Expected O, but got Unknown
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Expected O, but got Unknown
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Expected O, but got Unknown
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Expected O, but got Unknown
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Expected O, but got Unknown
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Expected O, but got Unknown
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Expected O, but got Unknown
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Expected O, but got Unknown
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Expected O, but got Unknown
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Expected O, but got Unknown
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Expected O, but got Unknown
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Expected O, but got Unknown
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Expected O, but got Unknown
			//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Expected O, but got Unknown
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: Expected O, but got Unknown
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Expected O, but got Unknown
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Expected O, but got Unknown
			//IL_0429: Expected O, but got Unknown
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Expected O, but got Unknown
			//IL_0439: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: Expected O, but got Unknown
			//IL_044f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0456: Expected O, but got Unknown
			//IL_0465: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Expected O, but got Unknown
			//IL_047b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0482: Expected O, but got Unknown
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a9: Expected O, but got Unknown
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b2: Expected O, but got Unknown
			//IL_04b8: Expected O, but got Unknown
			//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Expected O, but got Unknown
			//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04eb: Expected O, but got Unknown
			//IL_0506: Unknown result type (might be due to invalid IL or missing references)
			//IL_050b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0512: Expected O, but got Unknown
			//IL_0513: Unknown result type (might be due to invalid IL or missing references)
			//IL_051b: Expected O, but got Unknown
			//IL_0521: Expected O, but got Unknown
			//IL_051c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0523: Expected O, but got Unknown
			//IL_0530: Unknown result type (might be due to invalid IL or missing references)
			//IL_0535: Unknown result type (might be due to invalid IL or missing references)
			//IL_054d: Expected O, but got Unknown
			//IL_054e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0556: Expected O, but got Unknown
			//IL_055c: Expected O, but got Unknown
			//IL_0557: Unknown result type (might be due to invalid IL or missing references)
			//IL_055e: Expected O, but got Unknown
			//IL_05a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ac: Expected O, but got Unknown
			//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b5: Expected O, but got Unknown
			//IL_05bb: Expected O, but got Unknown
			//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bd: Expected O, but got Unknown
			//IL_05ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e7: Expected O, but got Unknown
			//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f0: Expected O, but got Unknown
			//IL_05f6: Expected O, but got Unknown
			//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f8: Expected O, but got Unknown
			ConfigEntry<int> minRemnantRarity = MinRemnantRarity;
			IntSliderOptions val = new IntSliderOptions();
			((BaseRangeOptions<int>)val).Min = 1;
			((BaseRangeOptions<int>)val).Max = 100;
			IntSliderConfigItem val2 = new IntSliderConfigItem(minRemnantRarity, val);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
			ConfigEntry<int> maxRemnantRarity = MaxRemnantRarity;
			IntSliderOptions val3 = new IntSliderOptions();
			((BaseRangeOptions<int>)val3).Min = MinRemnantRarity.Value;
			((BaseRangeOptions<int>)val3).Max = 100;
			IntSliderConfigItem val4 = new IntSliderConfigItem(maxRemnantRarity, val3);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val4);
			ConfigEntry<int> minRemnantBatteryCharge = MinRemnantBatteryCharge;
			IntSliderOptions val5 = new IntSliderOptions();
			((BaseRangeOptions<int>)val5).Min = 1;
			((BaseRangeOptions<int>)val5).Max = 100;
			IntSliderConfigItem val6 = new IntSliderConfigItem(minRemnantBatteryCharge, val5);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val6);
			ConfigEntry<int> maxRemnantBatteryCharge = MaxRemnantBatteryCharge;
			IntSliderOptions val7 = new IntSliderOptions();
			((BaseRangeOptions<int>)val7).Min = MinRemnantBatteryCharge.Value;
			((BaseRangeOptions<int>)val7).Max = 100;
			IntSliderConfigItem val8 = new IntSliderConfigItem(maxRemnantBatteryCharge, val7);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val8);
			ConfigEntry<int> remnantScrapMinCostPercentage = RemnantScrapMinCostPercentage;
			IntSliderOptions val9 = new IntSliderOptions();
			((BaseRangeOptions<int>)val9).Min = 0;
			((BaseRangeOptions<int>)val9).Max = 1000;
			IntSliderConfigItem val10 = new IntSliderConfigItem(remnantScrapMinCostPercentage, val9);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val10);
			ConfigEntry<int> remnantScrapMaxCostPercentage = RemnantScrapMaxCostPercentage;
			IntSliderOptions val11 = new IntSliderOptions();
			((BaseRangeOptions<int>)val11).Min = RemnantScrapMinCostPercentage.Value;
			((BaseRangeOptions<int>)val11).Max = 1000;
			IntSliderConfigItem val12 = new IntSliderConfigItem(remnantScrapMaxCostPercentage, val11);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val12);
			BoolCheckBoxConfigItem val13 = new BoolCheckBoxConfigItem(ShouldBodiesBeScrap, false);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val13);
			ConfigEntry<int> spawnRarityOfBody = SpawnRarityOfBody;
			IntSliderOptions val14 = new IntSliderOptions();
			((BaseRangeOptions<int>)val14).Min = 0;
			((BaseRangeOptions<int>)val14).Max = 100;
			((BaseOptions)val14).RequiresRestart = false;
			IntSliderConfigItem val15 = new IntSliderConfigItem(spawnRarityOfBody, val14);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val15);
			ConfigEntry<float> bodySpawnModifierRiskLevel = BodySpawnModifierRiskLevel;
			FloatSliderOptions val16 = new FloatSliderOptions();
			((BaseRangeOptions<float>)val16).Min = 0f;
			((BaseRangeOptions<float>)val16).Max = 10f;
			((BaseOptions)val16).RequiresRestart = false;
			FloatSliderConfigItem val17 = new FloatSliderConfigItem(bodySpawnModifierRiskLevel, val16);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val17);
			ConfigEntry<int> minBodyScrapValue = MinBodyScrapValue;
			IntSliderOptions val18 = new IntSliderOptions();
			((BaseRangeOptions<int>)val18).Min = 0;
			((BaseRangeOptions<int>)val18).Max = 1000;
			((BaseOptions)val18).RequiresRestart = false;
			IntSliderConfigItem val19 = new IntSliderConfigItem(minBodyScrapValue, val18);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val19);
			ConfigEntry<int> maxBodyScrapValue = MaxBodyScrapValue;
			IntSliderOptions val20 = new IntSliderOptions();
			((BaseRangeOptions<int>)val20).Min = MinBodyScrapValue.Value;
			((BaseRangeOptions<int>)val20).Max = 1000;
			((BaseOptions)val20).RequiresRestart = false;
			IntSliderConfigItem val21 = new IntSliderConfigItem(maxBodyScrapValue, val20);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val21);
			ConfigEntry<int> minRemnantItemsSpawning = MinRemnantItemsSpawning;
			IntSliderOptions val22 = new IntSliderOptions();
			((BaseRangeOptions<int>)val22).Min = 1;
			((BaseRangeOptions<int>)val22).Max = 50;
			((BaseOptions)val22).RequiresRestart = false;
			IntSliderConfigItem val23 = new IntSliderConfigItem(minRemnantItemsSpawning, val22);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val23);
			ConfigEntry<int> maxRemnantItemsSpawning = MaxRemnantItemsSpawning;
			IntSliderOptions val24 = new IntSliderOptions();
			((BaseRangeOptions<int>)val24).Min = MinRemnantItemsSpawning.Value;
			((BaseRangeOptions<int>)val24).Max = 50;
			((BaseOptions)val24).RequiresRestart = false;
			IntSliderConfigItem val25 = new IntSliderConfigItem(maxRemnantItemsSpawning, val24);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val25);
			ConfigEntry<float> remnantItemsSpawningModifier = RemnantItemsSpawningModifier;
			FloatSliderOptions val26 = new FloatSliderOptions();
			((BaseRangeOptions<float>)val26).Min = -1f;
			((BaseRangeOptions<float>)val26).Max = 10f;
			((BaseOptions)val26).RequiresRestart = false;
			FloatSliderConfigItem val27 = new FloatSliderConfigItem(remnantItemsSpawningModifier, val26);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val27);
			ConfigEntry<int> maxDuplicatesRemnantItems = MaxDuplicatesRemnantItems;
			IntSliderOptions val28 = new IntSliderOptions();
			((BaseRangeOptions<int>)val28).Min = 1;
			((BaseRangeOptions<int>)val28).Max = 15;
			((BaseOptions)val28).RequiresRestart = false;
			IntSliderConfigItem val29 = new IntSliderConfigItem(maxDuplicatesRemnantItems, val28);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val29);
			ConfigEntry<int> minItemsFoundOnBodies = MinItemsFoundOnBodies;
			IntSliderOptions val30 = new IntSliderOptions();
			((BaseRangeOptions<int>)val30).Min = 1;
			((BaseRangeOptions<int>)val30).Max = 10;
			((BaseOptions)val30).RequiresRestart = false;
			IntSliderConfigItem val31 = new IntSliderConfigItem(minItemsFoundOnBodies, val30);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val31);
			ConfigEntry<int> maxItemsFoundOnBodies = MaxItemsFoundOnBodies;
			IntSliderOptions val32 = new IntSliderOptions();
			((BaseRangeOptions<int>)val32).Min = MinItemsFoundOnBodies.Value;
			((BaseRangeOptions<int>)val32).Max = 10;
			((BaseOptions)val32).RequiresRestart = false;
			IntSliderConfigItem val33 = new IntSliderConfigItem(maxItemsFoundOnBodies, val32);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val33);
			BoolCheckBoxConfigItem val34 = new BoolCheckBoxConfigItem(UseLegacySpawning);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val34);
			ConfigEntry<int> increasedScrapSpawnPool = IncreasedScrapSpawnPool;
			IntSliderOptions val35 = new IntSliderOptions();
			((BaseRangeOptions<int>)val35).Min = 0;
			((BaseRangeOptions<int>)val35).Max = 30;
			((BaseOptions)val35).RequiresRestart = false;
			IntSliderConfigItem val36 = new IntSliderConfigItem(increasedScrapSpawnPool, val35);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val36);
			BoolCheckBoxConfigItem val37 = new BoolCheckBoxConfigItem(ShouldSaveRemnantItems);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val37);
			BoolCheckBoxConfigItem val38 = new BoolCheckBoxConfigItem(ShouldDespawnRemnantItemsOnPartyWipe);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val38);
			BoolCheckBoxConfigItem val39 = new BoolCheckBoxConfigItem(ShouldAlwaysDespawnRemnantItems);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val39);
			TextInputFieldConfigItem val40 = new TextInputFieldConfigItem(_bannedItemsFromSaving);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val40);
			ConfigEntry<float> maxRemnantItemCost = MaxRemnantItemCost;
			FloatSliderOptions val41 = new FloatSliderOptions();
			((BaseRangeOptions<float>)val41).Min = 5f;
			((BaseRangeOptions<float>)val41).Max = 10000f;
			FloatSliderConfigItem val42 = new FloatSliderConfigItem(maxRemnantItemCost, val41);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val42);
			TextInputFieldConfigItem val43 = new TextInputFieldConfigItem(_bannedNamesFromRegistering);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val43);
			TextInputFieldConfigItem val44 = new TextInputFieldConfigItem(_overriddenScrapItems, false);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val44);
			BoolCheckBoxConfigItem val45 = new BoolCheckBoxConfigItem(UseBeltBagTranspiler, true);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val45);
			BoolCheckBoxConfigItem val46 = new BoolCheckBoxConfigItem(UseTerminalScanItemsTranspiler, true);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val46);
			for (int i = 0; i < ConfigScrapDataList.Count; i++)
			{
				ConfigEntry<int> obj = ConfigScrapDataList[i];
				IntSliderOptions val47 = new IntSliderOptions();
				((BaseRangeOptions<int>)val47).Min = -1;
				((BaseRangeOptions<int>)val47).Max = 100;
				IntSliderConfigItem val48 = new IntSliderConfigItem(obj, val47);
				LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val48);
			}
			BoolCheckBoxConfigItem val49 = new BoolCheckBoxConfigItem(UseSpecificLevelRarities);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val49);
			for (int j = 0; j < _minRemnantLevelRarities.Count; j++)
			{
				ConfigEntry<int> obj2 = _minRemnantLevelRarities[j];
				IntSliderOptions val50 = new IntSliderOptions();
				((BaseRangeOptions<int>)val50).Min = 1;
				((BaseRangeOptions<int>)val50).Max = 100;
				IntSliderConfigItem val51 = new IntSliderConfigItem(obj2, val50);
				ConfigEntry<int> obj3 = _maxRemnantLevelRarities[j];
				IntSliderOptions val52 = new IntSliderOptions();
				((BaseRangeOptions<int>)val52).Min = _minRemnantLevelRarities[j].Value;
				((BaseRangeOptions<int>)val52).Max = 100;
				IntSliderConfigItem val53 = new IntSliderConfigItem(obj3, val52);
				LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val51);
				LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val53);
			}
			for (int k = 0; k < _minRemnantCustomLevelRarities.Count; k++)
			{
				ConfigEntry<int> obj4 = _minRemnantCustomLevelRarities[k];
				IntSliderOptions val54 = new IntSliderOptions();
				((BaseRangeOptions<int>)val54).Min = 1;
				((BaseRangeOptions<int>)val54).Max = 100;
				IntSliderConfigItem val55 = new IntSliderConfigItem(obj4, val54);
				ConfigEntry<int> obj5 = _maxRemnantCustomLevelRarities[k];
				IntSliderOptions val56 = new IntSliderOptions();
				((BaseRangeOptions<int>)val56).Min = _minRemnantCustomLevelRarities[k].Value;
				((BaseRangeOptions<int>)val56).Max = 100;
				IntSliderConfigItem val57 = new IntSliderConfigItem(obj5, val56);
				LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val55);
				LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val57);
			}
		}

		public List<string> GetBannedFromRegisteringItemNames()
		{
			if (Utility.IsNullOrWhiteSpace(_bannedNamesFromRegistering.Value))
			{
				return new List<string>();
			}
			return _bannedNamesFromRegistering.Value.Split(new char[1] { ',' }).ToList();
		}

		public List<string> GetBannedFromSavingItemNames()
		{
			if (Utility.IsNullOrWhiteSpace(_bannedItemsFromSaving.Value))
			{
				return new List<string>();
			}
			return _bannedItemsFromSaving.Value.Split(new char[1] { ',' }).ToList();
		}

		public List<string> GetOverriddenScrapItems()
		{
			if (Utility.IsNullOrWhiteSpace(_overriddenScrapItems.Value))
			{
				return new List<string>();
			}
			return _overriddenScrapItems.Value.Split(new char[1] { ',' }).ToList();
		}

		public List<RemnantData> GetRemnantItemList(bool reloadConfig = true)
		{
			if (reloadConfig)
			{
				_configFile.Reload();
			}
			if (ConfigScrapDataList == null || ConfigScrapDataList.Count == 0)
			{
				return new List<RemnantData>();
			}
			return ConfigScrapDataList.ConvertAll((ConfigEntry<int> configEntry) => new RemnantData
			{
				RemnantItemName = ((ConfigEntryBase)configEntry).Definition.Key,
				RarityInfo = configEntry.Value
			});
		}

		public void SetRemnantItemList(List<RemnantData> remnantDataList)
		{
			ConfigScrapDataList = remnantDataList.ConvertAll((RemnantData remnantData) => _configFile.Bind<int>(_remnantsSection, remnantData.RemnantItemName, remnantData.RarityInfo, "Set here the spawn rarity.\n -1 is the default using its store credits cost to calculate the rarity.\n 0 Is preventing from spawning it, and 1 to 100 is its costum rarity to spawn."));
			_configFile.Save();
		}

		public List<SuitData> GetSuitsList()
		{
			if (ConfigSuitsDataList == null || ConfigSuitsDataList.Count == 0)
			{
				return new List<SuitData>();
			}
			return ConfigSuitsDataList.ConvertAll((ConfigEntry<bool> configEntry) => new SuitData
			{
				SuitName = ((ConfigEntryBase)configEntry).Definition.Key,
				UseSuit = configEntry.Value
			});
		}

		public void SetSuitsList(List<SuitData> suitDataList)
		{
			ConfigSuitsDataList = suitDataList.ConvertAll((SuitData suitData) => _configFile.Bind<bool>(_suitsSection, suitData.SuitName, suitData.UseSuit, "By changing the value, you can choose whether this suit is used on a body or not."));
			_configFile.Save();
		}

		public void SetCustomLevelsRarities(List<string> customMoonNames, int minPercentage = 1, int maxPercentage = 100)
		{
			foreach (string customMoonName in customMoonNames)
			{
				if (!CustomLevelRarities.ContainsKey(customMoonName) && !(customMoonName == _bannedPlanetName))
				{
					_minRemnantCustomLevelRarities.Add(_configFile.Bind<int>(_customLevelsSection, customMoonName + " min remnant rarity", 1, "Minimum chance of a remnant item spawning on moon: " + customMoonName + "."));
					_minRemnantCustomLevelRarities.Last().Value = Mathf.Clamp(_minRemnantCustomLevelRarities.Last().Value, minPercentage, maxPercentage);
					_maxRemnantCustomLevelRarities.Add(_configFile.Bind<int>(_customLevelsSection, customMoonName + " max remnant rarity", 100, "Maximum chance of a remnant item spawning on moon: " + customMoonName + "."));
					_maxRemnantCustomLevelRarities.Last().Value = Mathf.Clamp(_maxRemnantCustomLevelRarities.Last().Value, _minRemnantCustomLevelRarities.Last().Value, maxPercentage);
					CustomLevelRarities.Add(customMoonName, new Tuple<int, int>(_minRemnantCustomLevelRarities.Last().Value, _maxRemnantCustomLevelRarities.Last().Value));
				}
			}
			_configFile.Save();
		}

		public Dictionary<string, Tuple<int, int>> GetCustomLevelRarities()
		{
			_configFile.Reload();
			if (CustomLevelRarities == null || CustomLevelRarities.Count == 0)
			{
				return new Dictionary<string, Tuple<int, int>>();
			}
			for (int i = 0; i < _minRemnantCustomLevelRarities.Count; i++)
			{
				CustomLevelRarities[((ConfigEntryBase)_minRemnantCustomLevelRarities[i]).Definition.Key] = new Tuple<int, int>(_minRemnantCustomLevelRarities[i].Value, _maxRemnantCustomLevelRarities[i].Value);
			}
			return CustomLevelRarities;
		}

		private string RemoveEndSentence(string fullSentence, string toRemoveAtEnd)
		{
			if (fullSentence.EndsWith(toRemoveAtEnd))
			{
				for (int i = 0; i < fullSentence.Length; i++)
				{
					if (fullSentence[i] == toRemoveAtEnd[0] && i + toRemoveAtEnd.Length == fullSentence.Length)
					{
						return fullSentence.Substring(0, i);
					}
				}
			}
			return fullSentence;
		}

		private List<ConfigData> GetConfigSectionData(string section)
		{
			List<ConfigData> list = new List<ConfigData>();
			if (!File.Exists(Paths.ConfigPath + _configFileName))
			{
				return list;
			}
			StreamReader streamReader = new StreamReader(Paths.ConfigPath + _configFileName);
			string text = streamReader.ReadLine();
			bool flag = false;
			while (text != null && (!flag || !text.StartsWith("[")))
			{
				if (flag)
				{
					AddDataToList(streamReader, text, list);
				}
				else if (text == "[" + section + "]")
				{
					flag = true;
					text = streamReader.ReadLine();
					AddDataToList(streamReader, text, list);
				}
				text = streamReader.ReadLine();
			}
			streamReader.Close();
			return list;
		}

		private void AddDataToList(StreamReader sr, string line, List<ConfigData> list)
		{
			string text = "## ";
			string value = "#";
			string text2 = " = ";
			ConfigData item = default(ConfigData);
			if (line.StartsWith(text))
			{
				item.Discription = line.Remove(0, text.Length);
				while (line != null && line.StartsWith(value))
				{
					line = sr.ReadLine();
				}
				ManualLogSource mls = Remnants.Instance.Mls;
				int num = line.LastIndexOf(text2);
				item.Name = line.Remove(num);
				item.StringValue = line.Remove(0, num + text2.Length - 1);
				list.Add(item);
			}
		}

		public bool CheckIsStoreOrRemnantItem(GrabbableObject grabbableObject)
		{
			ManualLogSource mls = Remnants.Instance.Mls;
			if ((Object)(object)grabbableObject == (Object)null || (Object)(object)grabbableObject.itemProperties == (Object)null)
			{
				mls.LogError((object)"GrabbableObject is null!");
				return false;
			}
			if (!grabbableObject.itemProperties.isScrap)
			{
				mls.LogError((object)"GrabbableObject is not scrap!");
				return true;
			}
			mls.LogInfo((object)("ConfigScrapDataList lengt: " + ConfigScrapDataList.Count));
			foreach (ConfigEntry<int> configScrapData in ConfigScrapDataList)
			{
				mls.LogInfo((object)((ConfigEntryBase)configScrapData).Definition.Key);
			}
			mls.LogWarning((object)(grabbableObject.itemProperties.itemName + " " + ((Object)grabbableObject.itemProperties).name));
			if (ConfigScrapDataList.FindIndex((ConfigEntry<int> configEntry) => ((ConfigEntryBase)configEntry).Definition.Key == grabbableObject.itemProperties.itemName || ((ConfigEntryBase)configEntry).Definition.Key == ((Object)grabbableObject.itemProperties).name) != -1)
			{
				mls.LogError((object)"GrabbableObject is a remnant item!");
				return true;
			}
			mls.LogError((object)"GrabbableObject is a normal scrap item!");
			return false;
		}
	}
	public class LoadAssetsBodies
	{
		private bool _hasInitialized = false;

		private bool _isLoadingBundle = false;

		private string _assetBundleName = "remnants";

		private string _prefabTypeName = ".prefab";

		private string _assetTypeName = ".asset";

		private string _iconSpriteName = "ScrapItemIcon2";

		private string _dropSoundName = "BodyCollision2";

		private string _grabSoundName = "StartJump";

		private AssetBundle _assetBundleBodies = null;

		private string[] _bodiesFileNamesArray = new string[4] { "DefaultBodyProp", "HeadBurstBodyProp", "CoilHeadBodyProp", "WebbedBodyProp" };

		private string[] _bodiesItemsFileNamesArray = new string[4] { "DefaultBodyItem", "HeadBurstBodyItem", "CoilBodyItem", "WebbedBodyItem" };

		public KeyValuePair<string, string>[] EnemiesAndBodiesNames = new KeyValuePair<string, string>[4]
		{
			new KeyValuePair<string, string>("Any", "DefaultBody"),
			new KeyValuePair<string, string>("Spring", "CoilHeadBody"),
			new KeyValuePair<string, string>("Bunker Spider", "WebbedBody"),
			new KeyValuePair<string, string>("Girl", "HeadBurstBody")
		};

		public string[] BannedPrefabTexturesChange = new string[2] { "WebbedBody", "WebbedBodyProp" };

		public string BannedPrefabTextureChange = "WebbedBody";

		public bool HasLoadedAnyAssets = false;

		public void Initialize()
		{
			if (!_hasInitialized)
			{
				_hasInitialized = true;
				SceneManager.sceneLoaded += LoadAssetBundle;
			}
		}

		private void LoadAssetBundle(Scene scene, LoadSceneMode mode)
		{
			ManualLogSource mls = Remnants.Instance.Mls;
			Sprite val = Resources.FindObjectsOfTypeAll<Sprite>().Concat(Object.FindObjectsByType<Sprite>((FindObjectsInactive)1, (FindObjectsSortMode)1)).ToList()
				.Find((Sprite sprite) => ((Object)sprite).name == _iconSpriteName);
			if (_isLoadingBundle || (Object)(object)val == (Object)null)
			{
				return;
			}
			_isLoadingBundle = true;
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			string text = Path.Combine(directoryName, _assetBundleName);
			if (!File.Exists(text))
			{
				mls.LogError((object)("Assetbundle " + _assetBundleName + " not found."));
				return;
			}
			_assetBundleBodies = AssetBundle.LoadFromFile(text);
			if ((Object)(object)_assetBundleBodies == (Object)null)
			{
				mls.LogError((object)("Failed to load: " + _assetBundleName));
				return;
			}
			List<AudioClip> list = Resources.FindObjectsOfTypeAll<AudioClip>().Concat(Object.FindObjectsByType<AudioClip>((FindObjectsInactive)1, (FindObjectsSortMode)1)).ToList();
			AudioClip dropSFX = list.Find((AudioClip audioClip) => ((Object)audioClip).name == _dropSoundName);
			AudioClip grabSFX = list.Find((AudioClip audioClip1) => ((Object)audioClip1).name == _grabSoundName);
			string[] bodiesItemsFileNamesArray = _bodiesItemsFileNamesArray;
			foreach (string assetName in bodiesItemsFileNamesArray)
			{
				LoadAndRegisterBodyItemAsset(assetName, _assetTypeName, val, dropSFX, grabSFX);
			}
			string[] bodiesFileNamesArray = _bodiesFileNamesArray;
			foreach (string assetName2 in bodiesFileNamesArray)
			{
				LoadAndRegisterBodyPropAsset(assetName2, _prefabTypeName);
			}
			SceneManager.sceneLoaded -= LoadAssetBundle;
		}

		private void LoadAndRegisterBodyPropAsset(string assetName, string assetType)
		{
			ManualLogSource mls = Remnants.Instance.Mls;
			GameObject val = _assetBundleBodies.LoadAsset<GameObject>(assetName + assetType);
			if ((Object)(object)val == (Object)null)
			{
				mls.LogError((object)("Failed to load: " + assetName));
				return;
			}
			mls.LogInfo((object)("Loaded asset: " + ((Object)val).name));
			val.AddComponent<BodySuitBehaviour>();
			NetworkPrefabs.RegisterNetworkPrefab(val);
			HasLoadedAnyAssets = true;
		}

		private void LoadAndRegisterBodyItemAsset(string assetName, string assetType, Sprite icon, AudioClip dropSFX, AudioClip grabSFX)
		{
			ManualLogSource mls = Remnants.Instance.Mls;
			Item val = _assetBundleBodies.LoadAsset<Item>(assetName + assetType);
			if ((Object)(object)val == (Object)null)
			{
				mls.LogError((object)("Failed to load: " + assetName));
				return;
			}
			mls.LogInfo((object)("Loaded asset: " + ((Object)val).name));
			val.itemIcon = icon;
			val.dropSFX = dropSFX;
			val.grabSFX = grabSFX;
			val.spawnPrefab.AddComponent<BodyMovementBehaviour>();
			val.spawnPrefab.AddComponent<BodySuitBehaviour>();
			BodyGrabbableObject bodyGrabbableObject = val.spawnPrefab.AddComponent<BodyGrabbableObject>();
			((GrabbableObject)bodyGrabbableObject).itemProperties = val;
			((GrabbableObject)bodyGrabbableObject).grabbable = true;
			((GrabbableObject)bodyGrabbableObject).grabbableToEnemies = true;
			((GrabbableObject)bodyGrabbableObject).isInFactory = true;
			Items.RegisterItem(val);
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			HasLoadedAnyAssets = true;
		}
	}
}
namespace Remnants.Behaviours
{
	public class BodyGrabbableObject : GrabbableObject
	{
		private int _saveSuitIndex = 0;

		private BodySuitBehaviour _bodySuitBehaviour = null;

		private void Awake()
		{
			ManualLogSource mls = Remnants.Instance.Mls;
			_bodySuitBehaviour = ((Component)this).GetComponent<BodySuitBehaviour>();
			if ((Object)(object)_bodySuitBehaviour == (Object)null)
			{
				mls.LogError((object)"Did not found BodySuitBehaviour.");
			}
		}

		private void Start()
		{
			//IL_0019: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			base.propColliders = ((Component)this).gameObject.GetComponentsInChildren<Collider>();
			base.originalScale = ((Component)this).transform.localScale;
			if (base.itemProperties.isScrap && (Object)(object)RoundManager.Instance.mapPropsContainer != (Object)null)
			{
				base.radarIcon = Object.Instantiate<GameObject>(StartOfRound.Instance.itemRadarIconPrefab, RoundManager.Instance.mapPropsContainer.transform).transform;
			}
			if (!base.itemProperties.isScrap)
			{
				HoarderBugAI.grabbableObjectsInMap.Add(((Component)this).gameObject);
			}
			base.originalScale = ((Component)this).transform.localScale;
			if (base.itemProperties.itemSpawnsOnGround)
			{
				base.startFallingPosition = ((Component)this).transform.position;
				if ((Object)(object)((Component)this).transform.parent != (Object)null)
				{
					base.startFallingPosition = ((Component)this).transform.parent.InverseTransformPoint(base.startFallingPosition);
				}
				((GrabbableObject)this).FallToGround(false);
			}
			else
			{
				base.fallTime = 1f;
				base.hasHitGround = true;
				base.reachedFloorTarget = true;
				base.targetFloorPosition = ((Component)this).transform.localPosition;
			}
			MeshRenderer[] componentsInChildren = ((Component)this).gameObject.GetComponentsInChildren<MeshRenderer>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Renderer)componentsInChildren[i]).renderingLayerMask = 1u;
			}
			SkinnedMeshRenderer[] componentsInChildren2 = ((Component)this).gameObject.GetComponentsInChildren<SkinnedMeshRenderer>();
			for (int j = 0; j < componentsInChildren2.Length; j++)
			{
				((Renderer)componentsInChildren2[j]).renderingLayerMask = 1u;
			}
			((GrabbableObject)this).EnablePhysics(true);
		}

		public override void EquipItem()
		{
			((GrabbableObject)this).EquipItem();
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
		}

		protected override void __initializeVariables()
		{
			((GrabbableObject)this).__initializeVariables();
		}

		protected override string __getTypeName()
		{
			return "BodyGrabbableObject";
		}

		public override int GetItemDataToSave()
		{
			if (!base.itemProperties.saveItemVariable)
			{
				Debug.LogError((object)("GetItemDataToSave is being called on " + base.itemProperties.itemName + ", which does not have saveItemVariable set true."));
			}
			if ((Object)(object)_bodySuitBehaviour != (Object)null)
			{
				_saveSuitIndex = _bodySuitBehaviour.saveSuitIndex;
			}
			return _saveSuitIndex;
		}

		public override void LoadItemSaveData(int saveData)
		{
			if (!base.itemProperties.saveItemVariable)
			{
				Debug.LogError((object)("LoadItemSaveData is being called on " + base.itemProperties.itemName + ", which does not have saveItemVariable set true."));
			}
			_saveSuitIndex = saveData;
			if ((Object)(object)_bodySuitBehaviour != (Object)null)
			{
				_bodySuitBehaviour.UpdateSuit(_saveSuitIndex);
			}
		}

		public void SyncIndexSuit(int indexSuit)
		{
			if ((Object)(object)_bodySuitBehaviour != (Object)null)
			{
				_bodySuitBehaviour.SyncIndexSuitClientRpc(indexSuit);
			}
		}
	}
	internal class BodyMovementBehaviour : MonoBehaviour
	{
		private bool _hasInitialized = false;

		private GrabbableObject _grabbableObject = null;

		private Rigidbody[] _rigidbodies = null;

		private string _skipRigidBodyName = "ScanNode";

		private bool _isInStasis = false;

		private float _onGroundTimer = 0f;

		private float _onHeldTimer = 0f;

		private const float _onGroundMoveDuration = 2f;

		private const float _heldMoveDuration = 0f;

		private void Awake()
		{
			ManualLogSource mls = Remnants.Instance.Mls;
			_grabbableObject = ((Component)this).GetComponent<GrabbableObject>();
			if ((Object)(object)_grabbableObject == (Object)null)
			{
				mls.LogWarning((object)"Did not found GrabbableObject.");
				return;
			}
			_rigidbodies = ((Component)_grabbableObject).GetComponentsInChildren<Rigidbody>();
			if (_rigidbodies == null)
			{
				mls.LogWarning((object)"Rigidbodies is null.");
				return;
			}
			_rigidbodies = _rigidbodies.Where((Rigidbody rigidbody) => ((Object)((Component)rigidbody).gameObject).name != _skipRigidBodyName).ToArray();
			_hasInitialized = true;
		}

		private void Update()
		{
			if (_hasInitialized)
			{
				UpdateMovementAtStart();
			}
		}

		private void UpdateMovementAtStart()
		{
			if (!_isInStasis)
			{
				_onGroundTimer += Time.deltaTime;
				if (_onGroundTimer > 2f)
				{
					SetStasis(shouldBeStatis: true);
					_isInStasis = true;
				}
			}
		}

		private void UpdateConstantMovement()
		{
			if (_grabbableObject.isHeld)
			{
				_onHeldTimer += Time.deltaTime;
				_onGroundTimer = 0f;
				if (_isInStasis && _onHeldTimer < 0f)
				{
					SetStasis(shouldBeStatis: false);
					_isInStasis = false;
				}
				if (!_isInStasis && _onHeldTimer > 0f)
				{
					SetStasis(shouldBeStatis: true);
					_isInStasis = true;
				}
			}
			else if (!_grabbableObject.isHeld)
			{
				_onGroundTimer += Time.deltaTime;
				_onHeldTimer = 0f;
				if (_isInStasis && _onGroundTimer < 2f)
				{
					_isInStasis = false;
					SetStasis(shouldBeStatis: false);
				}
				else if (!_isInStasis && _onGroundTimer > 2f)
				{
					SetStasis(shouldBeStatis: true);
					_isInStasis = true;
				}
			}
		}

		private void SetStasis(bool shouldBeStatis)
		{
			Rigidbody[] rigidbodies = _rigidbodies;
			foreach (Rigidbody val in rigidbodies)
			{
				val.isKinematic = shouldBeStatis;
			}
		}
	}
	internal class BodySuitBehaviour : NetworkBehaviour
	{
		private int _saveSuitIndex = 0;

		public int saveSuitIndex => _saveSuitIndex;

		public void UpdateSuit(int suitIndex)
		{
			_saveSuitIndex = suitIndex;
			if (((Object)((Component)this).gameObject).name.Contains(Remnants.Instance.LoadBodyAssets.BannedPrefabTextureChange) || Remnants.Instance.RegisterBodySuits.SuitsIndexList.Count == 0)
			{
				return;
			}
			SkinnedMeshRenderer componentInChildren = ((Component)this).gameObject.GetComponentInChildren<SkinnedMeshRenderer>();
			Material suitMaterial = StartOfRound.Instance.unlockablesList.unlockables[_saveSuitIndex].suitMaterial;
			if (!((Object)(object)suitMaterial == (Object)null))
			{
				((Renderer)componentInChildren).material = suitMaterial;
				for (int i = 0; i < ((Renderer)componentInChildren).materials.Length; i++)
				{
					((Renderer)componentInChildren).materials[i] = suitMaterial;
				}
			}
		}

		[HarmonyPrepare]
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_GrabbableObject()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3184508696u, new RpcReceiveHandler(__rpc_handler_3184508696));
			NetworkManager.__rpc_func_table.Add(2170264864u, new RpcReceiveHandler(__rpc_handler_2170264864));
		}

		[ServerRpc]
		public void SyncIndexSuitServerRpc(int indexSuit)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Invalid comparison between Unknown and I4
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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)
			//IL_0093: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3184508696u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, indexSuit);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3184508696u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				SyncIndexSuitClientRpc(indexSuit);
			}
		}

		[ClientRpc]
		public void SyncIndexSuitClientRpc(int indexSuit)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Invalid comparison between Unknown and I4
			//IL_0040: 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_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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2170264864u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, indexSuit);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2170264864u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					UpdateSuit(indexSuit);
				}
			}
		}

		private static void __rpc_handler_3184508696(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0021: 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)
			//IL_0027: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
			}
			else
			{
				Traverse val = Traverse.Create((object)target).Field("__rpc_exec_stage");
				int indexSuit = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref indexSuit);
				val.SetValue((object)(__RpcExecStage)1);
				((BodySuitBehaviour)(object)target).SyncIndexSuitServerRpc(indexSuit);
				val.SetValue((object)(__RpcExecStage)0);
			}
		}

		private static void __rpc_handler_2170264864(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int indexSuit = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref indexSuit);
				Traverse val = Traverse.Create((object)target).Field("__rpc_exec_stage");
				val.SetValue((object)(__RpcExecStage)2);
				((BodySuitBehaviour)(object)target).SyncIndexSuitClientRpc(indexSuit);
				val.SetValue((object)(__RpcExecStage)0);
			}
		}
	}
	internal class PositionOnNavMeshBehaviour
	{
		private float _maxReachDistance = 6f;

		private float _minReachDistance = 0.125f;

		private float _movedReachDistance = 5f;

		private float _moveDistance = 1f;

		private float _yOffset = 1f;

		private const int _areaMask = -1;

		private float _maxDistanceFromNavmesh = 0.5f;

		public PositionOnNavMeshBehaviour(float maxReachDistance, float minReachDistance, float movedReachDistance, float moveDistance, float yOffset)
		{
			_maxReachDistance = maxReachDistance;
			_minReachDistance = minReachDistance;
			_movedReachDistance = movedReachDistance;
			_moveDistance = moveDistance;
			_yOffset = yOffset;
		}

		public bool SetPositionOnNavMesh(Vector3 startPosition, out Vector3 newPosition)
		{
			//IL_000c: 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_0039: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_0095: 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_00a5: 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)
			//IL_00ae: 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_00b7: 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_00c4: 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_00cb: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource mls = Remnants.Instance.Mls;
			NavMeshHit val = default(NavMeshHit);
			if (!NavMesh.SamplePosition(startPosition, ref val, _maxReachDistance, -1))
			{
				mls.LogWarning((object)"Position is not in range of Navmesh.");
				newPosition = Vector3.zero;
				return false;
			}
			if (((NavMeshHit)(ref val)).distance <= _minReachDistance)
			{
				newPosition = startPosition;
				newPosition.y += _yOffset;
				return true;
			}
			Vector3 position = ((NavMeshHit)(ref val)).position;
			position.y = startPosition.y;
			Vector3 val2 = position - startPosition;
			float magnitude = ((Vector3)(ref val2)).magnitude;
			Vector3 val3 = val2 / magnitude;
			Vector3 val4 = ((NavMeshHit)(ref val)).position + val3 * _moveDistance;
			NavMeshHit val5 = default(NavMeshHit);
			if (NavMesh.SamplePosition(val4, ref val5, _movedReachDistance, -1))
			{
				newPosition = ((NavMeshHit)(ref val5)).position;
				newPosition.y += _yOffset;
				return true;
			}
			mls.LogWarning((object)"Moved position not found on navmesh, using older position on navmesh.");
			newPosition = ((NavMeshHit)(ref val)).position;
			newPosition.y += _yOffset;
			return true;
		}

		public bool SetRandomOffsetOnNavmesh(Vector3 startPosition, out Vector3 newPosition)
		{
			//IL_000c: 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_006f: 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_0034: 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_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_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)
			ManualLogSource mls = Remnants.Instance.Mls;
			NavMeshHit val = default(NavMeshHit);