Decompiled source of Lootrun v1.0.0

Lootrun.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Lootrun.NetcodePatcher;
using Lootrun.hooks;
using Lootrun.types;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Lootrun")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c73b84816b7c7d9f1f2ba246ee3120273b0daa06")]
[assembly: AssemblyProduct("Lootrun")]
[assembly: AssemblyTitle("Lootrun")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Lootrun
{
	[HarmonyPatch(typeof(HUDManager), "FillEndGameStats")]
	internal class FillEndGameStatsPatch
	{
		[HarmonyPostfix]
		private static void FillEndGameStatsHook(HUDManager __instance)
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			if (LootrunBase.isInLootrun)
			{
				float num = (float)((Vector2Int)(ref LootrunBase.currentRunResults.scrapCollectedOutOf)).x / (float)((Vector2Int)(ref LootrunBase.currentRunResults.scrapCollectedOutOf)).y * 100f;
				((TMP_Text)__instance.statsUIElements.quotaNumerator).text = LootrunBase.SecsToTimer(LootrunBase.LootrunTime);
				((TMP_Text)__instance.statsUIElements.quotaDenominator).text = $"{((Vector2Int)(ref LootrunBase.currentRunResults.scrapCollectedOutOf)).x}/{((Vector2Int)(ref LootrunBase.currentRunResults.scrapCollectedOutOf)).y}({(int)num}%)";
				RectTransform component = ((Component)__instance.statsUIElements.quotaDenominator).GetComponent<RectTransform>();
				component.sizeDelta = new Vector2(component.sizeDelta.x + 500f, component.sizeDelta.y);
			}
		}
	}
	[HarmonyPatch(typeof(KnifeItem), "__initializeVariables")]
	internal class KnifePatch
	{
		[HarmonyPostfix]
		private static void Hook(KnifeItem __instance)
		{
			LootrunBase.mls.LogInfo((object)"KNIFE IS HERE YAY");
			if (LootrunBase.isInLootrun)
			{
				LootrunBase.CurrentRoundSpecials.Add((GrabbableObject)(object)__instance);
			}
		}
	}
	[HarmonyPatch(typeof(NutcrackerEnemyAI), "GrabGun")]
	internal class NutcrackerEnemyAIGrabGunPatch
	{
		[HarmonyPrefix]
		private static void GrabGun(object[] __args)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (LootrunBase.isInLootrun)
			{
				LootrunBase.CurrentRoundSpecials.Add((GrabbableObject)(object)((GameObject)__args[0]).GetComponent<ShotgunItem>());
			}
		}
	}
	[HarmonyPatch(typeof(StartMatchLever), "StartGame")]
	internal class StartGamePatch
	{
		[HarmonyPostfix]
		private static void StartGameHook()
		{
			if (LootrunBase.isInLootrun)
			{
				LootrunBase.CurrentRoundBees.Clear();
				LootrunBase.CurrentRoundSpecials.Clear();
				LootrunBase.LootrunTime = 0f;
				LootrunBase.playersThisRound = StartOfRound.Instance.connectedPlayersAmount + 1;
			}
		}
	}
	[BepInPlugin("abb2k.Lootrun", "Lootrun", "1.0.0.0")]
	public class LootrunBase : BaseUnityPlugin
	{
		public const string GUID = "abb2k.Lootrun";

		public const string modName = "Lootrun";

		public const string modVersion = "1.0.0.0";

		private readonly Harmony harmony = new Harmony("abb2k.Lootrun");

		private static LootrunBase Instance;

		public static ManualLogSource mls;

		public static AssetBundle bundle;

		public static Sprite DialogueBox1Frame_5;

		public static Sprite BloodStain2;

		public static Sprite DialogueBoxSimple_1;

		public static Sprite DialogueBoxSimple;

		public static Sprite DropdownArrow;

		public static LootrunSettings currentRunSettings = new LootrunSettings();

		public static LootrunResults currentRunResults = new LootrunResults();

		public static bool isInLootrun;

		public static float LootrunTime;

		public static int playersThisRound;

		public static TextMeshProUGUI timerText;

		public static List<GrabbableObject> CurrentRoundScrap = new List<GrabbableObject>();

		public static List<GrabbableObject> CurrentRoundBees = new List<GrabbableObject>();

		public static List<GrabbableObject> CurrentRoundSpecials = new List<GrabbableObject>();

		public static List<Pair<LootrunSettings, LootrunResults>> allLootruns = new List<Pair<LootrunSettings, LootrunResults>>();

		private void Awake()
		{
			if (!Object.op_Implicit((Object)(object)Instance))
			{
				Instance = this;
			}
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			mls = ((BaseUnityPlugin)this).Logger;
			mls.LogInfo((object)"Lootrun has loaded :D");
			harmony.PatchAll(typeof(NetworkObjectManagerPatch));
			harmony.PatchAll(typeof(LootrunBase));
			harmony.PatchAll(typeof(MenuManagerHook));
			harmony.PatchAll(typeof(StartOfRoundHook));
			harmony.PatchAll(typeof(SaveGamePatch));
			harmony.PatchAll(typeof(SetShipToLeaveOnMidnightClientRpcPatcher));
			harmony.PatchAll(typeof(TextPostProcessHook));
			harmony.PatchAll(typeof(UpdateProfitQuotaCurrentTimePatch));
			harmony.PatchAll(typeof(PassTimeToNextDayPatch));
			harmony.PatchAll(typeof(waitForScrapToSpawnToSyncPatch));
			harmony.PatchAll(typeof(StartGamePatch));
			harmony.PatchAll(typeof(ShipHasLeftPatch));
			harmony.PatchAll(typeof(TimeOfDayUpdatePatch));
			harmony.PatchAll(typeof(FillEndGameStatsPatch));
			harmony.PatchAll(typeof(ApparatusStartPatch));
			harmony.PatchAll(typeof(RedLocustBeesStartPatch));
			harmony.PatchAll(typeof(NutcrackerEnemyAIGrabGunPatch));
			harmony.PatchAll(typeof(KnifePatch));
			harmony.PatchAll(typeof(AutoSaveShipDataPatch));
			harmony.PatchAll(typeof(LoadShipGrabbableItemsPatch));
			harmony.PatchAll(typeof(PlayerControllerBPatcher));
			allLootruns = ES3.Load<List<Pair<LootrunSettings, LootrunResults>>>("allLootruns", Application.persistentDataPath + "/LootrunSave", new List<Pair<LootrunSettings, LootrunResults>>());
			mls.LogInfo((object)allLootruns.Count);
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			location = location.TrimEnd("Lootrun.dll".ToCharArray());
			bundle = AssetBundle.LoadFromFile(location + "modassets");
			if ((Object)(object)bundle != (Object)null)
			{
				DialogueBox1Frame_5 = bundle.LoadAsset<Sprite>("DialogueBox1Frame 5");
				BloodStain2 = bundle.LoadAsset<Sprite>("BloodStain2");
				DialogueBoxSimple_1 = bundle.LoadAsset<Sprite>("DialogueBoxSimple 1");
				DialogueBoxSimple = bundle.LoadAsset<Sprite>("DialogueBoxSimple");
				DropdownArrow = bundle.LoadAsset<Sprite>("DropdownArrow");
			}
		}

		public static string SecsToTimer(float secondsTimer)
		{
			string empty = string.Empty;
			int num = 0;
			while (secondsTimer >= 60f)
			{
				secondsTimer -= 60f;
				num++;
			}
			int num2 = (int)secondsTimer;
			int num3 = (int)(secondsTimer % 1f * 100f);
			return $"{num:0}:{num2:00}:{num3:00}";
		}

		public static int MoonNameToID(string moonName)
		{
			return moonName switch
			{
				"41-Experimentation" => 0, 
				"220-Assurance" => 1, 
				"56-Vow" => 2, 
				"21-Offense" => 8, 
				"61-March" => 4, 
				"20-Adamance" => 5, 
				"85-Rend" => 6, 
				"7-Dine" => 7, 
				"8-Titan" => 9, 
				"68-Artifice" => 10, 
				"5-Embrion" => 12, 
				_ => 0, 
			};
		}

		public static string MoonIDToName(int moonID)
		{
			return moonID switch
			{
				0 => "41-Experimentation", 
				1 => "220-Assurance", 
				2 => "56-Vow", 
				8 => "21-Offense", 
				4 => "61-March", 
				5 => "20-Adamance", 
				6 => "85-Rend", 
				7 => "7-Dine", 
				9 => "8-Titan", 
				10 => "68-Artifice", 
				12 => "5-Embrion", 
				_ => "41-Experimentation", 
			};
		}

		public static List<LevelWeatherType> MoonAvalableWeathers(int moonID)
		{
			List<LevelWeatherType> list = new List<LevelWeatherType> { (LevelWeatherType)(-1) };
			switch (moonID)
			{
			case 0:
				list.Add((LevelWeatherType)1);
				list.Add((LevelWeatherType)2);
				list.Add((LevelWeatherType)3);
				list.Add((LevelWeatherType)4);
				list.Add((LevelWeatherType)5);
				break;
			case 1:
				list.Add((LevelWeatherType)1);
				list.Add((LevelWeatherType)2);
				list.Add((LevelWeatherType)3);
				list.Add((LevelWeatherType)4);
				list.Add((LevelWeatherType)5);
				break;
			case 2:
				list.Add((LevelWeatherType)2);
				list.Add((LevelWeatherType)3);
				list.Add((LevelWeatherType)4);
				list.Add((LevelWeatherType)5);
				break;
			case 8:
				list.Add((LevelWeatherType)1);
				list.Add((LevelWeatherType)2);
				list.Add((LevelWeatherType)3);
				list.Add((LevelWeatherType)4);
				list.Add((LevelWeatherType)5);
				break;
			case 4:
				list.Add((LevelWeatherType)2);
				list.Add((LevelWeatherType)3);
				list.Add((LevelWeatherType)4);
				list.Add((LevelWeatherType)5);
				break;
			case 5:
				list.Add((LevelWeatherType)1);
				list.Add((LevelWeatherType)2);
				list.Add((LevelWeatherType)3);
				list.Add((LevelWeatherType)4);
				list.Add((LevelWeatherType)5);
				break;
			case 6:
				list.Add((LevelWeatherType)2);
				list.Add((LevelWeatherType)5);
				break;
			case 7:
				list.Add((LevelWeatherType)1);
				list.Add((LevelWeatherType)4);
				list.Add((LevelWeatherType)5);
				break;
			case 9:
				list.Add((LevelWeatherType)2);
				list.Add((LevelWeatherType)3);
				list.Add((LevelWeatherType)5);
				break;
			case 10:
				list.Add((LevelWeatherType)1);
				list.Add((LevelWeatherType)2);
				list.Add((LevelWeatherType)4);
				list.Add((LevelWeatherType)5);
				break;
			case 12:
				list.Add((LevelWeatherType)3);
				list.Add((LevelWeatherType)5);
				break;
			default:
				list.Add((LevelWeatherType)1);
				list.Add((LevelWeatherType)2);
				list.Add((LevelWeatherType)3);
				list.Add((LevelWeatherType)4);
				list.Add((LevelWeatherType)5);
				break;
			}
			return list;
		}

		public static LevelWeatherType weatherNameToType(string name)
		{
			//IL_00d5: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			return (LevelWeatherType)(name switch
			{
				"None" => -1, 
				"DustClouds" => 0, 
				"Rainy" => 1, 
				"Stormy" => 2, 
				"Foggy" => 3, 
				"Flooded" => 4, 
				"Eclipsed" => 5, 
				_ => -1, 
			});
		}

		public static void addRunToListAndSave(LootrunSettings settings, LootrunResults res)
		{
			allLootruns.Add(new Pair<LootrunSettings, LootrunResults>(settings, res));
			ES3.Save<List<Pair<LootrunSettings, LootrunResults>>>("allLootruns", allLootruns, Application.persistentDataPath + "/LootrunSave");
		}
	}
}
namespace Lootrun.types
{
	public class LootrunResults : INetworkSerializable
	{
		[SerializeField]
		public int players;

