Decompiled source of Lootrun v2.0.0

Lootrun.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Threading;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Lootrun;
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+0775d71a93a46775e9bbc4c3a469dc3637a608e0")]
[assembly: AssemblyProduct("Lootrun")]
[assembly: AssemblyTitle("Lootrun")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: NetcodePatchedAssembly]
public class LootrunItemCell : MonoBehaviour
{
	public LootrunItemQuantity itemData = new LootrunItemQuantity();

	[CompilerGenerated]
	[DebuggerBrowsable(DebuggerBrowsableState.Never)]
	private UnityAction<LootrunItemCell> m_onCellDelete;

	[CompilerGenerated]
	[DebuggerBrowsable(DebuggerBrowsableState.Never)]
	private UnityAction<LootrunItemCell> m_onCellChanged;

	[CompilerGenerated]
	[DebuggerBrowsable(DebuggerBrowsableState.Never)]
	private UnityAction<LootrunItemCell> m_onSelectClicked;

	[SerializeField]
	private TextMeshProUGUI amountText;

	[SerializeField]
	private TextMeshProUGUI nameText;

	[SerializeField]
	private Image itemIcon;

	[SerializeField]
	private List<GameObject> selectMode;

	[SerializeField]
	private List<GameObject> countMode;

	public event UnityAction<LootrunItemCell> onCellDelete
	{
		[CompilerGenerated]
		add
		{
			UnityAction<LootrunItemCell> val = this.m_onCellDelete;
			UnityAction<LootrunItemCell> val2;
			do
			{
				val2 = val;
				UnityAction<LootrunItemCell> value2 = (UnityAction<LootrunItemCell>)(object)Delegate.Combine((Delegate?)(object)val2, (Delegate?)(object)value);
				val = Interlocked.CompareExchange(ref this.m_onCellDelete, value2, val2);
			}
			while (val != val2);
		}
		[CompilerGenerated]
		remove
		{
			UnityAction<LootrunItemCell> val = this.m_onCellDelete;
			UnityAction<LootrunItemCell> val2;
			do
			{
				val2 = val;
				UnityAction<LootrunItemCell> value2 = (UnityAction<LootrunItemCell>)(object)Delegate.Remove((Delegate?)(object)val2, (Delegate?)(object)value);
				val = Interlocked.CompareExchange(ref this.m_onCellDelete, value2, val2);
			}
			while (val != val2);
		}
	}

	public event UnityAction<LootrunItemCell> onCellChanged
	{
		[CompilerGenerated]
		add
		{
			UnityAction<LootrunItemCell> val = this.m_onCellChanged;
			UnityAction<LootrunItemCell> val2;
			do
			{
				val2 = val;
				UnityAction<LootrunItemCell> value2 = (UnityAction<LootrunItemCell>)(object)Delegate.Combine((Delegate?)(object)val2, (Delegate?)(object)value);
				val = Interlocked.CompareExchange(ref this.m_onCellChanged, value2, val2);
			}
			while (val != val2);
		}
		[CompilerGenerated]
		remove
		{
			UnityAction<LootrunItemCell> val = this.m_onCellChanged;
			UnityAction<LootrunItemCell> val2;
			do
			{
				val2 = val;
				UnityAction<LootrunItemCell> value2 = (UnityAction<LootrunItemCell>)(object)Delegate.Remove((Delegate?)(object)val2, (Delegate?)(object)value);
				val = Interlocked.CompareExchange(ref this.m_onCellChanged, value2, val2);
			}
			while (val != val2);
		}
	}

	public event UnityAction<LootrunItemCell> onSelectClicked
	{
		[CompilerGenerated]
		add
		{
			UnityAction<LootrunItemCell> val = this.m_onSelectClicked;
			UnityAction<LootrunItemCell> val2;
			do
			{
				val2 = val;
				UnityAction<LootrunItemCell> value2 = (UnityAction<LootrunItemCell>)(object)Delegate.Combine((Delegate?)(object)val2, (Delegate?)(object)value);
				val = Interlocked.CompareExchange(ref this.m_onSelectClicked, value2, val2);
			}
			while (val != val2);
		}
		[CompilerGenerated]
		remove
		{
			UnityAction<LootrunItemCell> val = this.m_onSelectClicked;
			UnityAction<LootrunItemCell> val2;
			do
			{
				val2 = val;
				UnityAction<LootrunItemCell> value2 = (UnityAction<LootrunItemCell>)(object)Delegate.Remove((Delegate?)(object)val2, (Delegate?)(object)value);
				val = Interlocked.CompareExchange(ref this.m_onSelectClicked, value2, val2);
			}
			while (val != val2);
		}
	}

	public void Setup(Item item, int quantity, bool selectMode = false)
	{
		if (!((Object)(object)item == (Object)null))
		{
			itemData.itemName = item.itemName;
			itemData.quantity = quantity;
			((TMP_Text)nameText).text = item.itemName;
			itemIcon.sprite = item.itemIcon;
			((TMP_Text)amountText).text = itemData.quantity.ToString();
			List<GameObject> list = ((!selectMode) ? this.selectMode : countMode);
			List<GameObject> list2 = (selectMode ? this.selectMode : countMode);
			list.ForEach(delegate(GameObject x)
			{
				x.SetActive(false);
			});
			list2.ForEach(delegate(GameObject x)
			{
				x.SetActive(true);
			});
		}
	}

	public void DisableAll()
	{
		selectMode.ForEach(delegate(GameObject x)
		{
			x.SetActive(false);
		});
		countMode.ForEach(delegate(GameObject x)
		{
			x.SetActive(false);
		});
	}

