Decompiled source of MedalsMod v1.0.1

plugins/MedalsMod.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.Json;
using System.Text.Json.Serialization;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using CellMenu;
using GTFO.API.JSON;
using GameData;
using GameEvent;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Attributes;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppInterop.Runtime.InteropTypes.Fields;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using Localization;
using MedalsMod.Data;
using MedalsMod.GameObj;
using MedalsMod.GameObj.Prefabs;
using MedalsMod.UI;
using MedalsMod.UI.Menu;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyFileVersion("1.0.1")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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;
		}
	}
}
internal class ManifestInfo
{
	internal const string TSName = "MedalsMod";

	internal const string TSDescription = "Makes speedrunning more accessible by giving players times to aim for.";

	internal const string TSVersion = "1.0.1";

	internal const string TSAuthor = "GTFOSpeedrunning";

	internal const string TSWebsite = "https://github.com/GTFO-Speedrunning/MedalsMod";
}
namespace MedalsMod
{
	[BepInPlugin("dev.GTFOSpeedrunning.MedalsMod", "MedalsMod", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal sealed class Plugin : BasePlugin
	{
		private const string MTFO_GUID = "com.dak.MTFO";

		private const string ARCHIVE_GUID = "dev.AuriRex.gtfo.TheArchive";

		private const string CCONSOLE_GUID = "CConsole";

		public const string GUID = "dev.GTFOSpeedrunning.MedalsMod";

		public const string MOD_NAME = "MedalsMod";

		public const string VERSION = "1.0.1";

		internal static ManualLogSource L;

		private static readonly Harmony _harmony = new Harmony("dev.GTFOSpeedrunning.MedalsMod");

		internal static bool IsMTFOLoaded => ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.Any((KeyValuePair<string, PluginInfo> kvp) => kvp.Key == "com.dak.MTFO");

		internal static bool IsArchiveLoaded => ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.Any((KeyValuePair<string, PluginInfo> kvp) => kvp.Key == "dev.AuriRex.gtfo.TheArchive");

		internal static bool IsCConsoleLoaded => ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.Any((KeyValuePair<string, PluginInfo> kvp) => kvp.Key == "CConsole");

		public override void Load()
		{
			L = ((BasePlugin)this).Log;
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			MedalsLocalization.Load();
			SavedMedals.Load();
			MedalImages.Load();
			L.LogInfo((object)"MedalsMod loaded!");
		}

		public static void OnLocalizationUpdate(Language language)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			MedalsLocalization.SetLanguage(language);
			MedalDisplays.OnLocalizationUpdate();
			HintsListUI.RefreshMenu();
		}

		[Conditional("DEBUG")]
		public static void LogDebug(string s)
		{
			L.LogDebug((object)s);
		}
	}
	internal static class Utils
	{
		internal static class SortingLayers
		{
			public const string POPUP_SPRITE = "MenuPopupSprite";

			public const string MENU_SPRITE = "MenuSprite";

			public const string GLOBAL_POPUP_TEXT = "GlobalPopupText";
		}

		internal class ExpeditionInTierDataWrapped
		{
			public uint ExpeditionStoryNumber { get; set; }

			public uint ExpeditionIndex { get; set; }

			public ExpeditionInTierData ExpeditionInTier { get; set; }

			public RundownDataBlock RundownBlock { get; set; }

			public eRundownTier Tier { get; set; }

			public ExpeditionInTierDataWrapped(RundownDataBlock rundownBlock, eRundownTier tier, ExpeditionInTierData expData, uint index, uint storyNumber)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				RundownBlock = rundownBlock;
				Tier = tier;
				ExpeditionIndex = index;
				ExpeditionStoryNumber = storyNumber;
				ExpeditionInTier = expData;
			}

			public string GetName()
			{
				DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(0, 2);
				DescriptiveData descriptive = ExpeditionInTier.Descriptive;
				defaultInterpolatedStringHandler.AppendFormatted((descriptive != null) ? descriptive.Prefix : null);
				DescriptiveData descriptive2 = ExpeditionInTier.Descriptive;
				defaultInterpolatedStringHandler.AppendFormatted((descriptive2 != null && descriptive2.SkipExpNumberInName) ? string.Empty : ((object)ExpeditionStoryNumber));
				return defaultInterpolatedStringHandler.ToStringAndClear();
			}

			public override string ToString()
			{
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				return $"Rundown_{((GameDataBlockBase<RundownDataBlock>)(object)RundownBlock).persistentID}__{Tier}__Index_{ExpeditionIndex}";
			}

			public bool Is(ExpeditionInTierData expedition)
			{
				if (expedition == null)
				{
					return false;
				}
				return ((Il2CppObjectBase)ExpeditionInTier).Pointer == ((Il2CppObjectBase)expedition).Pointer;
			}
		}

		[CompilerGenerated]
		private sealed class <IterateTiers>d__8 : IEnumerable<ExpeditionInTierDataWrapped>, IEnumerable, IEnumerator<ExpeditionInTierDataWrapped>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private ExpeditionInTierDataWrapped <>2__current;

			private int <>l__initialThreadId;

			private ExpeditionInTierData[] expeditionInTiers;

			public ExpeditionInTierData[] <>3__expeditionInTiers;

			private RundownDataBlock rundownBlock;

			public RundownDataBlock <>3__rundownBlock;

			private eRundownTier tier;

			public eRundownTier <>3__tier;

			private uint <storyNumber>5__2;

			private uint <index>5__3;

			private ExpeditionInTierData[] <>7__wrap3;

			private int <>7__wrap4;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Invalid comparison between Unknown and I4
				//IL_0084: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					int num = <>1__state;
					if (num != 0)
					{
						if (num != 1)
						{
							return false;
						}
						<>1__state = -3;
						<>m__Finally1();
						goto IL_00c1;
					}
					<>1__state = -1;
					<storyNumber>5__2 = 0u;
					<index>5__3 = 0u;
					<>7__wrap3 = expeditionInTiers;
					<>7__wrap4 = 0;
					goto IL_00cf;
					IL_00c1:
					<>7__wrap4++;
					goto IL_00cf;
					IL_00cf:
					if (<>7__wrap4 < <>7__wrap3.Length)
					{
						ExpeditionInTierData val = <>7__wrap3[<>7__wrap4];
						<>1__state = -3;
						if (val.Enabled && (int)val.Accessibility != 1)
						{
							<storyNumber>5__2++;
							<>2__current = new ExpeditionInTierDataWrapped(rundownBlock, tier, val, <index>5__3, <storyNumber>5__2);
							<>1__state = 1;
							return true;
						}
						<>m__Finally1();
						goto IL_00c1;
					}
					<>7__wrap3 = null;
					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;
				<index>5__3++;
			}

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

			[DebuggerHidden]
			IEnumerator<ExpeditionInTierDataWrapped> IEnumerable<ExpeditionInTierDataWrapped>.GetEnumerator()
			{
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				<IterateTiers>d__8 <IterateTiers>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<IterateTiers>d__ = this;
				}
				else
				{
					<IterateTiers>d__ = new <IterateTiers>d__8(0);
				}
				<IterateTiers>d__.rundownBlock = <>3__rundownBlock;
				<IterateTiers>d__.tier = <>3__tier;
				<IterateTiers>d__.expeditionInTiers = <>3__expeditionInTiers;
				return <IterateTiers>d__;
			}

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

		private static ExpeditionInTierDataWrapped[] _allExpeditions;

		public static ExpeditionInTierDataWrapped[] AllExpeditions => _allExpeditions ?? (_allExpeditions = GetAllLevels());

		public static string GetLevelName(ExpeditionInTierData expeditionInTierData, int expeditionIndex)
		{
			if (expeditionInTierData == null)
			{
				return null;
			}
			expeditionIndex++;
			DescriptiveData descriptive = expeditionInTierData.Descriptive;
			DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(0, 2);
			defaultInterpolatedStringHandler.AppendFormatted(descriptive.Prefix);
			defaultInterpolatedStringHandler.AppendFormatted(descriptive.SkipExpNumberInName ? string.Empty : ((object)expeditionIndex));
			return defaultInterpolatedStringHandler.ToStringAndClear();
		}

		public static string GetActiveLevelName()
		{
			return GetLevelName(RundownManager.ActiveExpedition);
		}

		public static string GetLevelName(ExpeditionInTierData expeditionInTierData)
		{
			if (expeditionInTierData == null)
			{
				return null;
			}
			return AllExpeditions.FirstOrDefault((ExpeditionInTierDataWrapped level) => ((Il2CppObjectBase)level.ExpeditionInTier).Pointer == ((Il2CppObjectBase)expeditionInTierData).Pointer)?.GetName();
		}

		public static eRundownTier GetTier(string levelName)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrWhiteSpace(levelName))
			{
				return (eRundownTier)0;
			}
			return (eRundownTier)(((??)AllExpeditions.FirstOrDefault((ExpeditionInTierDataWrapped exp) => exp.GetName() == levelName)?.Tier) ?? 0);
		}

		private static ExpeditionInTierDataWrapped[] GetAllLevels()
		{
			GameSetupDataBlock block = GameDataBlockBase<GameSetupDataBlock>.GetBlock(1u);
			List<ExpeditionInTierDataWrapped> list = new List<ExpeditionInTierDataWrapped>();
			RundownDataBlock block2 = GameDataBlockBase<RundownDataBlock>.GetBlock(39u);
			ExpeditionInTierData expData = ((IEnumerable<ExpeditionInTierData>)block2.TierA.ToArray()).FirstOrDefault((Func<ExpeditionInTierData, bool>)delegate(ExpeditionInTierData exp)
			{
				object obj;
				if (exp == null)
				{
					obj = null;
				}
				else
				{
					DescriptiveData descriptive = exp.Descriptive;
					obj = ((descriptive != null) ? descriptive.Prefix : null);
				}
				return (string?)obj == "T";
			});
			list.Add(new ExpeditionInTierDataWrapped(block2, (eRundownTier)1, expData, 1u, 1u));
			Enumerator<uint> enumerator = block.RundownIdsToLoad.GetEnumerator();
			while (enumerator.MoveNext())
			{
				RundownDataBlock block3 = GameDataBlockBase<RundownDataBlock>.GetBlock(enumerator.Current);
				list.AddRange(IterateTiers(block3, (eRundownTier)1, Il2CppArrayBase<ExpeditionInTierData>.op_Implicit(block3.TierA.ToArray())));
				list.AddRange(IterateTiers(block3, (eRundownTier)2, Il2CppArrayBase<ExpeditionInTierData>.op_Implicit(block3.TierB.ToArray())));
				list.AddRange(IterateTiers(block3, (eRundownTier)3, Il2CppArrayBase<ExpeditionInTierData>.op_Implicit(block3.TierC.ToArray())));
				list.AddRange(IterateTiers(block3, (eRundownTier)4, Il2CppArrayBase<ExpeditionInTierData>.op_Implicit(block3.TierD.ToArray())));
				list.AddRange(IterateTiers(block3, (eRundownTier)5, Il2CppArrayBase<ExpeditionInTierData>.op_Implicit(block3.TierE.ToArray())));
			}
			return list.ToArray();
		}

		[IteratorStateMachine(typeof(<IterateTiers>d__8))]
		private static IEnumerable<ExpeditionInTierDataWrapped> IterateTiers(RundownDataBlock rundownBlock, eRundownTier tier, ExpeditionInTierData[] expeditionInTiers)
		{
			//IL_000f: 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)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <IterateTiers>d__8(-2)
			{
				<>3__rundownBlock = rundownBlock,
				<>3__tier = tier,
				<>3__expeditionInTiers = expeditionInTiers
			};
		}
	}
}
namespace MedalsMod.UI
{
	internal sealed class HintsListUI
	{
		private readonly SelectionPopupMenu _menu;

