Decompiled source of ChallengeCreator v0.1.3

plugins/com.atomic.challengecreator.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Photon.Pun;
using TMPro;
using UnityEngine;
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("0.1.3.0")]
[assembly: AssemblyInformationalVersion("0.1.3+9c28d490a653fabe80ac93d7848e34ac369068dd")]
[assembly: AssemblyProduct("com.atomic.challengecreator")]
[assembly: AssemblyTitle("ChallengeCreator")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.3.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
{
	internal class ChallengeReader
	{
		public static CurrentChallenge currentChallenge = new CurrentChallenge();

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

		public static void GetCurrentChallenge()
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_00a6: Expected O, but got Unknown
			bool flag = Plugin.challengePreset.Value == "Custom";
			string text = (flag ? Plugin.challengeCustom.Value : Plugin.presets[Plugin.challengePreset.Value]);
			if (string.IsNullOrWhiteSpace(text) || text == "{}")
			{
				Plugin.Log.LogWarning((object)"Challenge JSON is empty. Using default settings.");
				ChallengeReader.currentChallenge = new CurrentChallenge();
				return;
			}
			try
			{
				text = text.Replace('\'', '"');
				JsonSerializerSettings val = new JsonSerializerSettings
				{
					MissingMemberHandling = (MissingMemberHandling)0,
					Error = delegate(object sender, ErrorEventArgs args)
					{
						Plugin.Log.LogError((object)("JSON Parsing Error at " + args.ErrorContext.Path + ": " + args.ErrorContext.Error.Message));
						args.ErrorContext.Handled = true;
					}
				};
				CurrentChallenge currentChallenge = JsonConvert.DeserializeObject<CurrentChallenge>(text, val);
				if (currentChallenge != null)
				{
					ChallengeReader.currentChallenge = currentChallenge;
					Plugin.Log.LogInfo((object)("Successfully loaded challenge: " + ChallengeReader.currentChallenge.Name));
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)"--- CHALLENGE LOAD ERROR ---");
				Plugin.Log.LogError((object)"Failed to parse challenge JSON. Ensure your formatting is correct.");
				Plugin.Log.LogError((object)("Error Details: " + ex.Message));
				if (flag)
				{
					Plugin.Log.LogError((object)("Current Custom JSON: " + text));
				}
				Plugin.Log.LogError((object)"----------------------------");
				ChallengeReader.currentChallenge = new CurrentChallenge();
			}
		}

		public static void ResetToDefault()
		{
			currentChallenge = new CurrentChallenge();
		}
	}
	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; }
	}
	[HarmonyPatch]
	public static class ChallengeCreatorPatches
	{
		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(RunManager), "StartRun")]
		public static void RunStarted(RunManager __instance)
		{
			UsedOneTimeUseItems.Clear();
			_characterHasTick = false;
			_usedOneUseInItemless = false;
			runValid = true;
			ChallengeReader.GetCurrentChallenge();
			UIUtils.DisplayChallenge(GUIManager.instance);
			if (Plugin.debugItemIDs.Value)
			{
				LogItemDatabase();
			}
		}

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

		[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), "Start")]
		public static void StartAsSkeleton(Character __instance)
		{
			if (__instance.IsLocal && Challenge.startSkeleton)
			{
				__instance.data.SetSkeleton(true);
				__instance.refs.customization.refs.SetSkeleton(true, true);
				__instance.refs.customization.HideHuman();
				if (!Challenge.endRunOnCurse)
				{
					__instance.refs.afflictions.AddStatus((STATUSTYPE)5, 0.25f, 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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			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 ExcessAndTick(Character __instance)
		{
			//IL_0039: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			if (!__instance.IsLocal)
			{
				return;
			}
			if (!Challenge.allowReserveStamina)
			{
				__instance.data.extraStamina = 0f;
			}
			if (!Challenge.alwaysHaveTick || _characterHasTick)
			{
				return;
			}
			Scene activeScene = SceneManager.GetActiveScene();
			if (!((Scene)(ref activeScene)).name.Contains("Level"))
			{
				return;
			}
			foreach (KeyValuePair<Bugfix, Character> allAttachedBug in Bugfix.AllAttachedBugs)
			{
				if ((Object)(object)allAttachedBug.Value == (Object)(object)__instance)
				{
					_characterHasTick = true;
					return;
				}
			}
			GameObject val = PhotonNetwork.Instantiate("BugfixOnYou", Vector3.zero, Quaternion.identity, (byte)0, (object[])null);
			val.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;
			}
			UIUtils.EndRunScreen(__instance, runValid);
		}
	}
	[BepInPlugin("com.atomic.challengecreator", "ChallengeCreator", "0.1.3")]
	public class Plugin : BaseUnityPlugin
	{
		public static ConfigEntry<string> challengeCustom;

		public static ConfigEntry<string> challengePreset;

		public static ConfigEntry<bool> debugItemIDs;

		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': '@piano.man', 'Notes': 'You are not allowed to use game-breaking glitches.', 'Itemless': true, 'endRunOnCurse': true, 'MinAscent': 0}" },
			{ "Crippled", "{'Name': 'Crippled', 'Creators': '@piano.man', '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': '@piano.man', 'Notes': 'No game breaking glitches, no scout cannon.', 'MinAscent': 0, 'controlLockLeftAndRight_Ground': true, 'controlLockForwardAndBackward_Climb': true, 'disallowedItems': [107]}" },
			{ "Tick", "{'Name': 'Tick: Shore -> PEAK', 'Creators': '@piano.man, @atomictyler :3', 'Notes': 'No game breaking glitches, you always have a tick, must get leave no trace badge. This must be solo. This is not the same challenge found on Pianos thread!', 'MinAscent': 7, 'noMultiplayer': true, 'disallowedItems': [47], 'alwaysHaveTick': 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 => "0.1.3";

		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. 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.");
			harmony.PatchAll();
		}
	}
	public class UIUtils
	{
		[CompilerGenerated]
		private sealed class <FadeAlertUI>d__3 : 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__3(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__5 : 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__5(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 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)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//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_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Expected O, but got Unknown
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.showMessage.Value && !activeBreakingMessages.Contains(message))
			{
				GUIManager val = Object.FindFirstObjectByType<GUIManager>();
				if (!((Object)(object)val == (Object)null))
				{
					TMP_FontAsset font = ((TMP_Text)val.heroDayText).font;
					activeBreakingMessages.Add(message);
					GameObject val2 = new GameObject("ChallengeBreaking_Canvas");
					Canvas val3 = val2.AddComponent<Canvas>();
					val3.renderMode = (RenderMode)0;
					val3.sortingOrder = 101;
					CanvasScaler val4 = val2.AddComponent<CanvasScaler>();
					val4.uiScaleMode = (ScaleMode)1;
					val4.referenceResolution = new Vector2(1920f, 1080f);
					GameObject val5 = new GameObject("BreakingMessageContainer");
					val5.transform.SetParent(val2.transform, false);
					CanvasGroup val6 = val5.AddComponent<CanvasGroup>();
					val6.alpha = 0f;
					RectTransform val7 = val5.AddComponent<RectTransform>();
					val7.anchorMin = new Vector2(0f, 0f);
					val7.anchorMax = new Vector2(1f, 0f);
					val7.pivot = new Vector2(0f, 0f);
					val7.anchoredPosition = new Vector2(20f, 20f);
					val7.sizeDelta = new Vector2(-40f, 60f);
					GameObject val8 = new GameObject("BreakingText");
					val8.transform.SetParent(val5.transform, false);
					RectTransform val9 = val8.AddComponent<RectTransform>();
					val9.anchorMin = Vector2.zero;
					val9.anchorMax = Vector2.one;
					val9.sizeDelta = Vector2.zero;
					TextMeshProUGUI val10 = val8.AddComponent<TextMeshProUGUI>();
					((TMP_Text)val10).text = message.ToUpper();
					((TMP_Text)val10).font = font;
					((TMP_Text)val10).fontSize = 28f;
					((TMP_Text)val10).alignment = (TextAlignmentOptions)1025;
					((TMP_Text)val10).textWrappingMode = (TextWrappingModes)0;
					((TMP_Text)val10).overflowMode = (TextOverflowModes)1;
					((Graphic)val10).color = new Color(1f, 0.2f, 0.2f);
					((TMP_Text)val10).outlineColor = Color32.op_Implicit(new Color(0.1f, 0f, 0f));
					((TMP_Text)val10).outlineWidth = 0.08f;
					((MonoBehaviour)val).StartCoroutine(FadeAlertUI(val6, val2, message));
				}
			}
		}

		[IteratorStateMachine(typeof(<FadeAlertUI>d__3))]
		private static IEnumerator FadeAlertUI(CanvasGroup group, GameObject fullCanvas, string message)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <FadeAlertUI>d__3(0)
			{
				group = group,
				fullCanvas = fullCanvas,
				message = message
			};
		}

		private static float GetCalculatedWaitTime()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			float num = Plugin.messageOnScreenTime.Value;
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name.Contains("Level"))
			{
				num += 5f;
			}
			return num;
		}

		[IteratorStateMachine(typeof(<FadeChallengeUI>d__5))]
		private static IEnumerator FadeChallengeUI(CanvasGroup group, GameObject fullCanvas)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <FadeChallengeUI>d__5(0)
			{
				group = group,
				fullCanvas = fullCanvas
			};
		}

		private static void CreateChallengeText(string objName, string content, float fontSize, TMP_FontAsset font, Transform parent)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			if (!string.IsNullOrEmpty(content))
			{
				GameObject val = new GameObject(objName);
				val.transform.SetParent(parent, false);
				TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
				((TMP_Text)val2).text = content.ToUpper();
				((TMP_Text)val2).font = font;
				((TMP_Text)val2).fontSize = fontSize;
				((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
				((Graphic)val2).color = new Color(0.2f, 1f, 0.2f);
				((TMP_Text)val2).outlineColor = Color32.op_Implicit(new Color(0f, 0.3f, 0f));
				((TMP_Text)val2).outlineWidth = 0.1f;
			}
		}

		public static void UpdateBoardingPass(BoardingPass __instance)
		{
			CurrentChallenge currentChallenge = ChallengeReader.currentChallenge;
			if (currentChallenge.noMultiplayer && PhotonNetwork.CurrentRoom.PlayerCount > 1)
			{
				LockBoardingPass(__instance, "Multiplayer is disabled for this challenge.", "Start");
				return;
			}
			int ascentIndex = __instance.ascentIndex;
			if (ascentIndex < currentChallenge.MinAscent)
			{
				LockBoardingPass(__instance, $"This challenge requires at least Ascent {currentChallenge.MinAscent}.", "Start");
			}
			else if (ascentIndex > currentChallenge.MinAscent && !currentChallenge.AllowHigherAscents)
			{
				LockBoardingPass(__instance, $"This challenge must be played exactly on Ascent {currentChallenge.MinAscent}.", "Start");
			}
			else
			{
				UnlockBoardingPass(__instance);
			}
		}

		public static void LockBoardingPass(BoardingPass __instance, string message, string disableStartMsg)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			Transform val = ((Component)__instance).gameObject.transform.Find("BoardingPass/Panel/Ascent");
			((Graphic)((Component)val).GetComponent<Image>()).color = new Color(1f, 0f, 0f, 0.5f);
			((TMP_Text)((Component)val.Find("Description")).GetComponent<TextMeshProUGUI>()).text = message;
			BoardingPassLock(__instance, disableStartMsg);
		}

		public static void UnlockBoardingPass(BoardingPass __instance)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			Transform val = ((Component)__instance).gameObject.transform.Find("BoardingPass/Panel/Ascent");
			((Graphic)((Component)val).GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.2f);
			BoardingPassUnlock(__instance);
		}

		public static void BoardingPassLock(BoardingPass __instance, string message)
		{
			Transform val = ((Component)__instance).gameObject.transform.Find("BoardingPass/Panel/StartGameButton");
			((Behaviour)((Component)val).GetComponent<Button>()).enabled = false;
			((TMP_Text)((Component)val.Find("Text")).GetComponent<TextMeshProUGUI>()).text = message;
		}

		public static void BoardingPassUnlock(BoardingPass __instance)
		{
			Transform val = ((Component)__instance).gameObject.transform.Find("BoardingPass/Panel/StartGameButton");
			((Behaviour)((Component)val).GetComponent<Button>()).enabled = true;
			((TMP_Text)((Component)val.Find("Text")).GetComponent<TextMeshProUGUI>()).text = "Start";
		}

		public static void EndRunScreen(EndScreen __instance, bool validRun)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_00df: Expected O, but got Unknown
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Expected O, but got Unknown
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Expected O, but got Unknown
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			Color color = ((Graphic)((Component)((Component)__instance).transform.Find("Panel/BG")).GetComponent<Image>()).color;
			TMP_FontAsset font = ((TMP_Text)GUIManager.instance.heroDayText).font;
			CurrentChallenge currentChallenge = ChallengeReader.currentChallenge;
			GameObject val = new GameObject("ChallengeInfoPanel");
			val.transform.SetParent(((Component)__instance).transform);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchorMin = new Vector2(0f, 1f);
			val2.anchorMax = new Vector2(0f, 1f);
			val2.pivot = new Vector2(0f, 1f);
			val2.anchoredPosition = new Vector2(20f, -20f);
			val2.sizeDelta = new Vector2(400f, 200f);
			VerticalLayoutGroup val3 = val.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)val3).padding = new RectOffset(15, 15, 15, 15);
			((HorizontalOrVerticalLayoutGroup)val3).spacing = 10f;
			((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = true;
			ContentSizeFitter val4 = val.AddComponent<ContentSizeFitter>();
			val4.verticalFit = (FitMode)2;
			val4.horizontalFit = (FitMode)2;
			CreateTextObject("ChallengeTitle", "CHALLENGE INFO", new Color(1f, 0.8f, 0.2f), 20, font, (TextAlignmentOptions)514).transform.SetParent(val.transform);
			CreateTextObject("ChallengeName", "Name: " + currentChallenge.Name, Color.white, 18, font, (TextAlignmentOptions)513).transform.SetParent(val.transform);
			CreateTextObject("ChallengeCreators", "Creators: " + currentChallenge.Creators, Color.white, 18, font, (TextAlignmentOptions)513).transform.SetParent(val.transform);
			bool flag = ChallengeReader.isPreset();
			Color color2 = (flag ? new Color(0.2f, 0.8f, 0.3f) : new Color(0.8f, 0.6f, 0.2f));
			CreateTextObject("PresetStatus", "Type: " + (flag ? "PRESET (OFFICIAL/BUILT-IN)" : "CUSTOM"), color2, 16, font, (TextAlignmentOptions)513).transform.SetParent(val.transform);
			Color color3 = (validRun ? new Color(0.2f, 1f, 0.2f) : new Color(1f, 0.2f, 0.2f));
			string text = (validRun ? "VALID RUN" : "INVALID RUN");
			CreateTextObject("ValidityStatus", "Status: " + text, color3, 16, font, (TextAlignmentOptions)513).transform.SetParent(val.transform);
			GameObject val5 = new GameObject("Divider");
			val5.transform.SetParent(val.transform);
			RectTransform val6 = val5.AddComponent<RectTransform>();
			val6.sizeDelta = new Vector2(350f, 2f);
			Image val7 = val5.AddComponent<Image>();
			((Graphic)val7).color = new Color(0.3f, 0.3f, 0.3f, 0.8f);
			LayoutElement val8 = val5.AddComponent<LayoutElement>();
			val8.minHeight = 2f;
			if (!string.IsNullOrEmpty(currentChallenge.Notes))
			{
				CreateTextObject("NotesTitle", "Notes:", new Color(0.6f, 0.8f, 1f), 16, font, (TextAlignmentOptions)513).transform.SetParent(val.transform);
				GameObject val9 = new GameObject("ChallengeNotes");
				val9.transform.SetParent(val.transform);
				TextMeshProUGUI val10 = val9.AddComponent<TextMeshProUGUI>();
				((TMP_Text)val10).text = currentChallenge.Notes;
				((Graphic)val10).color = new Color(0.9f, 0.9f, 0.9f);
				((TMP_Text)val10).font = font;
				((TMP_Text)val10).fontSize = 14f;
				((TMP_Text)val10).alignment = (TextAlignmentOptions)257;
				((TMP_Text)val10).textWrappingMode = (TextWrappingModes)1;
				((TMP_Text)val10).overflowMode = (TextOverflowModes)0;
				LayoutElement val11 = val9.AddComponent<LayoutElement>();
				val11.preferredWidth = 350f;
				((TMP_Text)val10).ForceMeshUpdate(false, false);
			}
		}

		private static GameObject CreateTextObject(string name, string text, Color color, int fontSize, TMP_FontAsset font, TextAlignmentOptions alignment)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0019: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.sizeDelta = new Vector2(350f, 30f);
			TextMeshProUGUI val3 = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val3).text = text;
			((Graphic)val3).color = color;
			((TMP_Text)val3).font = font;
			((TMP_Text)val3).fontSize = fontSize;
			((TMP_Text)val3).alignment = alignment;
			((TMP_Text)val3).overflowMode = (TextOverflowModes)0;
			((TMP_Text)val3).textWrappingMode = (TextWrappingModes)1;
			LayoutElement val4 = val.AddComponent<LayoutElement>();
			val4.preferredHeight = 30f;
			val4.minHeight = 20f;
			return val;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}