	public void OnMinusClicked()
	{
		itemData.quantity--;
		if (itemData.quantity < 0)
		{
			itemData.quantity = 0;
		}
		((TMP_Text)amountText).text = itemData.quantity.ToString();
		this.onCellChanged?.Invoke(this);
	}

	public void OnPlusClicked()
	{
		itemData.quantity++;
		if (itemData.quantity > 10)
		{
			itemData.quantity = 10;
		}
		((TMP_Text)amountText).text = itemData.quantity.ToString();
		this.onCellChanged?.Invoke(this);
	}

	public void OnCellDelete()
	{
		this.onCellDelete?.Invoke(this);
	}

	public void OnCellSelected()
	{
		this.onSelectClicked?.Invoke(this);
	}
}
public class LootrunRunCell : MonoBehaviour
{
	[SerializeField]
	private TextMeshProUGUI playersLabel;

	[SerializeField]
	private TextMeshProUGUI scrapCollectedLabel;

	[SerializeField]
	private TextMeshProUGUI timeSpentLabel;

	[Space]
	[SerializeField]
	private TextMeshProUGUI moonLabel;

	[SerializeField]
	private TextMeshProUGUI weatherLabel;

	[Space]
	[SerializeField]
	private TextMeshProUGUI beesLabel;

	[SerializeField]
	private TextMeshProUGUI specialsLabel;

	[SerializeField]
	private TextMeshProUGUI isEndlessLabel;

	[SerializeField]
	private TextMeshProUGUI cruiserLabel;

	[Space]
	[SerializeField]
	private TextMeshProUGUI moneyLabel;

	[SerializeField]
	private TextMeshProUGUI seedLabel;

	[Space]
	[SerializeField]
	private Transform itemsContent;

	[SerializeField]
	private GameObject itemPrefab;

	private LootrunResults myResults = null;

	private LootrunSettingsMenu settingsMenu = null;

	[CompilerGenerated]
	[DebuggerBrowsable(DebuggerBrowsableState.Never)]
	private UnityAction<LootrunPreset> m_OnUseCallback;

	public event UnityAction<LootrunPreset> OnUseCallback
	{
		[CompilerGenerated]
		add
		{
			UnityAction<LootrunPreset> val = this.m_OnUseCallback;
			UnityAction<LootrunPreset> val2;
			do
			{
				val2 = val;
				UnityAction<LootrunPreset> value2 = (UnityAction<LootrunPreset>)(object)Delegate.Combine((Delegate?)(object)val2, (Delegate?)(object)value);
				val = Interlocked.CompareExchange(ref this.m_OnUseCallback, value2, val2);
			}
			while (val != val2);
		}
		[CompilerGenerated]
		remove
		{
			UnityAction<LootrunPreset> val = this.m_OnUseCallback;
			UnityAction<LootrunPreset> val2;
			do
			{
				val2 = val;
				UnityAction<LootrunPreset> value2 = (UnityAction<LootrunPreset>)(object)Delegate.Remove((Delegate?)(object)val2, (Delegate?)(object)value);
				val = Interlocked.CompareExchange(ref this.m_OnUseCallback, value2, val2);
			}
			while (val != val2);
		}
	}

	public void SetSettingsMenuRef(LootrunSettingsMenu menu)
	{
		settingsMenu = menu;
	}

	public void Setup(LootrunResults lootrunResults)
	{
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0197: 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_0225: Expected O, but got Unknown
		((TMP_Text)playersLabel).text = "Players: " + string.Join(", ", lootrunResults.players);
		float num = (float)((Vector2Int)(ref lootrunResults.scrapCollectedOutOf)).x / (float)((Vector2Int)(ref lootrunResults.scrapCollectedOutOf)).y * 100f;
		((TMP_Text)scrapCollectedLabel).text = $"Scrap Collected: {((Vector2Int)(ref lootrunResults.scrapCollectedOutOf)).x}/{((Vector2Int)(ref lootrunResults.scrapCollectedOutOf)).y} ({num}%)";
		((TMP_Text)timeSpentLabel).text = "Time Spent: " + LootrunBase.SecsToTimer(lootrunResults.time);
		((TMP_Text)moonLabel).text = "Moon: " + LootrunBase.MoonIDToName(lootrunResults.presetUsed.moon);
		((TMP_Text)weatherLabel).text = "Weather: " + ((lootrunResults.presetUsed.weatherType == -2) ? "Random" : Enum.GetName(typeof(LevelWeatherType), (object)(LevelWeatherType)lootrunResults.presetUsed.weatherType));
		((Graphic)beesLabel).color = (lootrunResults.presetUsed.countBees ? Color.green : Color.gray);
		((Graphic)specialsLabel).color = (lootrunResults.presetUsed.countSpecials ? Color.green : Color.gray);
		((Graphic)isEndlessLabel).color = (lootrunResults.presetUsed.isEndless ? Color.green : Color.gray);
		((Graphic)cruiserLabel).color = (lootrunResults.presetUsed.cruiserOnStart ? Color.green : Color.gray);
		((TMP_Text)moneyLabel).text = $"Money: {lootrunResults.presetUsed.money}";
		((TMP_Text)seedLabel).text = "Seed: " + ((lootrunResults.presetUsed.seed == -1) ? "Random" : lootrunResults.presetUsed.seed.ToString());
		foreach (Transform item in itemsContent)
		{
			Transform val = item;
			Object.Destroy((Object)(object)((Component)val).gameObject);
		}
		if ((Object)(object)settingsMenu != (Object)null)
		{
			foreach (LootrunItemQuantity item2 in lootrunResults.presetUsed.items)
			{
				if (settingsMenu.allItems.ContainsKey(item2.itemName))
				{
					GameObject val2 = Object.Instantiate<GameObject>(itemPrefab, itemsContent);
					LootrunItemCell component = val2.GetComponent<LootrunItemCell>();
					component.Setup(settingsMenu.allItems[item2.itemName], item2.quantity, selectMode: true);
					component.DisableAll();
				}
			}
		}
		myResults = lootrunResults;
	}