		private static HintsListUI _instance;

		public static HintsListUI Instance => _instance ?? (_instance = new HintsListUI());

		private HintsListUI()
		{
			//IL_0057: 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_0065: Invalid comparison between Unknown and I4
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			_menu = new SelectionPopupMenu();
			Utils.ExpeditionInTierDataWrapped[] allExpeditions = Utils.AllExpeditions;
			string text = MedalsLocalization.Get("BestTime");
			string setActiveConfirmText = "<color=orange>" + MedalsLocalization.Get("ClickAgainToShowHints") + "</color>";
			eRundownTier[] values = Enum.GetValues<eRundownTier>();
			for (int i = 0; i < values.Length; i++)
			{
				eRundownTier tier = values[i];
				if ((int)tier == 99)
				{
					continue;
				}
				SelectionPopupHeader selectionPopupHeader = new SelectionPopupHeader(((object)(eRundownTier)(ref tier)).ToString().Substring(4) + " Tier")
				{
					IsActiveText = string.Empty,
					SetActiveConfirmText = setActiveConfirmText,
					SpriteLargeSize = Vector2.one * 3f
				};
				foreach (Utils.ExpeditionInTierDataWrapped item in allExpeditions.Where((Utils.ExpeditionInTierDataWrapped exp) => exp.Tier == tier).OrderBy(LevelOrder))
				{
					Sprite val = MedalImages.NoMedal;
					string name = item.GetName();
					if (SavedMedals.TryGetHighestMedal(name, out var highestMedal))
					{
						val = MedalImages.GetSpriteFromMedal(highestMedal);
					}
					string text2 = "<#333>--:--";
					if (SavedMedals.TryGetBestTime(name, out var bestTime))
					{
						text2 = bestTime.ToString();
					}
					selectionPopupHeader.AddItem(new SelectionPopupItem
					{
						ID = name,
						DisplayName = name + " - \"" + item.ExpeditionInTier.Descriptive.PublicName + "\"",
						clickedAction = OnItemClicked,
						CloseMenu = false,
						SpriteSmall = val,
						SpriteLarge = val,
						upperTextCustomization = UpperTextSetter,
						subtitleTextCustomization = SubtitleSetter,
						SubTitle = highestMedal.Localize(),
						Description = text2 + " " + text
					});
				}
				_menu.AddHeader(selectionPopupHeader);
			}
		}

		private string LevelOrder(Utils.ExpeditionInTierDataWrapped exp)
		{
			string name = exp.GetName();
			if (name == "T")
			{
				return "___";
			}
			return name;
		}

		private static string UpperTextSetter(ISelectionPopupItem item, string suptitle)
		{
			if (MedalsLocalization.HasHints(item.ID))
			{
				return suptitle;
			}
			return "<#100>" + MedalsLocalization.Get("NoHintsAvailable") + "</color>";
		}

		private static string SubtitleSetter(ISelectionPopupItem item, string subtitle)
		{
			string iD = item.ID;
			string text = "<#333>--:--";
			if (SavedMedals.TryGetBestTime(iD, out var bestTime))
			{
				text = bestTime.ToString();
			}
			return text + " " + MedalsLocalization.Get("BestTime");
		}

		private void OnItemClicked(ISelectionPopupItem item)
		{
			if (item.WasDoubleClick)
			{
				string iD = item.ID;
				if (MedalsLocalization.HasHints(iD))
				{
					item.CloseMenu = true;
					PopupExtended.ShowHintsPopup(iD);
				}
			}
		}

		public void Show(string levelName = null)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_0022: Expected I4, but got Unknown
			eRundownTier tier = Utils.GetTier(levelName);
			int key = Math.Max(0, tier - 1);
			_menu.Show(key);
			if (_menu.TryGetHeader(key, out var header))
			{
				header.LastSelectedItemID = levelName;
				float value = header.Items.FirstOrDefault((ISelectionPopupItem i) => i.ID == levelName)?.ScrollPosition ?? 0f;
				header.Draw(key, value);
			}
		}

		public void Hide()
		{
			_menu.Hide();
		}

		public static void RefreshMenu()
		{
			_instance = null;
		}
	}
	internal static class PopupExtended
	{
		public static void ShowHintsPopupCurrentLevel()
		{
			RundownManager current = RundownManager.Current;
			ShowHintsPopup(Utils.GetLevelName((current != null) ? current.m_actExp : null));
		}

		public static void ShowHintsPopupCurrentLevelOrAllHintsList()
		{
			RundownManager current = RundownManager.Current;
			string levelName = Utils.GetLevelName((current != null) ? current.m_actExp : null);
			if (MedalsLocalization.HasHints(levelName))
			{
				ShowHintsPopup(levelName);
			}
			HintsListUI.Instance.Show(levelName);
		}

		public static void ShowHintsPopup(string level)
		{
			//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_0029: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0060: Expected O, but got Unknown
			if (!string.IsNullOrWhiteSpace(level))
			{
				GlobalPopupMessageManager.ShowPopup(new PopupMessage
				{
					Header = MedalsLocalization.Get("Hints") + " - " + level,
					BlinkInContent = true,
					BlinkTimeInterval = 0.6f,
					PopupType = (PopupType)7,
					UpperText = level,
					LowerText = "",
					OnCloseCallback = null
				});
			}
		}
	}
	internal enum PopupTypeEx
	{
		Confirmation,
		RundownInfo,
		BoosterImplantReveal,
		BoosterImplantMissed,
		VanityItemReveal,
		FirstTimePlayer,
		_COUNT,
		Hints
	}
}
namespace MedalsMod.UI.Menu
{
	internal interface ISelectionPopupItem
	{
		string DisplayName { get; }

		string ID { get; }

		string SubTitle { get; }

		string Description { get; }

		Sprite SpriteSmall { get; }

		Sprite SpriteLarge { get; }

		bool WasDoubleClick { get; set; }

		bool IsActive { get; set; }

		bool IsSelected { get; set; }

		bool IsAllowedToSelect { get; set; }

		bool CloseMenu { get; set; }

		float ScrollPosition { get; set; }

		void OnClicked();

		void SubtitleTextCustomization(ref string suptitleText, ref string subtitleText)
		{
		}
	}
	internal sealed class SelectionPopupHeader
	{
		private Action<int> _drawAction;

		private CM_PlayerLobbyBar _lobbyBar;

		public string HeaderText { get; set; } = "No Text Set";


		public string IsActiveText { get; set; } = "<color=orange>Selected</color>";


		public string SetActiveConfirmText { get; set; } = "<color=orange>Click again to select.</color>";


		public Func<SelectionPopupHeader, ISelectionPopupItem, bool> AllowedToSelectItem { get; set; }

		public List<ISelectionPopupItem> Items { get; } = new List<ISelectionPopupItem>();


		public string ActiveItemID { get; set; }

		public string LastSelectedItemID { get; set; }

		public Vector2? SpriteLargeSize { get; set; }

		public Action<SelectionPopupHeader> PreDraw { get; set; }

		internal Action<int> DrawAction => Draw;

		internal SelectionPopupMenu Parent { get; set; }

		public bool IsUpdating { get; private set; }

		public ISelectionPopupItem LastClickedItem { get; private set; }

		public SelectionPopupHeader(string headerText)
		{
			HeaderText = headerText;
		}

		public void Show()
		{
			Parent.Show(Parent.GetKey(this));
			TrySetLargeSpriteSize();
		}

		public void Hide()
		{
			Parent.Hide();
		}

		public SelectionPopupHeader AddItem(ISelectionPopupItem item)
		{
			if (Items.Contains(item))
			{
				return this;
			}
			Items.Add(item);
			return this;
		}

		internal void Setup(CM_PlayerLobbyBar lobbyBar)
		{
			_lobbyBar = lobbyBar;
		}

		internal void Draw(int key)
		{
			Draw(key, null);
		}

		internal void Draw(int key, float? scrollPosOffset)
		{
			if (!((Object)(object)_lobbyBar == (Object)null))
			{
				IsUpdating = false;
				UpdateContent(key, scrollPosOffset);
			}
		}

