Decompiled source of BadgeRemover v1.1.6

plugins/BadgeRemover.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using Steamworks;
using UnityEngine;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BadgeRemover")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("BadgeRemover")]
[assembly: AssemblyTitle("BadgeLocker")]
[assembly: AssemblyVersion("0.1.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BadgeRemover
{
	[BepInPlugin("BadgeRemover", "Badge Manager", "1.1.7")]
	public class BadgeRemoverPlugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<BadgeData, bool> <>9__15_0;

			public static Func<BadgeData, bool> <>9__15_1;

			public static WindowFunction <>9__16_0;

			internal bool <RefreshCache>b__15_0(BadgeData b)
			{
				return (Object)(object)b != (Object)null && !b.IsLocked;
			}

			internal bool <RefreshCache>b__15_1(BadgeData b)
			{
				return (Object)(object)b != (Object)null && b.IsLocked;
			}

			internal void <OnGUI>b__16_0(int id)
			{
			}
		}

		private bool _showMenu = false;

		private Vector2 _scrollPosition;

		private int _currentTab = 0;

		private GUIStyle _windowStyle;

		private GUIStyle _buttonStyle;

		private GUIStyle _labelStyle;

		private GUIStyle _selectedButtonStyle;

		private GUIStyle _tooltipStyle;

		private ConfigEntry<KeyCode> _toggleBadgeMenuKey;

		private bool _needsRefresh = true;

		private int _cachedMaxAscent = 0;

		private List<BadgeData> _unlockedBadges = new List<BadgeData>();

		private List<BadgeData> _lockedBadges = new List<BadgeData>();

		private void Awake()
		{
			_toggleBadgeMenuKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("1. General", "Menu Key", (KeyCode)282, "The key used to open and close the Badge Manager menu.");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Badge Remover/Manager mod loaded!");
		}

		private void Update()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(_toggleBadgeMenuKey.Value))
			{
				_showMenu = !_showMenu;
				if (_showMenu)
				{
					_needsRefresh = true;
				}
			}
			if (_showMenu && _needsRefresh)
			{
				RefreshCache();
				_needsRefresh = false;
			}
		}

		private void RefreshCache()
		{
			AchievementManager instance = Singleton<AchievementManager>.Instance;
			if (!((Object)(object)instance != (Object)null))
			{
				return;
			}
			instance.GetSteamStatInt((STEAMSTATTYPE)13, ref _cachedMaxAscent);
			if ((Object)(object)GUIManager.instance != (Object)null && (Object)(object)GUIManager.instance.mainBadgeManager != (Object)null && GUIManager.instance.mainBadgeManager.badgeData != null)
			{
				BadgeData[] badgeData = GUIManager.instance.mainBadgeManager.badgeData;
				_unlockedBadges = badgeData.Where((BadgeData b) => (Object)(object)b != (Object)null && !b.IsLocked).ToList();
				_lockedBadges = badgeData.Where((BadgeData b) => (Object)(object)b != (Object)null && b.IsLocked).ToList();
			}
		}

		private void OnGUI()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Invalid comparison between Unknown and I4
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Expected O, but got Unknown
			if (!_showMenu)
			{
				return;
			}
			if (_windowStyle == null)
			{
				InitializeStyles();
			}
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(20f, 20f, 420f, 500f);
			GUI.Window(0, val, new WindowFunction(DrawMenuWindow), "Badge Manager (Press F1 to close)", _windowStyle);
			if (!string.IsNullOrEmpty(GUI.tooltip))
			{
				_tooltipStyle.richText = true;
				GUIContent val2 = new GUIContent(GUI.tooltip);
				Vector2 val3 = _tooltipStyle.CalcSize(val2);
				float num = 300f;
				float num2 = Mathf.Min(val3.x, num);
				float num3 = _tooltipStyle.CalcHeight(val2, num2);
				Rect val4 = default(Rect);
				((Rect)(ref val4))..ctor(Event.current.mousePosition.x + 15f, Event.current.mousePosition.y + 15f, num2, num3);
				Rect val5 = val4;
				object obj = <>c.<>9__16_0;
				if (obj == null)
				{
					WindowFunction val6 = delegate
					{
					};
					<>c.<>9__16_0 = val6;
					obj = (object)val6;
				}
				GUI.Window(999, val5, (WindowFunction)obj, val2, _tooltipStyle);
				GUI.BringWindowToFront(999);
			}
			if ((int)Event.current.type == 7)
			{
				GUI.tooltip = null;
			}
		}

		private void InitializeStyles()
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_009e: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Expected O, but got Unknown
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Expected O, but got Unknown
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Expected O, but got Unknown
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Expected O, but got Unknown
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Expected O, but got Unknown
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Expected O, but got Unknown
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Expected O, but got Unknown
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Expected O, but got Unknown
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Expected O, but got Unknown
			Color col = default(Color);
			((Color)(ref col))..ctor(0.12f, 0.13f, 0.15f, 0.98f);
			Color val = default(Color);
			((Color)(ref val))..ctor(0.18f, 0.2f, 0.22f);
			Color borderColor = default(Color);
			((Color)(ref borderColor))..ctor(0.23f, 0.29f, 0.36f);
			Color col2 = default(Color);
			((Color)(ref col2))..ctor(0.08f, 0.45f, 0.82f);
			Color col3 = default(Color);
			((Color)(ref col3))..ctor(0.1f, 0.55f, 0.95f);
			Color white = Color.white;
			_windowStyle = new GUIStyle(GUI.skin.window);
			_windowStyle.normal.background = MakeTex(1, 1, col);
			_windowStyle.onNormal.background = _windowStyle.normal.background;
			_windowStyle.normal.textColor = white;
			_windowStyle.fontStyle = (FontStyle)1;
			_windowStyle.padding = new RectOffset(10, 10, 25, 10);
			_buttonStyle = new GUIStyle(GUI.skin.button);
			_buttonStyle.normal.background = MakeTex(1, 1, val);
			_buttonStyle.hover.background = MakeTex(1, 1, col2);
			_buttonStyle.active.background = MakeTex(1, 1, col3);
			_buttonStyle.normal.textColor = white;
			_buttonStyle.hover.textColor = white;
			_buttonStyle.active.textColor = white;
			_buttonStyle.fontSize = 14;
			_buttonStyle.fontStyle = (FontStyle)1;
			_buttonStyle.padding = new RectOffset(10, 10, 8, 8);
			_buttonStyle.margin = new RectOffset(4, 4, 4, 4);
			_buttonStyle.border = new RectOffset(2, 2, 2, 2);
			_selectedButtonStyle = new GUIStyle(_buttonStyle);
			_selectedButtonStyle.normal.background = MakeTex(1, 1, col2);
			_selectedButtonStyle.hover.background = MakeTex(1, 1, col3);
			_labelStyle = new GUIStyle(GUI.skin.label);
			_labelStyle.normal.textColor = new Color(0.9f, 0.9f, 0.9f, 1f);
			_labelStyle.fontSize = 16;
			_labelStyle.alignment = (TextAnchor)3;
			_tooltipStyle = new GUIStyle(GUI.skin.box);
			_tooltipStyle.normal.background = MakeTexWithBorder(8, 8, val, borderColor, 1);
			_tooltipStyle.border = new RectOffset(3, 3, 3, 3);
			_tooltipStyle.normal.textColor = white;
			_tooltipStyle.alignment = (TextAnchor)0;
			_tooltipStyle.padding = new RectOffset(8, 8, 8, 8);
			_tooltipStyle.wordWrap = true;
		}

		private Texture2D MakeTexWithBorder(int width, int height, Color backgroundColor, Color borderColor, int borderThickness)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_0045: 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)
			Texture2D val = new Texture2D(width, height);
			for (int i = 0; i < height; i++)
			{
				for (int j = 0; j < width; j++)
				{
					if (j < borderThickness || j >= width - borderThickness || i < borderThickness || i >= height - borderThickness)
					{
						val.SetPixel(j, i, borderColor);
					}
					else
					{
						val.SetPixel(j, i, backgroundColor);
					}
				}
			}
			val.Apply();
			return val;
		}

		private void DrawMenuWindow(int windowID)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			GUI.DragWindow(new Rect(20f, 20f, 420f, 10f));
			if ((Object)(object)GUIManager.instance == (Object)null || (Object)(object)GUIManager.instance.mainBadgeManager == (Object)null || (Object)(object)Singleton<Customization>.Instance == (Object)null || (Object)(object)SingletonAsset<AscentData>.Instance == (Object)null || (Object)(object)Singleton<AchievementManager>.Instance == (Object)null)
			{
				GUILayout.Label("Waiting for game to load, please enter the Aiport.", _labelStyle, Array.Empty<GUILayoutOption>());
				return;
			}
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Lock Badges", (_currentTab == 0) ? _selectedButtonStyle : _buttonStyle, Array.Empty<GUILayoutOption>()))
			{
				_currentTab = 0;
			}
			if (GUILayout.Button("Unlock Badges", (_currentTab == 1) ? _selectedButtonStyle : _buttonStyle, Array.Empty<GUILayoutOption>()))
			{
				_currentTab = 1;
			}
			if (GUILayout.Button("Ascents", (_currentTab == 2) ? _selectedButtonStyle : _buttonStyle, Array.Empty<GUILayoutOption>()))
			{
				_currentTab = 2;
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(15f);
			if (_currentTab == 0)
			{
				DrawLockTab();
			}
			else if (_currentTab == 1)
			{
				DrawUnlockTab();
			}
			else
			{
				DrawAscentsTab();
			}
		}

		private void DrawAscentsTab()
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Expected O, but got Unknown
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Lock All Ascents", _buttonStyle, Array.Empty<GUILayoutOption>()))
			{
				Ascents.LockAll();
				TriggerRefresh();
			}
			if (GUILayout.Button("Unlock All Ascents", _buttonStyle, Array.Empty<GUILayoutOption>()))
			{
				Ascents.UnlockAll();
				TriggerRefresh();
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(10f);
			_scrollPosition = GUILayout.BeginScrollView(_scrollPosition, Array.Empty<GUILayoutOption>());
			List<AscentInstanceData> ascents = SingletonAsset<AscentData>.Instance.ascents;
			for (int i = 0; i < ascents.Count; i++)
			{
				AscentInstanceData val = ascents[i];
				string text = val.title.ToUpperInvariant();
				string text2 = val.localizedTitle.ToUpperInvariant();
				if (text.Contains("TENDERFOOT") || text2.Contains("TENDERFOOT") || text.Contains("CUSTOM") || text2.Contains("CUSTOM"))
				{
					continue;
				}
				bool flag = _cachedMaxAscent >= i - 1;
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				if ((Object)(object)val.sashSprite != (Object)null && (Object)(object)val.sashSprite.texture != (Object)null)
				{
					GUIContent val2 = new GUIContent((Texture)(object)val.sashSprite.texture, "<b>Reward:</b> " + val.localizedReward);
					GUILayout.Label(val2, (GUILayoutOption[])(object)new GUILayoutOption[2]
					{
						GUILayout.Width(48f),
						GUILayout.Height(48f)
					});
				}
				else
				{
					GUILayout.Space(56f);
				}
				string text3 = (flag ? " <color=green>(Unlocked)</color>" : " <color=red>(Locked)</color>");
				_labelStyle.richText = true;
				GUILayout.Label(val.localizedTitle + " " + text3, _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(210f),
					GUILayout.Height(48f)
				});
				_labelStyle.richText = false;
				if (flag)
				{
					if (GUILayout.Button("Lock", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
					{
						GUILayout.Width(100f),
						GUILayout.Height(48f)
					}))
					{
						int ascentLevel = Math.Max(0, i - 2);
						SetAscentLevel(ascentLevel);
					}
				}
				else if (GUILayout.Button("Unlock", _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(100f),
					GUILayout.Height(48f)
				}))
				{
					SetAscentLevel(i - 1);
				}
				GUILayout.EndHorizontal();
			}
			GUILayout.EndScrollView();
		}

		private void DrawLockTab()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Expected O, but got Unknown
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.Label("Click on a badge to remove/re-lock it.", _labelStyle, Array.Empty<GUILayoutOption>());
			_scrollPosition = GUILayout.BeginScrollView(_scrollPosition, Array.Empty<GUILayoutOption>());
			foreach (BadgeData unlockedBadge in _unlockedBadges)
			{
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				List<CustomizationOption> list = Singleton<Customization>.Instance.TryGetUnlockedCosmetics(unlockedBadge);
				if (list.Count > 0 && (Object)(object)list[0] != (Object)null && (Object)(object)list[0].texture != (Object)null)
				{
					GUIContent val = new GUIContent(list[0].texture, GetCosmeticRequirementText(list[0], unlockedBadge));
					GUILayout.Label(val, (GUILayoutOption[])(object)new GUILayoutOption[2]
					{
						GUILayout.Width(48f),
						GUILayout.Height(48f)
					});
				}
				else
				{
					GUILayout.Space(52f);
				}
				if ((Object)(object)unlockedBadge.icon != (Object)null)
				{
					GUIContent val2 = new GUIContent(unlockedBadge.icon, "<b>" + unlockedBadge.displayName + "</b>\n\n" + unlockedBadge.description);
					GUILayout.Label(val2, (GUILayoutOption[])(object)new GUILayoutOption[2]
					{
						GUILayout.Width(48f),
						GUILayout.Height(48f)
					});
				}
				if (GUILayout.Button(unlockedBadge.displayName, _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(260f),
					GUILayout.Height(48f)
				}))
				{
					LockAchievement(unlockedBadge.linkedAchievement);
				}
				GUILayout.EndHorizontal();
			}
			GUILayout.EndScrollView();
		}

		private void DrawUnlockTab()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Expected O, but got Unknown
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.Label("Click on a badge to unlock it.", _labelStyle, Array.Empty<GUILayoutOption>());
			_scrollPosition = GUILayout.BeginScrollView(_scrollPosition, Array.Empty<GUILayoutOption>());
			foreach (BadgeData lockedBadge in _lockedBadges)
			{
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				List<CustomizationOption> list = Singleton<Customization>.Instance.TryGetUnlockedCosmetics(lockedBadge);
				if (list.Count > 0 && (Object)(object)list[0] != (Object)null && (Object)(object)list[0].texture != (Object)null)
				{
					GUIContent val = new GUIContent(list[0].texture, GetCosmeticRequirementText(list[0], lockedBadge));
					GUILayout.Label(val, (GUILayoutOption[])(object)new GUILayoutOption[2]
					{
						GUILayout.Width(48f),
						GUILayout.Height(48f)
					});
				}
				else
				{
					GUILayout.Space(52f);
				}
				if ((Object)(object)lockedBadge.icon != (Object)null)
				{
					GUIContent val2 = new GUIContent(lockedBadge.icon, "<b>" + lockedBadge.displayName + "</b>\n\n" + lockedBadge.description);
					GUILayout.Label(val2, (GUILayoutOption[])(object)new GUILayoutOption[2]
					{
						GUILayout.Width(48f),
						GUILayout.Height(48f)
					});
				}
				if (GUILayout.Button(lockedBadge.displayName, _buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(260f),
					GUILayout.Height(48f)
				}))
				{
					UnlockAchievement(lockedBadge.linkedAchievement);
				}
				GUILayout.EndHorizontal();
			}
			GUILayout.EndScrollView();
		}

		private Texture2D MakeTex(int width, int height, Color col)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			Color[] array = (Color[])(object)new Color[width * height];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = col;
			}
			Texture2D val = new Texture2D(width, height);
			val.SetPixels(array);
			val.Apply();
			return val;
		}

		private string GetCosmeticRequirementText(CustomizationOption cosmetic, BadgeData badge)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Invalid comparison between Unknown and I4
			string text = "<b>Cosmetic: " + badge.displayName + "</b>\n\nRequired for unlock:\n";
			if ((Object)(object)cosmetic == (Object)(object)Singleton<Customization>.Instance.goatHat)
			{
				return text + "Complete the final Ascent.";
			}
			if ((Object)(object)cosmetic == (Object)(object)Singleton<Customization>.Instance.crownHat)
			{
				return text + "Unlock all base-game badges.";
			}
			if ((int)cosmetic.requiredAchievement > 0)
			{
				return text + badge.description;
			}
			return "<b>Cosmetic: " + badge.displayName + "</b>\n\nNo special requirement.";
		}

		private void SetAscentLevel(int level)
		{
			AchievementManager instance = Singleton<AchievementManager>.Instance;
			if ((Object)(object)instance != (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"Setting Max Ascent to {level}");
				instance.SetSteamStat((STEAMSTATTYPE)13, level);
				TriggerRefresh();
			}
		}

		private void UnlockAchievement(ACHIEVEMENTTYPE achievementToUnlock)
		{
			//IL_000c: 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)
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"Attempting to unlock achievement: {achievementToUnlock}");
			AchievementManager instance = Singleton<AchievementManager>.Instance;
			if ((Object)(object)instance != (Object)null)
			{
				MethodInfo method = typeof(AchievementManager).GetMethod("ThrowAchievement", BindingFlags.Instance | BindingFlags.NonPublic);
				if (method != null)
				{
					method.Invoke(instance, new object[1] { achievementToUnlock });
					TriggerRefresh();
				}
			}
		}

		private unsafe void LockAchievement(ACHIEVEMENTTYPE achievementToLock)
		{
			//IL_00c6: 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)
			string text = ((object)(*(ACHIEVEMENTTYPE*)(&achievementToLock))/*cast due to .constrained prefix*/).ToString();
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Attempting to lock achievement: " + text));
			AchievementManager instance = Singleton<AchievementManager>.Instance;
			if (!((Object)(object)instance != (Object)null))
			{
				return;
			}
			SteamUserStats.ClearAchievement(text);
			FieldInfo field = typeof(AchievementManager).GetField("steamStatBasedAchievements", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null && field.GetValue(instance) is IEnumerable enumerable)
			{
				foreach (object item in enumerable)
				{
					FieldInfo field2 = item.GetType().GetField("achievementType");
					if (field2 != null && (ACHIEVEMENTTYPE)field2.GetValue(item) == achievementToLock)
					{
						FieldInfo field3 = item.GetType().GetField("statType");
						if (field3 != null)
						{
							object value = field3.GetValue(item);
							SteamUserStats.SetStat(value.ToString(), 0);
						}
						break;
					}
				}
			}
			if (SteamUserStats.StoreStats())
			{
				TriggerRefresh();
			}
		}

		private void TriggerRefresh()
		{
			_needsRefresh = true;
			((MonoBehaviour)this).Invoke("RefreshGameUI", 0.2f);
		}

		private void RefreshGameUI()
		{
			if ((Object)(object)Character.localCharacter != (Object)null)
			{
				BadgeUnlocker component = ((Component)Character.localCharacter).GetComponent<BadgeUnlocker>();
				if ((Object)(object)component != (Object)null)
				{
					component.BadgeUnlockVisual();
				}
			}
			if ((Object)(object)GUIManager.instance != (Object)null && (Object)(object)GUIManager.instance.mainBadgeManager != (Object)null)
			{
				((MonoBehaviour)GUIManager.instance.mainBadgeManager).Invoke("InitBadges", 0f);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}