	public void OnUse()
	{
		if (myResults != null)
		{
			this.OnUseCallback?.Invoke(myResults.presetUsed);
		}
	}
}
public class LootrunSettingsMenu : MonoBehaviour
{
	private LootrunPreset myPreset = new LootrunPreset();

	[CompilerGenerated]
	[DebuggerBrowsable(DebuggerBrowsableState.Never)]
	private UnityAction<LootrunPreset> m_onPresetChanged;

	public Dictionary<string, Item> allItems = new Dictionary<string, Item>();

	[SerializeField]
	private TMP_Dropdown moonsDropdown;

	[SerializeField]
	private TMP_Dropdown weatherDropdown;

	[SerializeField]
	private Toggle beesToggle;

	[SerializeField]
	private Toggle specialsToggle;

	[SerializeField]
	private Toggle randomSeedToggle;

	[SerializeField]
	private Toggle endlessToggle;

	[SerializeField]
	private Toggle cruiserOnStartToggle;

	[SerializeField]
	private TMP_InputField seedInput;

	[SerializeField]
	private TMP_InputField moneyInput;

	[SerializeField]
	private CanvasGroup seedCG;

	[Space]
	[SerializeField]
	private GameObject itemCellPrefab;

	[SerializeField]
	private Transform itemsHolder;

	public GameObject itemSelectMenu;

	[SerializeField]
	private Transform itemSelectMenuParent;

	private List<string> weathersInOrder = new List<string>();

	[Space]
	public GameObject oldRunsPage;

	[SerializeField]
	private Transform runCellsContainer;

	[SerializeField]
	private GameObject runCellPrefab;

	public event UnityAction<LootrunPreset> onPresetChanged
	{
		[CompilerGenerated]
		add
		{
			UnityAction<LootrunPreset> val = this.m_onPresetChanged;
			UnityAction<LootrunPreset> val2;
			do
			{
				val2 = val;
				UnityAction<LootrunPreset> value2 = (UnityAction<LootrunPreset>)(object)Delegate.Combine((Delegate?)(object)val2, (Delegate?)(object)value);
				val = Interlocked.CompareExchange(ref this.m_onPresetChanged, value2, val2);
			}
			while (val != val2);
		}
		[CompilerGenerated]
		remove
		{
			UnityAction<LootrunPreset> val = this.m_onPresetChanged;
			UnityAction<LootrunPreset> val2;
			do
			{
				val2 = val;
				UnityAction<LootrunPreset> value2 = (UnityAction<LootrunPreset>)(object)Delegate.Remove((Delegate?)(object)val2, (Delegate?)(object)value);
				val = Interlocked.CompareExchange(ref this.m_onPresetChanged, value2, val2);
			}
			while (val != val2);
		}
	}