		private void UpdateContent(int key, float? scrollPosOffset = null)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			PreDraw?.Invoke(this);
			List<iScrollWindowContent> val = new List<iScrollWindowContent>();
			int num = 0;
			foreach (ISelectionPopupItem item in Items)
			{
				CM_LobbyScrollItem val2 = GOUtil.SpawnChildAndGetComp<CM_LobbyScrollItem>(_lobbyBar.m_clothesCardPrefab, ((Component)_lobbyBar).transform);
				val.Add(new iScrollWindowContent(((Il2CppObjectBase)val2).Pointer));
				((CM_Item)val2).TextMeshRoot = ((Component)_lobbyBar.m_parentPage).transform;
				val2.SetupFromLobby(((Component)_lobbyBar).transform, _lobbyBar, true);
				((RectTransformComp)val2).ForcePopupLayer(true, (GameObject)null);
				((Component)val2).transform.localScale = Vector3.one;
				((TMP_Text)val2.m_nameText).SetText(item.DisplayName ?? "", true);
				bool flag = item.ID == LastSelectedItemID;
				item.IsSelected = flag;
				val2.IsSelected = flag;
				bool flag2 = item.ID == ActiveItemID;
				item.IsActive = flag2;
				((Component)((Component)val2).transform.FindChild("EmptyIcon")).gameObject.SetActive(false);
				((Component)((Component)val2).transform.FindChild("Background")).gameObject.SetActive(flag);
				string suptitleText = string.Empty;
				item.IsAllowedToSelect = AllowedToSelectItem?.Invoke(this, item) ?? true;
				if (flag)
				{
					_lobbyBar.m_popupScrollWindow.InfoBox.SetInfoBox(item.DisplayName, item.SubTitle, item.Description, string.Empty, string.Empty, (Sprite)null);
					_lobbyBar.m_popupScrollWindow.InfoBox.SetInfoBox(item.DisplayName, item.SubTitle, item.Description, string.Empty, string.Empty, item.SpriteLarge);
					TrySetLargeSpriteSize();
					if (item.IsAllowedToSelect)
					{
						suptitleText = SetActiveConfirmText;
					}
				}
				if (flag2)
				{
					suptitleText = IsActiveText;
				}
				string subtitleText = item.ID;
				item.SubtitleTextCustomization(ref suptitleText, ref subtitleText);
				((TMP_Text)val2.m_subTitleText).SetText(suptitleText, true);
				((TMP_Text)val2.m_descText).SetText("   <#666>" + subtitleText + "</color>", true);
				((CM_Item)val2).OnBtnPressCallback = Action<int>.op_Implicit((Action<int>)delegate
				{
					bool flag3 = LastSelectedItemID == item.ID;
					item.WasDoubleClick = flag3;
					item.OnClicked();
					if (item.CloseMenu)
					{
						item.CloseMenu = false;
						Hide();
					}
					else
					{
						if (flag3)
						{
							ActiveItemID = item.ID;
						}
						LastSelectedItemID = item.ID;
						_lobbyBar.m_popupScrollWindow.InfoBox.SetInfoBox(item.DisplayName, item.SubTitle, item.Description, string.Empty, string.Empty, item.SpriteLarge);
						IsUpdating = true;
						LastClickedItem = item;
						UpdateContent(key, _lobbyBar.m_popupScrollWindow.m_posOffset);
					}
				});
				if ((Object)(object)item.SpriteSmall != (Object)null)
				{
					val2.m_icon.sprite = item.SpriteSmall;
				}
				val2.PlayIntro((float)num * 0.1f, -1);
				((CM_Item)val2).m_alphaSpriteOnHover = true;
				((CM_Item)val2).m_alphaTextOnHover = true;
				num++;
			}
			_lobbyBar.m_popupScrollWindow.SetContentItems(val, 0f);
			for (int i = 0; i < val.Count; i++)
			{
				CM_LobbyScrollItem val3 = ((Il2CppObjectBase)val[i]).TryCast<CM_LobbyScrollItem>();
				if (!((Object)(object)val3 == (Object)null))
				{
					val3.UpdateSizesAndOffsets();
					Items[i].ScrollPosition = val3.PosYStartEnd.x;
				}
			}
			if (scrollPosOffset.HasValue)
			{
				ScrollTo(scrollPosOffset.Value);
			}
			_lobbyBar.Select();
			_lobbyBar.ShowPopup();
			_lobbyBar.m_popupScrollWindow.SelectHeader(key);
		}

		private void TrySetLargeSpriteSize()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if (SpriteLargeSize.HasValue)
			{
				_lobbyBar.m_popupScrollWindow.InfoBox.m_infoMainIcon.size = SpriteLargeSize.Value;
			}
		}

		public void ScrollTo(ISelectionPopupItem item)
		{
			ScrollTo(item.ScrollPosition);
		}

		public void ScrollTo(float posOffset)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			CM_ScrollWindow popupScrollWindow = _lobbyBar.m_popupScrollWindow;
			if (popupScrollWindow.m_scrollBar.Visible)
			{
				float num = popupScrollWindow.m_contentContainerHeight - popupScrollWindow.m_windowHeight;
				popupScrollWindow.m_posOffset = Mathf.Clamp(posOffset, 0f, num);
				Vector2 position = popupScrollWindow.m_contentContainer.GetPosition();
				position.y = popupScrollWindow.m_posStart + popupScrollWindow.m_posOffset;
				popupScrollWindow.m_contentContainer.SetPosition(position);
				popupScrollWindow.UpdateContentItemVisibility();
				popupScrollWindow.m_scrollBar.SetHandlePosition(Mathf.Clamp01(posOffset / num), popupScrollWindow.m_windowHeight);
			}
		}
	}
	internal sealed class SelectionPopupItem : ISelectionPopupItem
	{
		public Action<ISelectionPopupItem> clickedAction;

		public Func<ISelectionPopupItem, string, string> upperTextCustomization;

		public Func<ISelectionPopupItem, string, string> subtitleTextCustomization;

		public string DisplayName { get; set; }

		public string ID { get; set; }

		public string SubTitle { get; set; }

		public string Description { get; set; }

		public Sprite SpriteSmall { get; set; }

		public Sprite SpriteLarge { get; set; }

		public bool WasDoubleClick { get; set; }

		public bool IsActive { get; set; }

		public bool IsSelected { get; set; }

		public bool IsAllowedToSelect { get; set; }

		public bool CloseMenu { get; set; }

		public float ScrollPosition { get; set; }

		public void OnClicked()
		{
			clickedAction?.Invoke(this);
		}

		public void SubtitleTextCustomization(ref string suptitleText, ref string subtitleText)
		{
			string text = upperTextCustomization?.Invoke(this, suptitleText);
			if (text != null)
			{
				suptitleText = text;
			}
			string text2 = subtitleTextCustomization?.Invoke(this, subtitleText);
			if (text2 != null)
			{
				subtitleText = text2;
			}
		}
	}
	internal sealed class SelectionPopupMenu
	{
		private readonly List<SelectionPopupHeader> _headers = new List<SelectionPopupHeader>();

		private CM_PlayerLobbyBar _lobbyBar;

		public SelectionPopupMenu AddHeader(SelectionPopupHeader header)
		{
			if (_headers.Contains(header))
			{
				return this;
			}
			_headers.Add(header);
			header.Parent = this;
			return this;
		}

		public void Show(int key = 0)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_0010: Invalid comparison between Unknown and I4
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Invalid comparison between Unknown and I4
			FocusStateManager.EnterMenu((eCM_MenuPage)13, false);
			eGameStateName currentStateName = GameStateManager.CurrentStateName;
			if ((int)currentStateName == 6 || (int)currentStateName == 10)
			{
				FocusStateManager.Current.m_previousToggleState = (eFocusState)4;
			}
			_lobbyBar = ((IEnumerable<CM_PlayerLobbyBar>)CM_PageLoadout.Current.m_playerLobbyBars).FirstOrDefault((Func<CM_PlayerLobbyBar, bool>)((CM_PlayerLobbyBar plb) => ((Behaviour)plb).isActiveAndEnabled));
			if ((Object)(object)_lobbyBar == (Object)null)
			{
				_lobbyBar = ((Il2CppArrayBase<CM_PlayerLobbyBar>)(object)CM_PageLoadout.Current.m_playerLobbyBars)[0];
			}
			Transform popupAlign = CM_PageLoadout.Current.m_popupAlign;
			ShowSelectionPopup(_lobbyBar, popupAlign, key);
		}

		public void Hide()
		{
			if (!((Object)(object)_lobbyBar == (Object)null))
			{
				_lobbyBar.HidePopup();
			}
		}

		public int GetKey(SelectionPopupHeader header)
		{
			return _headers.IndexOf(header);
		}

		public bool TryGetHeader(int key, out SelectionPopupHeader header)
		{
			header = null;
			if (key < 0 || key >= _headers.Count)
			{
				return false;
			}
			header = _headers[key];
			return header != null;
		}

		private void ShowSelectionPopup(CM_PlayerLobbyBar lobbyBar, Transform align, int keyToShow)
		{
			//IL_0013: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			lobbyBar.m_popupVisible = true;
			((Component)lobbyBar.m_popupHolder).transform.position = align.position + new Vector3(300f, 0f, 0f);
			lobbyBar.m_popupScrollWindow.m_infoBoxWidth = 600f;
			((Component)lobbyBar.m_popupHolder).gameObject.SetActive(true);
			((Component)lobbyBar.m_popupItemHolder).gameObject.SetActive(true);
			((RectTransformComp)lobbyBar.m_popupScrollWindow).SetSize(new Vector2(1600f, 760f));
			lobbyBar.m_popupScrollWindow.ResetHeaders();
			int num = 0;
			foreach (SelectionPopupHeader header in _headers)
			{
				header.Setup(lobbyBar);
				int keyLocal = num;
				lobbyBar.m_popupScrollWindow.AddHeader(header.HeaderText, num, Action<int>.op_Implicit((Action<int>)delegate
				{
					header.DrawAction(keyLocal);
				}));
				num++;
			}
			((RectTransformComp)lobbyBar.m_popupScrollWindow).SetPosition(new Vector2(0f, 350f));
			lobbyBar.m_popupScrollWindow.RespawnInfoBoxFromPrefab(lobbyBar.m_popupInfoBoxWeaponPrefab);
			if (TryGetHeader(keyToShow, out var header2))
			{
				header2.Draw(keyToShow);
			}
		}
	}
}
namespace MedalsMod.Patches
{
	[HarmonyPatch]
	internal static class ExpeditionMenuPatch
	{
		[HarmonyPatch(typeof(MainMenuGuiLayer), "OnExpeditionUpdated", new Type[]
		{
			typeof(pActiveExpedition),
			typeof(ExpeditionInTierData)
		})]
		[HarmonyPostfix]
		public static void PostfixLobby(pActiveExpedition activeExpedition, ExpeditionInTierData expeditionInTierData)
		{
			MedalDisplays.UpdateMedals(Utils.GetLevelName(expeditionInTierData, activeExpedition.expeditionIndex));
		}
	}
	[HarmonyPatch(typeof(GameDataInit), "Initialize")]
	internal static class GameDataInit__Initialize__Patch
	{
		public static void Postfix()
		{
			PrefabManager.Setup();
		}
	}
	[HarmonyPatch(typeof(CM_PageLoadout), "Setup")]
	internal static class CM_PageLoadout__Setup__Patch
	{
		public static void Postfix(CM_PageLoadout __instance)
		{
			PrefabManager.Instantiate(delegate(StackedMedalDisplay medalDisplay)
			{
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				((Component)medalDisplay).transform.SetParent((Transform)(object)((CM_PageBase)__instance).m_movingContentHolder);
				((Component)medalDisplay).transform.localPosition = new Vector3(1340f, 25f, 0f);
				((Component)medalDisplay).transform.localScale = Vector3.one * 0.8f;
				medalDisplay.SetPopupSpriteMode(value: false);
				MedalDisplays.PageLoadout = medalDisplay;
				MedalDisplays.RegisterLocalizationUpdateable(medalDisplay);
			});
			PrefabManager.Instantiate(delegate(GenericButton button)
			{
				//IL_0041: 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)
				((Component)button).transform.SetParent((Transform)(object)((CM_PageBase)__instance).m_movingContentHolder);
				((Component)button).transform.localPosition = new Vector3(1425f, -100f, 0f);
				((Component)button).transform.localScale = Vector3.one;
				button.SetPopupSpriteMode(value: false);
				button.OnButtonPressAction = PopupExtended.ShowHintsPopupCurrentLevelOrAllHintsList;
				MedalDisplays.ExpeditionPageLoadoutHintsButton = button;
				MedalDisplays.RegisterLocalizationUpdateable(new ActionLocalizationUpdate(delegate
				{
					MedalDisplays.SetHintButtonText(button, Utils.GetActiveLevelName());
				}));
				button.SetText(MedalsLocalization.Get("Hints"));
			});
		}
	}
	[HarmonyPatch(typeof(CM_PageExpeditionSuccess), "Setup")]
	internal static class CM_PageExpeditionSuccess__Setup__Patch
	{
		internal static MedalEndScreenDisplay DefaultEndScreenDisplay;

