Decompiled source of LostBranchCompanion v0.1.0

Companion.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AddWatermark;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Companion.Config;
using Companion.Patches;
using Companion.Utils;
using Cysharp.Threading.Tasks;
using HarmonyLib;
using LBoL.Base.Extensions;
using LBoL.ConfigData;
using LBoL.Core;
using LBoL.Core.Adventures;
using LBoL.Core.Battle;
using LBoL.Core.Cards;
using LBoL.Core.SaveData;
using LBoL.Core.Stations;
using LBoL.Core.Units;
using LBoL.Presentation;
using LBoL.Presentation.Environments;
using LBoL.Presentation.I10N;
using LBoL.Presentation.UI;
using LBoL.Presentation.UI.Dialogs;
using LBoL.Presentation.UI.ExtraWidgets;
using LBoL.Presentation.UI.Panels;
using LBoL.Presentation.UI.Widgets;
using LBoL.Presentation.Units;
using LBoLEntitySideloader;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Experimental.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("LBoL.Base")]
[assembly: IgnoresAccessChecksTo("LBoL.ConfigData")]
[assembly: IgnoresAccessChecksTo("LBoL.Core")]
[assembly: IgnoresAccessChecksTo("LBoL.EntityLib")]
[assembly: IgnoresAccessChecksTo("LBoL.Presentation")]
[assembly: IgnoresAccessChecksTo("Untitled.ConfigDataBuilder.Base")]
[assembly: AssemblyCompany("Companion")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Companion")]
[assembly: AssemblyTitle("Companion")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Companion
{
	[BepInPlugin("cyaneko.lbol.mods.companion", "Lost Branch Companion", "0.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInProcess("LBoL.exe")]
	public class BepinexPlugin : BaseUnityPlugin
	{
		private static readonly Harmony harmony = PInfo.harmony;

		internal static ManualLogSource log;

		internal static ConfigEntry<bool> AutoCollectMoney;

		internal static ConfigEntry<bool> AutoCollectExhibits;

		internal static ConfigEntry<string> AutoCollectExhibitList;

		internal static ConfigEntry<bool> AutoCollectTools;

		internal static ConfigEntry<bool> AutoOpenShop;

		internal static ConfigEntry<bool> AutoOpenMap;

		internal static ConfigEntry<bool> AutoAdvance;

		internal static ConfigEntry<QuickStartMode> QuickStartBehaviour;

		internal static bool SideloaderAvailable = false;

		private void Awake()
		{
			log = ((BaseUnityPlugin)this).Logger;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			AutoCollectMoney = ((BaseUnityPlugin)this).Config.Bind<bool>("Quality of Life", "Auto-collect money", true, "Automatically collect reward money.");
			AutoCollectExhibits = ((BaseUnityPlugin)this).Config.Bind<bool>("Quality of Life", "Auto-collect exhibits", true, "Automatically collect exhibits.");
			AutoCollectExhibitList = ((BaseUnityPlugin)this).Config.Bind<string>("Quality of Life", "Exhibit collection list", "putao, shaoyao, bingkuai, shiyou, shuye, tiangourongqiu, tiangoumuji, tangsan, tiangoushanzi, tiangouxiangji, tiangouyuyi, tiangoudunpai, shenmipifeng, tuanzi, jingzhichaju, diannaopeijian, huangyoujiqiren, pingfandao, jiangyouping, judashaozi, chaojimogu, xiaorenwan, shanbibu, saiqianxiang, shoushiyubi, songjingmuyu, shouyinji, shoubiao, fengrenji, zixingche, weifenghuban, diyinleigu, xiwangmianju, huonanmianju, hulimianju, boremianju, linghunbaoshi, zheyangsan, pingguo, portalgun, xiangrikui, bianhua, heilianhua, mengriji, yaoshi, yueyuyi, shanshuobishou, yueshan, zhangchibangqiu, shanliangdengpao, jimuwanju, zuoshan, yashemao, huanxiangxiangyuanqi, baochuanmoxing, penzaiyoutan, taozi, xijiansan, xunlongchi, sunhuaihufu, wanglingtideng, gaodangshoubao, he3, baota, ganzhuyao", "Comma-separated list of exhibit IDs to pick up by auto-collection. If you do not know what is an exhibit ID, ask a modder.");
			AutoCollectTools = ((BaseUnityPlugin)this).Config.Bind<bool>("Quality of Life", "Auto-collect tools", true, "Automatically collect tool cards (from Ringo or Toolbox)");
			AutoOpenShop = ((BaseUnityPlugin)this).Config.Bind<bool>("Quality of Life", "Auto-open shop", true, "Automatically open Takane's shop.");
			AutoOpenMap = ((BaseUnityPlugin)this).Config.Bind<bool>("Quality of Life", "Auto-open map", true, "Automatically open the map when an event is finished or all rewards are collected.");
			AutoAdvance = ((BaseUnityPlugin)this).Config.Bind<bool>("Quality of Life", "Auto-advance path", false, "Automatically advance to next node if there is only one available path.");
			QuickStartBehaviour = ((BaseUnityPlugin)this).Config.Bind<QuickStartMode>("Quick Start", "Mode", QuickStartMode.LastRun, "Determines behaviour of the Quick Start button");
			foreach (string item in from id in AutoCollectExhibitList.Value.Split(',', StringSplitOptions.RemoveEmptyEntries)
				select id.Trim())
			{
				Automation.ExhibitCollectionList.Add(item);
			}
			CompanionConfigUI.Lily = Texture.LoadTextureFromAssembly(Assembly.GetExecutingAssembly(), "lily.png");
			SideloaderAvailable = Chainloader.PluginInfos.ContainsKey("neo.lbol.frameworks.entitySideloader");
			harmony.PatchAll();
		}

		private void OnDestroy()
		{
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			if ((Object)null != (Object)(object)CompanionConfigUI.Lily)
			{
				Object.Destroy((Object)(object)CompanionConfigUI.Lily.texture);
				Object.Destroy((Object)(object)CompanionConfigUI.Lily);
				CompanionConfigUI.Lily = null;
			}
			Automation.ExhibitCollectionList.Clear();
		}
	}
	public static class PInfo
	{
		public const string GUID = "cyaneko.lbol.mods.companion";

		public const string Name = "Lost Branch Companion";

		public const string version = "0.1.0";

		public static readonly Harmony harmony = new Harmony("cyaneko.lbol.mods.companion");
	}
	internal class SideloaderWrapper
	{
		[CompilerGenerated]
		private sealed class <EnumerateLoadouts>d__1 : IEnumerable<(string, string)>, IEnumerable, IEnumerator<(string, string)>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private (string, string) <>2__current;

			private int <>l__initialThreadId;

			private Dictionary<string, List<CharLoadoutInfo>>.Enumerator <>7__wrap1;

			private KeyValuePair<string, List<CharLoadoutInfo>> <chara>5__3;

			private List<CharLoadoutInfo>.Enumerator <>7__wrap3;

			(string, string) IEnumerator<(string, string)>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <EnumerateLoadouts>d__1(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if ((uint)(num - -4) <= 1u || num == 1)
				{
					try
					{
						if (num == -4 || num == 1)
						{
							try
							{
							}
							finally
							{
								<>m__Finally2();
							}
						}
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<>7__wrap1 = default(Dictionary<string, List<CharLoadoutInfo>>.Enumerator);
				<chara>5__3 = default(KeyValuePair<string, List<CharLoadoutInfo>>);
				<>7__wrap3 = default(List<CharLoadoutInfo>.Enumerator);
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				try
				{
					int num = <>1__state;
					if (num != 0)
					{
						if (num != 1)
						{
							return false;
						}
						<>1__state = -4;
						goto IL_00ad;
					}
					<>1__state = -1;
					<>7__wrap1 = UniqueTracker.Instance.loadoutInfos.GetEnumerator();
					<>1__state = -3;
					goto IL_00d8;
					IL_00ad:
					if (<>7__wrap3.MoveNext())
					{
						CharLoadoutInfo current = <>7__wrap3.Current;
						<>2__current = (<chara>5__3.Key, current.ultimateSkill);
						<>1__state = 1;
						return true;
					}
					<>m__Finally2();
					<>7__wrap3 = default(List<CharLoadoutInfo>.Enumerator);
					<chara>5__3 = default(KeyValuePair<string, List<CharLoadoutInfo>>);
					goto IL_00d8;
					IL_00d8:
					if (<>7__wrap1.MoveNext())
					{
						<chara>5__3 = <>7__wrap1.Current;
						<>7__wrap3 = <chara>5__3.Value.GetEnumerator();
						<>1__state = -4;
						goto IL_00ad;
					}
					<>m__Finally1();
					<>7__wrap1 = default(Dictionary<string, List<CharLoadoutInfo>>.Enumerator);
					return false;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			private void <>m__Finally1()
			{
				<>1__state = -1;
				((IDisposable)<>7__wrap1).Dispose();
			}

			private void <>m__Finally2()
			{
				<>1__state = -3;
				((IDisposable)<>7__wrap3).Dispose();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}

			[DebuggerHidden]
			IEnumerator<(string, string)> IEnumerable<(string, string)>.GetEnumerator()
			{
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					return this;
				}
				return new <EnumerateLoadouts>d__1(0);
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<(string, string)>)this).GetEnumerator();
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		internal static bool TryGetLoadout(string playerName, string usId, out UltimateSkill ultimateSkill, out Exhibit startingExhibit, out IEnumerable<Card> startingLibrary)
		{
			ultimateSkill = null;
			startingExhibit = null;
			startingLibrary = null;
			if (UniqueTracker.Instance.loadoutInfos.TryGetValue(playerName, out var value))
			{
				CharLoadoutInfo val = value.Find((CharLoadoutInfo loadout) => loadout.ultimateSkill == usId);
				if (val != null)
				{
					try
					{
						ultimateSkill = Library.CreateUs(val.ultimateSkill);
						startingExhibit = Library.CreateExhibit(val.exhibit);
						startingLibrary = val.deck.Select((string c) => Library.CreateCard(c));
						return true;
					}
					catch (Exception arg)
					{
						BepinexPlugin.log.LogError((object)$"(SideloaderWrapper.TryGetLoadout) error while trying to create loadout:\n{arg}");
					}
				}
			}
			return false;
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		[IteratorStateMachine(typeof(<EnumerateLoadouts>d__1))]
		internal static IEnumerable<(string, string)> EnumerateLoadouts()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <EnumerateLoadouts>d__1(-2);
		}
	}
	internal class WatermarkWrapper
	{
		[MethodImpl(MethodImplOptions.NoInlining)]
		internal static void ActivateWatermark()
		{
			API.ActivateWatermark();
		}
	}
}
namespace Companion.Utils
{
	public static class Extensions
	{
		public static T GenericMax<T>(T a, T b) where T : IComparable
		{
			if (a.CompareTo(b) < 0)
			{
				return b;
			}
			return a;
		}

		public static T GenericMin<T>(T a, T b) where T : IComparable
		{
			if (a.CompareTo(b) > 0)
			{
				return b;
			}
			return a;
		}
	}
	public static class LBoLExtensions
	{
		public static bool CanAffordShopItem<T>(this ShopItem<T> item) where T : GameEntity
		{
			if (item._gameRun.TryGetTarget(out var target))
			{
				return item.Price <= target.Money;
			}
			return false;
		}
	}
	public static class Profile
	{
		public static void UnlockAllForProfile(ProfileSaveData prof)
		{
			if (prof != null)
			{
				if (prof.Exp < ExpHelper.MaxExp)
				{
					int num = ExpHelper.MaxExp - prof.Exp;
					prof.BluePoint += num;
					prof.Exp += num;
				}
				prof.CardsRevealed = (from cfg in CardConfig.AllConfig()
					where !cfg.HideMesuem && cfg.DebugLevel == 0
					select cfg.Id).ToList();
				prof.CardsRevealed.Sort();
				prof.ExhibitsRevealed = (from cfg in ExhibitConfig.AllConfig()
					where cfg.Revealable && !cfg.IsDebug
					select cfg.Id).ToList();
				prof.ExhibitsRevealed.Sort();
			}
		}

		public static bool TryGetLastRunInHistory(out GameRunRecordSaveData record)
		{
			record = null;
			GameMaster instance = Singleton<GameMaster>.Instance;
			if (instance.CurrentSaveIndex.HasValue)
			{
				int value = instance.CurrentSaveIndex.Value;
				string path = Path.Combine(GameMaster.PlatformHandler.GetSaveDataFolder(), GameMaster.GetHistoryFileName(value));
				List<GameRunRecordSaveData> list;
				try
				{
					if (!File.Exists(path))
					{
						BepinexPlugin.log.LogInfo((object)"(RunQuickstart.TryGetLastRunInHistory) Run history file does not exist");
						return false;
					}
					list = SaveDataHelper.DeserializeGameRunHistory(File.ReadAllBytes(path));
				}
				catch (Exception arg)
				{
					BepinexPlugin.log.LogError((object)$"(RunQuickstart.TryGetLastRunInHistory) Could not read run history file: {arg}");
					return false;
				}
				if (list.Count == 0)
				{
					BepinexPlugin.log.LogInfo((object)"(RunQuickstart.TryGetLastRunInHistory) Run history is empty");
					return false;
				}
				record = list.Last();
				return true;
			}
			return false;
		}
	}
	public static class Texture
	{
		public static Sprite LoadTextureFromAssembly(Assembly assembly, string id)
		{
			//IL_0073: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_00b2: 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)
			string text = assembly.GetManifestResourceNames().FirstOrDefault((string p) => p.EndsWith("." + id));
			if (text == null)
			{
				return null;
			}
			using Stream stream = assembly.GetManifestResourceStream(text);
			if (stream == null)
			{
				return null;
			}
			using MemoryStream memoryStream = new MemoryStream();
			byte[] array = new byte[32768];
			int count;
			while ((count = stream.Read(array, 0, array.Length)) > 0)
			{
				memoryStream.Write(array, 0, count);
			}
			Texture2D val = new Texture2D(0, 0, (GraphicsFormat)4, (TextureCreationFlags)0)
			{
				anisoLevel = 1,
				filterMode = (FilterMode)1
			};
			ImageConversion.LoadImage(val, memoryStream.ToArray());
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 1f);
		}
	}
	public static class UI
	{
		public static void ConfirmationPopup(string key, Action confirmAction)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			((UiDialog<MessageContent>)(object)UiManager.GetDialog<MessageDialog>()).Show(new MessageContent
			{
				TextKey = key,
				Icon = (MessageIcon)1,
				Buttons = (DialogButtons)1,
				OnConfirm = confirmAction
			});
		}
	}
}
namespace Companion.Patches
{
	[HarmonyPatch]
	public static class Automation
	{
		[CompilerGenerated]
		private sealed class <EndStationFlowWrapper>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Station station;

			public IEnumerator result;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <EndStationFlowWrapper>d__6(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Invalid comparison between I4 and Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (((Unit)station.GameRun.Player).IsDead || station.IsStageEnd || (!station.IsStageEnd && 2 != (int)station.GameRun.MapMode))
					{
						BepinexPlugin.log.LogDebug((object)"(GameMaster.EndStationFlow) Trying to skip next click");
						skipNextButtonClick = true;
					}
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (result.MoveNext())
				{
					<>2__current = result.Current;
					<>1__state = 1;
					return true;
				}
				if (BepinexPlugin.AutoOpenShop.Value)
				{
					Station obj = station;
					ShopStation val = (ShopStation)(object)((obj is ShopStation) ? obj : null);
					if (val != null && CanBuyCheck(val))
					{
						BepinexPlugin.log.LogDebug((object)"(GameMaster.EndStationFlow) Takane detected, smashing");
						GameDirector.Enemies[0].Clicked();
					}
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static readonly HashSet<string> ExhibitCollectionList = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);

		private static bool skipNextButtonClick = false;

		private static bool PickupCheck(StationReward reward)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected I4, but got Unknown
			StationRewardType type = reward.Type;
			switch ((int)type)
			{
			case 2:
			{
				if (!BepinexPlugin.AutoCollectExhibits.Value)
				{
					return false;
				}
				Exhibit exhibit = reward.Exhibit;
				if (exhibit == null)
				{
					return false;
				}
				return ExhibitCollectionList.Contains(((GameEntity)exhibit).Id);
			}
			case 0:
				return BepinexPlugin.AutoCollectMoney.Value;
			case 3:
				return BepinexPlugin.AutoCollectTools.Value;
			default:
				return false;
			}
		}

		private static bool CanBuyCheck(ShopStation shop)
		{
			if (!shop.ShopCards.Any((ShopItem<Card> c) => c.CanAffordShopItem<Card>()) && !shop.ShopExhibits.Any((ShopItem<Exhibit> e) => e.CanAffordShopItem<Exhibit>()))
			{
				if (shop.CanUseCardService)
				{
					int removeDeckCardPrice = shop.RemoveDeckCardPrice;
					GameRunController gameRun = ((Station)shop).GameRun;
					if (!(removeDeckCardPrice <= ((gameRun != null) ? new int?(gameRun.Money) : null)))
					{
						int upgradeDeckCardPrice = shop.UpgradeDeckCardPrice;
						GameRunController gameRun2 = ((Station)shop).GameRun;
						return upgradeDeckCardPrice <= ((gameRun2 != null) ? new int?(gameRun2.Money) : null);
					}
					return true;
				}
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(RewardPanel), "OnShowing", new Type[] { typeof(ShowRewardContent) })]
		[HarmonyPostfix]
		private static void AfterShow(RewardPanel __instance, ShowRewardContent showRewardContent)
		{
			List<RewardWidget> rewardWidgets = __instance._rewardWidgets;
			List<RewardWidget> list = new List<RewardWidget>();
			for (int i = 0; i < rewardWidgets.Count; i++)
			{
				RewardWidget val = rewardWidgets[i];
				if (PickupCheck(val.StationReward))
				{
					list.Add(val);
				}
			}
			foreach (RewardWidget item in list)
			{
				BepinexPlugin.log.LogDebug((object)$"(RewardPanel.OnShowing) Clicked reward {{{item.StationReward}}}");
				((UnityEvent)item.button.onClick).Invoke();
			}
		}

		[HarmonyPatch(typeof(GameMaster), "EndGameProcedure", new Type[] { typeof(GameRunController) })]
		[HarmonyPrefix]
		private static void PreGameEnd(GameMaster __instance)
		{
			BepinexPlugin.log.LogDebug((object)"(GameMaster.EndGameProcedure) Trying to skip next click");
			skipNextButtonClick = true;
		}

		[IteratorStateMachine(typeof(<EndStationFlowWrapper>d__6))]
		[HarmonyPatch(typeof(GameMaster), "EndStationFlow", new Type[]
		{
			typeof(Station),
			typeof(bool)
		})]
		[HarmonyPostfix]
		private static IEnumerator EndStationFlowWrapper(IEnumerator result, GameMaster __instance, Station station, bool skipBossReward)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <EndStationFlowWrapper>d__6(0)
			{
				result = result,
				station = station
			};
		}

		[HarmonyPatch(typeof(VnPanel), "SetNextButton", new Type[]
		{
			typeof(bool),
			typeof(int?),
			typeof(Action)
		})]
		[HarmonyPostfix]
		private static void ClickNextButton(VnPanel __instance, bool active, int? index, Action call)
		{
			if (skipNextButtonClick)
			{
				BepinexPlugin.log.LogDebug((object)"(VnPanel.SetNextButton) Click skipped...");
				skipNextButtonClick = false;
			}
			else if (BepinexPlugin.AutoOpenMap.Value && active && index.HasValue && 0 == index)
			{
				BepinexPlugin.log.LogDebug((object)"(VnPanel.SetNextButton) Event finished, clicking...");
				((UnityEvent)__instance.nextButton.onClick).Invoke();
			}
		}

		[HarmonyPatch(typeof(VnPanel), "End")]
		[HarmonyPostfix]
		private static void EndEvent(VnPanel __instance)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Invalid comparison between I4 and Unknown
			if (skipNextButtonClick)
			{
				BepinexPlugin.log.LogDebug((object)"(VnPanel.End) Click skipped...");
				skipNextButtonClick = false;
			}
			else if (BepinexPlugin.AutoOpenMap.Value)
			{
				MapNode val = ((UiPanelBase)__instance).GameRun.CurrentMap.Path.LastOrDefault();
				if (val == null || 10 != (int)val.StationType)
				{
					BepinexPlugin.log.LogDebug((object)"(VnPanel.End) Event finished, clicking...");
					((UnityEvent)__instance.nextButton.onClick).Invoke();
				}
			}
		}

		[HarmonyPatch(typeof(MapPanel), "OnShown")]
		[HarmonyPostfix]
		private static void AfterMapOpenClickNode(MapPanel __instance)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Invalid comparison between I4 and Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Invalid comparison between I4 and Unknown
			if (!BepinexPlugin.AutoAdvance.Value || ((UiPanelBase)__instance).Battle != null)
			{
				return;
			}
			RewardPanel panel = UiManager.GetPanel<RewardPanel>();
			if (0 < panel._rewardWidgets.Count)
			{
				return;
			}
			GameMap map = __instance._map;
			GameRunController gameRun = ((UiPanelBase)__instance).GameRun;
			IReadOnlyList<MapNode> path = map.Path;
			if (path.Count == 0)
			{
				return;
			}
			Station currentStation = gameRun.CurrentStation;
			ShopStation val = (ShopStation)(object)((currentStation is ShopStation) ? currentStation : null);
			if (val != null && CanBuyCheck(val))
			{
				BepinexPlugin.log.LogDebug((object)"(MapPanel.OnShown) Click skipped due to shop check");
				return;
			}
			MapNode val2 = path.Last();
			int count = path.Count;
			if (3 == (int)gameRun.MapMode || 1 == (int)gameRun.MapMode)
			{
				BepinexPlugin.log.LogDebug((object)"(MapPanel.OnShown) Click skipped due to special movement mode");
			}
			else if (1 != val2.FollowerList.Count)
			{
				BepinexPlugin.log.LogDebug((object)"(MapPanel.OnShown) Click skipped due to multiple movement paths");
			}
			else
			{
				((UnityEvent)__instance._mapNodeWidgets[count, val2.FollowerList[0]].button.onClick).Invoke();
			}
		}
	}
	[HarmonyPatch]
	public static class CompanionConfigUI
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction<bool> <>9__16_0;

			public static UnityAction<bool> <>9__16_1;

			public static UnityAction<bool> <>9__16_2;

			public static UnityAction<bool> <>9__16_3;

			public static UnityAction<bool> <>9__16_4;

			public static UnityAction<bool> <>9__16_5;

			public static UnityAction<int> <>9__16_6;

			public static Action <>9__16_8;

			public static UnityAction <>9__16_7;

			internal void <InitConfigTab>b__16_0(bool s)
			{
				BepinexPlugin.AutoCollectMoney.Value = s;
			}

			internal void <InitConfigTab>b__16_1(bool s)
			{
				BepinexPlugin.AutoCollectExhibits.Value = s;
			}

			internal void <InitConfigTab>b__16_2(bool s)
			{
				BepinexPlugin.AutoCollectTools.Value = s;
			}

			internal void <InitConfigTab>b__16_3(bool s)
			{
				BepinexPlugin.AutoOpenMap.Value = s;
			}

			internal void <InitConfigTab>b__16_4(bool s)
			{
				BepinexPlugin.AutoOpenShop.Value = s;
			}

			internal void <InitConfigTab>b__16_5(bool s)
			{
				BepinexPlugin.AutoAdvance.Value = s;
			}

			internal void <InitConfigTab>b__16_6(int idx)
			{
				BepinexPlugin.QuickStartBehaviour.Value = (QuickStartMode)idx;
			}

			internal void <InitConfigTab>b__16_7()
			{
				UI.ConfirmationPopup("ProfileUnlockWarning", delegate
				{
					Profile.UnlockAllForProfile(Singleton<GameMaster>.Instance.CurrentProfile);
					UiManager.GetPanel<MainMenuPanel>().RefreshProfile();
				});
			}

			internal void <InitConfigTab>b__16_8()
			{
				Profile.UnlockAllForProfile(Singleton<GameMaster>.Instance.CurrentProfile);
				UiManager.GetPanel<MainMenuPanel>().RefreshProfile();
			}
		}

		public static Sprite Lily = null;

		private static int tabIndex = -1;

		private static bool suppressInitClick = true;

		private static GameObject dropdownTemplate = null;

		private static GameObject smallDropdownTemplate = null;

		private static GameObject switchTemplate = null;

		private static GameObject sliderTemplate = null;

		private static GameObject buttonTemplate = null;

		private static GameObject CreateDropdown(Transform panelParent, string internalName, string tooltipKey, IEnumerable<string> options, int currentValue, UnityAction<int> callback, bool small = false)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			GameObject obj = Object.Instantiate<GameObject>(small ? smallDropdownTemplate : dropdownTemplate, panelParent);
			((Object)obj).name = internalName;
			TMP_Dropdown componentInChildren = obj.GetComponentInChildren<TMP_Dropdown>();
			componentInChildren.onValueChanged = new DropdownEvent();
			((UnityEvent<int>)(object)componentInChildren.onValueChanged).AddListener(callback);
			componentInChildren.ClearOptions();
			componentInChildren.AddOptions(options.ToList());
			componentInChildren.SetValueWithoutNotify(currentValue);
			string text = "Setting." + internalName;
			string text2 = "Setting." + tooltipKey;
			SimpleTooltipSource.CreateWithGeneralKey(obj, text, text2).WithPosition((TooltipDirection)3, (TooltipAlignment)0);
			((Component)obj.transform.Find("KeyTmp")).GetComponent<LocalizedText>().key = text;
			return obj;
		}

		private static GameObject CreateSwitch(Transform panelParent, string internalName, string tooltipKey, bool currentValue, UnityAction<bool> callback)
		{
			GameObject obj = Object.Instantiate<GameObject>(switchTemplate, panelParent);
			((Object)obj).name = internalName;
			SwitchWidget componentInChildren = obj.GetComponentInChildren<SwitchWidget>();
			componentInChildren.onToggleChanged = new UnityEvent<bool>();
			componentInChildren.onToggleChanged.AddListener(callback);
			componentInChildren.SetValueWithoutNotifier(currentValue, true);
			string text = "Setting." + internalName;
			string text2 = "Setting." + tooltipKey;
			SimpleTooltipSource.CreateWithGeneralKey(obj, text, text2).WithPosition((TooltipDirection)3, (TooltipAlignment)0);
			((Component)obj.transform.Find("KeyTmp")).GetComponent<LocalizedText>().key = text;
			return obj;
		}

		private static GameObject CreateSlider(Transform panelParent, string internalName, string tooltipKey, UnityAction<float> callback)
		{
			throw new NotImplementedException("Slide on my deez nuts");
		}

		private static GameObject CreateButton(Transform panelParent, string internalName, string tooltipKey, UnityAction callback, bool interactable)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			GameObject obj = Object.Instantiate<GameObject>(buttonTemplate, panelParent);
			((Object)obj).name = internalName;
			Transform val = obj.transform.Find("ResetHint");
			((Object)val).name = internalName;
			CommonButtonWidget component = ((Component)val).GetComponent<CommonButtonWidget>();
			component.button.onClick = new ButtonClickedEvent();
			((UnityEvent)component.button.onClick).AddListener(callback);
			((Selectable)component.button).interactable = interactable;
			string text = "UI." + internalName;
			string text2 = "UI." + tooltipKey;
			SimpleTooltipSource.CreateWithGeneralKey(obj, text, text2).WithPosition((TooltipDirection)3, (TooltipAlignment)0);
			((Component)(val.Find("Text (TMP)") ?? val.Find("Layout/Text (TMP)"))).GetComponent<LocalizedText>().key = text;
			return obj;
		}

		private static GameObject CreateToggle(Transform parent, bool on, UnityAction<bool> callback)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			PuzzleToggleWidget obj = Object.Instantiate<PuzzleToggleWidget>(UiManager.GetPanel<StartGamePanel>().puzzleToggleTemplate);
			obj.SetEnd();
			obj.Toggle.onValueChanged = new ToggleEvent();
			obj.Toggle.isOn = on;
			((UnityEvent<bool>)(object)obj.Toggle.onValueChanged).AddListener(callback);
			((Component)obj).transform.SetParent(parent);
			return ((Component)obj).gameObject;
		}

		private static bool TryGetChild(this Transform t, string childName, out Transform child)
		{
			child = t.Find(childName);
			if ((Object)null == (Object)(object)child)
			{
				BepinexPlugin.log.LogWarning((object)("Could not find " + childName + " Transform, the config UI will not be initialised"));
				return false;
			}
			return true;
		}

		private static bool TryGetOptionTab(this SettingPanel panel, string name, out CanvasGroup tab)
		{
			tab = panel.tabs.Where((CanvasGroup t) => ((Object)t).name == name).FirstOrDefault();
			if ((Object)null == (Object)(object)tab)
			{
				BepinexPlugin.log.LogWarning((object)("Could not find " + name + " tab, the config UI will not be initialised"));
				return false;
			}
			return true;
		}

		private static void SetupMuseumExhibitWidget(MuseumExhibitWidget ex)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = CreateToggle(((Component)ex).transform, Automation.ExhibitCollectionList.Contains(((GameEntity)ex.Exhibit).Id), delegate(bool on)
			{
				if ((on && Automation.ExhibitCollectionList.Add(((GameEntity)ex.Exhibit).Id)) || (!on && Automation.ExhibitCollectionList.Remove(((GameEntity)ex.Exhibit).Id)))
				{
					BepinexPlugin.AutoCollectExhibitList.Value = string.Join<string>(", ", (IEnumerable<string>)Automation.ExhibitCollectionList);
				}
			});
			RectTransform component = obj.GetComponent<RectTransform>();
			((Transform)component).localScale = Vector3.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.one * 10f;
			component.anchoredPosition3D = new Vector3(200f, 300f);
			string text = "Setting.AutoCollectThisExhibit";
			string text2 = "Setting.AutoCollectThisExhibitDesc";
			SimpleTooltipSource.CreateWithGeneralKey(obj, text, text2).WithPosition((TooltipDirection)3, (TooltipAlignment)1);
		}

		[HarmonyPatch(typeof(SettingPanel), "Awake")]
		[HarmonyPrefix]
		private static void InitConfigTab(SettingPanel __instance)
		{
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Expected O, but got Unknown
			if (!((Component)__instance).transform.TryGetChild("Root", out var child) || !child.TryGetChild("Tabs", out var child2) || !child2.TryGetChild("Main", out var child3) || !__instance.TryGetOptionTab("Main", out var tab) || !__instance.TryGetOptionTab("Preference", out var tab2))
			{
				return;
			}
			Transform val = ((Component)tab).transform.Find("LeftPanel");
			Transform val2 = ((Component)tab).transform.Find("RightPanel");
			Transform obj = ((Component)tab2).transform.Find("RightPanel");
			dropdownTemplate = ((Component)val.Find("Resolution")).gameObject;
			smallDropdownTemplate = ((Component)obj.Find("HintLevel")).gameObject;
			switchTemplate = ((Component)val.Find("FullScreen")).gameObject;
			sliderTemplate = ((Component)val2.Find("Master")).gameObject;
			buttonTemplate = ((Component)obj.Find("ResetHint")).gameObject;
			GameObject val3 = Object.Instantiate<GameObject>(((Component)child3).gameObject, child2);
			((Object)val3).name = "CompanionConfig";
			LocalizedText componentInChildren = val3.GetComponentInChildren<LocalizedText>();
			componentInChildren.key = "UI.CompanionConfig";
			componentInChildren.OnLocaleChanged();
			if ((Object)null != (Object)(object)Lily)
			{
				Transform val4 = val3.transform.Find("Icon");
				if ((Object)null != (Object)(object)val4)
				{
					((Component)val4).GetComponent<Image>().sprite = Lily;
				}
			}
			CanvasGroup val5 = Object.Instantiate<CanvasGroup>(tab, new InstantiateParameters
			{
				parent = ((Component)tab).transform.parent
			});
			((Object)val5).name = "CompanionConfig";
			((Component)val5).transform.SetSiblingIndex(((Component)child).transform.childCount - 2);
			Transform val6 = ((Component)val5).transform.Find("LeftPanel");
			Transform obj2 = ((Component)val5).transform.Find("RightPanel");
			TransformExtensions.DestroyChildren(val6);
			TransformExtensions.DestroyChildren(obj2);
			CreateSwitch(((Component)val6).transform, "AutoCollectMoney", "AutoCollectMoneyDesc", BepinexPlugin.AutoCollectMoney.Value, delegate(bool s)
			{
				BepinexPlugin.AutoCollectMoney.Value = s;
			});
			CreateSwitch(((Component)val6).transform, "AutoCollectExhibits", "AutoCollectExhibitsDesc", BepinexPlugin.AutoCollectExhibits.Value, delegate(bool s)
			{
				BepinexPlugin.AutoCollectExhibits.Value = s;
			});
			CreateSwitch(((Component)val6).transform, "AutoCollectTools", "AutoCollectToolsDesc", BepinexPlugin.AutoCollectTools.Value, delegate(bool s)
			{
				BepinexPlugin.AutoCollectTools.Value = s;
			});
			CreateSwitch(((Component)val6).transform, "AutoOpenMap", "AutoOpenMapDesc", BepinexPlugin.AutoOpenMap.Value, delegate(bool s)
			{
				BepinexPlugin.AutoOpenMap.Value = s;
			});
			CreateSwitch(((Component)val6).transform, "AutoOpenShop", "AutoOpenShopDesc", BepinexPlugin.AutoOpenShop.Value, delegate(bool s)
			{
				BepinexPlugin.AutoOpenShop.Value = s;
			});
			CreateSwitch(((Component)val6).transform, "AutoAdvance", "AutoAdvanceDesc", BepinexPlugin.AutoAdvance.Value, delegate(bool s)
			{
				BepinexPlugin.AutoAdvance.Value = s;
			});
			CreateDropdown(((Component)val6).transform, "QuickStartType", "QuickStartTypeDesc", Enum.GetNames(typeof(QuickStartMode)), CollectionsExtensions.IndexOf<QuickStartMode>((IReadOnlyList<QuickStartMode>)(QuickStartMode[])Enum.GetValues(typeof(QuickStartMode)), BepinexPlugin.QuickStartBehaviour.Value), delegate(int idx)
			{
				BepinexPlugin.QuickStartBehaviour.Value = (QuickStartMode)idx;
			}, small: true);
			Transform transform = ((Component)obj2).transform;
			object obj3 = <>c.<>9__16_7;
			if (obj3 == null)
			{
				UnityAction val7 = delegate
				{
					UI.ConfirmationPopup("ProfileUnlockWarning", delegate
					{
						Profile.UnlockAllForProfile(Singleton<GameMaster>.Instance.CurrentProfile);
						UiManager.GetPanel<MainMenuPanel>().RefreshProfile();
					});
				};
				<>c.<>9__16_7 = val7;
				obj3 = (object)val7;
			}
			CreateButton(transform, "UnlockProfile", "UnlockProfileDesc", (UnityAction)obj3, Singleton<GameMaster>.Instance.CurrentGameRun == null);
			__instance.tabs.Add(val5);
			tabIndex = __instance.tabs.IndexOf(val5);
			suppressInitClick = true;
			dropdownTemplate = null;
			smallDropdownTemplate = null;
			switchTemplate = null;
			sliderTemplate = null;
			buttonTemplate = null;
		}

		[HarmonyPatch(typeof(SettingPanel), "UI_OnTabToggleChanged", new Type[] { typeof(Toggle) })]
		[HarmonyPrefix]
		private static bool OnTabToggleChanged(SettingPanel __instance, Toggle item)
		{
			if ("CompanionConfig" == ((Object)item).name)
			{
				if (suppressInitClick)
				{
					suppressInitClick = false;
				}
				else
				{
					__instance.SwitchToTab(tabIndex);
				}
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(MuseumPanel), "Awake")]
		[HarmonyPostfix]
		private static void OnMuseumExhibitAwake(MuseumPanel __instance)
		{
			foreach (List<MuseumExhibitWidget> value in __instance._exhibitWidgetDic.Values)
			{
				foreach (MuseumExhibitWidget item in value)
				{
					SetupMuseumExhibitWidget(item);
				}
			}
		}
	}
	public static class LocalisationKeys
	{
		public const string UIPrefix = "UI.";

		public const string SettingsPrefix = "Setting.";

		public const string MessageDialogPrefix = "MessageDialog.";

		public const string ResetGameButton = "ResetGame";

		public const string QuickStartButton = "QuickStartGame";

		public const string ProfileUnlockButton = "UnlockProfile";

		public const string ProfileUnlockDesc = "UnlockProfileDesc";

		public const string ConfigTabHeader = "CompanionConfig";

		public const string AutoCollectMoney = "AutoCollectMoney";

		public const string AutoCollectMoneyDesc = "AutoCollectMoneyDesc";

		public const string AutoCollectExhibits = "AutoCollectExhibits";

		public const string AutoCollectExhibitsDesc = "AutoCollectExhibitsDesc";

		public const string AutoCollectThisExhibit = "AutoCollectThisExhibit";

		public const string AutoCollectThisExhibitDesc = "AutoCollectThisExhibitDesc";

		public const string AutoCollectTools = "AutoCollectTools";

		public const string AutoCollectToolsDesc = "AutoCollectToolsDesc";

		public const string AutoOpenMap = "AutoOpenMap";

		public const string AutoOpenMapDesc = "AutoOpenMapDesc";

		public const string AutoOpenShop = "AutoOpenShop";

		public const string AutoOpenShopDesc = "AutoOpenShopDesc";

		public const string AutoAdvance = "AutoAdvance";

		public const string AutoAdvanceDesc = "AutoAdvanceDesc";

		public const string QuickStartType = "QuickStartType";

		public const string QuickStartTypeDesc = "QuickStartTypeDesc";

		public const string GameResetWarning = "ResetGameWarning";

		public const string ProfileUnlockWarning = "ProfileUnlockWarning";

		public static readonly Dictionary<(Locale, string), string> LocTable = new Dictionary<(Locale, string), string>
		{
			[((Locale)0, "UI.ResetGame")] = "Reset Run",
			[((Locale)0, "UI.QuickStartGame")] = "Quick Start",
			[((Locale)0, "UI.UnlockProfile")] = "Unlock profile",
			[((Locale)0, "UI.CompanionConfig")] = "Companion",
			[((Locale)0, "Setting.AutoCollectMoney")] = "Auto-collect money",
			[((Locale)0, "Setting.AutoCollectExhibits")] = "Auto-collect exhibits",
			[((Locale)0, "Setting.AutoCollectThisExhibit")] = "Auto-collect this exhibit",
			[((Locale)0, "Setting.AutoCollectTools")] = "Auto-collect tools",
			[((Locale)0, "Setting.AutoOpenMap")] = "Auto-open map",
			[((Locale)0, "Setting.AutoOpenShop")] = "Auto-open shop",
			[((Locale)0, "Setting.AutoAdvance")] = "Auto-advance path",
			[((Locale)0, "Setting.QuickStartType")] = "Quick Start mode",
			[((Locale)0, "UI.UnlockProfileDesc")] = "Sets the current profile to unlock level 10, reveals all cards and |Exhibits|.",
			[((Locale)0, "Setting.AutoCollectMoneyDesc")] = "Automatically collect reward money.",
			[((Locale)0, "Setting.AutoCollectExhibitsDesc")] = "Automatically collect |Exhibits|. Configurable in collection.",
			[((Locale)0, "Setting.AutoCollectThisExhibitDesc")] = "Automatically collect this exhibit, if enabled in Companion.",
			[((Locale)0, "Setting.AutoCollectToolsDesc")] = "Automatically collect |Tool| cards (from Ringo or Toolbox).",
			[((Locale)0, "Setting.AutoOpenMapDesc")] = "Automatically open the map when all rewards are collected or an event is finished.",
			[((Locale)0, "Setting.AutoOpenShopDesc")] = "Automatically open Takane's shop if you can afford any item or service.",
			[((Locale)0, "Setting.AutoAdvanceDesc")] = "Automatically advance to next node if there is only one available path.",
			[((Locale)0, "Setting.QuickStartTypeDesc")] = "Determines behaviour of the Quick Start button.\n|LastRun| - Quick Start will choose the last picked character and deck.\n|Random| - Quick Start will randomly choose the character and deck.",
			[((Locale)0, "MessageDialog.ResetGameWarning")] = "Reset your current run?",
			[((Locale)0, "MessageDialog.ProfileUnlockWarning")] = "Unlock everything on this profile?",
			[((Locale)1, "UI.ResetGame")] = "rosl",
			[((Locale)1, "UI.QuickStartGame")] = "快速开局",
			[((Locale)1, "UI.UnlockProfile")] = "破解版帐号",
			[((Locale)1, "UI.CompanionConfig")] = "助手",
			[((Locale)1, "Setting.AutoCollectMoney")] = "自动抓钱",
			[((Locale)1, "Setting.AutoCollectExhibits")] = "自动抓展品",
			[((Locale)1, "Setting.AutoCollectThisExhibit")] = "自动抓此展品",
			[((Locale)1, "Setting.AutoCollectTools")] = "自动抓道具",
			[((Locale)1, "Setting.AutoOpenMap")] = "自动开启地图",
			[((Locale)1, "Setting.AutoOpenShop")] = "自动开启商店",
			[((Locale)1, "Setting.AutoAdvance")] = "自动前进",
			[((Locale)1, "Setting.QuickStartType")] = "快速开局模式",
			[((Locale)1, "UI.UnlockProfileDesc")] = "将帐号等级提升到10,显示所有卡牌和展品。",
			[((Locale)1, "Setting.AutoCollectMoneyDesc")] = "自动拾取金钱",
			[((Locale)1, "Setting.AutoCollectExhibitsDesc")] = "自动抓|展品|。可以在收集总览设定。",
			[((Locale)1, "Setting.AutoCollectThisExhibitDesc")] = "如在助手mod开启,则自动抓此展品。",
			[((Locale)1, "Setting.AutoCollectToolsDesc")] = "自动拾取|道具|牌(铃瑚或工具箱)。",
			[((Locale)1, "Setting.AutoOpenMapDesc")] = "当所有奖励或事件结束后自动开启地图",
			[((Locale)1, "Setting.AutoOpenShopDesc")] = "如有足够金钱购买任何商品/享用任何服务,则自动开启商店。",
			[((Locale)1, "Setting.AutoAdvanceDesc")] = "当只有一条能走的路时自动前进。",
			[((Locale)1, "Setting.QuickStartTypeDesc")] = "控制快速开局的模式。\n|上一局| - 快速开局会选择上一局的角色机体。\n|随机| - 快速开局会选择随机角色机体。",
			[((Locale)1, "MessageDialog.ResetGameWarning")] = "确定rosl?",
			[((Locale)1, "MessageDialog.ProfileUnlockWarning")] = "确定破解帐号?",
			[((Locale)2, "UI.ResetGame")] = "rosl",
			[((Locale)2, "UI.QuickStartGame")] = "快速開局",
			[((Locale)2, "UI.UnlockProfile")] = "破解版帳號",
			[((Locale)2, "UI.CompanionConfig")] = "助手",
			[((Locale)2, "Setting.AutoCollectMoney")] = "自動抓錢",
			[((Locale)2, "Setting.AutoCollectExhibits")] = "自動抓展品",
			[((Locale)2, "Setting.AutoCollectThisExhibit")] = "自動抓此展品",
			[((Locale)2, "Setting.AutoCollectTools")] = "自動抓道具",
			[((Locale)2, "Setting.AutoOpenMap")] = "自動開啟地圖",
			[((Locale)2, "Setting.AutoOpenShop")] = "自動開啟商店",
			[((Locale)2, "Setting.AutoAdvance")] = "自動前進",
			[((Locale)2, "Setting.QuickStartType")] = "快速開局模式",
			[((Locale)2, "UI.UnlockProfileDesc")] = "將帳號等級提升到10,顯示所有卡牌和展品。",
			[((Locale)2, "Setting.AutoCollectMoneyDesc")] = "自動拾取金錢",
			[((Locale)2, "Setting.AutoCollectExhibitsDesc")] = "自動抓|展品|。可以在收集總覽設定。",
			[((Locale)2, "Setting.AutoCollectThisExhibitDesc")] = "如在助手mod開啟,則自動抓此展品。",
			[((Locale)2, "Setting.AutoCollectToolsDesc")] = "自動拾取|道具|牌(鈴瑚或工具箱)。",
			[((Locale)2, "Setting.AutoOpenMapDesc")] = "當所有獎勵或事件結束後自動開啟地圖",
			[((Locale)2, "Setting.AutoOpenShopDesc")] = "如有足夠金錢購買任何商品/享用任何服務,則自動開啟商店。",
			[((Locale)2, "Setting.AutoAdvanceDesc")] = "當只有一條能走的路時自動前進。",
			[((Locale)2, "Setting.QuickStartTypeDesc")] = "控制快速開局的模式。\n|上一局| - 快速開局會選擇上一局的角色機體。\n|隨機| - 快速開局會選擇隨機角色機    體。",
			[((Locale)2, "MessageDialog.ResetGameWarning")] = "確定rosl?",
			[((Locale)2, "MessageDialog.ProfileUnlockWarning")] = "確定破解帳號?",
			[((Locale)3, "UI.ResetGame")] = "攻略リセット",
			[((Locale)3, "UI.QuickStartGame")] = "クイックスタート",
			[((Locale)3, "UI.UnlockProfile")] = "セーブデータのアンロック",
			[((Locale)3, "UI.CompanionConfig")] = "コンパニオン",
			[((Locale)3, "Setting.AutoCollectMoney")] = "資金力の自動取得",
			[((Locale)3, "Setting.AutoCollectExhibits")] = "展示品の自動取得",
			[((Locale)3, "Setting.AutoCollectThisExhibit")] = "この展示品を自動取得",
			[((Locale)3, "Setting.AutoCollectTools")] = "道具の自動取得",
			[((Locale)3, "Setting.AutoOpenMap")] = "マップの自動表示",
			[((Locale)3, "Setting.AutoOpenShop")] = "ショップの自動入店",
			[((Locale)3, "Setting.AutoAdvance")] = "自動で進む",
			[((Locale)3, "Setting.QuickStartType")] = "クイックスタートモード",
			[((Locale)3, "UI.UnlockProfileDesc")] = "現在のセーブデータのアンロックレベルを10にし、すべてのカードを|展示品|を収拾済みにします。",
			[((Locale)3, "Setting.AutoCollectMoneyDesc")] = "報酬の資金力を自動で取得します。",
			[((Locale)3, "Setting.AutoCollectExhibitsDesc")] = "|展示品|を自動で取得します。コレクション画面で設定できます。",
			[((Locale)3, "Setting.AutoCollectThisExhibitDesc")] = "コンパニオンで有効化している場合、この展示品を自動で取得します。",
			[((Locale)3, "Setting.AutoCollectToolsDesc")] = "|道具|カードを自動で取得します(鈴瑚または工具箱から)。",
			[((Locale)3, "Setting.AutoOpenMapDesc")] = "すべての報酬を取得したりイベントが終了したりした時、自動でマップを表示します。",
			[((Locale)3, "Setting.AutoOpenShopDesc")] = "資金が足りている時、たかねの店を自動で開きます。",
			[((Locale)3, "Setting.AutoAdvanceDesc")] = "一本道の時、自動で次へ進みます。",
			[((Locale)3, "Setting.QuickStartTypeDesc")] = "クイックスタートボタンの挙動を決めます。\n|LastRun|――直前の攻略で選択した主人公とデッキでクイックスタート。\n|Random|――ランダムな主人公とデッキでクイックスタート。",
			[((Locale)3, "MessageDialog.ResetGameWarning")] = "現在の攻略をリセットしますか?",
			[((Locale)3, "MessageDialog.ProfileUnlockWarning")] = "現在のセーブデータのすべてをアンロックしますか?",
			[((Locale)6, "UI.ResetGame")] = "Resetuj Przejście",
			[((Locale)6, "UI.QuickStartGame")] = "Szybka Gra",
			[((Locale)6, "UI.UnlockProfile")] = "Odblokuj profil",
			[((Locale)6, "UI.CompanionConfig")] = "Towarzysz",
			[((Locale)6, "Setting.AutoCollectMoney")] = "Zbieraj pieniądze",
			[((Locale)6, "Setting.AutoCollectExhibits")] = "Zbieraj eksponaty",
			[((Locale)6, "Setting.AutoCollectThisExhibit")] = "Zbierz ten eksponat",
			[((Locale)6, "Setting.AutoCollectTools")] = "Zbieraj narzędzia",
			[((Locale)6, "Setting.AutoOpenMap")] = "Auto-otwieranie mapy",
			[((Locale)6, "Setting.AutoOpenShop")] = "Auto-otwieranie sklepu",
			[((Locale)6, "Setting.AutoAdvance")] = "Auto-podróż",
			[((Locale)6, "Setting.QuickStartType")] = "Tryb Szybkiej Gry",
			[((Locale)6, "UI.UnlockProfileDesc")] = "Ustawia obecny profil na poziom odblokowania 10, ujawnia wszystkie karty oraz eksponaty.",
			[((Locale)6, "Setting.AutoCollectMoneyDesc")] = "Automatycznie zbieraj pieniądze za walki.",
			[((Locale)6, "Setting.AutoCollectExhibitsDesc")] = "Automatycznie zbieraj |Eksponaty|. Konfiguracja możliwa w kolekcji.",
			[((Locale)6, "Setting.AutoCollectThisExhibitDesc")] = "Automatycznie zbierz ten eksponat, jeśli została włączona opcja w Towarzyszu.",
			[((Locale)6, "Setting.AutoCollectToolsDesc")] = "Automatycznie zbieraj karty |Narzędzi| (Ringo, Skrzynka na Narzędzia).",
			[((Locale)6, "Setting.AutoOpenMapDesc")] = "Automatycznie otwieraj mapę kiedy wszystkie nagrody zostaną zebrane lub po zakończeniu wydarzeń.",
			[((Locale)6, "Setting.AutoOpenShopDesc")] = "Automatycznie otwieraj sklep Takane kiedy jesteś w stanie zakupić jakikolwiek przedmiot lub usługę.",
			[((Locale)6, "Setting.AutoAdvanceDesc")] = "Automatycznie przechodź do następnego węzła mapy kiedy istnieje tylko jedna ścieżka.",
			[((Locale)6, "Setting.QuickStartTypeDesc")] = "Zmienia zachowanie przycisku Szybkiej Gry.\n|LastRun| - Szybka Gra wybierze postać i talię z ostatniej gry.\n|Random| - Szybka Gra wybierze losową postać i jej talię.",
			[((Locale)6, "MessageDialog.ResetGameWarning")] = "Czy na pewno chcesz zresetować to przejście?",
			[((Locale)6, "MessageDialog.ProfileUnlockWarning")] = "Czy na pewno odblokować wszystko na tym profilu?"
		};
	}
	[HarmonyPatch]
	public static class LocalisationPatches
	{
		public static MethodBase TargetMethod()
		{
			return AccessTools.Method((from t in typeof(Localization).GetNestedTypes(AccessTools.allDeclared)
				where t.Name.Contains("<ReloadCommonAsync>")
				select t).Single(), "MoveNext", (Type[])null, (Type[])null);
		}

		public static void PostReloadCommon()
		{
			foreach (var (tuple2, value) in LocalisationKeys.LocTable.Where((KeyValuePair<(Locale, string), string> kvp) => kvp.Key.Item1 == Localization.CurrentLocale))
			{
				Localization.LocalizationTable.Add(tuple2.Item2, value);
			}
		}

		[HarmonyTranspiler]
		public static IEnumerable<CodeInstruction> AsyncPostfix(IEnumerable<CodeInstruction> instructions, ILGenerator gen)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			return new CodeMatcher(instructions, gen).End().MatchBack(true, (CodeMatch[])(object)new CodeMatch[8]
			{
				CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldarg_0, (object)null)),
				CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldc_I4_M1, (object)null)),
				CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Dup, (object)null)),
				CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Stloc_0, (object)null)),
				CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Stfld, (object)null)),
				CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ldloca_S, (object)null)),
				CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Call, (object)null)),
				CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Leave, (object)null))
			}).Advance(-1)
				.Insert((CodeInstruction[])(object)new CodeInstruction[1]
				{
					new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(LocalisationPatches), "PostReloadCommon", (Type[])null, (Type[])null))
				})
				.InstructionEnumeration();
		}
	}
	[HarmonyPatch]
	public static class RunQuickstart
	{
		[HarmonyPatch(typeof(GameMaster))]
		private class GameMaster_Patches
		{
			[CompilerGenerated]
			private sealed class <CoPostResetGameRun>d__0 : IEnumerator<object>, IEnumerator, IDisposable
			{
				private int <>1__state;

				private object <>2__current;

				public GameMaster gm;

				object IEnumerator<object>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				object IEnumerator.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				[DebuggerHidden]
				public <CoPostResetGameRun>d__0(int <>1__state)
				{
					this.<>1__state = <>1__state;
				}

				[DebuggerHidden]
				void IDisposable.Dispose()
				{
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					//IL_0040: Unknown result type (might be due to invalid IL or missing references)
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						if (gm.CurrentGameRun == null)
						{
							throw new InvalidOperationException("Not in game-run");
						}
						<>2__current = UniTaskExtensions.ToCoroutine(UiManager.ShowLoading(0.5f), (Action<Exception>)null);
						<>1__state = 1;
						return true;
					case 1:
					{
						<>1__state = -1;
						if (gm.CurrentGameRun.Battle != null)
						{
							UiManager.LeaveBattle();
						}
						UiManager.LeaveGameRun();
						gm.CurrentGameRun = null;
						Environment instance = Environment.Instance;
						if ((Object)null != (Object)(object)Environment.CurrentEnvironment)
						{
							instance.ClearEnvironment();
						}
						GameDirector.ClearAll();
						GameMaster.UnloadGameRunUi();
						GC.Collect();
						Resources.UnloadUnusedAssets();
						GameRunSaveData gameSave = GameSave;
						GameSave = null;
						GameRunController val = NewRunFromSave(gameSave);
						if (val != null)
						{
							AudioManager.PlayBgm("Stage1", 0f, false);
							AudioManager.PlayBgm("Stage1", 0f, true);
							<>2__current = gm.CoNewGameRun(val);
							<>1__state = 2;
							return true;
						}
						break;
					}
					case 2:
						<>1__state = -1;
						break;
					}
					return false;
				}

				bool IEnumerator.MoveNext()
				{
					//ILSpy generated this explicit interface implementation from .override directive in MoveNext
					return this.MoveNext();
				}

				[DebuggerHidden]
				void IEnumerator.Reset()
				{
					throw new NotSupportedException();
				}
			}

			[IteratorStateMachine(typeof(<CoPostResetGameRun>d__0))]
			private static IEnumerator CoPostResetGameRun(GameMaster gm)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <CoPostResetGameRun>d__0(0)
				{
					gm = gm
				};
			}

			[HarmonyPatch("EndGameProcedure")]
			[HarmonyPrefix]
			private static void OnGameEnd()
			{
				if ((Object)null != (Object)(object)SettingPanel_Patches.ResetGameBtn)
				{
					((Selectable)SettingPanel_Patches.ResetGameBtn).interactable = false;
				}
			}

			[HarmonyPatch("LeaveGameRun")]
			[HarmonyPrefix]
			private static bool OnLeaveRun()
			{
				if (HookCoLeave)
				{
					HookCoLeave = false;
					GameMaster instance = Singleton<GameMaster>.Instance;
					GameDirector.StopLoreChat();
					((MonoBehaviour)instance).StopAllCoroutines();
					((MonoBehaviour)instance).StartCoroutine(CoPostResetGameRun(instance));
					return false;
				}
				return true;
			}

			[HarmonyPatch("RequestAbandonGameRun")]
			[HarmonyTranspiler]
			private static IEnumerable<CodeInstruction> SkipMainMenuPanel(IEnumerable<CodeInstruction> instructions, ILGenerator gen)
			{
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Expected O, but got Unknown
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Expected O, but got Unknown
				//IL_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Expected O, but got Unknown
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Expected O, but got Unknown
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e3: 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
				//IL_010c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0116: Expected O, but got Unknown
				//IL_0151: Unknown result type (might be due to invalid IL or missing references)
				//IL_0157: Expected O, but got Unknown
				//IL_0165: Unknown result type (might be due to invalid IL or missing references)
				//IL_016b: Expected O, but got Unknown
				CodeMatch[] array = (CodeMatch[])(object)new CodeMatch[2]
				{
					CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(UiManager), "GetPanel", (Type[])null, new Type[1] { typeof(MainMenuPanel) }))),
					CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(MainMenuPanel), "RefreshProfile", (Type[])null, (Type[])null)))
				};
				CodeMatcher val = new CodeMatcher(instructions, gen);
				val.MatchForward(false, array);
				Label label = val.Advance(array.Length).Labels[0];
				CodeInstruction val2 = new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(RunQuickstart), "HookCoLeave"));
				CodeInstructionExtensions.MoveLabelsTo(val.Advance(-array.Length).Instruction, val2);
				val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2]
				{
					val2,
					new CodeInstruction(OpCodes.Brtrue, (object)label)
				});
				val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
				{
					CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Leave, (object)null)),
					CodeMatch.op_Implicit(new CodeInstruction(OpCodes.Ret, (object)null))
				});
				Label label2 = default(Label);
				val.CreateLabel(ref label2);
				val.MatchBack(false, array);
				val.Insert((CodeInstruction[])(object)new CodeInstruction[2]
				{
					new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(RunQuickstart), "HookCoLeave")),
					new CodeInstruction(OpCodes.Brtrue, (object)label2)
				});
				return val.InstructionEnumeration();
			}
		}

		[HarmonyPatch(typeof(MainMenuPanel))]
		private class MainMenuPanel_Patches
		{
			[Serializable]
			[CompilerGenerated]
			private sealed class <>c
			{
				public static readonly <>c <>9 = new <>c();

				public static Action <>9__4_1;

				public static UnityAction <>9__4_0;

				internal void <PanelAwake>b__4_0()
				{
					UI.ConfirmationPopup("ResetGameWarning", delegate
					{
						ResetGameRun(CoMenuResetGameRun);
					});
				}

				internal void <PanelAwake>b__4_1()
				{
					ResetGameRun(CoMenuResetGameRun);
				}
			}

			[CompilerGenerated]
			private sealed class <>c__DisplayClass3_0
			{
				public GameResultPanel grPanel;

				internal bool <CoMenuResetGameRun>b__0()
				{
					return ((UiBase)grPanel).IsVisible;
				}
			}

			[CompilerGenerated]
			private sealed class <CoMenuResetGameRun>d__3 : IEnumerator<object>, IEnumerator, IDisposable
			{
				private int <>1__state;

				private object <>2__current;

				public GameRunSaveData save;

				object IEnumerator<object>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				object IEnumerator.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				[DebuggerHidden]
				public <CoMenuResetGameRun>d__3(int <>1__state)
				{
					this.<>1__state = <>1__state;
				}

				[DebuggerHidden]
				void IDisposable.Dispose()
				{
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					//IL_0046: Unknown result type (might be due to invalid IL or missing references)
					//IL_0050: Expected O, but got Unknown
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
					{
						<>1__state = -1;
						<>c__DisplayClass3_0 CS$<>8__locals0 = new <>c__DisplayClass3_0
						{
							grPanel = UiManager.GetPanel<GameResultPanel>()
						};
						GameMaster.RequestAbandonGameRun(false);
						<>2__current = (object)new WaitWhile((Func<bool>)(() => ((UiBase)CS$<>8__locals0.grPanel).IsVisible));
						<>1__state = 1;
						return true;
					}
					case 1:
					{
						<>1__state = -1;
						GameRunController val = NewRunFromSave(save);
						if (val != null)
						{
							<>2__current = Singleton<GameMaster>.Instance.CoNewGameRun(val);
							<>1__state = 2;
							return true;
						}
						break;
					}
					case 2:
						<>1__state = -1;
						break;
					}
					return false;
				}

				bool IEnumerator.MoveNext()
				{
					//ILSpy generated this explicit interface implementation from .override directive in MoveNext
					return this.MoveNext();
				}

				[DebuggerHidden]
				void IEnumerator.Reset()
				{
					throw new NotSupportedException();
				}
			}

			private static GameObject ResetGameObj;

			private static GameObject QuickStartGameObj;

			private static void QuickStartGameRun()
			{
				GameMaster instance = Singleton<GameMaster>.Instance;
				if (instance.CurrentGameRun != null)
				{
					BepinexPlugin.log.LogError((object)"(MainMenuPanel.QuickStartGameRun) Already in game-run");
					return;
				}
				GameRunController val = NewQuickStartRun();
				if (val != null)
				{
					((MonoBehaviour)instance).StartCoroutine(instance.CoNewGameRun(val));
				}
				else
				{
					GameMaster.ShowErrorDialogWithKey("CorruptedGameRunSaveData");
				}
			}

			[IteratorStateMachine(typeof(<CoMenuResetGameRun>d__3))]
			private static IEnumerator CoMenuResetGameRun(GameRunSaveData save)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <CoMenuResetGameRun>d__3(0)
				{
					save = save
				};
			}

			[HarmonyPatch("Awake")]
			[HarmonyPostfix]
			private static void PanelAwake(MainMenuPanel __instance)
			{
				//IL_013c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0141: Unknown result type (might be due to invalid IL or missing references)
				//IL_014b: 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_0157: 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_0166: Unknown result type (might be due to invalid IL or missing references)
				//IL_016b: Unknown result type (might be due to invalid IL or missing references)
				//IL_017d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0187: Expected O, but got Unknown
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: 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)
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: 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_0093: Unknown result type (might be due to invalid IL or missing references)
				//IL_009d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e0: 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_00eb: Expected O, but got Unknown
				Transform transform = ((Component)__instance.mainMenuButtonGroup).transform;
				if ((Object)null == (Object)(object)transform.Find("ResetGame"))
				{
					GameObject gameObject = ((Component)__instance.restoreGameButton).gameObject;
					Transform[] componentsInChildren = ((Component)transform).GetComponentsInChildren<Transform>(true);
					foreach (Transform val in componentsInChildren)
					{
						RectTransform component = ((Component)val).GetComponent<RectTransform>();
						if (!((Object)null != (Object)(object)component))
						{
							continue;
						}
						Vector2 offsetMin = component.offsetMin;
						Vector2 offsetMax = component.offsetMax;
						component.offsetMin += Vector2.up * 120f;
						component.offsetMax += Vector2.up * 120f;
						if (!(((Object)val).name == ((Object)gameObject).name))
						{
							continue;
						}
						object obj = <>c.<>9__4_0;
						if (obj == null)
						{
							UnityAction val2 = delegate
							{
								UI.ConfirmationPopup("ResetGameWarning", delegate
								{
									ResetGameRun(CoMenuResetGameRun);
								});
							};
							<>c.<>9__4_0 = val2;
							obj = (object)val2;
						}
						ResetGameObj = CreateButton(gameObject, transform, offsetMin, offsetMax, "ResetGame", positionBeforeOrig: false, (UnityAction)obj);
						break;
					}
				}
				if ((Object)null == (Object)(object)transform.Find("QuickStartGame"))
				{
					GameObject gameObject2 = ((Component)__instance.newGameButton).gameObject;
					RectTransform component2 = gameObject2.GetComponent<RectTransform>();
					if ((Object)null != (Object)(object)component2)
					{
						QuickStartGameObj = CreateButton(gameObject2, transform, component2.offsetMin + Vector2.up * 120f, component2.offsetMax + Vector2.up * 120f, "QuickStartGame", positionBeforeOrig: true, new UnityAction(QuickStartGameRun));
					}
				}
			}

			[HarmonyPatch("RefreshProfile")]
			[HarmonyPostfix]
			private static void PanelShow(MainMenuPanel __instance)
			{
				bool flag = Singleton<GameMaster>.Instance.GameRunSaveData != null;
				GameObject resetGameObj = ResetGameObj;
				if (resetGameObj != null)
				{
					resetGameObj.SetActive(flag);
				}
				GameObject quickStartGameObj = QuickStartGameObj;
				if (quickStartGameObj != null)
				{
					quickStartGameObj.SetActive(!flag);
				}
			}
		}

		[HarmonyPatch(typeof(SettingPanel))]
		private class SettingPanel_Patches
		{
			[Serializable]
			[CompilerGenerated]
			private sealed class <>c
			{
				public static readonly <>c <>9 = new <>c();

				public static Action <>9__2_1;

				public static UnityAction <>9__2_0;

				internal void <PanelAwake>b__2_0()
				{
					UI.ConfirmationPopup("ResetGameWarning", delegate
					{
						ResetGameRun(CoMidRunResetGameRun);
					});
				}

				internal void <PanelAwake>b__2_1()
				{
					ResetGameRun(CoMidRunResetGameRun);
				}
			}

			[CompilerGenerated]
			private sealed class <>c__DisplayClass1_0
			{
				public GameResultPanel grPanel;

				internal bool <CoMidRunResetGameRun>b__0()
				{
					return ((UiBase)grPanel).IsVisible;
				}
			}

			[CompilerGenerated]
			private sealed class <CoMidRunResetGameRun>d__1 : IEnumerator<object>, IEnumerator, IDisposable
			{
				private int <>1__state;

				private object <>2__current;

				public GameRunSaveData save;

				object IEnumerator<object>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				object IEnumerator.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				[DebuggerHidden]
				public <CoMidRunResetGameRun>d__1(int <>1__state)
				{
					this.<>1__state = <>1__state;
				}

				[DebuggerHidden]
				void IDisposable.Dispose()
				{
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
					//IL_01fc: Expected O, but got Unknown
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
					{
						<>1__state = -1;
						<>c__DisplayClass1_0 CS$<>8__locals0 = new <>c__DisplayClass1_0
						{
							grPanel = UiManager.GetPanel<GameResultPanel>()
						};
						GameMaster instance = Singleton<GameMaster>.Instance;
						GameDirector instance2 = Singleton<GameDirector>.Instance;
						GameRunController currentGameRun = instance.CurrentGameRun;
						GameSave = save;
						HookCoLeave = true;
						((MonoBehaviour)instance).StopAllCoroutines();
						((Unit)currentGameRun.Player).Hp = 0;
						((Unit)currentGameRun.Player).Status = (UnitStatus)2;
						currentGameRun.Status = (GameRunStatus)3;
						BattleController battle = currentGameRun.Battle;
						if (battle != null)
						{
							currentGameRun.LeaveBattle(battle.EnemyGroup);
							UiManager.LeaveBattle();
							instance2.LeaveBattle(battle);
						}
						else
						{
							currentGameRun.GenerateRecords(true, (EnemyGroup)null, (Adventure)null);
						}
						GameDirector.ClearDoremyEnvironment();
						((Component)UiManager.GetPanel<BattleManaPanel>()).gameObject.SetActive(false);
						((Component)UiManager.GetPanel<BossExhibitPanel>()).gameObject.SetActive(false);
						((Component)UiManager.GetPanel<CardDetailPanel>()).gameObject.SetActive(false);
						((Component)UiManager.GetPanel<ExhibitInfoPanel>()).gameObject.SetActive(false);
						((Component)UiManager.GetPanel<GapOptionsPanel>()).gameObject.SetActive(false);
						((Component)UiManager.GetPanel<HintPanel>()).gameObject.SetActive(false);
						((Component)UiManager.GetPanel<MapPanel>()).gameObject.SetActive(false);
						((Component)UiManager.GetPanel<NazrinDetectPanel>()).gameObject.SetActive(false);
						((Component)UiManager.GetPanel<PlayBoard>()).gameObject.SetActive(false);
						((Component)UiManager.GetPanel<PopupHud>()).gameObject.SetActive(false);
						((Component)UiManager.GetPanel<RewardPanel>()).gameObject.SetActive(false);
						((Component)UiManager.GetPanel<SelectCardPanel>()).gameObject.SetActive(false);
						((Component)UiManager.GetPanel<ShopPanel>()).gameObject.SetActive(false);
						((Component)UiManager.GetPanel<ShowCardsPanel>()).gameObject.SetActive(false);
						((Component)UiManager.GetPanel<SettingPanel>()).gameObject.SetActive(false);
						((Behaviour)UiManager.GetPanel<SystemBoard>().mapButton).enabled = false;
						((Component)UiManager.GetPanel<SpellPanel>()).gameObject.SetActive(false);
						((Component)UiManager.GetPanel<UltimateSkillPanel>()).gameObject.SetActive(false);
						((Component)UiManager.GetPanel<VnPanel>()).gameObject.SetActive(false);
						GameMaster.RequestAbandonGameRun(true);
						GameMaster.EndGameProcedure(currentGameRun);
						<>2__current = (object)new WaitWhile((Func<bool>)(() => ((UiBase)CS$<>8__locals0.grPanel).IsVisible));
						<>1__state = 1;
						return true;
					}
					case 1:
						<>1__state = -1;
						return false;
					}
				}

				bool IEnumerator.MoveNext()
				{
					//ILSpy generated this explicit interface implementation from .override directive in MoveNext
					return this.MoveNext();
				}

				[DebuggerHidden]
				void IEnumerator.Reset()
				{
					throw new NotSupportedException();
				}
			}

			public static Button ResetGameBtn;

			[IteratorStateMachine(typeof(<CoMidRunResetGameRun>d__1))]
			private static IEnumerator CoMidRunResetGameRun(GameRunSaveData save)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <CoMidRunResetGameRun>d__1(0)
				{
					save = save
				};
			}

			[HarmonyPatch("Awake")]
			[HarmonyPostfix]
			private static void PanelAwake(SettingPanel __instance)
			{
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Expected O, but got Unknown
				Transform transform = __instance.inGameGroup.gameObject.transform;
				if (!((Object)null == (Object)(object)transform.Find("ResetGame")))
				{
					return;
				}
				GameObject obj = Object.Instantiate<GameObject>(((Component)__instance.reenterStationButton).gameObject, transform);
				((Object)obj).name = "ResetGame";
				obj.transform.SetSiblingIndex(2);
				object obj2 = <>c.<>9__2_0;
				if (obj2 == null)
				{
					UnityAction val = delegate
					{
						UI.ConfirmationPopup("ResetGameWarning", delegate
						{
							ResetGameRun(CoMidRunResetGameRun);
						});
					};
					<>c.<>9__2_0 = val;
					obj2 = (object)val;
				}
				PostCreateButton(obj, "ResetGame", (UnityAction)obj2);
				ResetGameBtn = obj.GetComponent<Button>();
			}
		}

		private static bool HookCoLeave;

		private static GameRunSaveData GameSave;

		private static GameObject CreateButton(GameObject orig, Transform parent, Vector2 rtfOffMin, Vector2 rtfOffMax, string key, bool positionBeforeOrig, UnityAction call)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = Object.Instantiate<GameObject>(orig, parent);
			((Object)obj).name = key;
			obj.transform.SetSiblingIndex(orig.transform.GetSiblingIndex() + ((!positionBeforeOrig) ? 1 : 0));
			RectTransform component = ((Component)obj.transform).GetComponent<RectTransform>();
			if ((Object)null != (Object)(object)component)
			{
				component.offsetMin = rtfOffMin;
				component.offsetMax = rtfOffMax;
			}
			PostCreateButton(obj, key, call);
			return obj;
		}

		private static void PostCreateButton(GameObject btnObj, string key, UnityAction call)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			Button component = btnObj.GetComponent<Button>();
			component.onClick = new ButtonClickedEvent();
			((UnityEvent)component.onClick).AddListener(call);
			btnObj.GetComponentInChildren<LocalizedText>().key = "UI." + key;
		}

		private static IEnumerable<(string, string)> EnumerateLoadouts()
		{
			HashSet<(string, string)> hashSet = (from ply in Library.GetSelectablePlayers()
				where ply.Config.UnlockLevel.HasValue
				select ply).SelectMany((PlayerUnit ply) => new HashSet<(string, string)>
			{
				(((GameEntity)ply).Id, ply.Config.UltimateSkillA),
				(((GameEntity)ply).Id, ply.Config.UltimateSkillB)
			}).ToHashSet();
			if (BepinexPlugin.SideloaderAvailable)
			{
				hashSet.UnionWith(SideloaderWrapper.EnumerateLoadouts());
			}
			return hashSet;
		}

		private static bool TryCreateLoadout(string playerName, string usId, out PlayerUnit ply, out PlayerType plyType, out Exhibit startingExhibit, out IEnumerable<Card> startingDeck)
		{
			ply = null;
			plyType = (PlayerType)0;
			startingExhibit = null;
			startingDeck = null;
			PlayerUnit val = (from p in Library.GetSelectablePlayers()
				where ((GameEntity)p).Id == playerName
				select p).FirstOrDefault();
			if (val == null)
			{
				BepinexPlugin.log.LogError((object)("(RunQuickstart.TryCreateLoadout) could not create loadout: unknown player " + playerName));
				return false;
			}
			PlayerUnitConfig config = val.Config;
			ply = Library.CreatePlayerUnit(((object)val).GetType());
			UltimateSkill ultimateSkill = null;
			bool flag = config.UltimateSkillA == usId;
			bool flag2 = config.UltimateSkillB == usId;
			if (!flag && !flag2)
			{
				if (!BepinexPlugin.SideloaderAvailable || !SideloaderWrapper.TryGetLoadout(playerName, usId, out ultimateSkill, out startingExhibit, out startingDeck))
				{
					BepinexPlugin.log.LogError((object)("(RunQuickstart.TryCreateLoadout) loadout for " + playerName + " with Us " + usId + " not found"));
					return false;
				}
			}
			else
			{
				plyType = (PlayerType)((!flag) ? 1 : 0);
				ultimateSkill = Library.CreateUs(flag ? config.UltimateSkillA : config.UltimateSkillB);
				startingExhibit = Library.CreateExhibit(flag ? config.ExhibitA : config.ExhibitB);
				startingDeck = (flag ? config.DeckA : config.DeckB).Select((string c) => Library.CreateCard(c));
			}
			ply.SetUs(ultimateSkill);
			return true;
		}

		private static GameRunController NewQuickStartRun()
		{
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: 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_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: 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_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: 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_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Expected O, but got Unknown
			if (!Profile.TryGetLastRunInHistory(out var record))
			{
				BepinexPlugin.log.LogError((object)"(RunQuickstart.NewQuickStartRun) could not start game run - could not get last run from profile");
				UiManager.GetPanel<MainMenuPanel>().RefreshProfile();
				return null;
			}
			try
			{
				string playerName = record.Player;
				string usId = record.Us;
				QuickStartMode value = BepinexPlugin.QuickStartBehaviour.Value;
				if (value != 0 && value == QuickStartMode.Random)
				{
					List<(string, string)> list = EnumerateLoadouts().ToList();
					Random random = new Random();
					(playerName, usId) = list[random.Next(0, list.Count)];
				}
				if (!TryCreateLoadout(playerName, usId, out var ply, out var plyType, out var startingExhibit, out var startingDeck))
				{
					BepinexPlugin.log.LogError((object)"(RunQuickstart.NewQuickStartRun) could not start game run - loadout creation failed");
					UiManager.GetPanel<MainMenuPanel>().RefreshProfile();
					return null;
				}
				GameMaster instance = Singleton<GameMaster>.Instance;
				ProfileSaveData currentProfile = instance.CurrentProfile;
				if (currentProfile == null)
				{
					BepinexPlugin.log.LogError((object)"(RunQuickstart.NewQuickStartRun) could not start game run - no profile selected");
					UiManager.GetPanel<MainMenuPanel>().RefreshProfile();
					return null;
				}
				IEnumerable<JadeBox> jadeBoxes = record.JadeBoxes.Select((string j) => Library.CreateJadeBox(j));
				StartGameData defaultMode = MainMenuPanel.DefaultMode;
				return GameRunController.Create(new GameRunStartupParameters
				{
					Mode = (GameMode)1,
					ShowRandomResult = GameMaster.DefaultShowRandomResult,
					Seed = (record.IsAutoSeed ? null : new ulong?(record.Seed)),
					Difficulty = record.Difficulty,
					Puzzles = record.Puzzles,
					Player = ply,
					PlayerType = plyType,
					InitExhibit = startingExhibit,
					InitMoneyOverride = null,
					Deck = startingDeck,
					Stages = defaultMode.StagesCreateFunc(),
					DebutAdventureType = defaultMode.DebutAdventure,
					UserProfile = currentProfile,
					UnlockLevel = instance.CurrentProfileLevel,
					JadeBoxes = jadeBoxes
				});
			}
			catch (Exception arg)
			{
				BepinexPlugin.log.LogError((object)$"(RunQuickstart.NewQuickStartRun) could not start game run:\n{arg}");
				UiManager.GetPanel<MainMenuPanel>().RefreshProfile();
				return null;
			}
		}

		private static GameRunController NewRunFromSave(GameRunSaveData save)
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: 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_0122: 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_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Expected O, but got Unknown
			string name = save.Player.Name;
			string us = save.Player.Us;
			try
			{
				if (!TryCreateLoadout(name, us, out var ply, out var plyType, out var startingExhibit, out var startingDeck))
				{
					BepinexPlugin.log.LogError((object)"(RunQuickstart.NewRunFromSave) could not start game run - loadout creation failed");
					UiManager.GetPanel<MainMenuPanel>().RefreshProfile();
					return null;
				}
				IEnumerable<JadeBox> jadeBoxes = save.JadeBoxes.Select((JadeBoxSaveData j) => Library.CreateJadeBox(j.Name));
				ulong? seed = null;
				if (!save.IsAutoSeed)
				{
					seed = save.RootSeed;
				}
				StartGameData defaultMode = MainMenuPanel.DefaultMode;
				GameMaster instance = Singleton<GameMaster>.Instance;
				ProfileSaveData currentProfile = instance.CurrentProfile;
				if (currentProfile == null)
				{
					BepinexPlugin.log.LogError((object)"(RunQuickstart.NewRunFromSave) could not start game run - no profile selected");
					UiManager.GetPanel<MainMenuPanel>().RefreshProfile();
					return null;
				}
				return GameRunController.Create(new GameRunStartupParameters
				{
					Mode = save.Mode,
					ShowRandomResult = save.ShowRandomResult,
					Seed = seed,
					Difficulty = save.Difficulty,
					Puzzles = save.Puzzles,
					Player = ply,
					PlayerType = plyType,
					InitExhibit = startingExhibit,
					InitMoneyOverride = null,
					Deck = startingDeck,
					Stages = defaultMode.StagesCreateFunc(),
					DebutAdventureType = defaultMode.DebutAdventure,
					UserProfile = currentProfile,
					UnlockLevel = instance.CurrentProfileLevel,
					JadeBoxes = jadeBoxes
				});
			}
			catch (Exception arg)
			{
				BepinexPlugin.log.LogError((object)$"(RunQuickstart.NewRunFromSave) could not start game run:\n{arg}");
				UiManager.GetPanel<MainMenuPanel>().RefreshProfile();
				return null;
			}
		}

		private static void ResetGameRun(Func<GameRunSaveData, IEnumerator> coro)
		{
			GameMaster instance = Singleton<GameMaster>.Instance;
			GameRunSaveData gameRunSaveData = instance.GameRunSaveData;
			if (gameRunSaveData != null)
			{
				((MonoBehaviour)instance).StartCoroutine(coro(gameRunSaveData));
			}
			else
			{
				GameMaster.ShowErrorDialogWithKey("CorruptedGameRunSaveData");
			}
		}
	}
	[HarmonyPatch(typeof(StartGamePanel))]
	public static class StartGameUI
	{
		[HarmonyPatch("RefreshConfirm")]
		[HarmonyPostfix]
		private static void UnlockCharacter(StartGamePanel __instance)
		{
			if (__instance._playerIndex >= 0 && __instance._playerIndex <= __instance._players.Count && __instance._players[__instance._playerIndex].Config.UnlockLevel.HasValue)
			{
				__instance.characterHintRoot.gameObject.SetActive(false);
				((TMP_Text)__instance.characterHint).text = "";
				((Selectable)__instance.characterConfirmButton).interactable = true;
			}
		}

		[HarmonyPatch("RefreshDifficultyConfirm")]
		[HarmonyPostfix]
		private static void UnlockDifficulty(StartGamePanel __instance)
		{
			if (!__instance.gameModeSwitch.IsOn)
			{
				__instance.difficultyGroups[__instance._difficultyIndex].SetLocked(false);
				__instance._isDifficultyLock = false;
				((Selectable)__instance.difficultyConfirmButton).interactable = true;
				__instance._confirmTooltip.SetDirect("", (string)null);
			}
		}

		[HarmonyPatch("SetPuzzleStatus")]
		[HarmonyPostfix]
		private static void UnlockRequests(StartGamePanel __instance)
		{
			for (int i = 0; i < PuzzleFlags.AllPuzzleFlags.Count; i++)
			{
				foreach (PuzzleToggleWidget value in __instance._puzzleToggles.Values)
				{
					value.IsLock = false;
				}
			}
			__instance.puzzleSelectAllGroup.SetActive(true);
		}

		[HarmonyPatch("SetJadeBoxStatus")]
		[HarmonyPostfix]
		private static void UnlockJadeboxes(StartGamePanel __instance)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			((Selectable)__instance.jadeBoxButton).interactable = true;
			((Behaviour)__instance._jadeBoxTooltip).enabled = false;
			((Component)__instance.jadeBoxLockImage).gameObject.SetActive(false);
			((Graphic)__instance.jadeBoxText).color = Color.white;
		}
	}
}
namespace Companion.Config
{
	public enum QuickStartMode
	{
		LastRun,
		Random
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}