	private void Start()
	{
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Expected O, but got Unknown
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Expected O, but got Unknown
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Expected O, but got Unknown
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Expected O, but got Unknown
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Expected O, but got Unknown
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Expected O, but got Unknown
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Expected O, but got Unknown
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Expected O, but got Unknown
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Expected O, but got Unknown
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Expected O, but got Unknown
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Expected O, but got Unknown
		string[] names = Enum.GetNames(typeof(LevelWeatherType));
		string[] array = names;
		foreach (string item in array)
		{
			weathersInOrder.Add(item);
		}
		UpdateWeathersOnList();
		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);
		moonsDropdown.RefreshShownValue();
		GrabbableObject[] array2 = Resources.FindObjectsOfTypeAll<GrabbableObject>();
		GrabbableObject[] array3 = array2;
		foreach (GrabbableObject val in array3)
		{
			if (!allItems.ContainsKey(val.itemProperties.itemName))
			{
				allItems.Add(val.itemProperties.itemName, val.itemProperties);
				GameObject val2 = Object.Instantiate<GameObject>(itemCellPrefab, itemSelectMenuParent);
				LootrunItemCell component = val2.GetComponent<LootrunItemCell>();
				component.Setup(val.itemProperties, 1, selectMode: true);
				component.onSelectClicked += OnCellSelected;
			}
		}
		string path = Application.persistentDataPath + "/Lootruns";
		if (Directory.Exists(path))
		{
			string[] files = Directory.GetFiles(path);
			string[] array4 = files;
			foreach (string path2 in array4)
			{
				try
				{
					LootrunResults lootrunResults = ES3.Load<LootrunResults>("Lootrun", Path.GetFullPath(path2));
					if (lootrunResults != null)
					{
						GameObject val3 = Object.Instantiate<GameObject>(runCellPrefab, runCellsContainer);
						LootrunRunCell component2 = val3.GetComponent<LootrunRunCell>();
						component2.SetSettingsMenuRef(this);
						component2.Setup(lootrunResults);
						component2.OnUseCallback += delegate(LootrunPreset preset)
						{
							SetToPreset(preset);
							oldRunsPage.SetActive(false);
						};
					}
				}
				catch (Exception)
				{
				}
			}
		}
		SetToPreset(myPreset);
	}

	public void AddItemCell(Item item, int quantity = 1)
	{
		GameObject val = Object.Instantiate<GameObject>(itemCellPrefab, itemsHolder);
		LootrunItemCell component = val.GetComponent<LootrunItemCell>();
		component.Setup(item, quantity);
		component.onCellChanged += OnItemCellChanged;
		component.onCellDelete += OnItemCellDeleted;
	}

	public void SetToPreset(LootrunPreset lootrunPreset)
	{
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Expected O, but got Unknown
		myPreset = lootrunPreset;
		weatherDropdown.value = ((myPreset.weatherType != -2) ? (myPreset.weatherType + 1) : 0);
		weatherDropdown.RefreshShownValue();
		string text = LootrunBase.MoonIDToName(myPreset.moon);
		for (int i = 0; i < moonsDropdown.options.Count; i++)
		{
			if (moonsDropdown.options[i].text == text)
			{
				moonsDropdown.value = i;
			}
		}
		moonsDropdown.RefreshShownValue();
		beesToggle.isOn = myPreset.countBees;
		specialsToggle.isOn = myPreset.countSpecials;
		randomSeedToggle.isOn = myPreset.seed != -1;
		endlessToggle.isOn = myPreset.isEndless;
		cruiserOnStartToggle.isOn = myPreset.cruiserOnStart;
		seedInput.text = ((myPreset.seed == -1) ? string.Empty : myPreset.seed.ToString());
		moneyInput.text = myPreset.money.ToString();
		foreach (Transform item in itemsHolder)
		{
			Transform val = item;
			Object.Destroy((Object)(object)((Component)val).gameObject);
		}
		foreach (LootrunItemQuantity item2 in myPreset.items)
		{
			if (allItems.ContainsKey(item2.itemName))
			{
				AddItemCell(allItems[item2.itemName], item2.quantity);
			}
		}
		UpdateSeedInputVisibility();
		SendChanges();
	}

	private void UpdateWeathersOnList()
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Expected O, but got Unknown
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Expected O, but got Unknown
		weatherDropdown.ClearOptions();
		List<OptionData> list = new List<OptionData>();
		list.Add(new OptionData("Random"));
		List<LevelWeatherType> list2 = LootrunBase.MoonAvalableWeathers(myPreset.moon);
		foreach (string item in weathersInOrder)
		{
			if (Enum.TryParse<LevelWeatherType>(item, out LevelWeatherType result) && list2.Contains(result))
			{
				list.Add(new OptionData(item));
			}
		}
		weatherDropdown.AddOptions(list);
		weatherDropdown.RefreshShownValue();
	}

	private void OnItemCellChanged(LootrunItemCell cell)
	{
		for (int i = 0; i < myPreset.items.Count; i++)
		{
			if (myPreset.items[i].itemName == cell.itemData.itemName)
			{
				myPreset.items[i] = cell.itemData;
			}
		}
	}

	private void OnItemCellDeleted(LootrunItemCell cell)
	{
		myPreset.items.RemoveAll((LootrunItemQuantity x) => x.itemName == cell.itemData.itemName);
		Object.Destroy((Object)(object)((Component)cell).gameObject);
	}

	private void UpdateSeedInputVisibility()
	{
		seedCG.alpha = ((myPreset.seed == -1) ? 0.2f : 1f);
		seedCG.interactable = myPreset.seed != -1;
	}

	private void SendChanges()
	{
		this.onPresetChanged?.Invoke(myPreset);
	}

	public void OnMoonChanged(int newMoon)
	{
		int moon = LootrunBase.MoonNameToID(moonsDropdown.options[newMoon].text);
		myPreset.moon = moon;
		UpdateWeathersOnList();
		SendChanges();
	}

	public void OnWeatherChanged(int newWeather)
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Expected I4, but got Unknown
		if (!Enum.TryParse<LevelWeatherType>(weatherDropdown.options[newWeather].text, out LevelWeatherType result))
		{
			myPreset.weatherType = -2;
		}
		else
		{
			myPreset.weatherType = (int)result;
		}
		SendChanges();
	}

	public void OnBeesChanged(bool bees)
	{
		myPreset.countBees = bees;
		SendChanges();
	}

	public void OnCruiserOnStartChanged(bool cruiserOnStart)
	{
		myPreset.cruiserOnStart = cruiserOnStart;
		SendChanges();
	}

	public void OnSpecialsChanged(bool specials)
	{
		myPreset.countSpecials = specials;
		SendChanges();
	}

	public void OnEndlessChanged(bool endless)
	{
		myPreset.isEndless = endless;
		UpdateSeedInputVisibility();
		SendChanges();
	}

	public void OnRandomSeedChanged(bool rs)
	{
		myPreset.seed = (rs ? (-1) : 0);
		seedInput.text = "0";
		UpdateSeedInputVisibility();
		SendChanges();
	}

	public void OnSeedInputChanged(string newSeed)
	{
		if (int.TryParse(newSeed, out var result))
		{
			myPreset.seed = result;
			UpdateSeedInputVisibility();
			SendChanges();
		}
	}

	public void OnMoneyInputChanged(string newMoney)
	{
		if (int.TryParse(newMoney, out var result))
		{
			myPreset.money = result;
			SendChanges();
		}
	}

	public void OnAddNewItembtn()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Expected O, but got Unknown
		itemSelectMenu.SetActive(true);
		foreach (Transform item in itemSelectMenuParent)
		{
			Transform val = item;
			LootrunItemCell cell = ((Component)val).GetComponent<LootrunItemCell>();
			int num = myPreset.items.FindIndex((LootrunItemQuantity x) => x.itemName == cell.itemData.itemName);
			if (num != -1)
			{
				((Component)cell).gameObject.SetActive(false);
			}
			else
			{
				((Component)cell).gameObject.SetActive(true);
			}
		}
	}

	private void OnCellSelected(LootrunItemCell cell)
	{
		itemSelectMenu.SetActive(false);
		myPreset.items.Add(cell.itemData);
		AddItemCell(allItems[cell.itemData.itemName], cell.itemData.quantity);
		SendChanges();
	}

	public void OnSelectionExitClicked()
	{
		itemSelectMenu.SetActive(false);
	}

	public void OnOldRunsClicked()
	{
		oldRunsPage.SetActive(true);
	}

	public void OnOldRunsExitClicked()
	{
		oldRunsPage.SetActive(false);
	}
}
namespace Lootrun
{
	[HarmonyPatch(typeof(HUDManager), "FillEndGameStats")]
	internal class FillEndGameStatsPatch
	{
		private static GameObject scrapTextObject;