		internal static MedalEndScreenDisplay LatestMedalEndScreen;

		public static void Postfix(CM_PageExpeditionSuccess __instance)
		{
			MedalEndScreenDisplay medalEndScreenDisplay = new MedalEndScreenDisplay();
			medalEndScreenDisplay.Setup(__instance);
			LatestMedalEndScreen = medalEndScreenDisplay;
			if (DefaultEndScreenDisplay == null)
			{
				DefaultEndScreenDisplay = medalEndScreenDisplay;
			}
		}
	}
	[HarmonyPatch(typeof(CM_PageExpeditionSuccess), "OnEnable")]
	internal static class CM_PageExpeditionSuccess__OnEnable__Patch
	{
		private static void Postfix(CM_PageExpeditionSuccess __instance)
		{
			if (!((Object)(object)__instance.m_root == (Object)null))
			{
				if (((Il2CppObjectBase)__instance).Pointer == ((Il2CppObjectBase)MainMenuGuiLayer.Current.PageExpeditionSuccess).Pointer)
				{
					CM_PageExpeditionSuccess__Setup__Patch.DefaultEndScreenDisplay.BlinkIn();
				}
				else
				{
					CM_PageExpeditionSuccess__Setup__Patch.LatestMedalEndScreen.BlinkIn();
				}
			}
		}
	}
	[HarmonyPatch(typeof(CM_ExpeditionWindow), "Setup")]
	internal static class CM_ExpeditionWindow__Setup__Patch
	{
		public static void Postfix(CM_ExpeditionWindow __instance)
		{
			PrefabManager.Instantiate(delegate(StackedMedalDisplay display)
			{
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				((Component)display).transform.SetParent(((Component)__instance).transform);
				((Component)display).transform.localPosition = new Vector3(-320f, -270f, 0f);
				((Component)display).transform.localScale = Vector3.one;
				display.SetPopupSpriteMode(value: true);
				MedalDisplays.ExpeditionWindow = display;
				MedalDisplays.RegisterLocalizationUpdateable(display);
			});
			PrefabManager.Instantiate(delegate(GenericButton button)
			{
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				((Component)button).transform.SetParent(((Component)__instance).transform);
				((Component)button).transform.localPosition = new Vector3(-200f, -400f, 0f);
				((Component)button).transform.localScale = Vector3.one;
				button.SetPopupSpriteMode(value: true);
				button.OnButtonPressAction = delegate
				{
					__instance.SetVisible(false, false);
					string levelName2 = Utils.GetLevelName(__instance.m_data, __instance.m_expIndex);
					if (MedalsLocalization.HasHints(levelName2))
					{
						PopupExtended.ShowHintsPopup(levelName2);
					}
					else
					{
						HintsListUI.Instance.Show(levelName2);
					}
				};
				MedalDisplays.ExpeditionWindowHintButton = button;
				MedalDisplays.RegisterLocalizationUpdateable(new ActionLocalizationUpdate(delegate
				{
					string levelName = Utils.GetLevelName(__instance.m_data, __instance.m_expIndex);
					MedalDisplays.SetHintButtonText(button, levelName);
				}));
				button.SetText(MedalsLocalization.Get("Hints"));
			});
		}
	}
	[HarmonyPatch(typeof(CM_ExpeditionWindow), "SetExpeditionInfo")]
	internal static class CM_ExpeditionWindow__SetExpeditionInfo__Patch
	{
		public static void Postfix(ExpeditionInTierData data, int expIndex)
		{
			string levelName = Utils.GetLevelName(data, expIndex);
			MedalDisplays.ExpeditionWindow?.UpdateMedals(levelName);
			MedalDisplays.SetHintButtonText(MedalDisplays.ExpeditionWindowHintButton, levelName);
		}
	}
	[HarmonyPatch]
	internal class GameStatePatch
	{
		[HarmonyPatch(typeof(GameEventManager), "PostEvent", new Type[]
		{
			typeof(eGameEvent),
			typeof(PlayerAgent),
			typeof(float),
			typeof(string),
			typeof(Dictionary<string, string>)
		})]
		[HarmonyPrefix]
		public static void Patch_PostEvent_Overload2(eGameEvent e, PlayerAgent player, float floatVal, string stringVal, Dictionary<string, string> customAnalyticsPayload)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected I4, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Invalid comparison between Unknown and I4
			switch (e - 72)
			{
			case 0:
				TimeCollector.Drop(GetLevelName(), RundownManager.GetActiveExpeditionData().sessionSeed);
				return;
			case 4:
				OnRunStart();
				return;
			case 7:
			case 9:
			case 10:
				TimeCollector.SetInvalid();
				return;
			case 8:
				OnRunFinish();
				return;
			case 1:
			case 2:
			case 3:
			case 5:
			case 6:
				return;
			}
			if ((int)e == 125)
			{
				TimeCollector.OnCheckpointReloaded();
				TimeCollector.SetInvalid();
			}
		}

		private static void OnRunStart()
		{
			string levelName = GetLevelName();
			TimeCollector.Start(levelName);
			Plugin.L.LogInfo((object)("Started level: " + levelName));
		}

		internal static void OnRunFinish(bool debugForceSetTime = false)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			TimedSession timedSession = TimeCollector.FinishRun(GetLevelName(), debugForceSetTime);
			if (SNet.IsMaster && timedSession.IsValid)
			{
				ManualLogSource l = Plugin.L;
				bool flag = default(bool);
				BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(27, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("We are host, saving run. (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Time>(timedSession.FinalTime);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
				}
				l.LogMessage(val);
				SavedMedals.AddRun(timedSession);
				SavedMedals.Save();
				Network.SendMatchEndData(timedSession);
			}
		}

		private static string GetLevelName()
		{
			return Utils.GetLevelName(RundownManager.ActiveExpedition, RundownManager.GetActiveExpeditionData().expeditionIndex);
		}
	}
	[HarmonyPatch(typeof(GameDataTextLocalizationService), "SetCurrentLanguage")]
	internal class GameDataTextLocalizationService__SetCurrentLanguage__Patch
	{
		private static void Postfix(Language language)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			Plugin.OnLocalizationUpdate(language);
		}
	}
	[HarmonyPatch]
	internal class LateJoinPatch
	{
		[HarmonyPatch(typeof(SNet_Capture), "OnReceiveBufferCompletion")]
		[HarmonyPrefix]
		private static void OnReceiveBufferCompletionPatch(pBufferCompletion completion)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			if ((int)completion.type == 1)
			{
				TimeCollector.UpdateLateJoin(new Time((ulong)(completion.data.progressionTime * 1000f)));
			}
		}
	}
	[HarmonyPatch(typeof(CM_ExpeditionIcon_New), "Setup", new Type[]
	{
		typeof(ExpeditionInTierData),
		typeof(string),
		typeof(eRundownTier),
		typeof(int),
		typeof(Color),
		typeof(Transform)
	})]
	internal static class CM_ExpeditionIcon_New__Setup__Patch
	{
		public static void Postfix(CM_ExpeditionIcon_New __instance, ExpeditionInTierData data, int expIndex)
		{
			if (!((Object)((Component)__instance).gameObject).name.Contains("_MenuBar"))
			{
				PrefabManager.Instantiate(delegate(RundownScreenSingleExpeditionDisplay display)
				{
					//IL_0028: 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_0042: Unknown result type (might be due to invalid IL or missing references)
					//IL_0094: Unknown result type (might be due to invalid IL or missing references)
					Transform parent = ((Component)__instance).transform.FindChild("Root");
					((Component)display).transform.SetParent(parent);
					((Component)display).transform.localRotation = Quaternion.identity;
					((Component)display).transform.localScale = Vector3.one * 0.75f;
					float num = ((((TMP_Text)__instance.m_statusText).text.Contains("<br>") || __instance.HostingFriendsCount > 0) ? (-140f) : (-110f));
					((Component)display).transform.localPosition = new Vector3(-110f, num, 0f);
					string shortName = __instance.ShortName;
					display.UpdateMedal(shortName);
					MedalDisplays.RegisterLocalizationUpdateable(display);
				});
			}
		}
	}
	[HarmonyPatch(typeof(CM_PageRundown_New), "RebuildFriendsInfo")]
	internal class CM_PageRundown_New__RebuildFriendsInfo__Patch
	{
		public static void Postfix(CM_PageRundown_New __instance)
		{
			if (((__instance != null) ? __instance.m_expIconsAll : null) == null)
			{
				return;
			}
			Enumerator<CM_ExpeditionIcon_New> enumerator = __instance.m_expIconsAll.GetEnumerator();
			while (enumerator.MoveNext())
			{
				CM_ExpeditionIcon_New current = enumerator.Current;
				if (!((Object)(object)current == (Object)null))
				{
					CM_ExpeditionIcon_New__SetStatus__Patch.UpdateDisplay(current);
				}
			}
		}
	}
	[HarmonyPatch(typeof(CM_ExpeditionIcon_New), "SetStatus")]
	internal class CM_ExpeditionIcon_New__SetStatus__Patch
	{
		private static void Postfix(CM_ExpeditionIcon_New __instance)
		{
			UpdateDisplay(__instance);
		}

		internal static void UpdateDisplay(CM_ExpeditionIcon_New icon)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			RundownScreenSingleExpeditionDisplay componentInChildren = ((Component)icon).GetComponentInChildren<RundownScreenSingleExpeditionDisplay>();
			if (!((Object)(object)componentInChildren == (Object)null))
			{
				float num = ((((TMP_Text)icon.m_statusText).text.Contains("<br>") || icon.HostingFriendsCount > 0) ? (-140f) : (-110f));
				((Component)componentInChildren).transform.localPosition = new Vector3(-110f, num, 0f);
				ExpeditionInTierData dataBlock = icon.DataBlock;
				int expIndex = icon.ExpIndex;
				string levelName = Utils.GetLevelName(dataBlock, expIndex);
				componentInChildren.UpdateMedal(levelName);
			}
		}
	}
	internal enum NetworkMessageType
	{
		MatchEndData
	}
	[HarmonyPatch]
	internal class Network
	{
		private static readonly ushort repKey = 65530;

		private static uint GetMessageId(NetworkMessageType messageType)
		{
			if (messageType == NetworkMessageType.MatchEndData)
			{
				return 1u;
			}
			return 0u;
		}

		public static void SendMatchEndData(Time time)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			if (!SNet.IsMaster)
			{
				return;
			}
			using MemoryStream memoryStream = new MemoryStream();
			using BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
			binaryWriter.Write(repKey);
			binaryWriter.Write(GetMessageId(NetworkMessageType.MatchEndData));
			binaryWriter.Write(time.stamp);
			byte[] array = memoryStream.ToArray();
			SNet_ChannelType val = (SNet_ChannelType)0;
			SNet_SendGroup val2 = default(SNet_SendGroup);
			SNet_SendQuality val3 = default(SNet_SendQuality);
			int num = default(int);
			SNet.GetSendSettings(ref val, ref val2, ref val3, ref num);
			List<SNet_Player> val4 = new List<SNet_Player>();
			Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
			while (enumerator.MoveNext())
			{
				PlayerAgent current = enumerator.Current;
				if (!current.Owner.IsBot && current.Owner.Lookup != SNet.LocalPlayer.Lookup)
				{
					val4.Add(current.Owner);
				}
			}
			SNet.Core.SendBytes(Il2CppStructArray<byte>.op_Implicit(array), val3, num, val4);
		}

		[HarmonyPatch(typeof(SNet_Replication), "RecieveBytes")]
		[HarmonyWrapSafe]
		[HarmonyPrefix]
		private static bool RecieveBytes_Prefix(Il2CppStructArray<byte> bytes, uint size, ulong messagerID)
		{
			if (size < 14)
			{
				return true;
			}
			if ((Object)(object)SNet.Master == (Object)null)
			{
				return true;
			}
			if (messagerID != SNet.Master.Lookup)
			{
				return true;
			}
			byte[] value = Il2CppArrayBase<byte>.op_Implicit((Il2CppArrayBase<byte>)(object)bytes);
			ushort num = BitConverter.ToUInt16(value, 0);
			if (repKey != num)
			{
				return true;
			}
			if (BitConverter.ToUInt32(value, 2) != GetMessageId(NetworkMessageType.MatchEndData))
			{
				return true;
			}
			TimeCollector.ReceivedTimeFromMaster(new Time(BitConverter.ToUInt64(value, 6)));
			return false;
		}
	}
	[HarmonyPatch(typeof(GlobalPopupMessageManager), "Setup")]
	internal static class PopupManagerPatch
	{
		public static void Postfix()
		{
			PrefabManager.Instantiate(delegate(HintPopupPrefab popupPrefab)
			{
				Plugin.L.LogDebug((object)"PopupPrefab Created!!");
				((Component)popupPrefab).gameObject.SetActive(false);
				GlobalPopupMessageManager.m_popupTypeToPrefabMap[(PopupType)7] = ((Component)popupPrefab).GetComponent<CM_GlobalPopup>();
			});
		}
	}
}
namespace MedalsMod.GameObj
{
	internal sealed class ActionLocalizationUpdate : ILocalizationUpdateReceiver
	{
		private Action _action;