		[SerializeField]
		public float time;

		[SerializeField]
		public Vector2Int scrapCollectedOutOf;

		public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref players, default(ForPrimitives));
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref time, default(ForPrimitives));
			serializer.SerializeValue(ref scrapCollectedOutOf);
		}
	}
	[SerializeField]
	public class LootrunSettings : INetworkSerializable
	{
		[SerializeField]
		public int moon;

		[SerializeField]
		public int weather;

		[SerializeField]
		public bool bees = true;

		[SerializeField]
		public bool spacials;

		[SerializeField]
		public bool randomseed = true;

		[SerializeField]
		public int seed;

		[SerializeField]
		public int money;

		[SerializeField]
		public bool startCrusier;

		[SerializeField]
		public bool startJetpack;

		public bool compare(LootrunSettings other)
		{
			if (other == null)
			{
				return false;
			}
			if (moon != other.moon)
			{
				return false;
			}
			if (weather != other.weather)
			{
				return false;
			}
			if (bees != other.bees)
			{
				return false;
			}
			if (spacials != other.spacials)
			{
				return false;
			}
			if (randomseed != other.randomseed)
			{
				return false;
			}
			if (seed != other.seed && randomseed)
			{
				return false;
			}
			if (money != other.money)
			{
				return false;
			}
			if (startCrusier != other.startCrusier)
			{
				return false;
			}
			if (startJetpack != other.startJetpack)
			{
				return false;
			}
			return true;
		}

		public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_00c3: 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)
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref moon, default(ForPrimitives));
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref weather, default(ForPrimitives));
			((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref bees, default(ForPrimitives));
			((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref spacials, default(ForPrimitives));
			((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref randomseed, default(ForPrimitives));
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref seed, default(ForPrimitives));
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref money, default(ForPrimitives));
			((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref startJetpack, default(ForPrimitives));
			((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref startCrusier, default(ForPrimitives));
		}
	}
	[SerializeField]
	public class Pair<T, U>
	{
		[SerializeField]
		public T First { get; set; }

		[SerializeField]
		public U Second { get; set; }

		public Pair()
		{
		}

		public Pair(T first, U second)
		{
			First = first;
			Second = second;
		}
	}
}
namespace Lootrun.hooks
{
	[HarmonyPatch(typeof(LungProp), "Start")]
	internal class ApparatusStartPatch
	{
		[HarmonyPostfix]
		private static void StartHook(LungProp __instance)
		{
			LootrunBase.CurrentRoundScrap.Add((GrabbableObject)(object)__instance);
		}
	}
	[HarmonyPatch]
	public class NetworkObjectManagerPatch
	{
		private static GameObject networkPrefab;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		public static void Init()
		{
			if (!((Object)(object)networkPrefab != (Object)null))
			{
				networkPrefab = LootrunBase.bundle.LoadAsset<GameObject>("NetPrefab");
				networkPrefab.AddComponent<LootrunNetworkHandler>();
				NetworkManager.Singleton.AddNetworkPrefab(networkPrefab);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		private static void SpawnNetworkHandler()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if ((NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) && Object.op_Implicit((Object)(object)networkPrefab))
			{
				GameObject val = Object.Instantiate<GameObject>(networkPrefab, Vector3.zero, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(false);
			}
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class SaveGamePatch
	{
		private static bool hasSubscribedToConnectionCallbacks;

		[HarmonyPrefix]
		[HarmonyPatch("SaveGame")]
		private static bool SaveGameHook()
		{
			if (GameNetworkManager.Instance.currentSaveFileName == "Speedloot")
			{
				GameNetworkManager.Instance.currentSaveFileName = "LCSaveFile1";
				return false;
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch("SubscribeToConnectionCallbacks")]
		private static void SubscribeToConnectionCallbacksPatch(GameNetworkManager __instance)
		{
			if (!hasSubscribedToConnectionCallbacks)
			{
				NetworkManager.Singleton.OnClientConnectedCallback += LootrunNetworkHandler.onClientConnected;
				hasSubscribedToConnectionCallbacks = true;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("Disconnect")]
		private static void DisconnectPatch()
		{
			if (hasSubscribedToConnectionCallbacks)
			{
				NetworkManager.Singleton.OnClientConnectedCallback -= LootrunNetworkHandler.onClientConnected;
				hasSubscribedToConnectionCallbacks = false;
			}
		}
	}
	public class LootrunNetworkHandler : NetworkBehaviour
	{
		public static LootrunNetworkHandler instance;

		private void Awake()
		{
			instance = this;
		}

		[ClientRpc]
		public void SyncInLootrunClientRpc(ulong playerID, bool enable)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: 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_006d: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2684428673u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerID);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref enable, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2684428673u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				LootrunBase.isInLootrun = enable;
				if (!Object.op_Implicit((Object)(object)LootrunBase.timerText) && LootrunBase.isInLootrun)
				{
					GameObject val3 = Object.Instantiate<GameObject>(LootrunBase.bundle.LoadAsset<GameObject>("RunTimer"), StartOfRound.Instance.allPlayerObjects[playerID].GetComponent<PlayerControllerB>().playerHudUIContainer);
					((Object)val3).name = "Lootrun time text";
					val3.transform.localPosition = new Vector3(325f, -210f, 0f);
					TextMeshProUGUI component = ((Component)val3.transform.GetChild(0)).GetComponent<TextMeshProUGUI>();
					((TMP_Text)component).text = LootrunBase.SecsToTimer(0f);
					LootrunBase.timerText = component;
				}
			}
		}

		[ClientRpc]
		public void SyncLootrunTimerClientRpc(float time)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			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(1144487935u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref time, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1144487935u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !NetworkManager.Singleton.IsHost && !NetworkManager.Singleton.IsServer)
				{
					LootrunBase.LootrunTime = time;
					((TMP_Text)LootrunBase.timerText).text = LootrunBase.SecsToTimer(LootrunBase.LootrunTime);
				}
			}
		}

		[ClientRpc]
		public void SyncLootrunResultsClientRpc(LootrunSettings s, LootrunResults res)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Invalid comparison between Unknown and I4
			//IL_005f: 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_006d: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3875230145u, val, (RpcDelivery)0);
				bool flag = s != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<LootrunSettings>(ref s, default(ForNetworkSerializable));
				}
				bool flag2 = res != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
				if (flag2)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<LootrunResults>(ref res, default(ForNetworkSerializable));
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3875230145u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !NetworkManager.Singleton.IsHost && !NetworkManager.Singleton.IsServer)
			{
				LootrunBase.currentRunSettings = s;
				LootrunBase.currentRunResults = res;
			}
		}

		[ClientRpc]
		public void SyncStatsClientRpc(int moon, int weather, int money)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Invalid comparison between Unknown and I4
			//IL_005f: 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_006d: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: 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(3633830683u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, moon);
					BytePacker.WriteValueBitPacked(val2, weather);
					BytePacker.WriteValueBitPacked(val2, money);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3633830683u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !NetworkManager.Singleton.IsHost && !NetworkManager.Singleton.IsServer)
				{
					StartOfRound.Instance.currentLevel = StartOfRound.Instance.levels[moon];
					StartOfRound.Instance.currentLevelID = moon;
					TimeOfDay.Instance.currentLevel = StartOfRound.Instance.currentLevel;
					RoundManager.Instance.currentLevel = StartOfRound.Instance.levels[moon];
					StartOfRound.Instance.currentLevel.currentWeather = (LevelWeatherType)weather;
					TimeOfDay val3 = Object.FindObjectOfType<TimeOfDay>();
					val3.quotaFulfilled = 0;
					val3.timesFulfilledQuota = 0;
					val3.UpdateProfitQuotaCurrentTime();
					Terminal val4 = Object.FindObjectOfType<Terminal>();
					val4.groupCredits = money;
					StartOfRound.Instance.ChangePlanet();
					StartOfRound.Instance.SetMapScreenInfoToCurrentLevel();
					((TMP_Text)StartOfRound.Instance.deadlineMonitorText).text = "DEADLINE:\nNever";
					((TMP_Text)StartOfRound.Instance.profitQuotaMonitorText).text = "PROFIT QUOTA:\nAll of them";
				}
			}
		}

		[ClientRpc]
		public void ClearInventoryClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(176124722u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 176124722u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				for (int i = 0; i < StartOfRound.Instance.localPlayerController.ItemSlots.Length; i++)
				{
					StartOfRound.Instance.localPlayerController.ItemSlots[i] = null;
				}
				for (int j = 0; j < HUDManager.Instance.itemSlotIcons.Length; j++)
				{
					((Behaviour)HUDManager.Instance.itemSlotIcons[j]).enabled = false;
				}
			}
		}

		public static void onClientConnected(ulong playerID)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected I4, but got Unknown
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				instance.SyncInLootrunClientRpc(playerID, LootrunBase.isInLootrun);
				if (LootrunBase.isInLootrun)
				{
					instance.SyncStatsClientRpc(LootrunBase.currentRunSettings.moon, (int)StartOfRound.Instance.currentLevel.overrideWeatherType, LootrunBase.currentRunSettings.money);
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_LootrunNetworkHandler()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2684428673u, new RpcReceiveHandler(__rpc_handler_2684428673));
			NetworkManager.__rpc_func_table.Add(1144487935u, new RpcReceiveHandler(__rpc_handler_1144487935));
			NetworkManager.__rpc_func_table.Add(3875230145u, new RpcReceiveHandler(__rpc_handler_3875230145));
			NetworkManager.__rpc_func_table.Add(3633830683u, new RpcReceiveHandler(__rpc_handler_3633830683));
			NetworkManager.__rpc_func_table.Add(176124722u, new RpcReceiveHandler(__rpc_handler_176124722));
		}

		private static void __rpc_handler_2684428673(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong playerID = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerID);
				bool enable = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref enable, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((LootrunNetworkHandler)(object)target).SyncInLootrunClientRpc(playerID, enable);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1144487935(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				float time = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref time, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((LootrunNetworkHandler)(object)target).SyncLootrunTimerClientRpc(time);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3875230145(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				LootrunSettings s = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<LootrunSettings>(ref s, default(ForNetworkSerializable));
				}
				bool flag2 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
				LootrunResults res = null;
				if (flag2)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<LootrunResults>(ref res, default(ForNetworkSerializable));
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((LootrunNetworkHandler)(object)target).SyncLootrunResultsClientRpc(s, res);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3633830683(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int moon = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref moon);
				int weather = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref weather);
				int money = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref money);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((LootrunNetworkHandler)(object)target).SyncStatsClientRpc(moon, weather, money);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_176124722(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((LootrunNetworkHandler)(object)target).ClearInventoryClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "LootrunNetworkHandler";
		}
	}
	[HarmonyPatch(typeof(MenuManager))]
	internal class MenuManagerHook
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction<int> <>9__11_0;

			public static UnityAction<string> <>9__11_1;

			public static UnityAction<string> <>9__11_2;

			public static UnityAction <>9__11_3;

			public static UnityAction <>9__11_4;

			public static UnityAction <>9__11_5;

			internal void <StartHook>b__11_0(int newVal)
			{
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Expected O, but got Unknown
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Expected O, but got Unknown
				weatherDropdown.ClearOptions();
				weatherDropdown.value = 0;
				List<OptionData> list = new List<OptionData>();
				List<LevelWeatherType> list2 = LootrunBase.MoonAvalableWeathers(LootrunBase.MoonNameToID(moonsDropdown.options[moonsDropdown.value].text));
				list.Add(new OptionData("Random"));
				for (int i = 0; i < list2.Count; i++)
				{
					LevelWeatherType val = list2[i];
					list.Add(new OptionData(((object)(LevelWeatherType)(ref val)).ToString()));
				}
				weatherDropdown.AddOptions(list);
			}

			internal void <StartHook>b__11_1(string newVal)
			{
				if (int.TryParse(newVal, out var result))
				{
					if (result < 0)
					{
						moneyAmountInput.text = "";
					}
				}
				else
				{
					moneyAmountInput.text = "";
				}
			}

			internal void <StartHook>b__11_2(string newVal)
			{
				if (int.TryParse(newVal, out var result))
				{
					if (result < 0)
					{
						seedInput.text = "";
					}
				}
				else
				{
					seedInput.text = "";
				}
			}

			internal void <StartHook>b__11_3()
			{
				speedlootMenuContainer.SetActive(false);
			}

			internal void <StartHook>b__11_4()
			{
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b3: Expected I4, but got Unknown
				speedlootMenuContainer.SetActive(false);
				LootrunBase.isInLootrun = true;
				GameNetworkManager.Instance.currentSaveFileName = "Speedloot";
				LootrunSettings lootrunSettings = new LootrunSettings
				{
					moon = LootrunBase.MoonNameToID(moonsDropdown.options[moonsDropdown.value].text)
				};
				if (weatherDropdown.options[weatherDropdown.value].text == "Random")
				{
					lootrunSettings.weather = -2;
				}
				else
				{
					lootrunSettings.weather = (int)LootrunBase.weatherNameToType(weatherDropdown.options[weatherDropdown.value].text);
					LootrunBase.mls.LogInfo((object)("weather " + lootrunSettings.weather));
				}
				lootrunSettings.bees = beesToggle.isOn;
				lootrunSettings.spacials = specialsToggle.isOn;
				lootrunSettings.startJetpack = SJetpacksToggle.isOn;
				lootrunSettings.startCrusier = SCrusierToggle.isOn;
				lootrunSettings.randomseed = randomSeedToggle.isOn;
				if (int.TryParse(seedInput.text, out var result))
				{
					lootrunSettings.seed = result;
				}
				else
				{
					lootrunSettings.seed = 0;
				}
				if (int.TryParse(moneyAmountInput.text, out var result2))
				{
					lootrunSettings.money = result2;
				}
				else
				{
					lootrunSettings.money = 0;
				}
				LootrunBase.currentRunSettings = lootrunSettings;
				GameNetworkManager.Instance.StartHost();
			}

			internal void <StartHook>b__11_5()
			{
				speedlootMenuContainer.SetActive(true);
			}
		}

		public static GameObject speedlootMenuContainer;

		public static TMP_Dropdown moonsDropdown;

		public static TMP_Dropdown weatherDropdown;

		public static Toggle beesToggle;

		public static Toggle specialsToggle;

		public static Toggle SJetpacksToggle;

		public static Toggle SCrusierToggle;

		public static Toggle randomSeedToggle;

		public static TMP_InputField seedInput;

		public static TMP_InputField moneyAmountInput;

		public static TextMeshProUGUI bestRunText;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartHook(ref GameObject ___menuButtons, ref GameObject ___HostSettingsScreen)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Expected O, but got Unknown
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Expected O, but got Unknown
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Expected O, but got Unknown
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Expected O, but got Unknown
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Expected O, but got Unknown
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cc: Expected O, but got Unknown
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Expected O, but got Unknown
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Expected O, but got Unknown
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Expected O, but got Unknown
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Expected O, but got Unknown
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_0421: Expected O, but got Unknown
			//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cf: Expected O, but got Unknown
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fa: Expected O, but got Unknown
			//IL_054d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0741: Unknown result type (might be due to invalid IL or missing references)
			//IL_075d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0784: Unknown result type (might be due to invalid IL or missing references)
			//IL_079c: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0852: Unknown result type (might be due to invalid IL or missing references)
			//IL_086e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0895: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d6: Expected O, but got Unknown
			//IL_0908: Unknown result type (might be due to invalid IL or missing references)
			//IL_08dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e7: Expected O, but got Unknown
			//IL_0947: Unknown result type (might be due to invalid IL or missing references)
			//IL_094c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0952: Expected O, but got Unknown
			if ((Object)(object)___menuButtons == (Object)null || (Object)(object)___menuButtons.transform.GetChild(1) == (Object)null)
			{
				return;
			}
			GameObject val = Object.Instantiate<GameObject>(((Component)___menuButtons.transform.GetChild(1)).gameObject, ___menuButtons.transform);
			((Object)val).name = "LootrunButton";
			val.GetComponent<RectTransform>().anchoredPosition = new Vector2(val.GetComponent<RectTransform>().anchoredPosition.x, 235f);
			Button component = val.GetComponent<Button>();
			((UnityEventBase)component.onClick).RemoveAllListeners();
			TextMeshProUGUI component2 = ((Component)val.transform.GetChild(1)).GetComponent<TextMeshProUGUI>();
			((TMP_Text)component2).text = "> Lootrun";
			LootrunBase.isInLootrun = false;
			LootrunBase.LootrunTime = 0f;
			speedlootMenuContainer = Object.Instantiate<GameObject>(LootrunBase.bundle.LoadAsset<GameObject>("speedlootMenuContainer"), ___HostSettingsScreen.transform.parent);
			((Object)speedlootMenuContainer).name = "speedlootMenuContainer";
			speedlootMenuContainer.transform.position = ___HostSettingsScreen.transform.position;
			speedlootMenuContainer.transform.localScale = ___HostSettingsScreen.transform.localScale;
			speedlootMenuContainer.SetActive(false);
			moonsDropdown = ((Component)speedlootMenuContainer.transform.GetChild(2)).GetComponent<TMP_Dropdown>();
			weatherDropdown = ((Component)speedlootMenuContainer.transform.GetChild(3)).GetComponent<TMP_Dropdown>();
			beesToggle = ((Component)speedlootMenuContainer.transform.GetChild(4)).GetComponent<Toggle>();
			specialsToggle = ((Component)speedlootMenuContainer.transform.GetChild(5)).GetComponent<Toggle>();
			SJetpacksToggle = ((Component)speedlootMenuContainer.transform.GetChild(6)).GetComponent<Toggle>();
			SCrusierToggle = ((Component)speedlootMenuContainer.transform.GetChild(7)).GetComponent<Toggle>();
			randomSeedToggle = ((Component)speedlootMenuContainer.transform.GetChild(9)).GetComponent<Toggle>();
			moneyAmountInput = ((Component)speedlootMenuContainer.transform.GetChild(8).GetChild(1)).GetComponent<TMP_InputField>();
			seedInput = ((Component)speedlootMenuContainer.transform.GetChild(10)).GetComponent<TMP_InputField>();
			((UnityEvent<int>)(object)moonsDropdown.onValueChanged).AddListener((UnityAction<int>)UpdateBest);
			((UnityEvent<int>)(object)weatherDropdown.onValueChanged).AddListener((UnityAction<int>)UpdateBest);
			((UnityEvent<bool>)(object)beesToggle.onValueChanged).AddListener((UnityAction<bool>)UpdateBest);
			((UnityEvent<bool>)(object)specialsToggle.onValueChanged).AddListener((UnityAction<bool>)UpdateBest);
			((UnityEvent<bool>)(object)SJetpacksToggle.onValueChanged).AddListener((UnityAction<bool>)UpdateBest);
			((UnityEvent<bool>)(object)SCrusierToggle.onValueChanged).AddListener((UnityAction<bool>)UpdateBest);
			((UnityEvent<bool>)(object)randomSeedToggle.onValueChanged).AddListener((UnityAction<bool>)toggleSeedInput);
			((UnityEvent<bool>)(object)randomSeedToggle.onValueChanged).AddListener((UnityAction<bool>)UpdateBest);
			((UnityEvent<string>)(object)moneyAmountInput.onValueChanged).AddListener((UnityAction<string>)UpdateBest);
			((UnityEvent<string>)(object)seedInput.onValueChanged).AddListener((UnityAction<string>)UpdateBest);
			bestRunText = ((Component)speedlootMenuContainer.transform.GetChild(12)).GetComponent<TextMeshProUGUI>();
			List<OptionData> list = new List<OptionData>
			{
				new OptionData("41-Experimentation"),
				new OptionData("220-Assurance"),
				new OptionData("56-Vow"),
				new OptionData("21-Offense"),
				new OptionData("61-March"),
				new OptionData("20-Adamance"),
				new OptionData("85-Rend"),
				new OptionData("7-Dine"),
				new OptionData("8-Titan"),
				new OptionData("68-Artifice"),
				new OptionData("5-Embrion")
			};
			moonsDropdown.AddOptions(list);
			string text = LootrunBase.MoonIDToName(LootrunBase.currentRunSettings.moon);
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].text == text)
				{
					moonsDropdown.value = i;
				}
			}
			moonsDropdown.RefreshShownValue();
			List<OptionData> list2 = new List<OptionData>();
			List<LevelWeatherType> list3 = LootrunBase.MoonAvalableWeathers(LootrunBase.MoonNameToID(moonsDropdown.options[moonsDropdown.value].text));
			list2.Add(new OptionData("Random"));
			for (int j = 0; j < list3.Count; j++)
			{
				LevelWeatherType val2 = list3[j];
				list2.Add(new OptionData(((object)(LevelWeatherType)(ref val2)).ToString()));
			}
			weatherDropdown.AddOptions(list2);
			if (LootrunBase.currentRunSettings.weather == -2)
			{
				weatherDropdown.value = 0;
			}
			else
			{
				LevelWeatherType val3 = (LevelWeatherType)LootrunBase.currentRunSettings.weather;
				for (int k = 0; k < weatherDropdown.options.Count; k++)
				{
					if (weatherDropdown.options[k].text == ((object)(LevelWeatherType)(ref val3)).ToString())
					{
						weatherDropdown.value = k;
					}
				}
			}
			weatherDropdown.RefreshShownValue();
			((UnityEvent<int>)(object)moonsDropdown.onValueChanged).AddListener((UnityAction<int>)delegate
			{
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Expected O, but got Unknown
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Expected O, but got Unknown
				weatherDropdown.ClearOptions();
				weatherDropdown.value = 0;
				List<OptionData> list4 = new List<OptionData>();
				List<LevelWeatherType> list5 = LootrunBase.MoonAvalableWeathers(LootrunBase.MoonNameToID(moonsDropdown.options[moonsDropdown.value].text));
				list4.Add(new OptionData("Random"));
				for (int l = 0; l < list5.Count; l++)
				{
					LevelWeatherType val9 = list5[l];
					list4.Add(new OptionData(((object)(LevelWeatherType)(ref val9)).ToString()));
				}
				weatherDropdown.AddOptions(list4);
			});
			beesToggle.isOn = LootrunBase.currentRunSettings.bees;
			randomSeedToggle.isOn = LootrunBase.currentRunSettings.randomseed;
			SCrusierToggle.isOn = LootrunBase.currentRunSettings.startCrusier;
			SJetpacksToggle.isOn = LootrunBase.currentRunSettings.startJetpack;
			specialsToggle.isOn = LootrunBase.currentRunSettings.spacials;
			if (LootrunBase.currentRunSettings.money != 0)
			{
				moneyAmountInput.text = LootrunBase.currentRunSettings.money.ToString();
			}
			if (LootrunBase.currentRunSettings.seed != 0)
			{
				seedInput.text = LootrunBase.currentRunSettings.seed.ToString();
			}
			((UnityEvent<string>)(object)moneyAmountInput.onValueChanged).AddListener((UnityAction<string>)delegate(string newVal)
			{
				if (int.TryParse(newVal, out var result4))
				{
					if (result4 < 0)
					{
						moneyAmountInput.text = "";
					}
				}
				else
				{
					moneyAmountInput.text = "";
				}
			});
			((UnityEvent<string>)(object)seedInput.onValueChanged).AddListener((UnityAction<string>)delegate(string newVal)
			{
				if (int.TryParse(newVal, out var result3))
				{
					if (result3 < 0)
					{
						seedInput.text = "";
					}
				}
				else
				{
					seedInput.text = "";
				}
			});
			GameObject val4 = Object.Instantiate<GameObject>(val, speedlootMenuContainer.transform);
			((Object)val4).name = "speedlootBack";
			val4.transform.localPosition = new Vector3(0f, -90f, 0f);
			val4.GetComponent<RectTransform>().sizeDelta = new Vector2(120f, 30f);
			((Component)val4.transform.GetChild(0)).GetComponent<RectTransform>().sizeDelta = new Vector2(120f, 25f);
			val4.transform.GetChild(0).localPosition = Vector3.zero;
			Button component3 = val4.GetComponent<Button>();
			ButtonClickedEvent onClick = component3.onClick;
			object obj = <>c.<>9__11_3;
			if (obj == null)
			{
				UnityAction val5 = delegate
				{
					speedlootMenuContainer.SetActive(false);
				};
				<>c.<>9__11_3 = val5;
				obj = (object)val5;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
			TextMeshProUGUI component4 = ((Component)val4.transform.GetChild(1)).GetComponent<TextMeshProUGUI>();
			((TMP_Text)component4).transform.localPosition = Vector3.zero;
			((TMP_Text)component4).alignment = (TextAlignmentOptions)514;
			((TMP_Text)component4).text = "[ Back ]";
			GameObject val6 = Object.Instantiate<GameObject>(val4, speedlootMenuContainer.transform);
			((Object)val6).name = "speedlootStart";
			val6.transform.localPosition = new Vector3(0f, -65f, 0f);
			val6.GetComponent<RectTransform>().sizeDelta = new Vector2(130f, 30f);
			((Component)val6.transform.GetChild(0)).GetComponent<RectTransform>().sizeDelta = new Vector2(130f, 25f);
			val6.transform.GetChild(0).localPosition = Vector3.zero;
			Button component5 = val6.GetComponent<Button>();
			ButtonClickedEvent onClick2 = component5.onClick;
			object obj2 = <>c.<>9__11_4;
			if (obj2 == null)
			{
				UnityAction val7 = delegate
				{
					//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b3: Expected I4, but got Unknown
					speedlootMenuContainer.SetActive(false);
					LootrunBase.isInLootrun = true;
					GameNetworkManager.Instance.currentSaveFileName = "Speedloot";
					LootrunSettings lootrunSettings = new LootrunSettings
					{
						moon = LootrunBase.MoonNameToID(moonsDropdown.options[moonsDropdown.value].text)
					};
					if (weatherDropdown.options[weatherDropdown.value].text == "Random")
					{
						lootrunSettings.weather = -2;
					}
					else
					{
						lootrunSettings.weather = (int)LootrunBase.weatherNameToType(weatherDropdown.options[weatherDropdown.value].text);
						LootrunBase.mls.LogInfo((object)("weather " + lootrunSettings.weather));
					}
					lootrunSettings.bees = beesToggle.isOn;
					lootrunSettings.spacials = specialsToggle.isOn;
					lootrunSettings.startJetpack = SJetpacksToggle.isOn;
					lootrunSettings.startCrusier = SCrusierToggle.isOn;
					lootrunSettings.randomseed = randomSeedToggle.isOn;
					if (int.TryParse(seedInput.text, out var result))
					{
						lootrunSettings.seed = result;
					}
					else
					{
						lootrunSettings.seed = 0;
					}
					if (int.TryParse(moneyAmountInput.text, out var result2))
					{
						lootrunSettings.money = result2;
					}
					else
					{
						lootrunSettings.money = 0;
					}
					LootrunBase.currentRunSettings = lootrunSettings;
					GameNetworkManager.Instance.StartHost();
				};
				<>c.<>9__11_4 = val7;
				obj2 = (object)val7;
			}
			((UnityEvent)onClick2).AddListener((UnityAction)obj2);
			TextMeshProUGUI component6 = ((Component)val6.transform.GetChild(1)).GetComponent<TextMeshProUGUI>();
			((TMP_Text)component6).transform.localPosition = Vector3.zero;
			((TMP_Text)component6).alignment = (TextAlignmentOptions)514;
			((TMP_Text)component6).text = "[ Start ]";
			ButtonClickedEvent onClick3 = component.onClick;
			object obj3 = <>c.<>9__11_5;
			if (obj3 == null)
			{
				UnityAction val8 = delegate
				{
					speedlootMenuContainer.SetActive(true);
				};
				<>c.<>9__11_5 = val8;
				obj3 = (object)val8;
			}
			((UnityEvent)onClick3).AddListener((UnityAction)obj3);
			UpdateBest(0);
			toggleSeedInput(randomSeedToggle.isOn);
		}

		public static void toggleSeedInput(bool val)
		{
			if (val)
			{
				seedInput.text = "";
				((Selectable)seedInput).interactable = false;
			}
			else
			{
				((Selectable)seedInput).interactable = true;
			}
		}

		public static void UpdateBest<T>(T type)
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected I4, but got Unknown
			if (weatherDropdown.options.Count == 0)
			{
				return;
			}
			LootrunSettings lootrunSettings = new LootrunSettings();
			lootrunSettings.moon = LootrunBase.MoonNameToID(moonsDropdown.options[moonsDropdown.value].text);
			if (weatherDropdown.options[weatherDropdown.value].text == "Random")
			{
				lootrunSettings.weather = -2;
			}
			else
			{
				lootrunSettings.weather = (int)LootrunBase.weatherNameToType(weatherDropdown.options[weatherDropdown.value].text);
				LootrunBase.mls.LogInfo((object)("weather " + lootrunSettings.weather));
			}
			lootrunSettings.bees = beesToggle.isOn;
			lootrunSettings.spacials = specialsToggle.isOn;
			lootrunSettings.startJetpack = SJetpacksToggle.isOn;
			lootrunSettings.startCrusier = SCrusierToggle.isOn;
			lootrunSettings.randomseed = randomSeedToggle.isOn;
			if (int.TryParse(seedInput.text, out var result))
			{
				lootrunSettings.seed = result;
			}
			else
			{
				lootrunSettings.seed = 0;
			}
			if (int.TryParse(moneyAmountInput.text, out var result2))
			{
				lootrunSettings.money = result2;
			}
			else
			{
				lootrunSettings.money = 0;
			}
			LootrunBase.currentRunSettings = lootrunSettings;
			float num = 0f;
			float num2 = -1f;
			for (int i = 0; i < LootrunBase.allLootruns.Count; i++)
			{
				if (LootrunBase.currentRunSettings.compare(LootrunBase.allLootruns[i].First))
				{
					float num3 = (float)((Vector2Int)(ref LootrunBase.allLootruns[i].Second.scrapCollectedOutOf)).x / (float)((Vector2Int)(ref LootrunBase.allLootruns[i].Second.scrapCollectedOutOf)).y;
					if (num2 == -1f)
					{
						num2 = LootrunBase.allLootruns[i].Second.time;
						num = num3;
					}
					else if (num3 > num)
					{
						num2 = LootrunBase.allLootruns[i].Second.time;
						num = num3;
					}
					else if (num3 == num && LootrunBase.allLootruns[i].Second.time < num2)
					{
						num2 = LootrunBase.allLootruns[i].Second.time;
						num = num3;
					}
				}
			}
			string empty = string.Empty;
			empty = ((num2 != -1f) ? $"{num * 100f:0.0}% - {LootrunBase.SecsToTimer(num2)}" : "No run found!");
			((TMP_Text)bestRunText).text = empty;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatcher
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		private static void ConnectClientToPlayerObjectPatch(PlayerControllerB __instance)
		{
			if (!((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)(object)__instance) && (((NetworkBehaviour)StartOfRound.Instance.localPlayerController).IsHost || ((NetworkBehaviour)StartOfRound.Instance.localPlayerController).IsServer))
			{
				LootrunNetworkHandler.instance.SyncInLootrunClientRpc(StartOfRound.Instance.localPlayerController.playerClientId, LootrunBase.isInLootrun);
			}
		}
	}
	[HarmonyPatch(typeof(RedLocustBees), "Start")]
	internal class RedLocustBeesStartPatch
	{
		[HarmonyPostfix]
		private static void StartHook(RedLocustBees __instance)
		{
			if (Object.op_Implicit((Object)(object)__instance.hive))
			{
				LootrunBase.CurrentRoundBees.Add(__instance.hive);
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager), "waitForScrapToSpawnToSync")]
	internal class waitForScrapToSpawnToSyncPatch
	{
		[HarmonyPrefix]
		private static void waitForScrapToSpawnToSyncHook(object[] __args)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (!LootrunBase.isInLootrun)
			{
				return;
			}
			List<NetworkObjectReference> list = ((NetworkObjectReference[])__args[0]).ToList();
			LootrunBase.CurrentRoundScrap.Clear();
			NetworkObject val2 = default(NetworkObject);
			GrabbableObject item = default(GrabbableObject);
			for (int i = 0; i < list.Count; i++)
			{
				NetworkObjectReference val = list[i];
				if (((NetworkObjectReference)(ref val)).TryGet(ref val2, (NetworkManager)null) && ((Component)val2).gameObject.TryGetComponent<GrabbableObject>(ref item))
				{
					LootrunBase.CurrentRoundScrap.Add(item);
				}
			}
		}
	}
	[HarmonyPatch]
	internal class StartOfRoundHook
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		private static void StartHook(StartOfRound __instance)
		{
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Expected I4, but got Unknown
			if (LootrunBase.isInLootrun && (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer))
			{
				__instance.currentLevel = Object.Instantiate<SelectableLevel>(__instance.levels[LootrunBase.currentRunSettings.moon]);
				__instance.currentLevelID = LootrunBase.currentRunSettings.moon;
				TimeOfDay.Instance.currentLevel = __instance.currentLevel;
				RoundManager.Instance.currentLevel = __instance.currentLevel;
				if (LootrunBase.currentRunSettings.weather == -2)
				{
					__instance.currentLevel.currentWeather = __instance.currentLevel.randomWeathers[Random.Range(0, __instance.currentLevel.randomWeathers.Length)].weatherType;
					LootrunBase.mls.LogInfo((object)("w - " + ((object)(LevelWeatherType)(ref __instance.currentLevel.overrideWeatherType)).ToString()));
				}
				else
				{
					__instance.currentLevel.currentWeather = (LevelWeatherType)LootrunBase.currentRunSettings.weather;
				}
				TimeOfDay val = Object.FindObjectOfType<TimeOfDay>();
				val.quotaFulfilled = 0;
				val.timesFulfilledQuota = 0;
				val.UpdateProfitQuotaCurrentTime();
				__instance.ChangePlanet();
				__instance.SetMapScreenInfoToCurrentLevel();
				__instance.overrideRandomSeed = !LootrunBase.currentRunSettings.randomseed;
				__instance.overrideSeedNumber = LootrunBase.currentRunSettings.seed;
				((TMP_Text)StartOfRound.Instance.deadlineMonitorText).text = "DEADLINE:\nNever";
				((TMP_Text)StartOfRound.Instance.profitQuotaMonitorText).text = "PROFIT QUOTA:\nAll of them";
				LootrunNetworkHandler.instance.SyncStatsClientRpc(LootrunBase.currentRunSettings.moon, (int)__instance.currentLevel.overrideWeatherType, LootrunBase.currentRunSettings.money);
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "LoadShipGrabbableItems")]
	internal class LoadShipGrabbableItemsPatch
	{
		[HarmonyPostfix]
		private static void LoadShipGrabbableItemsHook(StartOfRound __instance)
		{
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			if (!LootrunBase.isInLootrun || (!NetworkManager.Singleton.IsHost && !NetworkManager.Singleton.IsServer))
			{
				return;
			}
			GameObject val = null;
			GameObject val2 = null;
			for (int i = 0; i < __instance.allItemsList.itemsList.Count; i++)
			{
				LootrunBase.mls.LogInfo((object)__instance.allItemsList.itemsList[i].itemName);
				if (__instance.allItemsList.itemsList[i].itemName == "Jetpack")
				{
					val = __instance.allItemsList.itemsList[i].spawnPrefab;
				}
				if (__instance.allItemsList.itemsList[i].itemName == "Weed killer")
				{
					val2 = __instance.allItemsList.itemsList[i].spawnPrefab;
				}
			}
			if (LootrunBase.currentRunSettings.startJetpack)
			{
				for (int j = 0; j < 4; j++)
				{
					GrabbableObject component = Object.Instantiate<GameObject>(val, new Vector3(-3.5f, 1f, -14.5f), Quaternion.identity, __instance.elevatorTransform).GetComponent<GrabbableObject>();
					component.fallTime = 1f;
					component.hasHitGround = true;
					component.scrapPersistedThroughRounds = true;
					component.isInElevator = true;
					component.isInShipRoom = true;
					((NetworkBehaviour)component).NetworkObject.Spawn(false);
				}
			}
			GameObject val3 = null;
			for (int k = 0; k < __instance.VehiclesList.Length; k++)
			{
				if (((Object)__instance.VehiclesList[k]).name == "CompanyCruiser")
				{
					val3 = __instance.VehiclesList[k];
				}
			}
			if (!LootrunBase.currentRunSettings.startCrusier)
			{
				return;
			}
			GameObject val4 = Object.Instantiate<GameObject>(val3, __instance.magnetPoint.position + __instance.magnetPoint.forward * 5f, Quaternion.identity, RoundManager.Instance.VehiclesContainer);
			__instance.attachedVehicle = val4.GetComponent<VehicleController>();
			__instance.isObjectAttachedToMagnet = true;
			((NetworkBehaviour)__instance.attachedVehicle).NetworkObject.Spawn(false);
			__instance.magnetOn = true;
			__instance.magnetLever.initialBoolState = true;
			__instance.magnetLever.setInitialState = true;
			__instance.magnetLever.SetInitialState();
			if (Object.op_Implicit((Object)(object)val2))
			{
				for (int l = 0; l < 2; l++)
				{
					GrabbableObject component2 = Object.Instantiate<GameObject>(val2, new Vector3(10f, 1.5f, -13f), Quaternion.identity, __instance.elevatorTransform).GetComponent<GrabbableObject>();
					component2.fallTime = 1f;
					component2.hasHitGround = true;
					component2.scrapPersistedThroughRounds = true;
					component2.isInElevator = true;
					component2.isInShipRoom = true;
					((NetworkBehaviour)component2).NetworkObject.Spawn(false);
				}
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "PassTimeToNextDay")]
	internal class PassTimeToNextDayPatch
	{
		[HarmonyPrefix]
		private static bool PassTimeToNextDayHook()
		{
			LootrunBase.LootrunTime = 0f;
			if (LootrunBase.isInLootrun)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "ShipHasLeft")]
	internal class ShipHasLeftPatch
	{
		[HarmonyPrefix]
		private static void ShipHasLeftHook()
		{
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			if (!LootrunBase.isInLootrun || (!NetworkManager.Singleton.IsHost && !NetworkManager.Singleton.IsServer))
			{
				return;
			}
			TimeOfDay.Instance.currentDayTimeStarted = false;
			LootrunResults lootrunResults = new LootrunResults();
			int num = 0;
			for (int i = 0; i < RoundManager.Instance.scrapCollectedThisRound.Count; i++)
			{
				if (LootrunBase.CurrentRoundScrap.Contains(RoundManager.Instance.scrapCollectedThisRound[i]))
				{
					num++;
				}
				if (LootrunBase.currentRunSettings.bees && LootrunBase.CurrentRoundBees.Contains(RoundManager.Instance.scrapCollectedThisRound[i]))
				{
					num++;
				}
				if (LootrunBase.currentRunSettings.spacials && LootrunBase.CurrentRoundSpecials.Contains(RoundManager.Instance.scrapCollectedThisRound[i]))
				{
					num++;
				}
			}
			int num2 = LootrunBase.CurrentRoundScrap.Count;
			if (LootrunBase.currentRunSettings.bees)
			{
				num2 += LootrunBase.CurrentRoundBees.Count;
			}
			if (LootrunBase.currentRunSettings.spacials)
			{
				num2 += LootrunBase.CurrentRoundSpecials.Count;
			}
			lootrunResults.players = LootrunBase.playersThisRound;
			lootrunResults.time = LootrunBase.LootrunTime;
			lootrunResults.scrapCollectedOutOf = new Vector2Int(num, num2);
			LootrunBase.currentRunResults = lootrunResults;
			LootrunNetworkHandler.instance.SyncLootrunResultsClientRpc(LootrunBase.currentRunSettings, lootrunResults);
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "AutoSaveShipData")]
	internal class AutoSaveShipDataPatch
	{
		[HarmonyPrefix]
		private static bool AutoSaveShipDataHook(StartOfRound __instance)
		{
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0561: Unknown result type (might be due to invalid IL or missing references)
			//IL_0518: Unknown result type (might be due to invalid IL or missing references)
			//IL_051d: Unknown result type (might be due to invalid IL or missing references)
			//IL_058a: Unknown result type (might be due to invalid IL or missing references)
			//IL_059e: Expected I4, but got Unknown
			//IL_045d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Unknown result type (might be due to invalid IL or missing references)
			if (LootrunBase.isInLootrun)
			{
				HUDManager.Instance.saveDataIconAnimatorB.SetTrigger("save");
				LootrunBase.addRunToListAndSave(LootrunBase.currentRunSettings, LootrunBase.currentRunResults);
				if (!NetworkManager.Singleton.IsHost && !NetworkManager.Singleton.IsServer)
				{
					return false;
				}
				LootrunNetworkHandler.instance.ClearInventoryClientRpc();
				List<GrabbableObject> list = Object.FindObjectsOfType<GrabbableObject>().ToList();
				NetworkObject val = default(NetworkObject);
				foreach (GrabbableObject item in list)
				{
					if (((Component)item).TryGetComponent<NetworkObject>(ref val))
					{
						val.Despawn(true);
					}
					if (Object.op_Implicit((Object)(object)((Component)item).gameObject))
					{
						Object.Destroy((Object)(object)((Component)item).gameObject);
					}
				}
				if (StartOfRound.Instance.localPlayerController.twoHanded)
				{
					HUDManager.Instance.PingHUDElement(HUDManager.Instance.Inventory, 1.5f, 1f, 0.13f);
					((Behaviour)HUDManager.Instance.holdingTwoHandedItem).enabled = false;
				}
				for (int i = 0; i < StartOfRound.Instance.localPlayerController.ItemSlots.Length; i++)
				{
					StartOfRound.Instance.localPlayerController.ItemSlots[i] = null;
				}
				for (int j = 0; j < HUDManager.Instance.itemSlotIcons.Length; j++)
				{
					((Behaviour)HUDManager.Instance.itemSlotIcons[j]).enabled = false;
				}
				if ((Object)(object)__instance.attachedVehicle != (Object)null)
				{
					((NetworkBehaviour)__instance.attachedVehicle).NetworkObject.Despawn(true);
					if ((Object)(object)((Component)__instance.attachedVehicle).gameObject != (Object)null)
					{
						Object.Destroy((Object)(object)((Component)__instance.attachedVehicle).gameObject);
					}
				}
				GameObject val2 = null;
				GameObject val3 = null;
				for (int k = 0; k < __instance.allItemsList.itemsList.Count; k++)
				{
					LootrunBase.mls.LogInfo((object)__instance.allItemsList.itemsList[k].itemName);
					if (__instance.allItemsList.itemsList[k].itemName == "Jetpack")
					{
						val2 = __instance.allItemsList.itemsList[k].spawnPrefab;
					}
					if (__instance.allItemsList.itemsList[k].itemName == "Weed killer")
					{
						val3 = __instance.allItemsList.itemsList[k].spawnPrefab;
					}
				}
				if (LootrunBase.currentRunSettings.startJetpack)
				{
					for (int l = 0; l < 4; l++)
					{
						GrabbableObject component = Object.Instantiate<GameObject>(val2, new Vector3(-3.5f, 1f, -14.5f), Quaternion.identity, __instance.elevatorTransform).GetComponent<GrabbableObject>();
						component.fallTime = 1f;
						component.hasHitGround = true;
						component.scrapPersistedThroughRounds = true;
						component.isInElevator = true;
						component.isInShipRoom = true;
						((NetworkBehaviour)component).NetworkObject.Spawn(false);
					}
				}
				GameObject val4 = null;
				for (int m = 0; m < __instance.VehiclesList.Length; m++)
				{
					if (((Object)__instance.VehiclesList[m]).name == "CompanyCruiser")
					{
						val4 = __instance.VehiclesList[m];
					}
				}
				if (LootrunBase.currentRunSettings.startCrusier)
				{
					GameObject val5 = Object.Instantiate<GameObject>(val4, __instance.magnetPoint.position + __instance.magnetPoint.forward * 5f, Quaternion.identity, RoundManager.Instance.VehiclesContainer);
					__instance.attachedVehicle = val5.GetComponent<VehicleController>();
					__instance.isObjectAttachedToMagnet = true;
					((NetworkBehaviour)__instance.attachedVehicle).NetworkObject.Spawn(false);
					__instance.magnetOn = true;
					__instance.magnetLever.initialBoolState = true;
					__instance.magnetLever.setInitialState = true;
					__instance.magnetLever.SetInitialState();
					if (Object.op_Implicit((Object)(object)val3))
					{
						for (int n = 0; n < 2; n++)
						{
							GrabbableObject component2 = Object.Instantiate<GameObject>(val3, new Vector3(10f, 1.5f, -13f), Quaternion.identity, __instance.elevatorTransform).GetComponent<GrabbableObject>();
							component2.fallTime = 1f;
							component2.hasHitGround = true;
							component2.scrapPersistedThroughRounds = true;
							component2.isInElevator = true;
							component2.isInShipRoom = true;
							((NetworkBehaviour)component2).NetworkObject.Spawn(false);
						}
					}
				}
				Terminal val6 = Object.FindObjectOfType<Terminal>();
				val6.groupCredits = LootrunBase.currentRunSettings.money;
				if (LootrunBase.currentRunSettings.weather == -2)
				{
					__instance.currentLevel.currentWeather = __instance.currentLevel.randomWeathers[Random.Range(0, __instance.currentLevel.randomWeathers.Length)].weatherType;
					LootrunBase.mls.LogInfo((object)("w - " + ((object)(LevelWeatherType)(ref __instance.currentLevel.overrideWeatherType)).ToString()));
				}
				else
				{
					__instance.currentLevel.currentWeather = (LevelWeatherType)LootrunBase.currentRunSettings.weather;
				}
				__instance.ChangePlanet();
				__instance.SetMapScreenInfoToCurrentLevel();
				LootrunNetworkHandler.instance.SyncStatsClientRpc(LootrunBase.currentRunSettings.moon, (int)__instance.currentLevel.overrideWeatherType, LootrunBase.currentRunSettings.money);
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Terminal), "LoadNewNodeIfAffordable")]
	internal class TextPostProcessHook
	{
		[HarmonyPrefix]
		private static bool patch(object[] __args, Terminal __instance)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			TerminalNode val = (TerminalNode)__args[0];
			if (val.buyRerouteToMoon != -1 && val.buyRerouteToMoon != -2 && LootrunBase.isInLootrun)
			{
				TerminalNode val2 = new TerminalNode();
				val2.displayText = "You can change planets while on a lootrun!\n";
				val2.clearPreviousText = true;
				val2.playClip = __instance.terminalNodes.specialNodes[24].playClip;
				val2.playSyncedClip = __instance.terminalNodes.specialNodes[24].playSyncedClip;
				__instance.LoadNewNode(val2);
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(TimeOfDay), "SetShipToLeaveOnMidnightClientRpc")]
	internal class SetShipToLeaveOnMidnightClientRpcPatcher
	{
		[HarmonyPrefix]
		private static bool SetShipToLeaveOnMidnightClientRpcPatch()
		{
			if (LootrunBase.isInLootrun)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(TimeOfDay), "UpdateProfitQuotaCurrentTime")]
	internal class UpdateProfitQuotaCurrentTimePatch
	{
		[HarmonyPrefix]
		private static bool UpdateProfitQuotaCurrentTimeHook()
		{
			if (LootrunBase.isInLootrun)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch]
	internal class TimeOfDayUpdatePatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(TimeOfDay), "Update")]
		private static void UpdateHook(TimeOfDay __instance)
		{
			if (__instance.currentDayTimeStarted && LootrunBase.isInLootrun && (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer))
			{
				LootrunBase.LootrunTime += Time.deltaTime;
				((TMP_Text)LootrunBase.timerText).text = LootrunBase.SecsToTimer(LootrunBase.LootrunTime);
				LootrunNetworkHandler.instance.SyncLootrunTimerClientRpc(LootrunBase.LootrunTime);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(TimeOfDay), "Awake")]
		private static void AwakeHook(TimeOfDay __instance)
		{
			if (LootrunBase.isInLootrun && __instance.quotaVariables != null)
			{
				__instance.quotaVariables.startingCredits = LootrunBase.currentRunSettings.money;
			}
		}
	}
}
namespace Lootrun.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}