Decompiled source of ChallengeCreator v1.0.4

plugins/com.atomic.challengecreator.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ChallengeCreator.Networking;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Peak.Afflictions;
using Photon.Pun;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.atomic.challengecreator")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.4+382f5d3d84be95d9fbde134d924483b4ac27d48b")]
[assembly: AssemblyProduct("com.atomic.challengecreator")]
[assembly: AssemblyTitle("ChallengeCreator")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.4.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace ChallengeCreator
{
	public class ChallengeBrowser : MonoBehaviour
	{
		[Serializable]
		public class ChallengeEntry
		{
			public string id;

			public CurrentChallenge config;

			public string DisplayName => config?.Name ?? "Unnamed";

			public string DisplayCreators => config?.Creators ?? "Unknown";

			public string DisplayNotes => config?.Notes ?? "";

			public string ShortId => id;
		}

		[Serializable]
		public class SupabaseResponse
		{
			public string id;

			public CurrentChallenge config;
		}

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

			private object <>2__current;

			public ChallengeBrowser <>4__this;

			private GameObject <loadingText>5__2;

			private UnityWebRequest <request>5__3;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<loadingText>5__2 = null;
				<request>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dd: Invalid comparison between Unknown and I4
				bool result;
				try
				{
					int num = <>1__state;
					ChallengeBrowser challengeBrowser = <>4__this;
					switch (num)
					{
					default:
						result = false;
						break;
					case 0:
					{
						<>1__state = -1;
						if ((Object)(object)challengeBrowser.contentContainer == (Object)null)
						{
							result = false;
							break;
						}
						challengeBrowser.ClearContentContainer();
						<loadingText>5__2 = challengeBrowser.CreateLoadingText();
						string text = "https://dujpxiwctslbpcziquqr.supabase.co/rest/v1/challenges?select=id,config&limit=100";
						<request>5__3 = UnityWebRequest.Get(text);
						<>1__state = -3;
						<request>5__3.SetRequestHeader("apikey", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImR1anB4aXdjdHNsYnBjemlxdXFyIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzA1MzkzMjIsImV4cCI6MjA4NjExNTMyMn0.FKJ3Mei_i3psMBkWbrZ11HwMuNl2h6-wEFloYGRkOnw");
						<request>5__3.SetRequestHeader("Authorization", "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImR1anB4aXdjdHNsYnBjemlxdXFyIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzA1MzkzMjIsImV4cCI6MjA4NjExNTMyMn0.FKJ3Mei_i3psMBkWbrZ11HwMuNl2h6-wEFloYGRkOnw");
						<>2__current = <request>5__3.SendWebRequest();
						<>1__state = 1;
						result = true;
						break;
					}
					case 1:
						<>1__state = -3;
						if ((Object)(object)<loadingText>5__2 != (Object)null)
						{
							Object.DestroyImmediate((Object)(object)<loadingText>5__2);
						}
						if ((int)<request>5__3.result != 1)
						{
							challengeBrowser.ShowErrorMessage("Failed to load challenges: " + <request>5__3.error);
							result = false;
							<>m__Finally1();
							break;
						}
						try
						{
							List<SupabaseResponse> list = JsonConvert.DeserializeObject<List<SupabaseResponse>>(<request>5__3.downloadHandler.text);
							if (list != null)
							{
								challengeBrowser.allChallenges.Clear();
								foreach (SupabaseResponse item in list)
								{
									if (item.config != null)
									{
										challengeBrowser.allChallenges.Add(new ChallengeEntry
										{
											id = item.id,
											config = item.config
										});
									}
								}
								challengeBrowser.filteredChallenges = new List<ChallengeEntry>(challengeBrowser.allChallenges);
								challengeBrowser.RefreshChallengeList();
							}
						}
						catch (Exception ex)
						{
							challengeBrowser.ShowErrorMessage("Error parsing challenge data: " + ex.Message);
						}
						<>m__Finally1();
						<request>5__3 = null;
						result = false;
						break;
					}
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
				return result;
			}

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

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<request>5__3 != null)
				{
					((IDisposable)<request>5__3).Dispose();
				}
			}

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

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

			private object <>2__current;

			public ChallengeBrowser <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				int num = <>1__state;
				ChallengeBrowser challengeBrowser = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 4;
					return true;
				case 4:
					<>1__state = -1;
					if ((Object)(object)challengeBrowser.contentContainer == (Object)null)
					{
						if ((Object)(object)challengeBrowser.mainPanel != (Object)null)
						{
							Transform val = challengeBrowser.mainPanel.transform.Find("ContentArea/Viewport/Content");
							if ((Object)(object)val != (Object)null)
							{
								challengeBrowser.contentContainer = val;
							}
						}
						if ((Object)(object)challengeBrowser.contentContainer == (Object)null)
						{
							return false;
						}
					}
					((MonoBehaviour)challengeBrowser).StartCoroutine(challengeBrowser.FetchChallenges());
					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();
			}
		}

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

			private object <>2__current;

			public GameObject entryObj;

			public ChallengeBrowser <>4__this;

			public ChallengeEntry entry;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0119: Unknown result type (might be due to invalid IL or missing references)
				//IL_011f: Expected O, but got Unknown
				//IL_014a: 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_0176: 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_01b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ca: Expected O, but got Unknown
				//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0208: Unknown result type (might be due to invalid IL or missing references)
				//IL_0214: Unknown result type (might be due to invalid IL or missing references)
				//IL_0220: Unknown result type (might be due to invalid IL or missing references)
				//IL_025c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0263: Expected O, but got Unknown
				//IL_0282: Unknown result type (might be due to invalid IL or missing references)
				//IL_028e: Unknown result type (might be due to invalid IL or missing references)
				//IL_029a: Unknown result type (might be due to invalid IL or missing references)
				//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_02cf: 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_02f6: Expected O, but got Unknown
				//IL_031f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0335: Unknown result type (might be due to invalid IL or missing references)
				//IL_034b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0357: Unknown result type (might be due to invalid IL or missing references)
				//IL_036d: Unknown result type (might be due to invalid IL or missing references)
				//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b8: Expected O, but got Unknown
				//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e7: Expected O, but got Unknown
				//IL_0410: Unknown result type (might be due to invalid IL or missing references)
				//IL_0426: Unknown result type (might be due to invalid IL or missing references)
				//IL_043c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0448: Unknown result type (might be due to invalid IL or missing references)
				//IL_045e: Unknown result type (might be due to invalid IL or missing references)
				//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				ChallengeBrowser challengeBrowser = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					LayoutElement component = entryObj.GetComponent<LayoutElement>();
					if ((Object)(object)challengeBrowser.currentExpandedEntry == (Object)(object)entryObj)
					{
						Transform val = entryObj.transform.Find("ExpandedContent");
						if ((Object)(object)val != (Object)null)
						{
							Object.DestroyImmediate((Object)(object)((Component)val).gameObject);
						}
						component.preferredHeight = 130f;
						challengeBrowser.currentExpandedEntry = null;
						return false;
					}
					if ((Object)(object)challengeBrowser.currentExpandedEntry != (Object)null)
					{
						Transform val2 = challengeBrowser.currentExpandedEntry.transform.Find("StaticHeader/ButtonsArea/Button_Expand");
						if ((Object)(object)val2 != (Object)null)
						{
							TextMeshProUGUI componentInChildren = ((Component)val2).GetComponentInChildren<TextMeshProUGUI>();
							if ((Object)(object)componentInChildren != (Object)null)
							{
								((TMP_Text)componentInChildren).text = "Expand";
							}
						}
						Transform val3 = challengeBrowser.currentExpandedEntry.transform.Find("ExpandedContent");
						if ((Object)(object)val3 != (Object)null)
						{
							Object.DestroyImmediate((Object)(object)((Component)val3).gameObject);
						}
						challengeBrowser.currentExpandedEntry.GetComponent<LayoutElement>().preferredHeight = 130f;
					}
					GameObject val4 = new GameObject("ExpandedContent");
					val4.transform.SetParent(entryObj.transform, false);
					RectTransform val5 = val4.AddComponent<RectTransform>();
					val5.anchorMin = new Vector2(0f, 0f);
					val5.anchorMax = new Vector2(1f, 0f);
					val5.pivot = new Vector2(0.5f, 0f);
					val5.sizeDelta = new Vector2(0f, 350f);
					Image val6 = val4.AddComponent<Image>();
					((Graphic)val6).color = new Color(0f, 0f, 0f, 0.4f);
					GameObject val7 = new GameObject("ScrollView");
					val7.transform.SetParent(val4.transform, false);
					RectTransform val8 = val7.AddComponent<RectTransform>();
					val8.anchorMin = new Vector2(0.02f, 0.02f);
					val8.anchorMax = new Vector2(0.98f, 0.98f);
					val8.offsetMin = Vector2.zero;
					val8.offsetMax = Vector2.zero;
					ScrollRect val9 = val7.AddComponent<ScrollRect>();
					val9.horizontal = false;
					val9.vertical = true;
					val9.movementType = (MovementType)2;
					val9.scrollSensitivity = 20f;
					GameObject val10 = new GameObject("Viewport");
					val10.transform.SetParent(val7.transform, false);
					RectTransform val11 = val10.AddComponent<RectTransform>();
					val11.anchorMin = Vector2.zero;
					val11.anchorMax = Vector2.one;
					val11.offsetMin = Vector2.zero;
					val11.offsetMax = Vector2.zero;
					Image val12 = val10.AddComponent<Image>();
					((Graphic)val12).color = new Color(0f, 0f, 0f, 0.25f);
					Mask val13 = val10.AddComponent<Mask>();
					val13.showMaskGraphic = false;
					GameObject val14 = new GameObject("Content");
					val14.transform.SetParent(val10.transform, false);
					RectTransform val15 = val14.AddComponent<RectTransform>();
					val15.anchorMin = new Vector2(0f, 1f);
					val15.anchorMax = new Vector2(1f, 1f);
					val15.pivot = new Vector2(0.5f, 1f);
					val15.anchoredPosition = Vector2.zero;
					val15.sizeDelta = new Vector2(0f, 0f);
					VerticalLayoutGroup val16 = val14.AddComponent<VerticalLayoutGroup>();
					((HorizontalOrVerticalLayoutGroup)val16).childForceExpandWidth = true;
					((HorizontalOrVerticalLayoutGroup)val16).childControlWidth = true;
					((HorizontalOrVerticalLayoutGroup)val16).childControlHeight = true;
					((HorizontalOrVerticalLayoutGroup)val16).spacing = 0f;
					((LayoutGroup)val16).padding = new RectOffset(10, 10, 10, 10);
					ContentSizeFitter val17 = val14.AddComponent<ContentSizeFitter>();
					val17.verticalFit = (FitMode)2;
					val9.viewport = val11;
					val9.content = val15;
					GameObject val18 = new GameObject("ConfigText");
					val18.transform.SetParent(val14.transform, false);
					RectTransform val19 = val18.AddComponent<RectTransform>();
					val19.anchorMin = new Vector2(0f, 1f);
					val19.anchorMax = new Vector2(1f, 1f);
					val19.pivot = new Vector2(0.5f, 1f);
					val19.anchoredPosition = Vector2.zero;
					val19.sizeDelta = new Vector2(0f, 0f);
					TextMeshProUGUI val20 = val18.AddComponent<TextMeshProUGUI>();
					((TMP_Text)val20).text = JsonConvert.SerializeObject((object)entry.config, (Formatting)1);
					((TMP_Text)val20).fontSize = 12f;
					((TMP_Text)val20).alignment = (TextAlignmentOptions)257;
					((TMP_Text)val20).fontStyle = (FontStyles)0;
					((TMP_Text)val20).enableWordWrapping = true;
					((TMP_Text)val20).overflowMode = (TextOverflowModes)0;
					((Graphic)val20).color = Color.white;
					if ((Object)(object)UIUtils.gameFont != (Object)null)
					{
						((TMP_Text)val20).font = UIUtils.gameFont;
					}
					LayoutElement val21 = val18.AddComponent<LayoutElement>();
					val21.flexibleWidth = 1f;
					ContentSizeFitter val22 = val18.AddComponent<ContentSizeFitter>();
					val22.verticalFit = (FitMode)2;
					Canvas.ForceUpdateCanvases();
					LayoutRebuilder.ForceRebuildLayoutImmediate(val15);
					component.preferredHeight = 480f;
					challengeBrowser.currentExpandedEntry = entryObj;
					<>2__current = null;
					<>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();
			}
		}

		private const string SUPABASE_URL = "https://dujpxiwctslbpcziquqr.supabase.co/rest/v1/challenges";

		private const string ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImR1anB4aXdjdHNsYnBjemlxdXFyIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzA1MzkzMjIsImV4cCI6MjA4NjExNTMyMn0.FKJ3Mei_i3psMBkWbrZ11HwMuNl2h6-wEFloYGRkOnw";

		private GameObject mainCanvas;

		private GameObject backgroundOverlay;

		private GameObject mainPanel;

		private GameObject contentArea;

		private TMP_InputField searchInput;

		private ScrollRect scrollRect;

		private Transform contentContainer;

		private Material cellMaterial;

		private bool isInitialized;

		private List<ChallengeEntry> allChallenges = new List<ChallengeEntry>();

		private List<ChallengeEntry> filteredChallenges = new List<ChallengeEntry>();

		private List<GameObject> entryObjects = new List<GameObject>();

		private GameObject currentExpandedEntry;

		private MainMenu cachedMainMenu;

		private void Awake()
		{
		}

		public void Show(MainMenu mainMenu)
		{
			cachedMainMenu = mainMenu;
			if ((Object)(object)mainCanvas != (Object)null)
			{
				mainCanvas.SetActive(true);
				if (!isInitialized)
				{
					((MonoBehaviour)this).StartCoroutine(FetchChallenges());
				}
			}
			else
			{
				CreateUI();
				((MonoBehaviour)this).StartCoroutine(FetchChallengesDelayed());
			}
		}

		[IteratorStateMachine(typeof(<FetchChallengesDelayed>d__20))]
		private IEnumerator FetchChallengesDelayed()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <FetchChallengesDelayed>d__20(0)
			{
				<>4__this = this
			};
		}

		public void Hide()
		{
			if ((Object)(object)mainCanvas != (Object)null)
			{
				mainCanvas.SetActive(false);
			}
			if ((Object)(object)cachedMainMenu != (Object)null)
			{
				Transform val = ((Component)cachedMainMenu).transform.Find("Canvas/MainPage");
				if ((Object)(object)val != (Object)null)
				{
					((Component)val).gameObject.SetActive(true);
				}
			}
		}

		private void CreateUI()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_006e: 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_009a: Expected O, but got Unknown
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Expected O, but got Unknown
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: 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_01a6: Unknown result type (might be due to invalid IL or missing references)
			mainCanvas = new GameObject("ChallengeBrowser");
			mainCanvas.transform.SetParent(((Component)this).transform);
			Canvas val = mainCanvas.AddComponent<Canvas>();
			CanvasScaler val2 = mainCanvas.AddComponent<CanvasScaler>();
			GraphicRaycaster val3 = mainCanvas.AddComponent<GraphicRaycaster>();
			val.renderMode = (RenderMode)0;
			val.sortingOrder = 200;
			val2.uiScaleMode = (ScaleMode)1;
			val2.referenceResolution = new Vector2(1920f, 1080f);
			val2.screenMatchMode = (ScreenMatchMode)0;
			val2.matchWidthOrHeight = 0.5f;
			backgroundOverlay = new GameObject("BackgroundOverlay");
			backgroundOverlay.transform.SetParent(mainCanvas.transform, false);
			Image val4 = backgroundOverlay.AddComponent<Image>();
			((Graphic)val4).color = new Color(0f, 0f, 0f, 0.87f);
			RectTransform component = backgroundOverlay.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.sizeDelta = Vector2.zero;
			mainPanel = new GameObject("MainPanel");
			mainPanel.transform.SetParent(mainCanvas.transform, false);
			RectTransform val5 = mainPanel.AddComponent<RectTransform>();
			val5.anchorMin = new Vector2(0.05f, 0.05f);
			val5.anchorMax = new Vector2(0.95f, 0.95f);
			val5.sizeDelta = Vector2.zero;
			Image val6 = mainPanel.AddComponent<Image>();
			((Graphic)val6).color = new Color(0.1792f, 0.1253f, 0.0905f, 0.7294f);
			LoadCellMaterial();
			if ((Object)(object)cellMaterial != (Object)null)
			{
				((Graphic)val6).material = cellMaterial;
			}
			CreateSearchBar();
			CreateContentArea();
			CreateBottomLink();
			CreateCloseButton();
			isInitialized = true;
		}

		private void LoadCellMaterial()
		{
			try
			{
				GameObject val = GameObject.Find("MainMenu/Canvas/SettingsPage");
				if (!((Object)(object)val != (Object)null))
				{
					return;
				}
				Transform val2 = val.transform.Find("SettingsPageShared/Content/Parent/SettingsCell(Clone)");
				if ((Object)(object)val2 != (Object)null)
				{
					Image component = ((Component)val2).GetComponent<Image>();
					if ((Object)(object)component != (Object)null && (Object)(object)((Graphic)component).material != (Object)null)
					{
						cellMaterial = Object.Instantiate<Material>(((Graphic)component).material);
					}
				}
			}
			catch (Exception)
			{
			}
		}

		private void CreateSearchBar()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("SearchBar");
			val.transform.SetParent(mainPanel.transform, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchorMin = new Vector2(0.02f, 0.92f);
			val2.anchorMax = new Vector2(0.98f, 0.98f);
			val2.sizeDelta = Vector2.zero;
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = new Color(0.2f, 0.16f, 0.13f, 0.9f);
			searchInput = val.AddComponent<TMP_InputField>();
			GameObject val4 = new GameObject("TextArea");
			val4.transform.SetParent(val.transform, false);
			RectTransform val5 = val4.AddComponent<RectTransform>();
			val5.anchorMin = Vector2.zero;
			val5.anchorMax = Vector2.one;
			val5.sizeDelta = Vector2.zero;
			searchInput.textComponent = (TMP_Text)(object)CreateInputText(val4.transform);
			searchInput.placeholder = (Graphic)(object)CreatePlaceholderText(val4.transform);
			((UnityEvent<string>)(object)searchInput.onValueChanged).AddListener((UnityAction<string>)OnSearchChanged);
		}

		private TextMeshProUGUI CreateInputText(Transform parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Text");
			val.transform.SetParent(parent, false);
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val2).fontSize = 20f;
			((Graphic)val2).color = Color.white;
			((TMP_Text)val2).alignment = (TextAlignmentOptions)513;
			((TMP_Text)val2).fontStyle = (FontStyles)0;
			if ((Object)(object)UIUtils.gameFont != (Object)null)
			{
				((TMP_Text)val2).font = UIUtils.gameFont;
			}
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = new Vector2(15f, 5f);
			component.offsetMax = new Vector2(-15f, -5f);
			return val2;
		}

		private TextMeshProUGUI CreatePlaceholderText(Transform parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0045: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Placeholder");
			val.transform.SetParent(parent, false);
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val2).text = "Search by name or shortcode...";
			((TMP_Text)val2).fontSize = 20f;
			((Graphic)val2).color = new Color(0.7f, 0.7f, 0.7f);
			((TMP_Text)val2).alignment = (TextAlignmentOptions)513;
			((TMP_Text)val2).fontStyle = (FontStyles)0;
			if ((Object)(object)UIUtils.gameFont != (Object)null)
			{
				((TMP_Text)val2).font = UIUtils.gameFont;
			}
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = new Vector2(15f, 5f);
			component.offsetMax = new Vector2(-15f, -5f);
			return val2;
		}

		private void CreateContentArea()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0043: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: 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_0152: Expected O, but got Unknown
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Expected O, but got Unknown
			contentArea = new GameObject("ContentArea");
			contentArea.transform.SetParent(mainPanel.transform, false);
			RectTransform val = contentArea.AddComponent<RectTransform>();
			val.anchorMin = new Vector2(0.02f, 0.08f);
			val.anchorMax = new Vector2(0.98f, 0.9f);
			val.sizeDelta = Vector2.zero;
			scrollRect = contentArea.AddComponent<ScrollRect>();
			scrollRect.horizontal = false;
			scrollRect.vertical = true;
			scrollRect.movementType = (MovementType)1;
			scrollRect.inertia = true;
			scrollRect.scrollSensitivity = 20f;
			GameObject val2 = new GameObject("Viewport");
			val2.transform.SetParent(contentArea.transform, false);
			RectTransform val3 = val2.AddComponent<RectTransform>();
			val3.anchorMin = Vector2.zero;
			val3.anchorMax = Vector2.one;
			val3.sizeDelta = Vector2.zero;
			Mask val4 = val2.AddComponent<Mask>();
			val4.showMaskGraphic = false;
			Image val5 = val2.AddComponent<Image>();
			((Graphic)val5).color = new Color(0f, 0f, 0f, 0.3f);
			((Graphic)val5).raycastTarget = false;
			GameObject val6 = new GameObject("Content");
			val6.transform.SetParent(val2.transform, false);
			contentContainer = val6.transform;
			RectTransform val7 = val6.AddComponent<RectTransform>();
			val7.anchorMin = new Vector2(0f, 1f);
			val7.anchorMax = new Vector2(1f, 1f);
			val7.pivot = new Vector2(0.5f, 1f);
			val7.anchoredPosition = Vector2.zero;
			val7.sizeDelta = new Vector2(0f, 0f);
			VerticalLayoutGroup val8 = val6.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)val8).padding = new RectOffset(20, 20, 20, 20);
			((HorizontalOrVerticalLayoutGroup)val8).spacing = 15f;
			((LayoutGroup)val8).childAlignment = (TextAnchor)1;
			((HorizontalOrVerticalLayoutGroup)val8).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)val8).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)val8).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)val8).childForceExpandHeight = false;
			ContentSizeFitter val9 = val6.AddComponent<ContentSizeFitter>();
			val9.verticalFit = (FitMode)2;
			val9.horizontalFit = (FitMode)0;
			scrollRect.viewport = val3;
			scrollRect.content = val7;
		}

		private void CreateBottomLink()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("BottomLink");
			val.transform.SetParent(mainPanel.transform, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchorMin = new Vector2(0.02f, 0.01f);
			val2.anchorMax = new Vector2(0.98f, 0.07f);
			val2.sizeDelta = Vector2.zero;
			HorizontalLayoutGroup val3 = val.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)val3).childAlignment = (TextAnchor)4;
			((HorizontalOrVerticalLayoutGroup)val3).spacing = 8f;
			((LayoutGroup)val3).padding = new RectOffset(10, 10, 10, 10);
			((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = true;
			TextMeshProUGUI val4 = CreateText("Want to know how to upload challenges? Go to:", 14, (FontStyles)0);
			((TMP_Text)val4).transform.SetParent(val.transform, false);
			((Graphic)val4).color = new Color(0.8f, 0.8f, 0.8f);
			LayoutElement val5 = ((Component)val4).gameObject.AddComponent<LayoutElement>();
			val5.minWidth = 300f;
			GameObject val6 = CreateLinkButton("atomictyler.dev/#peakPresets");
			val6.transform.SetParent(val.transform, false);
			LayoutElement val7 = val6.AddComponent<LayoutElement>();
			val7.minWidth = 200f;
		}

		private GameObject CreateLinkButton(string url)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("LinkButton");
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val2).text = url;
			((TMP_Text)val2).fontSize = 14f;
			((TMP_Text)val2).fontStyle = (FontStyles)0;
			((Graphic)val2).color = new Color(0.4f, 0.8f, 1f);
			((TMP_Text)val2).textWrappingMode = (TextWrappingModes)1;
			if ((Object)(object)UIUtils.gameFont != (Object)null)
			{
				((TMP_Text)val2).font = UIUtils.gameFont;
			}
			return val;
		}

		private GameObject CreateCloseButton()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("CloseButton");
			val.transform.SetParent(mainPanel.transform, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchorMin = new Vector2(0.98f, 0.98f);
			val2.anchorMax = new Vector2(0.99f, 0.99f);
			val2.sizeDelta = new Vector2(40f, 40f);
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = new Color(0.4f, 0.3f, 0.25f);
			Button val4 = val.AddComponent<Button>();
			((UnityEvent)val4.onClick).AddListener(new UnityAction(Hide));
			GameObject val5 = new GameObject("X");
			val5.transform.SetParent(val.transform, false);
			TextMeshProUGUI val6 = val5.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val6).text = "X";
			((TMP_Text)val6).fontSize = 24f;
			((TMP_Text)val6).alignment = (TextAlignmentOptions)514;
			((Graphic)val6).color = Color.white;
			((TMP_Text)val6).fontStyle = (FontStyles)0;
			if ((Object)(object)UIUtils.gameFont != (Object)null)
			{
				((TMP_Text)val6).font = UIUtils.gameFont;
			}
			RectTransform component = val5.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.sizeDelta = Vector2.zero;
			return val;
		}

		[IteratorStateMachine(typeof(<FetchChallenges>d__31))]
		private IEnumerator FetchChallenges()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <FetchChallenges>d__31(0)
			{
				<>4__this = this
			};
		}

		private void ClearContentContainer()
		{
			if ((Object)(object)contentContainer == (Object)null)
			{
				return;
			}
			foreach (GameObject entryObject in entryObjects)
			{
				if ((Object)(object)entryObject != (Object)null)
				{
					Object.DestroyImmediate((Object)(object)entryObject);
				}
			}
			entryObjects.Clear();
			for (int num = contentContainer.childCount - 1; num >= 0; num--)
			{
				if ((Object)(object)contentContainer.GetChild(num) != (Object)null)
				{
					Object.DestroyImmediate((Object)(object)((Component)contentContainer.GetChild(num)).gameObject);
				}
			}
		}

		private GameObject CreateLoadingText()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)contentContainer == (Object)null)
			{
				return null;
			}
			GameObject val = new GameObject("LoadingText");
			val.transform.SetParent(contentContainer, false);
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val2).text = "Loading challenges...";
			((TMP_Text)val2).fontSize = 24f;
			((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
			((Graphic)val2).color = Color.white;
			((TMP_Text)val2).fontStyle = (FontStyles)0;
			if ((Object)(object)UIUtils.gameFont != (Object)null)
			{
				((TMP_Text)val2).font = UIUtils.gameFont;
			}
			return val;
		}

		private void ShowErrorMessage(string message)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)contentContainer == (Object)null))
			{
				GameObject val = new GameObject("ErrorText");
				val.transform.SetParent(contentContainer, false);
				TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
				((TMP_Text)val2).text = message;
				((TMP_Text)val2).fontSize = 20f;
				((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
				((Graphic)val2).color = new Color(1f, 0.5f, 0.5f);
				((TMP_Text)val2).fontStyle = (FontStyles)0;
				if ((Object)(object)UIUtils.gameFont != (Object)null)
				{
					((TMP_Text)val2).font = UIUtils.gameFont;
				}
			}
		}

		private void OnSearchChanged(string searchText)
		{
			if (string.IsNullOrWhiteSpace(searchText))
			{
				filteredChallenges = new List<ChallengeEntry>(allChallenges);
			}
			else
			{
				string lowerSearch = searchText.ToLower();
				filteredChallenges = allChallenges.Where((ChallengeEntry c) => c.DisplayName.ToLower().Contains(lowerSearch) || c.ShortId.ToLower().Contains(lowerSearch)).ToList();
			}
			RefreshChallengeList();
		}

		private void RefreshChallengeList()
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)contentContainer == (Object)null)
			{
				return;
			}
			ClearContentContainer();
			currentExpandedEntry = null;
			if (filteredChallenges.Count == 0)
			{
				ShowErrorMessage("No challenges match your search.");
				return;
			}
			for (int i = 0; i < filteredChallenges.Count; i++)
			{
				GameObject val = CreateChallengeEntry(filteredChallenges[i], i);
				if ((Object)(object)val != (Object)null)
				{
					val.transform.SetParent(contentContainer, false);
					entryObjects.Add(val);
				}
			}
			if ((Object)(object)scrollRect != (Object)null && (Object)(object)scrollRect.content != (Object)null)
			{
				scrollRect.content.anchoredPosition = Vector2.zero;
			}
		}

		private GameObject CreateChallengeEntry(ChallengeEntry entry, int index)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_00fe: 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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Expected O, but got Unknown
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Expected O, but got Unknown
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Expected O, but got Unknown
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Expected O, but got Unknown
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_045e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0468: Expected O, but got Unknown
			ChallengeEntry entry2 = entry;
			if ((Object)(object)contentContainer == (Object)null)
			{
				return null;
			}
			GameObject entryObj = new GameObject($"Entry_{index}");
			entryObj.transform.SetParent(contentContainer, false);
			LayoutElement val = entryObj.AddComponent<LayoutElement>();
			val.preferredHeight = 130f;
			val.minHeight = 130f;
			val.flexibleWidth = 1f;
			Image val2 = entryObj.AddComponent<Image>();
			((Graphic)val2).color = new Color(0.1792f, 0.1253f, 0.0905f, 0.7294f);
			if ((Object)(object)cellMaterial != (Object)null)
			{
				((Graphic)val2).material = cellMaterial;
			}
			GameObject val3 = new GameObject("StaticHeader");
			val3.transform.SetParent(entryObj.transform, false);
			RectTransform val4 = val3.AddComponent<RectTransform>();
			val4.anchorMin = new Vector2(0f, 1f);
			val4.anchorMax = new Vector2(1f, 1f);
			val4.pivot = new Vector2(0.5f, 1f);
			val4.sizeDelta = new Vector2(0f, 130f);
			HorizontalLayoutGroup val5 = val3.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)val5).padding = new RectOffset(25, 20, 20, 20);
			((HorizontalOrVerticalLayoutGroup)val5).spacing = 20f;
			((LayoutGroup)val5).childAlignment = (TextAnchor)3;
			((HorizontalOrVerticalLayoutGroup)val5).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)val5).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)val5).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)val5).childForceExpandHeight = false;
			GameObject val6 = new GameObject("InfoArea");
			val6.transform.SetParent(val3.transform, false);
			VerticalLayoutGroup val7 = val6.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val7).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)val7).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)val7).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)val7).spacing = 5f;
			LayoutElement val8 = val6.AddComponent<LayoutElement>();
			val8.flexibleWidth = 1f;
			val8.minWidth = 450f;
			TextMeshProUGUI val9 = CreateText(entry2.DisplayName, 22, (FontStyles)0);
			((TMP_Text)val9).transform.SetParent(val6.transform, false);
			((Graphic)val9).color = new Color(1f, 0.9f, 0.7f);
			TextMeshProUGUI val10 = CreateText("By: " + entry2.DisplayCreators, 14, (FontStyles)0);
			((TMP_Text)val10).transform.SetParent(val6.transform, false);
			((Graphic)val10).color = new Color(0.8f, 0.8f, 0.8f);
			string text = (string.IsNullOrEmpty(entry2.DisplayNotes) ? "" : (" • " + entry2.DisplayNotes));
			string text2 = ((text.Length > 100) ? (text.Substring(0, 97) + "...") : text);
			TextMeshProUGUI val11 = CreateText("ID: " + entry2.ShortId + text2, 12, (FontStyles)0);
			((TMP_Text)val11).transform.SetParent(val6.transform, false);
			((Graphic)val11).color = new Color(0.7f, 0.7f, 0.7f);
			GameObject val12 = new GameObject("ButtonsArea");
			val12.transform.SetParent(val3.transform, false);
			HorizontalLayoutGroup val13 = val12.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val13).spacing = 10f;
			((LayoutGroup)val13).childAlignment = (TextAnchor)5;
			((HorizontalOrVerticalLayoutGroup)val13).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)val13).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)val13).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)val13).childForceExpandHeight = false;
			LayoutElement val14 = val12.AddComponent<LayoutElement>();
			val14.preferredWidth = 160f;
			TextMeshProUGUI tmp;
			GameObject val15 = CreateSquareButton("Apply", new Color(0.3f, 0.6f, 0.3f), out tmp, 65f);
			val15.transform.SetParent(val12.transform, false);
			((UnityEvent)val15.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				ShowApplyConfirmation(entry2);
			});
			TextMeshProUGUI expandTMP;
			GameObject val16 = CreateSquareButton("Expand", new Color(0.5f, 0.5f, 0.6f), out expandTMP, 65f);
			val16.transform.SetParent(val12.transform, false);
			((UnityEvent)val16.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				bool flag = (Object)(object)currentExpandedEntry != (Object)(object)entryObj;
				((MonoBehaviour)this).StartCoroutine(ToggleExpand(entryObj, entry2));
				((TMP_Text)expandTMP).text = (flag ? "Collapse" : "Expand");
			});
			return entryObj;
		}

		private GameObject CreateSquareButton(string text, Color color, out TextMeshProUGUI tmp, float size = 45f)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_00dc: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Button_" + text);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.sizeDelta = new Vector2(size, size);
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = color;
			Button val4 = val.AddComponent<Button>();
			LayoutElement val5 = val.AddComponent<LayoutElement>();
			val5.preferredWidth = size;
			val5.preferredHeight = size;
			val5.minWidth = size;
			val5.minHeight = size;
			GameObject val6 = new GameObject("Text");
			val6.transform.SetParent(val.transform, false);
			tmp = val6.AddComponent<TextMeshProUGUI>();
			((TMP_Text)tmp).text = text;
			((TMP_Text)tmp).fontSize = 12f;
			((TMP_Text)tmp).alignment = (TextAlignmentOptions)514;
			((TMP_Text)tmp).fontStyle = (FontStyles)0;
			if ((Object)(object)UIUtils.gameFont != (Object)null)
			{
				((TMP_Text)tmp).font = UIUtils.gameFont;
			}
			RectTransform component = val6.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.sizeDelta = Vector2.zero;
			return val;
		}

		[IteratorStateMachine(typeof(<ToggleExpand>d__39))]
		private IEnumerator ToggleExpand(GameObject entryObj, ChallengeEntry entry)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ToggleExpand>d__39(0)
			{
				<>4__this = this,
				entryObj = entryObj,
				entry = entry
			};
		}

		private void ShowApplyConfirmation(ChallengeEntry entry)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_00d2: 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_00e8: Expected O, but got Unknown
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: 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_0157: 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_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Expected O, but got Unknown
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Expected O, but got Unknown
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Expected O, but got Unknown
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Expected O, but got Unknown
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Expected O, but got Unknown
			ChallengeEntry entry2 = entry;
			if (!((Object)(object)mainCanvas == (Object)null))
			{
				GameObject root = new GameObject("ConfirmationDialog");
				root.transform.SetParent(mainCanvas.transform, false);
				RectTransform val = root.AddComponent<RectTransform>();
				val.anchorMin = Vector2.zero;
				val.anchorMax = Vector2.one;
				val.offsetMin = Vector2.zero;
				val.offsetMax = Vector2.zero;
				Canvas val2 = root.AddComponent<Canvas>();
				val2.overrideSorting = true;
				val2.sortingOrder = 300;
				root.AddComponent<GraphicRaycaster>();
				Image val3 = root.AddComponent<Image>();
				((Graphic)val3).color = new Color(0f, 0f, 0f, 0.85f);
				GameObject val4 = new GameObject("Panel");
				val4.transform.SetParent(root.transform, false);
				RectTransform val5 = val4.AddComponent<RectTransform>();
				val5.anchorMin = new Vector2(0.5f, 0.5f);
				val5.anchorMax = new Vector2(0.5f, 0.5f);
				val5.pivot = new Vector2(0.5f, 0.5f);
				val5.sizeDelta = new Vector2(420f, 220f);
				Image val6 = val4.AddComponent<Image>();
				((Graphic)val6).color = new Color(0.18f, 0.14f, 0.1f);
				VerticalLayoutGroup val7 = val4.AddComponent<VerticalLayoutGroup>();
				((LayoutGroup)val7).padding = new RectOffset(20, 20, 20, 20);
				((HorizontalOrVerticalLayoutGroup)val7).spacing = 15f;
				((LayoutGroup)val7).childAlignment = (TextAnchor)4;
				GameObject val8 = new GameObject("Text");
				val8.transform.SetParent(val4.transform, false);
				TextMeshProUGUI val9 = val8.AddComponent<TextMeshProUGUI>();
				((TMP_Text)val9).text = "Apply this challenge?\nYour current config will be lost.";
				((TMP_Text)val9).fontSize = 18f;
				((TMP_Text)val9).alignment = (TextAlignmentOptions)514;
				((TMP_Text)val9).fontStyle = (FontStyles)0;
				((Graphic)val9).color = Color.white;
				if ((Object)(object)UIUtils.gameFont != (Object)null)
				{
					((TMP_Text)val9).font = UIUtils.gameFont;
				}
				GameObject val10 = new GameObject("Buttons");
				val10.transform.SetParent(val4.transform, false);
				HorizontalLayoutGroup val11 = val10.AddComponent<HorizontalLayoutGroup>();
				((HorizontalOrVerticalLayoutGroup)val11).spacing = 20f;
				((LayoutGroup)val11).childAlignment = (TextAnchor)4;
				((HorizontalOrVerticalLayoutGroup)val11).childForceExpandWidth = false;
				GameObject val12 = CreateRectangularButton("Apply", new Color(0.25f, 0.65f, 0.3f), 130f, 45f);
				val12.transform.SetParent(val10.transform, false);
				((UnityEvent)val12.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
				{
					ApplyChallenge(entry2);
					Object.Destroy((Object)(object)root);
				});
				GameObject val13 = CreateRectangularButton("Cancel", new Color(0.65f, 0.25f, 0.25f), 130f, 45f);
				val13.transform.SetParent(val10.transform, false);
				((UnityEvent)val13.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
				{
					Object.Destroy((Object)(object)root);
				});
			}
		}

		private GameObject CreateRectangularButton(string text, Color color, float width, float height)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			//IL_00b7: 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_00f1: 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)
			GameObject val = new GameObject("Button_" + text);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.sizeDelta = new Vector2(width, height);
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = color;
			Button val4 = val.AddComponent<Button>();
			LayoutElement val5 = val.AddComponent<LayoutElement>();
			val5.preferredWidth = width;
			val5.preferredHeight = height;
			val5.minWidth = width;
			val5.minHeight = height;
			GameObject val6 = new GameObject("Text");
			val6.transform.SetParent(val.transform, false);
			TextMeshProUGUI val7 = val6.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val7).text = text;
			((TMP_Text)val7).fontSize = 16f;
			((TMP_Text)val7).alignment = (TextAlignmentOptions)514;
			((TMP_Text)val7).fontStyle = (FontStyles)0;
			((Graphic)val7).color = Color.white;
			if ((Object)(object)UIUtils.gameFont != (Object)null)
			{
				((TMP_Text)val7).font = UIUtils.gameFont;
			}
			RectTransform component = val6.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.sizeDelta = Vector2.zero;
			return val;
		}

		private TextMeshProUGUI CreateText(string text, int fontSize, FontStyles style)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Text");
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val2).text = text;
			((TMP_Text)val2).fontSize = fontSize;
			((TMP_Text)val2).fontStyle = style;
			((Graphic)val2).color = Color.white;
			if ((Object)(object)UIUtils.gameFont != (Object)null)
			{
				((TMP_Text)val2).font = UIUtils.gameFont;
			}
			return val2;
		}

		private void ApplyChallenge(ChallengeEntry entry)
		{
			if (entry.config != null)
			{
				Plugin.challengeCustom.Value = entry.ShortId;
				Plugin.challengePreset.Value = "Custom";
				UIUtils.WarningMessage("Applied: " + entry.DisplayName);
			}
		}
	}
	internal class ChallengeReader
	{
		public class SupabaseResponse
		{
			public CurrentChallenge config { get; set; }
		}

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

			private object <>2__current;

			public Action onComplete;

			private string <finalJson>5__2;

			private string <shortId>5__3;

			private UnityWebRequest <www>5__4;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<finalJson>5__2 = null;
				<shortId>5__3 = null;
				<www>5__4 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0164: Unknown result type (might be due to invalid IL or missing references)
				//IL_016a: Invalid comparison between Unknown and I4
				//IL_0216: Unknown result type (might be due to invalid IL or missing references)
				//IL_021b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0224: Expected O, but got Unknown
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
					{
						<>1__state = -1;
						string text = ((Plugin.challengePreset.Value == "Custom") ? Plugin.challengeCustom.Value : Plugin.presets[Plugin.challengePreset.Value]);
						ChallengeReader.currentChallenge = new CurrentChallenge();
						if (string.IsNullOrWhiteSpace(text) || text == "{}")
						{
							onComplete?.Invoke();
							return false;
						}
						<finalJson>5__2 = "";
						if (text.StartsWith("CHALLENGE_") || !text.StartsWith("{"))
						{
							<shortId>5__3 = text.Replace("CHALLENGE_", "").Trim().ToUpper();
							string text2 = "https://dujpxiwctslbpcziquqr.supabase.co/rest/v1/challenges?id=eq." + <shortId>5__3 + "&select=config";
							<www>5__4 = UnityWebRequest.Get(text2);
							<>1__state = -3;
							<www>5__4.SetRequestHeader("apikey", publicAnonKey);
							<www>5__4.SetRequestHeader("Authorization", "Bearer " + publicAnonKey);
							<>2__current = <www>5__4.SendWebRequest();
							<>1__state = 1;
							return true;
						}
						<finalJson>5__2 = text.Replace('\'', '"');
						break;
					}
					case 1:
						<>1__state = -3;
						if ((int)<www>5__4.result != 1)
						{
							Plugin.Log.LogError((object)("Failed to fetch challenge code: " + <www>5__4.error));
							<finalJson>5__2 = "{}";
						}
						else
						{
							List<SupabaseResponse> list = JsonConvert.DeserializeObject<List<SupabaseResponse>>(<www>5__4.downloadHandler.text);
							if (list != null && list.Count > 0)
							{
								<finalJson>5__2 = JsonConvert.SerializeObject((object)list[0].config);
								Plugin.Log.LogInfo((object)("Fetched fresh config for: " + <shortId>5__3));
							}
						}
						<>m__Finally1();
						<www>5__4 = null;
						<shortId>5__3 = null;
						break;
					}
					try
					{
						JsonSerializerSettings val = new JsonSerializerSettings
						{
							MissingMemberHandling = (MissingMemberHandling)0
						};
						CurrentChallenge currentChallenge = JsonConvert.DeserializeObject<CurrentChallenge>(<finalJson>5__2, val);
						if (currentChallenge != null)
						{
							ChallengeReader.currentChallenge = currentChallenge;
							Plugin.Log.LogInfo((object)("Successfully loaded: " + ChallengeReader.currentChallenge.Name));
						}
					}
					catch (Exception ex)
					{
						Plugin.Log.LogError((object)("Load Error: " + ex.Message));
					}
					onComplete?.Invoke();
					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;
				if (<www>5__4 != null)
				{
					((IDisposable)<www>5__4).Dispose();
				}
			}

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

		public static CurrentChallenge currentChallenge = new CurrentChallenge();

		private static string publicAnonKey = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImR1anB4aXdjdHNsYnBjemlxdXFyIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzA1MzkzMjIsImV4cCI6MjA4NjExNTMyMn0.FKJ3Mei_i3psMBkWbrZ11HwMuNl2h6-wEFloYGRkOnw";

		public static bool isPreset()
		{
			return Plugin.challengePreset.Value != "Custom";
		}

		[IteratorStateMachine(typeof(<GetCurrentChallengeRoutine>d__3))]
		public static IEnumerator GetCurrentChallengeRoutine(Action onComplete)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GetCurrentChallengeRoutine>d__3(0)
			{
				onComplete = onComplete
			};
		}

		public static string GetCurrentChallengeJson()
		{
			return JsonConvert.SerializeObject((object)currentChallenge);
		}

		public static void LoadChallengeFromJson(string json)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			try
			{
				JsonSerializerSettings val = new JsonSerializerSettings
				{
					MissingMemberHandling = (MissingMemberHandling)0
				};
				CurrentChallenge currentChallenge = JsonConvert.DeserializeObject<CurrentChallenge>(json, val);
				if (currentChallenge != null)
				{
					ChallengeReader.currentChallenge = currentChallenge;
					Plugin.Log.LogInfo((object)("Synced Challenge: " + ChallengeReader.currentChallenge.Name));
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Sync Error: " + ex.Message));
			}
		}
	}
	public class CurrentChallenge
	{
		public string Name { get; set; } = "";


		public string Creators { get; set; } = "";


		public string Notes { get; set; } = "";


		public int MinAscent { get; set; } = -1;


		public bool AllowHigherAscents { get; set; } = true;


		public List<int> disallowedItems { get; set; } = new List<int>();


		public List<int> oneTimeUseItems { get; set; } = new List<int>();


		public List<int> allowedItemsOnly { get; set; } = new List<int>();


		public bool Itemless { get; set; }

		public bool DisableRopeTypes { get; set; }

		public bool alwaysHaveTick { get; set; }

		public bool noMultiplayer { get; set; }

		public int minimumPlayers { get; set; } = 1;


		public bool allowReserveStamina { get; set; } = true;


		public bool controlLockLeftAndRight_Ground { get; set; }

		public bool controlLockForwardAndBackward_Ground { get; set; }

		public bool controlLockLeftAndRight_Climb { get; set; }

		public bool controlLockForwardAndBackward_Climb { get; set; }

		public bool noSprinting { get; set; }

		public bool noJumping { get; set; }

		public bool endRunOnCurse { get; set; }

		public bool noBackpack { get; set; }

		public bool startSkeleton { get; set; }

		public bool noLuggages { get; set; }

		public bool noAncientStatues { get; set; }

		public bool noCampfireHealAndMorale { get; set; }

		public bool temporaryStatusesDecay { get; set; } = true;


		public List<int> requiredBadges { get; set; } = new List<int>();


		public bool cannotSeeStaminaBar { get; set; }

		public bool alwaysNearSighted { get; set; }

		public bool disableHunger { get; set; }

		public bool crab { get; set; }

		public bool pandoraFires { get; set; }
	}
	[HarmonyPatch]
	public static class ChallengeCreatorPatches
	{
		public static List<ACHIEVEMENTTYPE> gainedAchievements = new List<ACHIEVEMENTTYPE>();

		private static bool _usedOneUseInItemless = false;

		private static bool _characterHasTick = false;

		public static bool runValid = true;

		private static readonly HashSet<int> ItemlessBlockedItems = new HashSet<int>
		{
			1, 7, 13, 124, 14, 125, 15, 16, 77, 126,
			17, 18, 23, 61, 74, 113, 25, 29, 30, 31,
			34, 37, 42, 43, 47, 49, 58, 59, 62, 63,
			64, 65, 67, 69, 70, 72, 78, 98, 164, 99,
			100, 105, 106, 107, 109, 115, 116, 163, 165
		};

		public static CurrentChallenge Challenge => ChallengeReader.currentChallenge;

		public static HashSet<int> UsedOneTimeUseItems { get; } = new HashSet<int>();


		[HarmonyPostfix]
		[HarmonyPatch(typeof(MainMenu), "Start")]
		public static void CreateMMUI(MainMenu __instance)
		{
			UIUtils.CreateMainMenuGUI(__instance);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(RunManager), "StartRun")]
		public static void RunStarted(RunManager __instance)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			UsedOneTimeUseItems.Clear();
			_characterHasTick = false;
			_usedOneUseInItemless = false;
			runValid = true;
			if ((Object)(object)ChallengeNetworker.Instance == (Object)null)
			{
				GameObject val = new GameObject("ChallengeNetworker");
				PhotonView val2 = val.AddComponent<PhotonView>();
				val2.ViewID = 1763;
				val.AddComponent<ChallengeNetworker>();
			}
			if (PhotonNetwork.IsMasterClient)
			{
				((MonoBehaviour)__instance).StartCoroutine(ChallengeReader.GetCurrentChallengeRoutine(delegate
				{
					string currentChallengeJson = ChallengeReader.GetCurrentChallengeJson();
					ChallengeNetworker instance = ChallengeNetworker.Instance;
					if (instance != null)
					{
						((MonoBehaviourPun)instance).photonView.RPC("RPC_ReceiveSync", (RpcTarget)1, new object[1] { currentChallengeJson });
					}
					UIUtils.DisplayChallenge(GUIManager.instance);
					Plugin.Log.LogInfo((object)("Current challenge config:\n\n" + currentChallengeJson + "\n\n"));
				}));
			}
			else
			{
				ChallengeNetworker.Instance?.RequestConfigFromHost();
				UIUtils.WarningMessage("Requesting challenge configuration from the host...");
			}
			if (Plugin.debugItemIDs.Value)
			{
				LogItemDatabase();
			}
			if (Plugin.debugAchievementTypes.Value)
			{
				LogBadgeTypes();
			}
		}

		private static void LogItemDatabase()
		{
			ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
			Dictionary<string, List<int>> dictionary = new Dictionary<string, List<int>>();
			foreach (Item @object in ((DatabaseAsset<ItemDatabase, Item>)(object)instance).Objects)
			{
				string key = @object.GetName().ToUpper();
				ushort itemID = @object.itemID;
				if (!dictionary.ContainsKey(key))
				{
					dictionary[key] = new List<int>();
				}
				dictionary[key].Add(itemID);
			}
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("{");
			int num = 0;
			foreach (KeyValuePair<string, List<int>> item in dictionary)
			{
				string text = string.Join(", ", item.Value);
				stringBuilder.Append("  \"" + item.Key + "\": [" + text + "]");
				if (++num < dictionary.Count)
				{
					stringBuilder.AppendLine(",");
				}
				else
				{
					stringBuilder.AppendLine();
				}
			}
			stringBuilder.Append("}");
			Plugin.Log.LogInfo((object)stringBuilder.ToString());
		}

		private static void LogBadgeTypes()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected I4, but got Unknown
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			foreach (ACHIEVEMENTTYPE value2 in Enum.GetValues(typeof(ACHIEVEMENTTYPE)))
			{
				ACHIEVEMENTTYPE val = value2;
				string key = ((object)(ACHIEVEMENTTYPE)(ref val)).ToString().ToUpper();
				int value = (int)val;
				dictionary[key] = value;
			}
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("{");
			int num = 0;
			foreach (KeyValuePair<string, int> item in dictionary)
			{
				stringBuilder.Append($"  \"{item.Key}\": {item.Value}");
				if (++num < dictionary.Count)
				{
					stringBuilder.AppendLine(",");
				}
				else
				{
					stringBuilder.AppendLine();
				}
			}
			stringBuilder.Append("}");
			Plugin.Log.LogInfo((object)((dictionary.Count > 0) ? stringBuilder.ToString() : "{}"));
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(BoardingPass), "UpdateAscent")]
		public static void BoardingPassUpdateAscent(BoardingPass __instance)
		{
			UIUtils.UpdateBoardingPass(__instance);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CharacterMovement), "TryToJump")]
		public static bool BlockJump(CharacterMovement __instance)
		{
			if (!__instance.character.IsLocal)
			{
				return true;
			}
			if (Challenge.noJumping)
			{
				UIUtils.ChallengeBreakingMessage("You cannot jump!");
				return false;
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Character), "Update")]
		public static void GiveSkeleton(Character __instance)
		{
			if (!__instance.IsLocal)
			{
				return;
			}
			if (Challenge.startSkeleton && !__instance.data._isSkeleton)
			{
				__instance.data._isSkeleton = true;
				__instance.data.SetSkeleton(true);
				if (Challenge.endRunOnCurse)
				{
					return;
				}
				__instance.refs.afflictions.AddStatus((STATUSTYPE)5, 0.25f, false, true, true);
			}
			if (Challenge.crab && Character.localCharacter.refs.afflictions.GetCurrentStatus((STATUSTYPE)4) == 0f)
			{
				Character.localCharacter.refs.afflictions.AddStatus((STATUSTYPE)4, 0.975f, false, true, true);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CharacterMovement), "SetMovementState")]
		public static void BlockSprintingPostfix(CharacterMovement __instance)
		{
			if (__instance.character.IsLocal && Challenge.noSprinting)
			{
				if (__instance.character.data.isSprinting)
				{
					UIUtils.ChallengeBreakingMessage("You cannot sprint!");
				}
				__instance.character.data.isSprinting = false;
				__instance.sprintToggleEnabled = false;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Character), "UseStamina")]
		public static bool BlockStaminaDrain(Character __instance)
		{
			if (__instance.IsLocal && Challenge.noSprinting)
			{
				return !__instance.data.isSprinting;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CharacterClimbing), "RPCA_ClimbJump")]
		public static bool BlockLungeJump(CharacterMovement __instance)
		{
			if (!__instance.character.IsLocal)
			{
				return true;
			}
			if (Challenge.noJumping)
			{
				UIUtils.ChallengeBreakingMessage("You cannot jump so you cannot lunge!!");
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Character), "CalculateWorldMovementDir")]
		public static void ControlLock(Character __instance)
		{
			//IL_002b: 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_009c: 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)
			if (!__instance.IsLocal)
			{
				return;
			}
			bool flag = __instance.data.isClimbing || __instance.data.isRopeClimbing;
			Vector2 movementInput = __instance.input.movementInput;
			if (flag)
			{
				if (Challenge.controlLockLeftAndRight_Climb)
				{
					movementInput.y = 0f;
				}
				if (Challenge.controlLockForwardAndBackward_Climb)
				{
					movementInput.x = 0f;
				}
			}
			else
			{
				if (Challenge.controlLockLeftAndRight_Ground)
				{
					movementInput.y = 0f;
				}
				if (Challenge.controlLockForwardAndBackward_Ground)
				{
					movementInput.x = 0f;
				}
			}
			__instance.input.movementInput = movementInput;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(RopeSegment), "IsInteractible")]
		public static bool DisableRope(RopeSegment __instance, ref bool __result)
		{
			if (Challenge.noJumping || Challenge.DisableRopeTypes)
			{
				__result = false;
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(JungleVine), "IsInteractible")]
		public static bool DisableVine(JungleVine __instance, ref bool __result)
		{
			if (Challenge.noJumping || Challenge.DisableRopeTypes)
			{
				__result = false;
				return false;
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Item), "FinishCastPrimary")]
		public static void TrackOneTimeUseItems(Item __instance)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if (!__instance.holderCharacter.IsLocal)
			{
				return;
			}
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name.Contains("Level"))
			{
				ushort itemID = __instance.itemID;
				if (Challenge.oneTimeUseItems.Contains(itemID) && itemID != 32 && itemID != 6 && !UsedOneTimeUseItems.Contains(itemID))
				{
					UsedOneTimeUseItems.Add(itemID);
					Plugin.Log.LogInfo((object)$"Added item {itemID} to used one-time use items list");
				}
				if (Challenge.Itemless && itemID != 32 && itemID != 6)
				{
					_usedOneUseInItemless = true;
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Item), "StartUsePrimary")]
		public static bool CheckOneTimeUseItems(Item __instance)
		{
			return CheckItemUsage(__instance, isPrimary: true);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Item), "StartUseSecondary")]
		public static bool CheckOneTimeUseItemsSecondary(Item __instance)
		{
			return CheckItemUsage(__instance, isPrimary: false);
		}

		private static bool CheckItemUsage(Item item, bool isPrimary)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			if (!item.holderCharacter.IsLocal)
			{
				return true;
			}
			Scene activeScene = SceneManager.GetActiveScene();
			if (!((Scene)(ref activeScene)).name.Contains("Level"))
			{
				return true;
			}
			ushort itemID = item.itemID;
			if (itemID == 6 && !Challenge.noBackpack)
			{
				return true;
			}
			if (itemID == 32)
			{
				return true;
			}
			if (Challenge.allowedItemsOnly.Count > 0 && !Challenge.allowedItemsOnly.Contains(itemID))
			{
				DropItemWithMessage(item, "The challenge has not added this item id to the allowedItemsOnly!");
				return false;
			}
			if (Challenge.Itemless)
			{
				if (ItemlessBlockedItems.Contains(itemID) || Challenge.disallowedItems.Contains(itemID))
				{
					DropItemWithMessage(item, "You cannot use this item!");
					return false;
				}
				if (_usedOneUseInItemless && itemID != 6 && itemID != 32)
				{
					DropItemWithMessage(item, "Itemless only allows one item use!");
					return false;
				}
			}
			if (Challenge.oneTimeUseItems.Contains(itemID) && UsedOneTimeUseItems.Contains(itemID))
			{
				DropItemWithMessage(item, "You have already used this item once!");
				return false;
			}
			if (Challenge.disallowedItems.Contains(itemID))
			{
				DropItemWithMessage(item, "This item is disallowed in the challenge!");
				return false;
			}
			return true;
		}

		private static void DropItemWithMessage(Item item, string message)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_0056: 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_007e: 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)
			UIUtils.ChallengeBreakingMessage(message);
			Character holderCharacter = item.holderCharacter;
			Transform transform = ((Component)holderCharacter.data.currentItem).transform;
			Vector3 val = transform.position + Vector3.down * 0.2f;
			Vector3 linearVelocity = holderCharacter.data.currentItem.rig.linearVelocity;
			Quaternion rotation = transform.rotation;
			holderCharacter.refs.items.DropItemRpc(5f, holderCharacter.refs.items.currentSelectedSlot.Value, val, linearVelocity, rotation, item.data, false);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Item), "RequestPickup")]
		public static bool ItemPickup(Item __instance, PhotonView characterView)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)characterView == (Object)null))
			{
				Scene activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).name.Contains("Level"))
				{
					if (characterView.OwnerActorNr != PhotonNetwork.LocalPlayer.ActorNumber)
					{
						return true;
					}
					ushort itemID = __instance.itemID;
					if ((itemID == 6 && !Challenge.noBackpack) || itemID == 32)
					{
						return true;
					}
					if (Challenge.alwaysHaveTick && itemID == 95)
					{
						return false;
					}
					if (Challenge.allowedItemsOnly.Count > 0 && !Challenge.allowedItemsOnly.Contains(itemID))
					{
						DenyPickup(__instance, characterView, "The challenge has not added this item id to the allowedItemsOnly list!");
						return false;
					}
					if (Challenge.oneTimeUseItems.Contains(itemID) && UsedOneTimeUseItems.Contains(itemID))
					{
						DenyPickup(__instance, characterView, "You have already used this item once!");
						return false;
					}
					if (Challenge.Itemless)
					{
						if (ItemlessBlockedItems.Contains(itemID))
						{
							DenyPickup(__instance, characterView, "You cannot pick this item up in itemless!");
							return false;
						}
						if (_usedOneUseInItemless)
						{
							DenyPickup(__instance, characterView, "You cannot pick this item as Itemless only allows 1 item.");
							return false;
						}
					}
					if (Challenge.disallowedItems.Contains(itemID))
					{
						DenyPickup(__instance, characterView, "This item is disallowed in the challenge!");
						return false;
					}
					return true;
				}
			}
			return true;
		}

		private static void DenyPickup(Item item, PhotonView characterView, string message)
		{
			UIUtils.ChallengeBreakingMessage(message);
			item.view.RPC("DenyPickupRPC", characterView.Owner, Array.Empty<object>());
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Backpack), "Stash")]
		public static bool DisableBackpack(Backpack __instance)
		{
			if (Challenge.noBackpack)
			{
				UIUtils.ChallengeBreakingMessage("You cannot use the backpack!");
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(BackpackWheel), "Choose")]
		public static bool DisableBackpackWheel(BackpackWheel __instance)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if (Challenge.noBackpack && __instance.chosenSlice.Value.isBackpackWear)
			{
				UIUtils.ChallengeBreakingMessage("You cannot use the backpack!");
				return false;
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CharacterAfflictions), "AddCurse")]
		public static void RestartRunOnCurse(CharacterAfflictions __instance)
		{
			if (Challenge.endRunOnCurse)
			{
				runValid = false;
				UIUtils.ChallengeBreakingMessage("You got cursed. The run is invalid.");
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Bugfix), "RPCA_Remove")]
		public static bool PreventTickRemoval(Bugfix __instance)
		{
			if (Challenge.alwaysHaveTick)
			{
				UIUtils.ChallengeBreakingMessage("You cannot remove the tick!");
				return false;
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Character), "FixedUpdate")]
		public static void ChracterFixedUpdte(Character __instance)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			//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)
			if (!__instance.IsLocal)
			{
				return;
			}
			Scene activeScene = SceneManager.GetActiveScene();
			string name = ((Scene)(ref activeScene)).name;
			if (!Challenge.allowReserveStamina)
			{
				__instance.data.extraStamina = 0f;
			}
			if (Challenge.cannotSeeStaminaBar && name.Contains("Level"))
			{
				GUIManager.instance.staminaCanvasGroup.alpha = 0f;
				GUIManager.instance.mushroomsCanvasGroup.alpha = 1f;
				((Component)GUIManager.instance.mushroomsCanvasGroup).gameObject.SetActive(true);
			}
			Affliction val = default(Affliction);
			if (Challenge.alwaysNearSighted && !__instance.refs.afflictions.HasAfflictionType((AfflictionType)18, ref val) && name.Contains("Level"))
			{
				Affliction_Blind val2 = new Affliction_Blind
				{
					totalTime = 10f
				};
				__instance.refs.afflictions.AddAffliction((Affliction)(object)val2, false);
			}
			if (!Challenge.alwaysHaveTick || _characterHasTick || !name.Contains("Level"))
			{
				return;
			}
			foreach (KeyValuePair<Bugfix, Character> allAttachedBug in Bugfix.AllAttachedBugs)
			{
				if ((Object)(object)allAttachedBug.Value == (Object)(object)__instance)
				{
					_characterHasTick = true;
					return;
				}
			}
			GameObject val3 = PhotonNetwork.Instantiate("BugfixOnYou", Vector3.zero, Quaternion.identity, (byte)0, (object[])null);
			val3.GetComponent<PhotonView>().RPC("AttachBug", (RpcTarget)0, new object[1] { ((MonoBehaviourPun)__instance).photonView.ViewID });
			_characterHasTick = true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EndScreen), "Start")]
		public static void ClearOnRunEnd(EndScreen __instance)
		{
			CharacterStats stats = Character.localCharacter.refs.stats;
			if (!stats.won && !stats.somebodyElseWon && stats.lost)
			{
				runValid = false;
			}
			if (Challenge.requiredBadges.Count > 0)
			{
				foreach (int requiredBadge in Challenge.requiredBadges)
				{
					if (!gainedAchievements.Contains((ACHIEVEMENTTYPE)requiredBadge))
					{
						runValid = false;
						UIUtils.ChallengeBreakingMessage($"You did not earn the required badge: {(object)(ACHIEVEMENTTYPE)requiredBadge}");
					}
				}
			}
			UIUtils.EndRunScreen(__instance, runValid);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(AchievementManager), "ThrowAchievement")]
		public static void GainBadge(AchievementManager __instance, ACHIEVEMENTTYPE type)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected I4, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (!gainedAchievements.Contains(type) && Challenge.requiredBadges.Contains((int)type))
			{
				gainedAchievements.Add(type);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Luggage), "OpenLuggageRPC")]
		public static bool BlockLuggage(Luggage __instance)
		{
			if (Challenge.noLuggages)
			{
				UIUtils.ChallengeBreakingMessage("You cannot open luggages!");
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(RespawnChest), "GetInteractionText")]
		public static bool AncientStatueText(RespawnChest __instance, ref string __result)
		{
			if (Challenge.noAncientStatues)
			{
				__result = "CANNOT USE";
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(RespawnChest), "Interact_CastFinished")]
		public static bool BlockAncientStatue(RespawnChest __instance)
		{
			if (Challenge.noAncientStatues)
			{
				UIUtils.ChallengeBreakingMessage("You cannot interact with ancient statues!");
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Campfire), "Light_Rpc")]
		public static void BlockCampfireHeal(Campfire __instance)
		{
			if (Challenge.noCampfireHealAndMorale)
			{
				float moraleBoostRadius = __instance.moraleBoostRadius;
				moraleBoostRadius = 0f;
				__instance.moraleBoostRadius = moraleBoostRadius;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CharacterAfflictions), "UpdateNormalStatuses")]
		public static bool BlockRemovalOfStatuses(CharacterAfflictions __instance)
		{
			if (Challenge.disableHunger)
			{
				__instance.hungerPerSecond = 0f;
			}
			if (!Challenge.temporaryStatusesDecay)
			{
				if (Ascents.isNightCold && Object.op_Implicit((Object)(object)Singleton<MountainProgressHandler>.Instance) && Singleton<MountainProgressHandler>.Instance.maxProgressPointReached < 3 && (Object)(object)DayNightManager.instance != (Object)null && DayNightManager.instance.isDay < 0.5f)
				{
					__instance.AddStatus((STATUSTYPE)2, Time.deltaTime * (1f - DayNightManager.instance.isDay) * Ascents.nightColdRate, false, true, true);
				}
				if (__instance.character.data.fullyConscious)
				{
					__instance.AddStatus((STATUSTYPE)1, Time.deltaTime * __instance.hungerPerSecond * Ascents.hungerRateMultiplier, false, true, true);
				}
				return false;
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Campfire), "Light_Rpc")]
		public static void GivePandoraEffect(Campfire __instance)
		{
			//IL_000c: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			if (Challenge.pandoraFires)
			{
				Affliction_Chaos val = new Affliction_Chaos
				{
					averageBonusStamina = 0.3f,
					standardDeviationBonusStamina = 0.25f,
					statusAmountAverage = 0.4f,
					statusAmountStandardDeviation = 0.3f
				};
				Character.localCharacter.refs.afflictions.AddAffliction((Affliction)(object)val, false);
				Random random = new Random();
				float num = random.Next(10) / 100;
				Character.localCharacter.refs.afflictions.AddStatus((STATUSTYPE)5, num, false, true, true);
			}
		}
	}
	[BepInPlugin("com.atomic.challengecreator", "ChallengeCreator", "1.0.4")]
	public class Plugin : BaseUnityPlugin
	{
		public static ConfigEntry<string> challengeCustom;

		public static ConfigEntry<string> challengePreset;

		public static ConfigEntry<bool> debugItemIDs;

		public static ConfigEntry<bool> debugAchievementTypes;

		public static ConfigEntry<bool> showMessage;

		public static ConfigEntry<float> messageOnScreenTime;

		public static Harmony harmony = new Harmony("com.atomic.challengecreator");

		public static Dictionary<string, string> presets = new Dictionary<string, string>
		{
			{ "Custom", "" },
			{ "Itemless", "{'Name': 'Itemless', 'Creators': 'PEAK Community', 'Notes': 'You are not allowed to use game-breaking glitches.', 'Itemless': true, 'endRunOnCurse': true, 'MinAscent': 0}" },
			{ "Crippled", "{'Name': 'Crippled', 'Creators': 'PEAK Community', 'Notes': 'No game breaking glitches, no scout cannon and no reserve stamina. You cannot jump, sprint or lunge.', 'MinAscent': 0, 'noSprinting': true, 'noJumping': true, 'disallowedItems': [107], 'allowReserveStamina': false}" },
			{ "Control-locked", "{'Name': 'Control Locked', 'Creators': 'PEAK Community', 'Notes': 'No game breaking glitches, no scout cannon.', 'MinAscent': 0, 'controlLockLeftAndRight_Ground': true, 'controlLockForwardAndBackward_Climb': true, 'disallowedItems': [107]}" },
			{ "Tick", "{'Name': 'Tick: Shore -> PEAK', 'Creators': 'PEAK Community', 'Notes': 'No game breaking glitches, you always have a tick, must get leave no trace badge. This must be solo.', 'MinAscent': 7, 'noMultiplayer': true, 'disallowedItems': [47], 'alwaysHaveTick': true}" },
			{ "Low-Stamina", "{'Name': 'Crab - 2.5% stamina', 'Creators': 'PEAK Community', 'Notes': 'You do not gain hunger, you have 97.5% of your stamina being filled with the secret crab status', 'disallowedItems': [58], 'crab': true, 'disableHunger': true}" }
		};

		public const string Id = "com.atomic.challengecreator";

		internal static ManualLogSource Log { get; private set; } = null;


		public static string Name => "ChallengeCreator";

		public static string Version => "1.0.4";

		private void Awake()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
			ConfigDescription val = new ConfigDescription("Select a premade preset or make your own, to use your own select custom. All premade presets will be available at https://atomictyler.dev/#peakPresets", (AcceptableValueBase)(object)new AcceptableValueList<string>(new List<string>(presets.Keys).ToArray()), Array.Empty<object>());
			challengePreset = ((BaseUnityPlugin)this).Config.Bind<string>("General", "challengePreset", "Custom", val);
			challengeCustom = ((BaseUnityPlugin)this).Config.Bind<string>("General", "challengeCustom", "{}", "Custom challenge JSON or CODE, codes look like CHALLENGE_xxxxxx. Go to https://atomictyler.dev/#peakPresets to make a config value.");
			messageOnScreenTime = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Message On Screen Time", 5f, "How long challenge warning messages stay on screen for.");
			showMessage = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Show Challenge Warnings", true, "If true, when you try to do something the challenge deems invalid, along with not doing it a message will appear warning you.");
			debugItemIDs = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Debug Item IDs", false, "If true, item IDs will be printed to the log. Useful for making challenges.");
			debugAchievementTypes = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Debug Achievement Types", false, "If true, achievement types will be printed to the log. Useful for making challenges.");
			harmony.PatchAll();
		}
	}
	public class UIUtils
	{
		[CompilerGenerated]
		private sealed class <FadeAlertUI>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public CanvasGroup group;

			public string message;

			public GameObject fullCanvas;

			private float <elapsed>5__2;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				//IL_0090: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<elapsed>5__2 = 0f;
					goto IL_0073;
				case 1:
					<>1__state = -1;
					goto IL_0073;
				case 2:
					<>1__state = -1;
					<elapsed>5__2 = 0f;
					break;
				case 3:
					{
						<>1__state = -1;
						break;
					}
					IL_0073:
					if (<elapsed>5__2 < 0.5f)
					{
						<elapsed>5__2 += Time.deltaTime;
						group.alpha = <elapsed>5__2 / 0.5f;
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					<>2__current = (object)new WaitForSeconds(4f);
					<>1__state = 2;
					return true;
				}
				if (<elapsed>5__2 < 1f)
				{
					<elapsed>5__2 += Time.deltaTime;
					group.alpha = 1f - <elapsed>5__2 / 1f;
					<>2__current = null;
					<>1__state = 3;
					return true;
				}
				activeBreakingMessages.Remove(message);
				Object.Destroy((Object)(object)fullCanvas);
				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();
			}
		}

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

			private object <>2__current;

			public CanvasGroup group;

			public GameObject fullCanvas;

			private float <elapsed>5__2;

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

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

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

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

			private bool MoveNext()
			{
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<elapsed>5__2 = 0f;
					goto IL_0078;
				case 1:
					<>1__state = -1;
					goto IL_0078;
				case 2:
					<>1__state = -1;
					<elapsed>5__2 = 0f;
					break;
				case 3:
					{
						<>1__state = -1;
						break;
					}
					IL_0078:
					if (<elapsed>5__2 < 2f)
					{
						<elapsed>5__2 += Time.deltaTime;
						group.alpha = Mathf.Clamp01(<elapsed>5__2 / 2f);
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					group.alpha = 1f;
					<>2__current = (object)new WaitForSeconds(GetCalculatedWaitTime());
					<>1__state = 2;
					return true;
				}
				if (<elapsed>5__2 < 2f)
				{
					<elapsed>5__2 += Time.deltaTime;
					group.alpha = Mathf.Clamp01(1f - <elapsed>5__2 / 2f);
					<>2__current = null;
					<>1__state = 3;
					return true;
				}
				group.alpha = 0f;
				Object.Destroy((Object)(object)fullCanvas);
				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 Sprite ChallengeCreatorMenuIcon = null;

		public static TMP_FontAsset gameFont;

		private static HashSet<string> activeBreakingMessages = new HashSet<string>();

		public static void DisplayChallenge(GUIManager guiManager)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			TMP_FontAsset font = ((TMP_Text)guiManager.heroDayText).font;
			CurrentChallenge currentChallenge = ChallengeReader.currentChallenge;
			GameObject val = new GameObject("ChallengeUI_Canvas");
			Canvas val2 = val.AddComponent<Canvas>();
			val2.renderMode = (RenderMode)0;
			val2.sortingOrder = 100;
			CanvasScaler val3 = val.AddComponent<CanvasScaler>();
			val3.uiScaleMode = (ScaleMode)1;
			val3.referenceResolution = new Vector2(1920f, 1080f);
			val.AddComponent<GraphicRaycaster>();
			GameObject val4 = new GameObject("TextContainer");
			val4.transform.SetParent(val.transform, false);
			CanvasGroup val5 = val4.AddComponent<CanvasGroup>();
			val5.alpha = 0f;
			RectTransform val6 = val4.AddComponent<RectTransform>();
			val6.anchorMin = new Vector2(0.5f, 1f);
			val6.anchorMax = new Vector2(0.5f, 1f);
			val6.pivot = new Vector2(0.5f, 1f);
			val6.anchoredPosition = new Vector2(0f, 0f);
			val6.sizeDelta = new Vector2(800f, 300f);
			VerticalLayoutGroup val7 = val4.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)val7).childAlignment = (TextAnchor)1;
			((HorizontalOrVerticalLayoutGroup)val7).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)val7).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)val7).spacing = -100f;
			CreateChallengeText("NameText", currentChallenge.Name, 45f, font, val4.transform);
			CreateChallengeText("CreatorsText", "BY: " + currentChallenge.Creators, 25f, font, val4.transform);
			CreateChallengeText("NotesText", currentChallenge.Notes, 20f, font, val4.transform);
			((MonoBehaviour)guiManager).StartCoroutine(FadeChallengeUI(val5, val));
		}

		public static void ChallengeBreakingMessage(string message, bool ignoreUserConfig = false)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00d6: 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_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: 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_01dc: Unknown result type (might be due to invalid IL or missing referenc