		public ActionLocalizationUpdate(Action onUpdate)
		{
			_action = onUpdate;
		}

		public void UpdateLocalization()
		{
			_action?.Invoke();
		}
	}
	internal interface ILocalizationUpdateReceiver
	{
		void UpdateLocalization();
	}
	internal interface IMedalPrefab
	{
		void Init();
	}
	internal static class MedalDisplays
	{
		internal static StackedMedalDisplay PageLoadout;

		internal static StackedMedalDisplay ExpeditionWindow;

		internal static GenericButton ExpeditionWindowHintButton;

		internal static GenericButton ExpeditionPageLoadoutHintsButton;

		private static readonly HashSet<ILocalizationUpdateReceiver> _localizationReceivers = new HashSet<ILocalizationUpdateReceiver>();

		internal static void RegisterLocalizationUpdateable(ILocalizationUpdateReceiver receiver)
		{
			_localizationReceivers.Add(receiver);
		}

		internal static void OnLocalizationUpdate()
		{
			foreach (ILocalizationUpdateReceiver localizationReceiver in _localizationReceivers)
			{
				localizationReceiver?.UpdateLocalization();
			}
		}

		public static void UpdateMedals(string levelName)
		{
			PageLoadout?.UpdateMedals(levelName);
			SetHintButtonText(ExpeditionPageLoadoutHintsButton, levelName);
		}

		public static void SetHintButtonText(GenericButton button, string levelName)
		{
			if (!((Object)(object)button == (Object)null))
			{
				bool flag = MedalsLocalization.HasHints(levelName);
				string localizationKey = (flag ? "Hints" : "NoHints");
				button.SetText((flag ? string.Empty : "<#644>") + MedalsLocalization.Get(localizationKey));
			}
		}
	}
	internal sealed class MedalEndScreenDisplay
	{
		internal enum StatusIndicator
		{
			None,
			Waiting,
			SavedHostTime,
			SavedClientTime,
			Uploaded
		}

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

			private object <>2__current;

			public MedalEndScreenDisplay <>4__this;

			private Time <time>5__2;

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

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

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

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

			private bool MoveNext()
			{
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Expected O, but got Unknown
				//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: Expected O, but got Unknown
				int num = <>1__state;
				MedalEndScreenDisplay medalEndScreenDisplay = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					((Component)medalEndScreenDisplay._pbDisplay).gameObject.SetActive(false);
					medalEndScreenDisplay._statusIconContainer.SetActive(false);
					<>2__current = (object)new WaitForSeconds(5f);
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					Medal medalForRun = Medal.None;
					string text = "<#333>--:--";
					if (TimeCollector.TryGetPreviousBest(out var medal, out <time>5__2))
					{
						medalForRun = medal;
						text = <time>5__2.ToString();
					}
					medalEndScreenDisplay._pbDisplay.SetMedalIcon(medalForRun);
					medalEndScreenDisplay._pbDisplay.SetMedalText(MedalsLocalization.Get("BestTime"));
					medalEndScreenDisplay._pbDisplay.SetTimeText(text);
					CoroutineManager.BlinkIn(((Component)medalEndScreenDisplay._pbDisplay).gameObject, 0f);
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 2;
					return true;
				}
				case 2:
				{
					<>1__state = -1;
					TimeCollector.TrySaveLocalTime();
					TimedSession lastCompletedSession = TimeCollector.LastCompletedSession;
					if (<time>5__2 == null || lastCompletedSession.FinalTime < <time>5__2)
					{
						string text = lastCompletedSession.FinalTime.ToString();
						Medal medalForRun = TimeCollector.GetMedalForRun(lastCompletedSession);
						medalEndScreenDisplay._pbDisplay.SetMedalIcon(medalForRun);
						if (<time>5__2 != null)
						{
							ulong value = <time>5__2.TotalSeconds - lastCompletedSession.FinalTime.TotalSeconds;
							medalEndScreenDisplay._pbDisplay.SetMedalText($"<size=70%>(<color=green>-{value}s</color>)</size> {MedalsLocalization.Get("BestTime")}");
						}
						else
						{
							medalEndScreenDisplay._pbDisplay.SetMedalText(MedalsLocalization.Get("BestTime") ?? "");
						}
						medalEndScreenDisplay._pbDisplay.SetTimeText(text ?? "");
						CoroutineManager.BlinkIn(((Component)medalEndScreenDisplay._pbDisplay).gameObject, 0f);
					}
					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 <Rotate>d__10 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public float speed;

			public MedalEndScreenDisplay <>4__this;

			private float <rotation>5__2;

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

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

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

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

			private bool MoveNext()
			{
				int num = <>1__state;
				MedalEndScreenDisplay medalEndScreenDisplay = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<rotation>5__2 = 0f;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (((CM_PageBase)medalEndScreenDisplay._pageSuccess).m_isActive)
				{
					<rotation>5__2 += Time.deltaTime * speed;
					<rotation>5__2 %= 360f;
					if (!(<rotation>5__2 < 120f))
					{
						if (!(<rotation>5__2 < 240f))
						{
							if (<rotation>5__2 < 360f && ((TMP_Text)medalEndScreenDisplay._statusTMP).text != "\\")
							{
								((TMP_Text)medalEndScreenDisplay._statusTMP).SetText("\\", true);
							}
						}
						else if (((TMP_Text)medalEndScreenDisplay._statusTMP).text != "-")
						{
							((TMP_Text)medalEndScreenDisplay._statusTMP).SetText("-", true);
						}
					}
					else if (((TMP_Text)medalEndScreenDisplay._statusTMP).text != "/")
					{
						((TMP_Text)medalEndScreenDisplay._statusTMP).SetText("/", true);
					}
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				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 CM_PageExpeditionSuccess _pageSuccess;

		private SingleMedalTimeDisplay _pbDisplay;

		private MedalIconsHorizontal _medals;

		private GameObject _statusIconContainer;

		private TextMeshPro _statusTMP;

		private Coroutine _statusIndicatorCoroutine;

		internal const string R8E1_CUSTOM_END_SCREEN = "CM_PageExpeditionSuccess_Resources expended_CellUI 2";

		public void Setup(CM_PageExpeditionSuccess pageSuccess)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0077: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			_pageSuccess = pageSuccess;
			PrefabManager.Instantiate(delegate(MedalIconsHorizontal display)
			{
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				((Component)display).transform.SetParent((Transform)(object)((CM_PageBase)pageSuccess).m_movingContentHolder);
				((Component)display).transform.localPosition = new Vector3(-378f, 364f, 0f);
				((Component)display).transform.localScale = Vector3.one;
				_medals = display;
				PrefabManager.Instantiate(delegate(SingleMedalTimeDisplay bestTimeDisplay)
				{
					//IL_002b: Unknown result type (might be due to invalid IL or missing references)
					//IL_003b: Unknown result type (might be due to invalid IL or missing references)
					((Component)bestTimeDisplay).transform.SetParent((Transform)(object)((CM_PageBase)pageSuccess).m_movingContentHolder);
					((Component)bestTimeDisplay).transform.localPosition = new Vector3(-890f, 320f, 0f);
					((Component)bestTimeDisplay).transform.localScale = Vector3.one;
					((Component)bestTimeDisplay).transform.SetParent(((Component)_medals).transform, true);
					bestTimeDisplay.SetMedalIcon(Medal.Champion);
					bestTimeDisplay.SetMedalText("Champignon");
					bestTimeDisplay.SetTimeText("69:420");
					_pbDisplay = bestTimeDisplay;
				});
			});
			_statusIconContainer = new GameObject("StatusThingie");
			_statusIconContainer.transform.SetParent((Transform)(object)((CM_PageBase)pageSuccess).m_movingContentHolder);
			_statusIconContainer.transform.localPosition = new Vector3(-378f, 500f, 0f);
			_statusIconContainer.transform.localScale = Vector3.one * 10f;
			_statusIconContainer.AddComponent<RectTransform>().pivot = new Vector2(0.2f, 0.5f);
			_statusIconContainer.layer = LayerManager.LAYER_UI;
			_statusTMP = _statusIconContainer.AddComponent<TextMeshPro>();
			_statusTMP.SetToGTFOFont();
			((Renderer)((Component)_statusTMP).GetComponent<MeshRenderer>()).sortingLayerName = "MenuPopupSprite";
			((TMP_Text)_statusTMP).SetText("!", true);
		}

		private void PositionStatusIcon()
		{
			//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)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			Vector2 renderedValues = ((TMP_Text)_pageSuccess.m_expeditionName).GetRenderedValues();
			_statusIconContainer.transform.localPosition = _pageSuccess.m_expeditionName.transform.localPosition;
			Transform transform = _statusIconContainer.transform;
			transform.localPosition += new Vector3(renderedValues.x + 50f, 0f - renderedValues.y - 23f, 0f);
		}

		internal void SetStatusIndicator(StatusIndicator state)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			if (((CM_PageBase)_pageSuccess).m_isActive)
			{
				Color color = Color.white;
				switch (state)
				{
				case StatusIndicator.Waiting:
					color = Color.yellow;
					break;
				case StatusIndicator.SavedHostTime:
					color = Color.green;
					((TMP_Text)_statusTMP).SetText("H", true);
					break;
				case StatusIndicator.SavedClientTime:
					color = Color.cyan;
					((TMP_Text)_statusTMP).SetText("C", true);
					break;
				case StatusIndicator.Uploaded:
					color = Color.magenta;
					((TMP_Text)_statusTMP).SetText("U", true);
					break;
				}
				((Graphic)_statusTMP).color = color;
				if (_statusIndicatorCoroutine != null)
				{
					((MonoBehaviour)_pageSuccess).StopCoroutine(_statusIndicatorCoroutine);
					_statusIndicatorCoroutine = null;
				}
				if (state == StatusIndicator.Waiting)
				{
					_statusIndicatorCoroutine = ((MonoBehaviour)_pageSuccess).StartCoroutine(CollectionExtensions.WrapToIl2Cpp(Rotate(((Component)_statusTMP).gameObject)));
				}
				else
				{
					_statusIndicatorCoroutine = CoroutineManager.BlinkIn(_statusIconContainer, 0f);
				}
			}
		}

		[IteratorStateMachine(typeof(<Rotate>d__10))]
		private IEnumerator Rotate(GameObject go, float speed = 120f)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Rotate>d__10(0)
			{
				<>4__this = this,
				speed = speed
			};
		}