		[HarmonyPostfix]
		private static void FillEndGameStatsHook(HUDManager __instance)
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			if (LootrunBase.isInLootrun)
			{
				if ((Object)(object)scrapTextObject != (Object)null)
				{
					Object.Destroy((Object)(object)scrapTextObject);
				}
				scrapTextObject = Object.Instantiate<GameObject>(((Component)__instance.statsUIElements.quotaNumerator).gameObject, ((TMP_Text)__instance.statsUIElements.quotaNumerator).transform.parent);
				((TMP_Text)scrapTextObject.GetComponent<TextMeshProUGUI>()).alignment = (TextAlignmentOptions)513;
				scrapTextObject.GetComponent<RectTransform>().anchoredPosition = new Vector2(52.5f, -165f);
				((Object)scrapTextObject).name = "Scrap Collected Text";
				float num = (float)((Vector2Int)(ref LootrunBase.currentRunResult.scrapCollectedOutOf)).x / (float)((Vector2Int)(ref LootrunBase.currentRunResult.scrapCollectedOutOf)).y * 100f;
				((TMP_Text)__instance.statsUIElements.quotaNumerator).text = LootrunBase.SecsToTimer(LootrunBase.LootrunTime);
				((TMP_Text)__instance.statsUIElements.quotaDenominator).text = $"{((Vector2Int)(ref LootrunBase.currentRunResult.scrapCollectedOutOf)).x}/{((Vector2Int)(ref LootrunBase.currentRunResult.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)
		{
			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)
			{
				return;
			}
			LootrunBase.CurrentRoundBees.Clear();
			LootrunBase.CurrentRoundSpecials.Clear();
			LootrunBase.LootrunTime = 0f;
			LootrunBase.playersThisRound.Clear();
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (!((Object)(object)val == (Object)null) && !val.playerUsername.Any(char.IsDigit))
				{
					LootrunBase.playersThisRound.Add(val.playerUsername);
				}
			}
		}
	}
	[BepInPlugin("abb2k.Lootrun", "Lootrun", "1.2.0.0")]
	public class LootrunBase : BaseUnityPlugin
	{
		public const string GUID = "abb2k.Lootrun";

		public const string modName = "Lootrun";

		public const string modVersion = "1.2.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 LootrunPreset currentRunSettings = new LootrunPreset();

		public static LootrunResults currentRunResult = new LootrunResults();

		public static bool isInLootrun;

		public static float LootrunTime;

		public static List<string> playersThisRound = new List<string>();

		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>();

		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));
			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 SaveResults(LootrunResults res)
		{
			string text = Application.persistentDataPath + "/Lootruns";
			if (!Directory.Exists(text))
			{
				Directory.CreateDirectory(text);
			}
			int num = 0;
			string text2 = text + "/" + DateTime.Now.ToString().Replace('/', '_').Replace(':', '-');
			string text3 = text2;
			while (File.Exists(text3))
			{
				num++;
				text3 = text2 + $" ({num})";
			}
			text2 = text3;
			ES3.Save<LootrunResults>("Lootrun", res, text2);
		}
	}
}
namespace Lootrun.types
{
	public class LootrunItemQuantity : INetworkSerializable
	{
		[SerializeField]
		public string itemName = string.Empty;

		[SerializeField]
		public int quantity;