		public void BlinkIn()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_medals == (Object)null))
			{
				((Component)_medals).transform.SetParent(_pageSuccess.m_sectorIconAlign);
				ManualLogSource l = Plugin.L;
				bool flag = default(bool);
				BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(18, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Blinking in Page: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)_pageSuccess).name);
				}
				l.LogDebug(val);
				if (((Object)_pageSuccess).name.StartsWith("CM_PageExpeditionSuccess_Resources expended_CellUI 2"))
				{
					Transform transform = ((Component)_medals).transform;
					transform.localPosition -= new Vector3(0f, 138f, 0f);
					Transform transform2 = ((Component)_pbDisplay).transform;
					transform2.localPosition += new Vector3(0f, 16f, 0f);
				}
				_medals.BlinkIn();
				CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(BlinkInRoutine()), (Action)null);
			}
		}

		[IteratorStateMachine(typeof(<BlinkInRoutine>d__13))]
		private IEnumerator BlinkInRoutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <BlinkInRoutine>d__13(0)
			{
				<>4__this = this
			};
		}
	}
	internal static class MedalImages
	{
		private static Sprite _championMedal;

		private static Sprite _goldMedal;

		private static Sprite _silverMedal;

		private static Sprite _bronzeMedal;

		public static Sprite Mask { get; private set; }

		public static Sprite NoMedal { get; private set; }

		public static void Load()
		{
			string? directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			_championMedal = LoadSingle(directoryName + "/Resources/Champion.png");
			_goldMedal = LoadSingle(directoryName + "/Resources/Gold.png");
			_silverMedal = LoadSingle(directoryName + "/Resources/Silver.png");
			_bronzeMedal = LoadSingle(directoryName + "/Resources/Bronze.png");
			Mask = LoadSingle(directoryName + "/Resources/mask_1024px.png");
			NoMedal = LoadSingle(directoryName + "/Resources/NoMedal.png");
		}

		private static Sprite LoadSingle(string path)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			if (!File.Exists(path))
			{
				ManualLogSource l = Plugin.L;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(28, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Medal image file not found: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(path);
				}
				l.LogError(val);
				return null;
			}
			try
			{
				byte[] array = File.ReadAllBytes(path);
				Texture2D val2 = new Texture2D(2, 2);
				ImageConversion.LoadImage(val2, Il2CppStructArray<byte>.op_Implicit(array));
				Object.DontDestroyOnLoad((Object)(object)val2);
				((Object)val2).hideFlags = (HideFlags)61;
				Sprite obj = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f), 100f);
				string text = Path.GetFileName(path).Replace('.', '_');
				((Object)obj).name = "Sprite_" + text;
				((Object)val2).name = "Texture2D_" + text;
				Object.DontDestroyOnLoad((Object)(object)obj);
				((Object)obj).hideFlags = (HideFlags)61;
				return obj;
			}
			catch (Exception ex)
			{
				Plugin.L.LogError((object)ex);
				return null;
			}
		}

		public static Sprite GetSpriteFromMedal(Medal medal)
		{
			return (Sprite)(medal switch
			{
				Medal.Bronze => _bronzeMedal, 
				Medal.Silver => _silverMedal, 
				Medal.Gold => _goldMedal, 
				Medal.Champion => _championMedal, 
				_ => null, 
			});
		}
	}
	internal static class PrefabManager
	{
		private class PrefabInfo
		{
			public bool HasPrefab => (Object)(object)Prefab != (Object)null;

			public bool IsReady { get; private set; }

			public GameObject Prefab { get; private set; }

			public event Action<PrefabInfo> OnReady;

			internal void Create(Type runtimeType, MethodInfo createMethod)
			{
				Action<GameObject> action = delegate(GameObject prefab)
				{
					CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(AfterTwoFrames(delegate
					{
						Prefab = prefab;
						IsReady = true;
						this.OnReady?.Invoke(this);
					})), (Action)null);
				};
				createMethod?.Invoke(null, new object[1] { action });
			}
		}

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

			private object <>2__current;

			public Action action;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				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;
					action?.Invoke();
					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 readonly HashSet<string> _ourTypes = new HashSet<string>();

		private static bool _isSettingUp;

		private static readonly Dictionary<Type, PrefabInfo> _medalPrefabInfos = new Dictionary<Type, PrefabInfo>();

		public static TMP_FontAsset Font { get; internal set; }

		[IteratorStateMachine(typeof(<AfterTwoFrames>d__8))]
		private static IEnumerator AfterTwoFrames(Action action)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <AfterTwoFrames>d__8(0)
			{
				action = action
			};
		}

		internal static void Setup()
		{
			if (!_isSettingUp)
			{
				_isSettingUp = true;
				CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(AfterTwoFrames(CreateAllPrefabs)), (Action)null);
			}
		}

		internal static void Instantiate<T>(Action<T> onInstantiated, Medal medal = Medal.None) where T : IMedalPrefab
		{
			Instantiate(typeof(T), ActionWrapped, medal);
			void ActionWrapped(IMedalPrefab prefab)
			{
				onInstantiated?.Invoke((T)prefab);
			}
		}

		internal static void Instantiate(Type type, Action<IMedalPrefab> onInstantiated, Medal medal = Medal.None)
		{
			Action action = delegate
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Expected O, but got Unknown
				if (!_medalPrefabInfos.TryGetValue(type, out var value2) || !value2.HasPrefab)
				{
					ManualLogSource l2 = Plugin.L;
					bool flag2 = default(bool);
					BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(62, 1, ref flag2);
					if (flag2)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("PrefabManager.Instantiate(): Could not find prefab for type '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(type.Name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'");
					}
					l2.LogError(val2);
				}
				else
				{
					GameObject val3 = Object.Instantiate<GameObject>(value2.Prefab);
					val3.SetActive(true);
					foreach (MonoBehaviour componentsInChild in val3.GetComponentsInChildren<MonoBehaviour>())
					{
						Type il2CppType = ((Object)componentsInChild).GetIl2CppType();
						if (_ourTypes.Contains(il2CppType.FullName))
						{
							MethodInfo method = il2CppType.GetMethod("Init");
							if (method != null)
							{
								((MethodBase)method).Invoke((Object)(object)componentsInChild, (Il2CppReferenceArray<Object>)null);
							}
						}
					}
					IMedalPrefab medalPrefab = ((Il2CppObjectBase)val3.AddComponent(Il2CppType.From(type))).TryCast<MonoBehaviour>() as IMedalPrefab;
					medalPrefab.Init();
					onInstantiated?.Invoke(medalPrefab);
				}
			};
			if (!_medalPrefabInfos.TryGetValue(type, out var value))
			{
				value = (_medalPrefabInfos[type] = new PrefabInfo());
			}
			if (value.IsReady)
			{
				InvokeAction();
			}
			value.OnReady += InvokeAction;
			void InvokeAction(object _ = null)
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Expected O, but got Unknown
				try
				{
					action();
				}
				catch (Exception ex)
				{
					ManualLogSource l = Plugin.L;
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(46, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("PrefabInstantiation action failed! (Type: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(type.FullName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("): ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\n");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
					}
					l.LogError(val);
				}
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private static void CreateAllPrefabs()
		{
			GrabFont(MainMenuGuiLayer.Current.PageLoadout);
			foreach (Type item in from t in AccessTools.GetTypesFromAssembly(Assembly.GetExecutingAssembly())
				where t.IsAssignableTo(typeof(IMedalPrefab))
				select t)
			{
				if (!item.IsInterface)
				{
					if (item.IsAssignableTo(typeof(MonoBehaviour)))
					{
						ClassInjector.RegisterTypeInIl2Cpp(item);
						_ourTypes.Add(item.FullName);
					}
					MethodInfo creatMethod = GetCreatMethod(item, item.FullName);
					if (!_medalPrefabInfos.TryGetValue(item, out var value))
					{
						value = (_medalPrefabInfos[item] = new PrefabInfo());
					}
					value.Create(item, creatMethod);
				}
			}
		}

		private static MethodInfo GetCreatMethod(Type type, string debugName)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			bool flag = default(bool);
			MethodInfo method;
			while (true)
			{
				if (type == typeof(MonoBehaviour) || type == null)
				{
					ManualLogSource l = Plugin.L;
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(42, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Could not find 'Create' method for type '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(debugName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
					}
					l.LogError(val);
					return null;
				}
				method = type.GetMethod("Create", AccessTools.all);
				if (method != null)
				{
					break;
				}
				type = type.BaseType;
			}
			return method;
		}

		internal static void GrabFont(CM_PageLoadout pageLoadout)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			try
			{
				Font = ((TMP_Text)((Il2CppArrayBase<TextMeshPro>)(object)pageLoadout.m_discordButton.m_texts)[0]).font;
			}
			catch (Exception ex)
			{
				ManualLogSource l = Plugin.L;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(37, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to get font and material! - ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.GetType().Name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				l.LogError(val);
			}
		}

		public static void SetToGTFOFont(this TextMeshPro tmp)
		{
			if ((Object)(object)tmp.m_renderer == (Object)null)
			{
				tmp.m_renderer = (Renderer)(object)((Component)tmp).gameObject.GetComponent<MeshRenderer>();
			}
			((TMP_Text)tmp).font = Font;
		}

		public static void SetUILayer(this GameObject go)
		{
			DefaultControls.SetLayerRecursively(go, LayerManager.LAYER_UI);
		}

		public static void DontDestroyAndSetHideFlags(this Object obj)
		{
			if (!(obj == (Object)null))
			{
				Object.DontDestroyOnLoad(obj);
				obj.hideFlags = (HideFlags)61;
			}
		}
	}
}
namespace MedalsMod.GameObj.Prefabs
{
	internal sealed class GenericButton : MonoBehaviour, IMedalPrefab
	{
		public Action OnButtonPressAction;

		[HideFromIl2Cpp]
		public TextMeshPro Text { get; set; }

		public void Init()
		{
			((Component)this).gameObject.GetComponentInChildren<CM_Item>().OnBtnPressCallback = Action<int>.op_Implicit((Action<int>)OnButtonPressed);
			Text = ((Component)this).gameObject.GetComponentInChildren<TextMeshPro>();
			((TMP_Text)Text).SetText("Button", true);
		}

		public void SetPopupSpriteMode(bool value)
		{
			string sortingLayerName = (value ? "MenuPopupSprite" : "MenuSprite");
			foreach (Renderer componentsInChild in ((Component)this).gameObject.GetComponentsInChildren<Renderer>())
			{
				componentsInChild.sortingLayerName = sortingLayerName;
			}
		}

		public void SetText(string text)
		{
			((TMP_Text)Text).SetText(text, true);
		}

		private void OnButtonPressed(int _)
		{
			OnButtonPressAction?.Invoke();
		}

		[HideFromIl2Cpp]
		public static void Create(Action<GameObject> onCompleted)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			GameObject val = Object.Instantiate<GameObject>(((Component)MainMenuGuiLayer.Current.PageRundownNew.m_discordButton).gameObject);
			((Object)val).name = "GenericButton";
			CM_Item componentInChildren = val.GetComponentInChildren<CM_Item>();
			Object.DestroyImmediate((Object)(object)val.GetComponent<TMP_Localizer>());
			componentInChildren.OnBtnPressCallback = Action<int>.op_Implicit((Action<int>)Nothing);
			componentInChildren.m_onBtnPress = new UnityEvent();
			((Object)(object)val).DontDestroyAndSetHideFlags();
			onCompleted?.Invoke(val);
		}