		public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			serializer.SerializeValue(ref itemName, false);
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref quantity, default(ForPrimitives));
		}
	}
	public class LootrunPreset : INetworkSerializable
	{
		[SerializeField]
		public string presetName = string.Empty;

		[SerializeField]
		public List<LootrunItemQuantity> items = new List<LootrunItemQuantity>();

		[SerializeField]
		public int moon;

		[SerializeField]
		public int weatherType = -2;

		[SerializeField]
		public bool countBees = true;

		[SerializeField]
		public bool cruiserOnStart;

		[SerializeField]
		public bool countSpecials;

		[SerializeField]
		public bool isEndless = true;

		[SerializeField]
		public int seed = -1;

		[SerializeField]
		public int money = 0;

		public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: 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_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			serializer.SerializeValue(ref presetName, false);
			int num = ((items != null) ? items.Count : 0);
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref num, default(ForPrimitives));
			if (serializer.IsReader)
			{
				items = new List<LootrunItemQuantity>(num);
				for (int i = 0; i < num; i++)
				{
					LootrunItemQuantity item = new LootrunItemQuantity();
					((BufferSerializer<LootrunItemQuantity>*)(&serializer))->SerializeValue<LootrunItemQuantity>(ref item, default(ForNetworkSerializable));
					items.Add(item);
				}
			}
			else
			{
				for (int j = 0; j < num && items.Count != j; j++)
				{
					LootrunItemQuantity lootrunItemQuantity = items[j];
					if (lootrunItemQuantity != null)
					{
						((BufferSerializer<LootrunItemQuantity>*)(&serializer))->SerializeValue<LootrunItemQuantity>(ref lootrunItemQuantity, default(ForNetworkSerializable));
					}
				}
			}
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref moon, default(ForPrimitives));
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref weatherType, default(ForPrimitives));
			((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref countBees, default(ForPrimitives));
			((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref cruiserOnStart, default(ForPrimitives));
			((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref countSpecials, default(ForPrimitives));
			((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref isEndless, default(ForPrimitives));
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref seed, default(ForPrimitives));
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref money, default(ForPrimitives));
		}
	}
	public class LootrunResults : INetworkSerializable
	{
		[SerializeField]
		public List<string> players = new List<string>();

		[SerializeField]
		public float time;

		[SerializeField]
		public Vector2Int scrapCollectedOutOf;

		[SerializeField]
		public LootrunPreset presetUsed = new LootrunPreset();

		public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			int num = ((players != null) ? players.Count : 0);
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref num, default(ForPrimitives));
			if (serializer.IsReader)
			{
				players = new List<string>(num);
				for (int i = 0; i < num; i++)
				{
					string empty = string.Empty;
					serializer.SerializeValue(ref empty, false);
					players.Add(empty);
				}
			}
			else
			{
				for (int j = 0; j < num; j++)
				{
					string text = players[j];
					serializer.SerializeValue(ref text, false);
				}
			}
			((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref time, default(ForPrimitives));
			serializer.SerializeValue(ref scrapCollectedOutOf);
			((BufferSerializer<LootrunPreset>*)(&serializer))->SerializeValue<LootrunPreset>(ref presetUsed, default(ForNetworkSerializable));
		}
	}
	[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");
				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_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: 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 != 1 && (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 != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			base.__rpc_exec_stage = (__RpcExecStage)0;
			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);
				if (!LootrunBase.currentRunSettings.isEndless)
				{
					val3.SetActive(false);
				}
				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)
			//IL_00dc: 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 != 1 && (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 == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				if (!NetworkManager.Singleton.IsHost && !NetworkManager.Singleton.IsServer)
				{
					LootrunBase.LootrunTime = time;
					((TMP_Text)LootrunBase.timerText).text = LootrunBase.SecsToTimer(LootrunBase.LootrunTime);
				}
			}
		}

		[ClientRpc]
		public void SyncLootrunResultsClientRpc(LootrunPreset 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_0157: 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 != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(38266704u, val, (RpcDelivery)0);
				bool flag = s != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<LootrunPreset>(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, 38266704u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				if (!NetworkManager.Singleton.IsHost && !NetworkManager.Singleton.IsServer)
				{
					LootrunBase.currentRunSettings = s;
					LootrunBase.currentRunResult = 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_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: 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 != 1 && (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 == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				if (!NetworkManager.Singleton.IsHost && !NetworkManager.Singleton.IsServer)
				{
					StartOfRound.Instance.ChangeLevel(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)
			//IL_00c1: 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 != 1 && (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 == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				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.currentWeather, LootrunBase.currentRunSettings.money);
				}
			}
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(2684428673u, new RpcReceiveHandler(__rpc_handler_2684428673), "SyncInLootrunClientRpc");
			((NetworkBehaviour)this).__registerRpc(1144487935u, new RpcReceiveHandler(__rpc_handler_1144487935), "SyncLootrunTimerClientRpc");
			((NetworkBehaviour)this).__registerRpc(38266704u, new RpcReceiveHandler(__rpc_handler_38266704), "SyncLootrunResultsClientRpc");
			((NetworkBehaviour)this).__registerRpc(3633830683u, new RpcReceiveHandler(__rpc_handler_3633830683), "SyncStatsClientRpc");
			((NetworkBehaviour)this).__registerRpc(176124722u, new RpcReceiveHandler(__rpc_handler_176124722), "ClearInventoryClientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		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)1;
				((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)1;
				((LootrunNetworkHandler)(object)target).SyncLootrunTimerClientRpc(time);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_38266704(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));
				LootrunPreset s = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<LootrunPreset>(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)1;
				((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)1;
				((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)1;
				((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<LootrunPreset> <>9__2_0;

			public static UnityAction <>9__2_1;

			public static UnityAction <>9__2_3;

			public static UnityAction <>9__2_4;

			internal void <StartHook>b__2_0(LootrunPreset preset)
			{
				LootrunBase.currentRunSettings = preset;
			}

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

			internal void <StartHook>b__2_3()
			{
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Expected O, but got Unknown
				speedlootMenuContainer.SetActive(false);
				LootrunBase.isInLootrun = true;
				GameNetworkManager.Instance.currentSaveFileName = "Speedloot";
				GameNetworkManager.Instance.lobbyHostSettings = new HostSettings("LootrunLobby", false, "");
				GameNetworkManager.Instance.StartHost();
			}

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

		public static GameObject speedlootMenuContainer;

		public static GameObject speedlootButton;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartHook(ref GameObject ___menuButtons, ref GameObject ___HostSettingsScreen)
		{
			//IL_007f: 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_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Expected O, but got Unknown
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//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_01e9: Expected O, but got Unknown
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Expected O, but got Unknown
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Expected O, but got Unknown
			if ((Object)(object)___menuButtons == (Object)null || (Object)(object)___menuButtons.transform.GetChild(1) == (Object)null)
			{
				return;
			}
			speedlootButton = Object.Instantiate<GameObject>(((Component)___menuButtons.transform.GetChild(1)).gameObject, ___menuButtons.transform);
			((Object)speedlootButton).name = "LootrunButton";
			speedlootButton.GetComponent<RectTransform>().anchoredPosition = new Vector2(speedlootButton.GetComponent<RectTransform>().anchoredPosition.x, 235f);
			Button component = speedlootButton.GetComponent<Button>();
			((UnityEventBase)component.onClick).RemoveAllListeners();
			TextMeshProUGUI component2 = ((Component)speedlootButton.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);
			LootrunSettingsMenu settingsMenu = speedlootMenuContainer.GetComponent<LootrunSettingsMenu>();
			settingsMenu.SetToPreset(LootrunBase.currentRunSettings);
			settingsMenu.onPresetChanged += delegate(LootrunPreset preset)
			{
				LootrunBase.currentRunSettings = preset;
			};
			Transform transform = speedlootMenuContainer.transform;
			Vector2 size = new Vector2(120f, 30f);
			object obj = <>c.<>9__2_1;
			if (obj == null)
			{
				UnityAction val = delegate
				{
					speedlootMenuContainer.SetActive(false);
				};
				<>c.<>9__2_1 = val;
				obj = (object)val;
			}
			GameObject val2 = CopyCoolButton("speedlootBack", transform, size, "[ Back ]", (UnityAction)obj);
			val2.transform.localPosition = new Vector3(175f, -115f, 0f);
			GameObject val3 = CopyCoolButton("speedlootOldRuns", speedlootMenuContainer.transform, new Vector2(130f, 30f), "[ Runs ]", (UnityAction)delegate
			{
				settingsMenu.OnOldRunsClicked();
			});
			val3.transform.localPosition = new Vector3(175f, -70f, 0f);
			Transform transform2 = speedlootMenuContainer.transform;
			Vector2 size2 = new Vector2(130f, 30f);
			object obj2 = <>c.<>9__2_3;
			if (obj2 == null)
			{
				UnityAction val4 = delegate
				{
					//IL_0032: Unknown result type (might be due to invalid IL or missing references)
					//IL_003c: Expected O, but got Unknown
					speedlootMenuContainer.SetActive(false);
					LootrunBase.isInLootrun = true;
					GameNetworkManager.Instance.currentSaveFileName = "Speedloot";
					GameNetworkManager.Instance.lobbyHostSettings = new HostSettings("LootrunLobby", false, "");
					GameNetworkManager.Instance.StartHost();
				};
				<>c.<>9__2_3 = val4;
				obj2 = (object)val4;
			}
			GameObject val5 = CopyCoolButton("speedlootStart", transform2, size2, "[ Start ]", (UnityAction)obj2);
			val5.transform.localPosition = new Vector3(175f, -22f, 0f);
			ButtonClickedEvent onClick = component.onClick;
			object obj3 = <>c.<>9__2_4;
			if (obj3 == null)
			{
				UnityAction val6 = delegate
				{
					speedlootMenuContainer.SetActive(true);
				};
				<>c.<>9__2_4 = val6;
				obj3 = (object)val6;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj3);
			settingsMenu.itemSelectMenu.transform.SetAsLastSibling();
			settingsMenu.oldRunsPage.transform.SetAsLastSibling();
		}

		private static GameObject CopyCoolButton(string objectName, Transform parent, Vector2 size, string btnText, UnityAction callback)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(speedlootButton, parent);
			((Object)val).name = objectName;
			val.GetComponent<RectTransform>().sizeDelta = size;
			((Component)val.transform.GetChild(0)).GetComponent<RectTransform>().sizeDelta = size - Vector2.up * 5f;
			val.transform.GetChild(0).localPosition = Vector3.zero;
			Button component = val.GetComponent<Button>();
			((UnityEventBase)component.onClick).RemoveAllListeners();
			((UnityEvent)component.onClick).AddListener(callback);
			TextMeshProUGUI component2 = ((Component)val.transform.GetChild(1)).GetComponent<TextMeshProUGUI>();
			((TMP_Text)component2).transform.localPosition = Vector3.zero;
			((TMP_Text)component2).alignment = (TextAlignmentOptions)514;
			((TMP_Text)component2).text = btnText;
			return val;
		}
	}
	[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_00a2: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Expected I4, but got Unknown
			if (LootrunBase.isInLootrun && (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer))
			{
				__instance.ChangeLevel(LootrunBase.currentRunSettings.moon);
				if (LootrunBase.currentRunSettings.weatherType == -2)
				{
					int num = Random.Range(0, __instance.currentLevel.randomWeathers.Length);
					__instance.currentLevel.currentWeather = __instance.currentLevel.randomWeathers[num].weatherType;
				}
				else
				{
					__instance.currentLevel.currentWeather = (LevelWeatherType)LootrunBase.currentRunSettings.weatherType;
				}
				TimeOfDay val = Object.FindObjectOfType<TimeOfDay>();
				val.quotaFulfilled = 0;
				val.timesFulfilledQuota = 0;
				val.UpdateProfitQuotaCurrentTime();
				__instance.ChangePlanet();
				__instance.SetMapScreenInfoToCurrentLevel();
				__instance.overrideRandomSeed = LootrunBase.currentRunSettings.seed != -1;
				__instance.overrideSeedNumber = LootrunBase.currentRunSettings.seed;
				SelectableLevel[] levels = __instance.levels;
				foreach (SelectableLevel val2 in levels)
				{
					LootrunBase.mls.LogInfo((object)$"{val2.PlanetName} - {val2.levelID}");
				}
				((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.currentWeather, LootrunBase.currentRunSettings.money);
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "LoadShipGrabbableItems")]
	internal class LoadShipGrabbableItemsPatch
	{
		[HarmonyPostfix]
		private static void LoadShipGrabbableItemsHook(StartOfRound __instance)
		{
			if (LootrunBase.isInLootrun && (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer))
			{
				SpawnStartItems(__instance);
			}
		}

		public static void SpawnStartItems(StartOfRound SOR)
		{
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			List<(GameObject, int)> list = new List<(GameObject, int)>();
			int i;
			for (i = 0; i < LootrunBase.currentRunSettings.items.Count; i++)
			{
				int num = SOR.allItemsList.itemsList.FindIndex((Item x) => x.itemName.Equals(LootrunBase.currentRunSettings.items[i].itemName));
				if (num != -1)
				{
					list.Add((SOR.allItemsList.itemsList[num].spawnPrefab, LootrunBase.currentRunSettings.items[i].quantity));
				}
			}
			foreach (var item in list)
			{
				for (int j = 0; j < item.Item2; j++)
				{
					GrabbableObject component = Object.Instantiate<GameObject>(item.Item1, new Vector3(-3.5f, 1f, -14.5f), Quaternion.identity, SOR.elevatorTransform).GetComponent<GrabbableObject>();
					component.fallTime = 1f;
					component.hasHitGround = true;
					component.scrapPersistedThroughRounds = true;
					component.isInElevator = true;
					component.isInShipRoom = true;
					((NetworkBehaviour)component).NetworkObject.Spawn(false);
				}
			}
			GameObject val = null;
			for (int k = 0; k < SOR.VehiclesList.Length; k++)
			{
				if (((Object)SOR.VehiclesList[k]).name == "CompanyCruiser")
				{
					val = SOR.VehiclesList[k];
				}
			}
			if (!LootrunBase.currentRunSettings.cruiserOnStart)
			{
				return;
			}
			GameObject val2 = Object.Instantiate<GameObject>(val, SOR.magnetPoint.position + SOR.magnetPoint.forward * 5f, Quaternion.identity, RoundManager.Instance.VehiclesContainer);
			SOR.attachedVehicle = val2.GetComponent<VehicleController>();
			SOR.isObjectAttachedToMagnet = true;
			((NetworkBehaviour)SOR.attachedVehicle).NetworkObject.Spawn(false);
			SOR.magnetOn = true;
			SOR.magnetLever.initialBoolState = true;
			SOR.magnetLever.setInitialState = true;
			SOR.magnetLever.SetInitialState();
			int num2 = SOR.allItemsList.itemsList.FindIndex((Item x) => x.itemName.Equals("Weed killer"));
			if (num2 != -1)
			{
				for (int l = 0; l < 2; l++)
				{
					GrabbableObject component2 = Object.Instantiate<GameObject>(SOR.allItemsList.itemsList[num2].spawnPrefab, new Vector3(10f, 1.5f, -13f), Quaternion.identity, SOR.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_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)
			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.countBees && LootrunBase.CurrentRoundBees.Contains(RoundManager.Instance.scrapCollectedThisRound[i]))
				{
					num++;
				}
				if (LootrunBase.currentRunSettings.countSpecials && LootrunBase.CurrentRoundSpecials.Contains(RoundManager.Instance.scrapCollectedThisRound[i]))
				{
					num++;
				}
			}
			int num2 = LootrunBase.CurrentRoundScrap.Count;
			if (LootrunBase.currentRunSettings.countBees)
			{
				num2 += LootrunBase.CurrentRoundBees.Count;
			}
			if (LootrunBase.currentRunSettings.countSpecials)
			{
				num2 += LootrunBase.CurrentRoundSpecials.Count;
			}
			lootrunResults.players = LootrunBase.playersThisRound;
			lootrunResults.presetUsed = LootrunBase.currentRunSettings;
			lootrunResults.time = LootrunBase.LootrunTime;
			lootrunResults.scrapCollectedOutOf = new Vector2Int(num, num2);
			LootrunBase.currentRunResult = lootrunResults;
			LootrunNetworkHandler.instance.SyncLootrunResultsClientRpc(LootrunBase.currentRunSettings, lootrunResults);
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "AutoSaveShipData")]
	internal class AutoSaveShipDataPatch
	{
		[HarmonyPrefix]
		private static bool AutoSaveShipDataHook(StartOfRound __instance)
		{
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Expected I4, but got Unknown
			if (LootrunBase.isInLootrun)
			{
				HUDManager.Instance.saveDataIconAnimatorB.SetTrigger("save");
				LootrunBase.SaveResults(LootrunBase.currentRunResult);
				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);
					}
				}
				LoadShipGrabbableItemsPatch.SpawnStartItems(__instance);
				Terminal val2 = Object.FindObjectOfType<Terminal>();
				val2.groupCredits = LootrunBase.currentRunSettings.money;
				if (LootrunBase.currentRunSettings.weatherType == -2)
				{
					__instance.currentLevel.currentWeather = __instance.currentLevel.randomWeathers[Random.Range(0, __instance.currentLevel.randomWeathers.Length)].weatherType;
				}
				else
				{
					__instance.currentLevel.currentWeather = (LevelWeatherType)LootrunBase.currentRunSettings.weatherType;
				}
				__instance.ChangePlanet();
				__instance.SetMapScreenInfoToCurrentLevel();
				LootrunNetworkHandler.instance.SyncStatsClientRpc(LootrunBase.currentRunSettings.moon, (int)__instance.currentLevel.currentWeather, 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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 && LootrunBase.currentRunSettings.isEndless)
			{
				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 __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace Lootrun.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}