		private static void Nothing(int _)
		{
		}
	}
	internal sealed class HintPopupPrefab : MonoBehaviour, IMedalPrefab
	{
		private class SingleHintDisplay
		{
			public GameObject GameObject { get; set; }

			private TextMeshPro TextMeshPro { get; set; }

			private RectTransform RectTransform { get; set; }

			private MedalWithTimeHeader MedalDisplay { get; set; }

			public SingleHintDisplay(GameObject go)
			{
				GameObject = go;
				TextMeshPro = ((Component)go.transform.FindChild("MainTMP")).GetComponent<TextMeshPro>();
				RectTransform = ((Component)TextMeshPro).GetComponent<RectTransform>();
				MedalDisplay = go.GetComponentInChildren<MedalWithTimeHeader>(true);
			}

			public void UpdateMedalTime(Medal medal, string time)
			{
				MedalDisplay.UpdateDisplay(medal, time);
			}

			public void SetHintText(string text)
			{
				((TMP_Text)TextMeshPro).SetText(text, true);
			}

			public void ApplyLayout(Layout.Entry layout)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: 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)
				GameObject.transform.localPosition = layout.Position;
				((Transform)RectTransform).localPosition = layout.LocalTextPosition;
				RectTransform.sizeDelta = layout.SizeDelta;
			}
		}

		private enum LayoutType
		{
			SquareFour,
			List
		}

		private class Layout
		{
			internal class Entry
			{
				public Vector3 Position { get; init; }

				public Vector3 LocalTextPosition { get; init; }

				public Vector2 SizeDelta { get; init; }
			}

			internal Entry A { get; init; }

			internal Entry B { get; init; }

			internal Entry C { get; init; }

			internal Entry D { get; init; }

			public Entry Get(Medal medal)
			{
				return medal switch
				{
					Medal.Bronze => D, 
					Medal.Silver => C, 
					Medal.Gold => B, 
					_ => A, 
				};
			}
		}

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

			private object <>2__current;

			public HintPopupPrefab <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				int num = <>1__state;
				HintPopupPrefab hintPopupPrefab = <>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;
					string text = ((TMP_Text)hintPopupPrefab._popup.m_upperText).text;
					hintPopupPrefab.SetLayout(LayoutType.List);
					hintPopupPrefab.SetContent(text);
					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 CUSTOM_CONTENT_HOLDER = "CustomContentHolder";

		private const string EXTRA_HEADER_GO = "ExtraHeaderGO";

		private const string DISABLED_PARTS_GO = "DisabledGOs";

		private const string PREFIX_HINT_HOLDER = "HintHolder_";

		private const string TMP_MAIN_GO = "MainTMP";

		private bool _hasInitialized;

		private CM_GlobalPopup _popup;

		private Transform _disabledGOsTrans;

		private Transform _contentHolder;

		private readonly Dictionary<Medal, SingleHintDisplay> _hintDisplays = new Dictionary<Medal, SingleHintDisplay>();

		private TextMeshPro _allHintsHeaderTMP;

		private string _lastLevel;

		private static readonly Dictionary<LayoutType, Layout> Layouts = new Dictionary<LayoutType, Layout>
		{
			{
				LayoutType.SquareFour,
				new Layout
				{
					A = new Layout.Entry
					{
						Position = new Vector3(-620f, 280f, 0f),
						LocalTextPosition = new Vector3(-100f, -55f, 0f),
						SizeDelta = new Vector2(115f, 37.5f)
					},
					B = new Layout.Entry
					{
						Position = new Vector3(-620f, -60f, 0f),
						LocalTextPosition = new Vector3(-100f, -55f, 0f),
						SizeDelta = new Vector2(115f, 37.5f)
					},
					C = new Layout.Entry
					{
						Position = new Vector3(120f, 280f, 0f),
						LocalTextPosition = new Vector3(-100f, -55f, 0f),
						SizeDelta = new Vector2(115f, 37.5f)
					},
					D = new Layout.Entry
					{
						Position = new Vector3(120f, -60f, 0f),
						LocalTextPosition = new Vector3(-100f, -55f, 0f),
						SizeDelta = new Vector2(115f, 37.5f)
					}
				}
			},
			{
				LayoutType.List,
				new Layout
				{
					A = new Layout.Entry
					{
						Position = new Vector3(-620f, 280f, 0f),
						LocalTextPosition = new Vector3(200f, 30f, 0f),
						SizeDelta = new Vector2(172.5f, 18.75f)
					},
					B = new Layout.Entry
					{
						Position = new Vector3(-620f, 90f, 0f),
						LocalTextPosition = new Vector3(200f, 30f, 0f),
						SizeDelta = new Vector2(172.5f, 18.75f)
					},
					C = new Layout.Entry
					{
						Position = new Vector3(-620f, -100f, 0f),
						LocalTextPosition = new Vector3(200f, 30f, 0f),
						SizeDelta = new Vector2(172.5f, 18.75f)
					},
					D = new Layout.Entry
					{
						Position = new Vector3(-620f, -290f, 0f),
						LocalTextPosition = new Vector3(200f, 30f, 0f),
						SizeDelta = new Vector2(172.5f, 18.75f)
					}
				}
			}
		};

		public void Init()
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			if (_hasInitialized)
			{
				return;
			}
			_hasInitialized = true;
			_popup = ((Component)this).gameObject.GetComponent<CM_GlobalPopup>();
			_disabledGOsTrans = ((Component)this).transform.FindChild("DisabledGOs");
			_contentHolder = ((Component)this).transform.FindChild("CustomContentHolder");
			Transform val = _popup.m_contentHolder.FindChild("ExtraHeaderGO");
			CM_Item componentInChildren = ((Component)val).GetComponentInChildren<CM_Item>();
			componentInChildren.m_textAlphaOut = 1f;
			componentInChildren.m_textAlphaOver = 1f;
			componentInChildren.m_spriteAlphaOut = 0.8f;
			componentInChildren.m_spriteAlphaOver = 1f;
			((Il2CppArrayBase<Color>)(object)componentInChildren.m_textColorOut)[0] = Color.black;
			componentInChildren.m_spriteColorOut = new Color(0.75f, 0.67f, 0.64f, 0.8f);
			componentInChildren.m_spriteColorOver = Color.white;
			componentInChildren.OnHoverOut();
			_allHintsHeaderTMP = ((Component)val).GetComponentInChildren<TextMeshPro>();
			componentInChildren.OnBtnPressCallback = Action<int>.op_Implicit((Action<int>)DismissAndShowAll);
			MedalDisplays.RegisterLocalizationUpdateable(new ActionLocalizationUpdate(delegate
			{
				((TMP_Text)_allHintsHeaderTMP).SetText(MedalsLocalization.Get("AllHints"), true);
			}));
			for (int i = 0; i < _contentHolder.childCount; i++)
			{
				Transform child = _contentHolder.GetChild(i);
				if (((Object)child).name.StartsWith("HintHolder_") && Enum.TryParse<Medal>(((Object)child).name.Remove(0, "HintHolder_".Length), out var result))
				{
					_hintDisplays[result] = new SingleHintDisplay(((Component)child).gameObject);
				}
			}
		}

		private void DismissAndShowAll(int _)
		{
			_popup.Close();
			HintsListUI.Instance.Show(_lastLevel);
		}

		public void Start()
		{
			Init();
			foreach (KeyValuePair<Medal, SingleHintDisplay> hintDisplay in _hintDisplays)
			{
				hintDisplay.Deconstruct(out var _, out var value);
				value.GameObject.SetActive(false);
			}
			CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(DelayedSetup()), (Action)null);
		}

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

		private void SetLayout(LayoutType layoutType)
		{
			if (!Layouts.TryGetValue(layoutType, out var value))
			{
				return;
			}
			foreach (var (medal2, singleHintDisplay2) in _hintDisplays)
			{
				singleHintDisplay2.ApplyLayout(value.Get(medal2));
			}
		}

		private void SetContent(string level)
		{
			_lastLevel = level;
			if (!MedalRegistry.AllMedals.TryGetValue(level, out var value))
			{
				value = new MedalTimes("0:0 0:0 0:0 0:0");
			}
			CellSoundPlayer popupSoundPlayer = GlobalPopupMessageManager.Current.m_popupSoundPlayer;
			int num = 0;
			foreach (var (medal2, singleHintDisplay2) in _hintDisplays)
			{
				if (!TryGetHint(level, medal2, out var hint))
				{
					singleHintDisplay2.GameObject.SetActive(false);
					continue;
				}
				float num2 = 1f + 0.6f * (float)num++;
				CoroutineManager.BlinkIn(singleHintDisplay2.GameObject, num2);
				_popup.PlayPopupSoundEffect(singleHintDisplay2.GameObject, popupSoundPlayer, num, num2);
				singleHintDisplay2.UpdateMedalTime(medal2, $"{value.GetTime(medal2)}");
				singleHintDisplay2.SetHintText(hint);
			}
		}

		private static bool TryGetHint(string level, Medal medal, out string hint)
		{
			hint = MedalsLocalization.GetHint(level, medal);
			if (string.IsNullOrWhiteSpace(hint))
			{
				return false;
			}
			return !hint.StartsWith("LOCALIZATION HINT NOT FOUND:");
		}

		[HideFromIl2Cpp]
		public static void Create(Action<GameObject> onCompleted)
		{
			PrefabManager.Instantiate(delegate(MedalWithTimeHeader hintPrefab)
			{
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Expected O, but got Unknown
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_010f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0148: Unknown result type (might be due to invalid IL or missing references)
				//IL_0181: Unknown result type (might be due to invalid IL or missing references)
				//IL_0190: Unknown result type (might be due to invalid IL or missing references)
				//IL_0196: Expected O, but got Unknown
				//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_0230: Unknown result type (might be due to invalid IL or missing references)
				//IL_0244: Unknown result type (might be due to invalid IL or missing references)
				//IL_0249: Unknown result type (might be due to invalid IL or missing references)
				//IL_0283: Unknown result type (might be due to invalid IL or missing references)
				//IL_0297: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_0309: Expected O, but got Unknown
				GameObject val = Object.Instantiate<GameObject>(((Component)GlobalPopupMessageManager.m_popupTypeToPrefabMap[(PopupType)0]).gameObject);
				CM_GlobalPopup component = val.GetComponent<CM_GlobalPopup>();
				((Object)val).name = "MedalsModHintsPopupPrefab";
				GameObject val2 = new GameObject("CustomContentHolder");
				val2.transform.SetParent(val.transform);
				val2.transform.localPosition = Vector3.zero;
				val2.transform.localScale = Vector3.one;
				val2.AddComponent<RectTransform>();
				((Component)hintPrefab).transform.SetParent(val2.transform);
				((Component)hintPrefab).transform.localPosition = new Vector3(-60f, 120f, 0f);
				((Component)hintPrefab).gameObject.SetActive(false);
				CreateHintThing(val2.transform, "HintHolder_" + Medal.Champion, new Vector3(-620f, 280f, 0f));
				CreateHintThing(val2.transform, "HintHolder_" + Medal.Gold, new Vector3(-620f, -60f, 0f));
				CreateHintThing(val2.transform, "HintHolder_" + Medal.Silver, new Vector3(120f, 280f, 0f));
				CreateHintThing(val2.transform, "HintHolder_" + Medal.Bronze, new Vector3(120f, -60f, 0f));
				GameObject val3 = new GameObject("DisabledGOs");
				val3.transform.SetParent(val.transform);
				val3.transform.localPosition = Vector3.zero;
				val3.SetActive(false);
				component.m_upperText.transform.SetParent(val3.transform);
				component.m_lowerText.transform.SetParent(val3.transform);
				GameObject val4 = Object.Instantiate<GameObject>(((Component)component.m_headerText.transform.parent).gameObject, component.m_headerText.transform.parent.parent, true);
				((Object)val4).name = "ExtraHeaderGO";
				Transform transform = val4.transform;
				transform.localPosition += new Vector3(450f, 0f, 0f);
				((TMP_Text)val4.GetComponentInChildren<TextMeshPro>()).SetText(MedalsLocalization.Get("AllHints"), true);
				CM_Item obj = val4.AddComponent<CM_Item>();
				BoxCollider2D obj2 = val4.AddComponent<BoxCollider2D>();
				obj2.size = new Vector2(350f, 35f);
				((Collider2D)obj2).offset = new Vector2(175f, 18f);
				obj.m_textAlphaOut = 1f;
				obj.m_textAlphaOver = 1f;
				obj.m_spriteAlphaOut = 0.9f;
				obj.m_spriteAlphaOver = 1f;
				obj.m_alphaSpriteOnHover = true;
				obj.m_alphaTextOnHover = true;
				obj.m_hoverSpriteArray = Il2CppReferenceArray<SpriteRenderer>.op_Implicit(((IEnumerable<SpriteRenderer>)val4.GetComponentsInChildren<SpriteRenderer>()).ToArray());
				((RectTransformComp)obj).Setup();
				obj.CheckAndSetTextAlpha();
				obj.m_onBtnPress = new UnityEvent();
				obj.OnBtnPressCallback = Action<int>.op_Implicit((Action<int>)delegate
				{
				});
				Object.DontDestroyOnLoad((Object)(object)val);
				((Object)val).hideFlags = (HideFlags)61;
				val.SetActive(false);
				onCompleted(val);
			});
		}

		private static void CreateHintThing(Transform parent, string goName, Vector3 localPosition)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			PrefabManager.Instantiate(delegate(MedalWithTimeHeader hintPrefab)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Expected O, but got Unknown
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0070: 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_0096: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: Unknown result type (might be due to invalid IL or missing references)
				GameObject val = new GameObject(goName);
				val.AddComponent<RectTransform>();
				val.transform.SetParent(parent);
				val.transform.localPosition = localPosition;
				val.transform.localScale = Vector3.one;
				((Component)hintPrefab).transform.parent = val.transform;
				((Component)hintPrefab).transform.localPosition = Vector3.zero;
				GameObject val2 = new GameObject("MainTMP");
				val2.transform.SetParent(val.transform);
				val2.transform.localPosition = new Vector3(-100f, -55f, 0f);
				val2.transform.localScale = Vector3.one * 6f;
				RectTransform obj = val2.AddComponent<RectTransform>();
				obj.sizeDelta = new Vector2(115f, 37.5f);
				obj.pivot = new Vector2(0f, 1f);
				TextMeshPro obj2 = val2.AddComponent<TextMeshPro>();
				obj2.SetToGTFOFont();
				obj2.sortingLayerID = SortingLayer.NameToID("GlobalPopupText");
				((TMP_Text)obj2).SetText(string.Empty, true);
				((TMP_Text)obj2).overflowMode = (TextOverflowModes)1;
				val.SetUILayer();
			});
		}
	}
	internal sealed class MedalIconsHorizontal : MonoBehaviour, IMedalPrefab
	{
		[CompilerGenerated]
		private sealed class <BlinkInRoutine>d__4 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public MedalIconsHorizontal <>4__this;

			public float initialDelay;

			private Medal <achievedMedal>5__2;

			private Dictionary<Medal, SingleMedalWithMask>.Enumerator <>7__wrap2;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 2)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<>7__wrap2 = default(Dictionary<Medal, SingleMedalWithMask>.Enumerator);
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0108: Expected O, but got Unknown
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Expected O, but got Unknown
				try
				{
					int num = <>1__state;
					MedalIconsHorizontal medalIconsHorizontal = <>4__this;
					Medal key;
					SingleMedalWithMask value;
					switch (num)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						foreach (KeyValuePair<Medal, SingleMedalWithMask> medalDisplay in medalIconsHorizontal.MedalDisplays)
						{
							medalDisplay.Deconstruct(out key, out value);
							value.Reset();
						}
						<>2__current = (object)new WaitForSeconds(initialDelay);
						<>1__state = 1;
						return true;
					case 1:
						<>1__state = -1;
						<achievedMedal>5__2 = TimeCollector.GetMedalForLastRun();
						if (<achievedMedal>5__2 == Medal.None)
						{
							return false;
						}
						<>7__wrap2 = medalIconsHorizontal.MedalDisplays.GetEnumerator();
						<>1__state = -3;
						break;
					case 2:
						<>1__state = -3;
						break;
					}
					while (<>7__wrap2.MoveNext())
					{
						<>7__wrap2.Current.Deconstruct(out key, out value);
						Medal num2 = key;
						SingleMedalWithMask singleMedalWithMask = value;
						if (num2 <= <achievedMedal>5__2)
						{
							singleMedalWithMask.Reveal();
							<>2__current = (object)new WaitForSeconds(0.7f);
							<>1__state = 2;
							return true;
						}
					}
					<>m__Finally1();
					<>7__wrap2 = default(Dictionary<Medal, SingleMedalWithMask>.Enumerator);
					return false;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

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

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

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

		private const string PREFIX_GAMEOBJECTS = "MedalHolder_";

		internal Dictionary<Medal, SingleMedalWithMask> MedalDisplays = new Dictionary<Medal, SingleMedalWithMask>();

		public void Init()
		{
			for (int i = 0; i < ((Component)this).transform.childCount; i++)
			{
				Transform child = ((Component)this).transform.GetChild(i);
				if (((Object)child).name.StartsWith("MedalHolder_") && Enum.TryParse<Medal>(((Object)child).name.Substring("MedalHolder_".Length), out var result))
				{
					SingleMedalWithMask component = ((Component)child).GetComponent<SingleMedalWithMask>();
					MedalDisplays[result] = component;
					component.Setup(result);
				}
			}
		}

		public void BlinkIn()
		{
			float num = 8.5f;
			bool num2 = RundownManager.HasSecondaryLayer(RundownManager.ActiveExpedition);
			bool flag = RundownManager.HasThirdLayer(RundownManager.ActiveExpedition);
			if (!num2)
			{
				num -= 1.1f;
			}
			if (!flag)
			{
				num -= 1.1f;
			}
			CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(BlinkInRoutine(num)), (Action)null);
		}

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

		[HideFromIl2Cpp]
		public static void Create(Action<GameObject> onCompleted)
		{
			PrefabManager.Instantiate(delegate(SingleMedalWithMask displayBronze)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Expected O, but got Unknown
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				GameObject val = new GameObject("MedalContainer");
				val.AddComponent<RectTransform>();
				SortingGroup obj = val.AddComponent<SortingGroup>();
				obj.sortingLayerName = "MenuPopupSprite";
				obj.sortingOrder = 3;
				((Object)displayBronze).name = $"{"MedalHolder_"}{1}";
				((Component)displayBronze).transform.SetParent(val.transform);
				((Component)displayBronze).transform.localPosition = Vector3.zero;
				CreateMedal(val.transform, Medal.Silver);
				CreateMedal(val.transform, Medal.Gold);
				CreateMedal(val.transform, Medal.Champion);
				val.SetUILayer();
				((Object)(object)val).DontDestroyAndSetHideFlags();
				onCompleted?.Invoke(val);
			});
		}

		private static void CreateMedal(Transform parent, Medal medal)
		{
			PrefabManager.Instantiate(delegate(SingleMedalWithMask display)
			{
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: Unknown result t