Decompiled source of Risky Stats v1.2.2

plugins/RiskyStats.dll

Decompiled 2 months 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.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using On.RoR2;
using On.RoR2.UI;
using RoR2;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RiskyStats")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RiskyStats")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e2f06f9f-3a70-4624-ba24-44bb1f34c38f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RiskyStats;

public static class ProgressSettings
{
	public static KeyCode ToggleKey = (KeyCode)98;

	private static ConfigEntry<KeyCode> toggleKeyEntry;

	public static void Init(ConfigFile config)
	{
		//IL_0022: 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)
		toggleKeyEntry = config.Bind<KeyCode>("General", "Progress Toggle Key", (KeyCode)98, "Key to hold to show the run progress panel");
		ToggleKey = toggleKeyEntry.Value;
	}
}
public static class RunProgressStats
{
	public static float TotalDamage;

	public static float TotalDamageTaken;

	public static float TotalHealing;

	public static float MaxSpeed;

	public static float BiggestHit;

	public static bool BiggestHitCrit;

	public static float TotalDistance;

	public static int ChestsOpened;

	public static float GoldCollected;

	public static int DronesUsed;

	private static bool hooked;

	private static Vector3 lastPosition;

	private static bool hasLastPosition;

	public static void Init()
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Expected O, but got Unknown
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Expected O, but got Unknown
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Expected O, but got Unknown
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Expected O, but got Unknown
		if (!hooked)
		{
			hooked = true;
			GlobalEventManager.onServerDamageDealt += OnDamageDealt;
			HealthComponent.TakeDamage += new hook_TakeDamage(OnDamageTaken);
			HealthComponent.Heal += new hook_Heal(OnHealing);
			Run.onRunStartGlobal += OnRunStart;
			CharacterMaster.GiveMoney += new hook_GiveMoney(OnGiveMoney);
			PurchaseInteraction.OnInteractionBegin += new hook_OnInteractionBegin(OnPurchaseInteractionBegin);
		}
	}

	private static void OnRunStart(Run run)
	{
		ResetStats();
	}

	public static void ResetStats()
	{
		TotalDamage = 0f;
		TotalDamageTaken = 0f;
		TotalHealing = 0f;
		MaxSpeed = 0f;
		BiggestHit = 0f;
		BiggestHitCrit = false;
		TotalDistance = 0f;
		hasLastPosition = false;
		ChestsOpened = 0;
		GoldCollected = 0f;
		DronesUsed = 0;
	}

	private static bool IsLocalPlayerBody(CharacterBody body)
	{
		LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
		CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
		return (Object)(object)val != (Object)null && (Object)(object)body == (Object)(object)val;
	}

	private static bool IsLocalPlayerMaster(CharacterMaster master)
	{
		LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
		CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
		return (Object)(object)val != (Object)null && (Object)(object)master != (Object)null && (Object)(object)master == (Object)(object)val.master;
	}

	private static void OnDamageDealt(DamageReport report)
	{
		LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
		CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
		if (!((Object)(object)val == (Object)null) && !((Object)(object)report.attackerBody != (Object)(object)val))
		{
			TotalDamage += report.damageDealt;
			if (report.damageDealt > BiggestHit)
			{
				BiggestHit = report.damageDealt;
				BiggestHitCrit = report.damageInfo.crit;
			}
		}
	}

	private static void OnDamageTaken(orig_TakeDamage orig, HealthComponent self, DamageInfo info)
	{
		orig.Invoke(self, info);
		LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
		CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
		if (!((Object)(object)val == (Object)null) && !((Object)(object)self.body != (Object)(object)val))
		{
			TotalDamageTaken += info.damage;
		}
	}

	private static float OnHealing(orig_Heal orig, HealthComponent self, float amount, ProcChainMask procChainMask, bool nonRegen)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		float num = orig.Invoke(self, amount, procChainMask, nonRegen);
		LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
		CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
		if ((Object)(object)val != (Object)null && (Object)(object)self.body == (Object)(object)val)
		{
			TotalHealing += num;
		}
		return num;
	}

	private static void OnGiveMoney(orig_GiveMoney orig, CharacterMaster self, uint amount)
	{
		orig.Invoke(self, amount);
		if (IsLocalPlayerMaster(self))
		{
			GoldCollected += amount;
		}
	}

	private static void OnPurchaseInteractionBegin(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator)
	{
		bool available = self.available;
		orig.Invoke(self, activator);
		if ((Object)(object)activator == (Object)null || !available)
		{
			return;
		}
		CharacterBody component = ((Component)activator).GetComponent<CharacterBody>();
		if (!IsLocalPlayerBody(component))
		{
			return;
		}
		if ((Object)(object)((Component)self).GetComponent<ChestBehavior>() != (Object)null)
		{
			ChestsOpened++;
			return;
		}
		SummonMasterBehavior component2 = ((Component)self).GetComponent<SummonMasterBehavior>();
		if (!((Object)(object)component2 == (Object)null) && ((Object)((Component)self).gameObject).name.IndexOf("Drone", StringComparison.OrdinalIgnoreCase) >= 0)
		{
			DronesUsed++;
		}
	}

	public static void TrackSpeed(CharacterBody body)
	{
		if (!((Object)(object)body == (Object)null) && !((Object)(object)body.characterMotor == (Object)null))
		{
			float magnitude = ((Vector3)(ref body.characterMotor.velocity)).magnitude;
			if (magnitude > MaxSpeed)
			{
				MaxSpeed = magnitude;
			}
		}
	}

	public static void TrackDistance(CharacterBody body)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: 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_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)body == (Object)null)
		{
			hasLastPosition = false;
			return;
		}
		Vector3 position = ((Component)body).transform.position;
		if (hasLastPosition)
		{
			float num = Vector3.Distance(lastPosition, position);
			if (num < 50f)
			{
				TotalDistance += num;
			}
		}
		lastPosition = position;
		hasLastPosition = true;
	}

	public static string FormatNumber(float number)
	{
		if (number >= 1E+12f)
		{
			return (number / 1E+12f).ToString("0.0") + "t";
		}
		if (number >= 1E+09f)
		{
			return (number / 1E+09f).ToString("0.0") + "b";
		}
		if (number >= 1000000f)
		{
			return (number / 1000000f).ToString("0.0") + "m";
		}
		if (number >= 1000f)
		{
			return (number / 1000f).ToString("0.0") + "k";
		}
		return number.ToString("0");
	}

	public static string FormatDistance(float meters)
	{
		if (meters >= 1000f)
		{
			return (meters / 1000f).ToString("0.00") + " km";
		}
		return meters.ToString("0") + " m";
	}
}
public class RunProgressUI : MonoBehaviour
{
	private GameObject panelObject;

	private HUD cachedHud;

	private TextMeshProUGUI damageText;

	private TextMeshProUGUI damageTakenText;

	private TextMeshProUGUI healingText;

	private TextMeshProUGUI maxSpeedText;

	private TextMeshProUGUI biggestHitText;

	private TextMeshProUGUI chestsOpenedText;

	private TextMeshProUGUI goldCollectedText;

	private TextMeshProUGUI dronesUsedText;

	private TextMeshProUGUI distanceRanText;

	private static readonly Color BackgroundColor = new Color(0.05f, 0.07f, 0.18f, 0.97f);

	private static readonly Color BorderColor = new Color(1f, 0.82f, 0.2f, 1f);

	private static readonly Color RowColor = new Color(0.09f, 0.11f, 0.24f, 1f);

	private static readonly Color RowColorAlt = new Color(0.11f, 0.13f, 0.27f, 1f);

	private static readonly Color AccentColor = new Color(1f, 0.82f, 0.2f, 1f);

	private static readonly Color SubTextColor = new Color(0.65f, 0.68f, 0.8f, 1f);

	private const float PanelWidth = 420f;

	private const float RowHeight = 34f;

	private const float RowSpacing = 6f;

	private float refreshTimer;

	private const float RefreshInterval = 0.05f;

	private void Awake()
	{
		RunProgressStats.Init();
	}

	private void Update()
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)panelObject == (Object)null)
		{
			if ((Object)(object)cachedHud == (Object)null)
			{
				cachedHud = Object.FindObjectOfType<HUD>();
			}
			if ((Object)(object)cachedHud == (Object)null)
			{
				return;
			}
			CreatePanel(cachedHud);
		}
		bool key = UnityInput.Current.GetKey(ProgressSettings.ToggleKey);
		if (key != panelObject.activeSelf)
		{
			panelObject.SetActive(key);
		}
		LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
		CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
		RunProgressStats.TrackDistance(val);
		CharacterBody body = (key ? val : null);
		if (key)
		{
			RunProgressStats.TrackSpeed(body);
		}
		if (key)
		{
			refreshTimer += Time.deltaTime;
			if (refreshTimer >= 0.05f)
			{
				refreshTimer = 0f;
				RefreshValues();
			}
		}
	}

	private void CreatePanel(HUD hud)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: 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
		panelObject = new GameObject("RiskyStatsProgressPanel");
		panelObject.transform.SetParent(hud.mainContainer.transform, false);
		RectTransform val = panelObject.AddComponent<RectTransform>();
		val.anchorMin = new Vector2(0.5f, 0.5f);
		val.anchorMax = new Vector2(0.5f, 0.5f);
		val.pivot = new Vector2(0.5f, 0.5f);
		val.anchoredPosition = Vector2.zero;
		val.sizeDelta = new Vector2(420f, 100f);
		Image val2 = panelObject.AddComponent<Image>();
		((Graphic)val2).color = BackgroundColor;
		Outline val3 = panelObject.AddComponent<Outline>();
		((Shadow)val3).effectColor = BorderColor;
		((Shadow)val3).effectDistance = new Vector2(2f, -2f);
		VerticalLayoutGroup val4 = panelObject.AddComponent<VerticalLayoutGroup>();
		((LayoutGroup)val4).padding = new RectOffset(18, 18, 18, 18);
		((HorizontalOrVerticalLayoutGroup)val4).spacing = 6f;
		((LayoutGroup)val4).childAlignment = (TextAnchor)1;
		((HorizontalOrVerticalLayoutGroup)val4).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)val4).childControlHeight = true;
		((HorizontalOrVerticalLayoutGroup)val4).childForceExpandWidth = false;
		((HorizontalOrVerticalLayoutGroup)val4).childForceExpandHeight = false;
		ContentSizeFitter val5 = panelObject.AddComponent<ContentSizeFitter>();
		val5.horizontalFit = (FitMode)0;
		val5.verticalFit = (FitMode)2;
		CreateTitle(panelObject.transform);
		CreateDivider(panelObject.transform);
		damageText = CreateStatRow(panelObject.transform, "Total Damage", alt: false);
		damageTakenText = CreateStatRow(panelObject.transform, "Total Damage Taken", alt: true);
		healingText = CreateStatRow(panelObject.transform, "Total Healing", alt: false);
		maxSpeedText = CreateStatRow(panelObject.transform, "Max Speed Achieved", alt: true);
		biggestHitText = CreateStatRow(panelObject.transform, "Biggest Hit", alt: false);
		chestsOpenedText = CreateStatRow(panelObject.transform, "Chests Opened", alt: true);
		goldCollectedText = CreateStatRow(panelObject.transform, "Gold Collected", alt: false);
		dronesUsedText = CreateStatRow(panelObject.transform, "Drones Used", alt: true);
		distanceRanText = CreateStatRow(panelObject.transform, "Distance Ran", alt: false);
		panelObject.SetActive(false);
	}

	private void CreateTitle(Transform parent)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("Title");
		val.transform.SetParent(parent, false);
		TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val2).text = "RUN PROGRESS";
		((TMP_Text)val2).fontSize = 24f;
		((Graphic)val2).color = AccentColor;
		((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
		((TMP_Text)val2).fontStyle = (FontStyles)1;
		LayoutElement val3 = val.AddComponent<LayoutElement>();
		val3.minHeight = 30f;
		val3.preferredHeight = 30f;
		val3.flexibleWidth = 1f;
	}

	private void CreateDivider(Transform parent)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("Divider");
		val.transform.SetParent(parent, false);
		Image val2 = val.AddComponent<Image>();
		((Graphic)val2).color = new Color(BorderColor.r, BorderColor.g, BorderColor.b, 0.35f);
		LayoutElement val3 = val.AddComponent<LayoutElement>();
		val3.minHeight = 2f;
		val3.preferredHeight = 2f;
		val3.flexibleWidth = 1f;
	}

	private TextMeshProUGUI CreateStatRow(Transform parent, string labelText, bool alt)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Expected O, but got Unknown
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Expected O, but got Unknown
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Expected O, but got Unknown
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("Row_" + labelText.Replace(" ", ""));
		val.transform.SetParent(parent, false);
		LayoutElement val2 = val.AddComponent<LayoutElement>();
		val2.minHeight = 34f;
		val2.preferredHeight = 34f;
		val2.flexibleWidth = 1f;
		HorizontalLayoutGroup val3 = val.AddComponent<HorizontalLayoutGroup>();
		((LayoutGroup)val3).padding = new RectOffset(12, 12, 4, 4);
		((LayoutGroup)val3).childAlignment = (TextAnchor)3;
		((HorizontalOrVerticalLayoutGroup)val3).spacing = 10f;
		((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = true;
		((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = false;
		((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = true;
		Image val4 = val.AddComponent<Image>();
		((Graphic)val4).color = (alt ? RowColorAlt : RowColor);
		GameObject val5 = new GameObject("Label");
		val5.transform.SetParent(val.transform, false);
		TextMeshProUGUI val6 = val5.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val6).text = labelText;
		((TMP_Text)val6).fontSize = 17f;
		((Graphic)val6).color = SubTextColor;
		((TMP_Text)val6).alignment = (TextAlignmentOptions)4097;
		LayoutElement val7 = val5.AddComponent<LayoutElement>();
		val7.flexibleWidth = 1f;
		GameObject val8 = new GameObject("Value");
		val8.transform.SetParent(val.transform, false);
		TextMeshProUGUI val9 = val8.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val9).text = "0";
		((TMP_Text)val9).fontSize = 17f;
		((Graphic)val9).color = Color.white;
		((TMP_Text)val9).alignment = (TextAlignmentOptions)4100;
		((TMP_Text)val9).fontStyle = (FontStyles)1;
		LayoutElement val10 = val8.AddComponent<LayoutElement>();
		val10.preferredWidth = 120f;
		val10.minWidth = 120f;
		val10.flexibleWidth = 0f;
		return val9;
	}

	private static void SetTextIfChanged(TextMeshProUGUI text, string value)
	{
		if (((TMP_Text)text).text != value)
		{
			((TMP_Text)text).text = value;
		}
	}

	private void RefreshValues()
	{
		SetTextIfChanged(damageText, "<color=#FFFFFF>" + RunProgressStats.FormatNumber(RunProgressStats.TotalDamage) + "</color>");
		SetTextIfChanged(damageTakenText, "<color=#8B0000>" + RunProgressStats.FormatNumber(RunProgressStats.TotalDamageTaken) + "</color>");
		SetTextIfChanged(healingText, "<color=#90EE90>" + RunProgressStats.FormatNumber(RunProgressStats.TotalHealing) + "</color>");
		SetTextIfChanged(maxSpeedText, $"<color=#00FFFF>{RunProgressStats.MaxSpeed:0.0} m/s</color>");
		string text = (RunProgressStats.BiggestHitCrit ? "FF0000" : "FFFFFF");
		SetTextIfChanged(biggestHitText, "<color=#" + text + ">" + RunProgressStats.FormatNumber(RunProgressStats.BiggestHit) + "</color>");
		SetTextIfChanged(chestsOpenedText, $"<color=#4A90E2>{RunProgressStats.ChestsOpened}</color>");
		SetTextIfChanged(goldCollectedText, "<color=#FFD700>" + RunProgressStats.FormatNumber(RunProgressStats.GoldCollected) + "</color>");
		SetTextIfChanged(dronesUsedText, $"<color=#006400>{RunProgressStats.DronesUsed}</color>");
		SetTextIfChanged(distanceRanText, "<color=#00FFFF>" + RunProgressStats.FormatDistance(RunProgressStats.TotalDistance) + "</color>");
	}
}
public enum StatAlignment
{
	Horizontal,
	Vertical
}
public enum StatTextAlign
{
	Center,
	Left
}
public static class RSSettings
{
	public static Dictionary<string, bool> StatVisibility = new Dictionary<string, bool>
	{
		{ "AttackSpeed", true },
		{ "Armor", true },
		{ "Crit", true },
		{ "Healing", true },
		{ "Damage", true },
		{ "Streak", true },
		{ "DamageTaken", true },
		{ "DamageTakenStreak", true },
		{ "Speed", true }
	};

	public static float StatFontSize = 27f;

	public static float StatSpacing = 40f;

	public static StatAlignment Alignment = StatAlignment.Horizontal;

	public static StatTextAlign TextAlign = StatTextAlign.Center;

	private static ConfigEntry<StatTextAlign> textAlignEntry;

	public static bool PanelVisible = true;

	public static KeyCode ToggleKey = (KeyCode)118;

	public static bool ShowThankYouMessage = true;

	private static ConfigFile config;

	private static Dictionary<string, ConfigEntry<bool>> visibilityEntries = new Dictionary<string, ConfigEntry<bool>>();

	private static ConfigEntry<float> fontSizeEntry;

	private static ConfigEntry<float> spacingEntry;

	private static ConfigEntry<StatAlignment> alignmentEntry;

	private static ConfigEntry<KeyCode> toggleKeyEntry;

	private static ConfigEntry<bool> showThankYouMessageEntry;

	public static event Action OnSettingsChanged;

	public static void Init(ConfigFile cfg)
	{
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		config = cfg;
		foreach (string item in new List<string>(StatVisibility.Keys))
		{
			ConfigEntry<bool> val = config.Bind<bool>("Stats Visibility", item, true, "Show or hide the " + item + " stat");
			visibilityEntries[item] = val;
			StatVisibility[item] = val.Value;
		}
		fontSizeEntry = config.Bind<float>("Appearance", "Font Size", 27f, "Text size of each stat");
		spacingEntry = config.Bind<float>("Appearance", "Spacing", 40f, "Spacing between stats");
		alignmentEntry = config.Bind<StatAlignment>("Appearance", "Alignment", StatAlignment.Horizontal, "Horizontal or vertical layout");
		textAlignEntry = config.Bind<StatTextAlign>("Appearance", "Text Alignment", StatTextAlign.Center, "Text alignment when using vertical layout");
		toggleKeyEntry = config.Bind<KeyCode>("General", "Toggle Key", (KeyCode)118, "Key used to show/hide the stats panel");
		showThankYouMessageEntry = config.Bind<bool>("General", "Show Thank You Message", true, "Whether to show the developer message in the settings panel");
		StatFontSize = fontSizeEntry.Value;
		StatSpacing = spacingEntry.Value;
		Alignment = alignmentEntry.Value;
		TextAlign = textAlignEntry.Value;
		ToggleKey = toggleKeyEntry.Value;
		ShowThankYouMessage = showThankYouMessageEntry.Value;
	}

	public static void SetVisibility(string key, bool value)
	{
		StatVisibility[key] = value;
		if (visibilityEntries.ContainsKey(key))
		{
			visibilityEntries[key].Value = value;
		}
		RSSettings.OnSettingsChanged?.Invoke();
	}

	public static void SetFontSize(float value)
	{
		StatFontSize = value;
		if (fontSizeEntry != null)
		{
			fontSizeEntry.Value = value;
		}
		RSSettings.OnSettingsChanged?.Invoke();
	}

	public static void SetSpacing(float value)
	{
		StatSpacing = value;
		if (spacingEntry != null)
		{
			spacingEntry.Value = value;
		}
		RSSettings.OnSettingsChanged?.Invoke();
	}

	public static void SetAlignment(StatAlignment value)
	{
		Alignment = value;
		if (alignmentEntry != null)
		{
			alignmentEntry.Value = value;
		}
		RSSettings.OnSettingsChanged?.Invoke();
	}

	public static void SetTextAlign(StatTextAlign value)
	{
		TextAlign = value;
		if (textAlignEntry != null)
		{
			textAlignEntry.Value = value;
		}
		RSSettings.OnSettingsChanged?.Invoke();
	}

	public static void TogglePanelVisible()
	{
		PanelVisible = !PanelVisible;
		RSSettings.OnSettingsChanged?.Invoke();
	}

	public static void DismissThankYouMessage()
	{
		ShowThankYouMessage = false;
		if (showThankYouMessageEntry != null)
		{
			showThankYouMessageEntry.Value = false;
		}
	}

	public static void ResetToDefault()
	{
		foreach (string item in new List<string>(StatVisibility.Keys))
		{
			StatVisibility[item] = true;
			if (visibilityEntries.ContainsKey(item))
			{
				visibilityEntries[item].Value = true;
			}
		}
		StatFontSize = 27f;
		if (fontSizeEntry != null)
		{
			fontSizeEntry.Value = 27f;
		}
		StatSpacing = 40f;
		if (spacingEntry != null)
		{
			spacingEntry.Value = 40f;
		}
		Alignment = StatAlignment.Horizontal;
		if (alignmentEntry != null)
		{
			alignmentEntry.Value = StatAlignment.Horizontal;
		}
		Alignment = StatAlignment.Horizontal;
		if (alignmentEntry != null)
		{
			alignmentEntry.Value = StatAlignment.Horizontal;
		}
		TextAlign = StatTextAlign.Center;
		if (textAlignEntry != null)
		{
			textAlignEntry.Value = StatTextAlign.Center;
		}
		RSPlusSettings.ResetToDefault();
		RSSettings.OnSettingsChanged?.Invoke();
	}
}
public static class RSPlusSettings
{
	public static Dictionary<string, bool> StatVisibility = new Dictionary<string, bool>
	{
		{ "Jumps", false },
		{ "MountainShrines", false },
		{ "Drones", false },
		{ "Luck", false },
		{ "Kills", false }
	};

	public static float StatFontSize = 27f;

	public static float StatSpacing = 40f;

	private static ConfigFile config;

	private static Dictionary<string, ConfigEntry<bool>> visibilityEntries = new Dictionary<string, ConfigEntry<bool>>();

	private static ConfigEntry<float> fontSizeEntry;

	private static ConfigEntry<float> spacingEntry;

	public static event Action OnSettingsChanged;

	public static void Init(ConfigFile cfg)
	{
		config = cfg;
		foreach (string item in new List<string>(StatVisibility.Keys))
		{
			ConfigEntry<bool> val = config.Bind<bool>("Plus Stats Visibility", item, false, "Show or hide the " + item + " stat (Risky Stats+)");
			visibilityEntries[item] = val;
			StatVisibility[item] = val.Value;
		}
		fontSizeEntry = config.Bind<float>("Plus Appearance", "Font Size", 27f, "Text size of each Risky Stats+ stat");
		spacingEntry = config.Bind<float>("Plus Appearance", "Spacing", 40f, "Spacing between Risky Stats+ stats");
		StatFontSize = fontSizeEntry.Value;
		StatSpacing = spacingEntry.Value;
	}

	public static void SetVisibility(string key, bool value)
	{
		StatVisibility[key] = value;
		if (visibilityEntries.ContainsKey(key))
		{
			visibilityEntries[key].Value = value;
		}
		RSPlusSettings.OnSettingsChanged?.Invoke();
	}

	public static void SetFontSize(float value)
	{
		StatFontSize = value;
		if (fontSizeEntry != null)
		{
			fontSizeEntry.Value = value;
		}
		RSPlusSettings.OnSettingsChanged?.Invoke();
	}

	public static void SetSpacing(float value)
	{
		StatSpacing = value;
		if (spacingEntry != null)
		{
			spacingEntry.Value = value;
		}
		RSPlusSettings.OnSettingsChanged?.Invoke();
	}

	public static void ResetToDefault()
	{
		foreach (string item in new List<string>(StatVisibility.Keys))
		{
			StatVisibility[item] = false;
			if (visibilityEntries.ContainsKey(item))
			{
				visibilityEntries[item].Value = false;
			}
		}
		StatFontSize = 27f;
		if (fontSizeEntry != null)
		{
			fontSizeEntry.Value = 27f;
		}
		StatSpacing = 40f;
		if (spacingEntry != null)
		{
			spacingEntry.Value = 40f;
		}
		RSPlusSettings.OnSettingsChanged?.Invoke();
	}
}
public class RSSettingsUI : MonoBehaviour
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static Func<HGButton, bool> <>9__27_0;

		public static Func<Transform, bool> <>9__27_2;

		public static UnityAction <>9__30_0;

		public static UnityAction <>9__35_0;

		public static UnityAction <>9__41_0;

		public static Action <>9__44_0;

		public static Action <>9__44_1;

		public static Action <>9__45_0;

		public static Action <>9__45_1;

		internal bool <CreateSettingsButton>b__27_0(HGButton b)
		{
			return ((Component)b).gameObject.activeInHierarchy;
		}

		internal bool <CreateSettingsButton>b__27_2(Transform t)
		{
			return ((Object)t).name.IndexOf("quit", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)t).name.IndexOf("exit", StringComparison.OrdinalIgnoreCase) >= 0;
		}

		internal void <BuildNavButton>b__30_0()
		{
			NavigateToggle();
			EventSystem.current.SetSelectedGameObject((GameObject)null);
		}

		internal void <BuildThankYouMessage>b__35_0()
		{
			RSSettings.DismissThankYouMessage();
			if ((Object)(object)thankYouMessageObject != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)thankYouMessageObject);
				thankYouMessageObject = null;
			}
			EventSystem.current.SetSelectedGameObject((GameObject)null);
		}

		internal void <CreateAlignmentRow>b__41_0()
		{
			StatAlignment alignment = ((RSSettings.Alignment == StatAlignment.Horizontal) ? StatAlignment.Vertical : StatAlignment.Horizontal);
			RSSettings.SetAlignment(alignment);
			if ((Object)(object)thankYouMessageObject != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)thankYouMessageObject);
				thankYouMessageObject = null;
			}
			Transform parent = panelObject.transform.parent;
			Object.DestroyImmediate((Object)(object)panelObject);
			BuildPanel(parent);
			SyncThankYouMessageVisibility();
		}

		internal void <CreateBottomButtonsRow>b__44_0()
		{
			RSSettings.ResetToDefault();
			if ((Object)(object)thankYouMessageObject != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)thankYouMessageObject);
				thankYouMessageObject = null;
			}
			Transform parent = panelObject.transform.parent;
			Object.DestroyImmediate((Object)(object)panelObject);
			BuildPanel(parent);
			if ((Object)(object)plusPanelObject != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)plusPanelObject);
				plusPanelObject = null;
			}
			UpdateNavButtonLabel();
			SyncThankYouMessageVisibility();
		}

		internal void <CreateBottomButtonsRow>b__44_1()
		{
			panelObject.SetActive(false);
			if ((Object)(object)navButtonObject != (Object)null)
			{
				navButtonObject.SetActive(false);
			}
			if ((Object)(object)backdropObject != (Object)null)
			{
				backdropObject.SetActive(false);
			}
			SyncThankYouMessageVisibility();
		}

		internal void <CreatePlusBottomButtonsRow>b__45_0()
		{
			RSSettings.ResetToDefault();
			if ((Object)(object)thankYouMessageObject != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)thankYouMessageObject);
				thankYouMessageObject = null;
			}
			Transform parent = panelObject.transform.parent;
			Object.DestroyImmediate((Object)(object)panelObject);
			BuildPanel(parent);
			Object.DestroyImmediate((Object)(object)plusPanelObject);
			plusPanelObject = null;
			UpdateNavButtonLabel();
			SyncThankYouMessageVisibility();
		}

		internal void <CreatePlusBottomButtonsRow>b__45_1()
		{
			plusPanelObject.SetActive(false);
			if ((Object)(object)navButtonObject != (Object)null)
			{
				navButtonObject.SetActive(false);
			}
			if ((Object)(object)backdropObject != (Object)null)
			{
				backdropObject.SetActive(false);
			}
			SyncThankYouMessageVisibility();
		}
	}

	private static GameObject panelObject;

	private static GameObject plusPanelObject;

	private static GameObject navButtonObject;

	private static GameObject backdropObject;

	private static GameObject thankYouMessageObject;

	private static Transform rootCanvasTransform;

	private static readonly Color BackgroundColor = new Color(0.05f, 0.07f, 0.18f, 0.97f);

	private static readonly Color BorderColor = new Color(1f, 0.82f, 0.2f, 1f);

	private static readonly Color RowColor = new Color(0.09f, 0.11f, 0.24f, 1f);

	private static readonly Color RowColorAlt = new Color(0.11f, 0.13f, 0.27f, 1f);

	private static readonly Color AccentColor = new Color(1f, 0.82f, 0.2f, 1f);

	private static readonly Color OffColor = new Color(0.3f, 0.3f, 0.35f, 1f);

	private static readonly Color DarkTextColor = new Color(0.05f, 0.07f, 0.18f, 1f);

	private static readonly Color SubTextColor = new Color(0.65f, 0.68f, 0.8f, 1f);

	private static readonly Color ThankYouBackgroundColor = new Color(0f, 0.1019f, 0.5098f, 0.97f);

	private static readonly Color ThankYouOutlineColor = new Color(0.53f, 0.81f, 1f, 1f);

	private static readonly Color ThankYouDismissColor = new Color(0.8f, 0.15f, 0.15f, 1f);

	private const float PanelWidth = 560f;

	private const float RowHeight = 32f;

	private const float RowSpacing = 6f;

	private static readonly string[] StatOrder = new string[9] { "AttackSpeed", "Armor", "Crit", "Healing", "Damage", "Streak", "DamageTaken", "DamageTakenStreak", "Speed" };

	private static readonly Dictionary<string, string> StatLabels = new Dictionary<string, string>
	{
		{ "AttackSpeed", "Attack Speed" },
		{ "Armor", "Armor" },
		{ "Crit", "Crit" },
		{ "Healing", "Healing" },
		{ "Damage", "Damage" },
		{ "Streak", "Streak" },
		{ "DamageTaken", "Damage Taken" },
		{ "DamageTakenStreak", "Damage Taken Streak" },
		{ "Speed", "Speed" }
	};

	private static readonly string[] PlusStatOrder = new string[5] { "Jumps", "MountainShrines", "Drones", "Luck", "Kills" };

	private static readonly Dictionary<string, string> PlusStatLabels = new Dictionary<string, string>
	{
		{ "Jumps", "Jumps" },
		{ "MountainShrines", "Mountain Shrines" },
		{ "Drones", "Drones" },
		{ "Luck", "Luck" },
		{ "Kills", "Kills" }
	};

	private static readonly Color ResetColor = new Color(0.4f, 0.4f, 0.45f, 1f);

	private void Awake()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		PauseScreenController.Awake += new hook_Awake(PauseScreenController_Awake);
	}

	private void OnDestroy()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		PauseScreenController.Awake -= new hook_Awake(PauseScreenController_Awake);
	}

	private void PauseScreenController_Awake(orig_Awake orig, PauseScreenController self)
	{
		orig.Invoke(self);
		Debug.Log((object)"[RiskyStats] PauseScreenController_Awake fired");
		CreateSettingsButton(self);
	}

	private void CreateSettingsButton(PauseScreenController self)
	{
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Expected O, but got Unknown
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: Expected O, but got Unknown
		HGButton[] componentsInChildren = ((Component)self).GetComponentsInChildren<HGButton>(true);
		Debug.Log((object)$"[RiskyStats] Found {componentsInChildren.Length} buttons");
		HGButton[] array = componentsInChildren;
		foreach (HGButton val in array)
		{
			string[] obj = new string[7]
			{
				"[RiskyStats] Button: ",
				((Object)((Component)val).gameObject).name,
				" | Parent: ",
				null,
				null,
				null,
				null
			};
			Transform parent = ((Component)val).transform.parent;
			obj[3] = ((parent != null) ? ((Object)parent).name : null);
			obj[4] = " | ";
			obj[5] = $"Sibling: {((Component)val).transform.GetSiblingIndex()} | ";
			obj[6] = $"Active: {((Component)val).gameObject.activeInHierarchy}";
			Debug.Log((object)string.Concat(obj));
		}
		HGButton val2 = ((IEnumerable<HGButton>)componentsInChildren).FirstOrDefault((Func<HGButton, bool>)((HGButton b) => ((Component)b).gameObject.activeInHierarchy));
		if ((Object)(object)val2 == (Object)null)
		{
			return;
		}
		Transform parent2 = ((Component)val2).transform.parent;
		GameObject val3 = Object.Instantiate<GameObject>(((Component)val2).gameObject, parent2);
		((Object)val3).name = "RiskyStatsSettingsButton";
		HGButton component = val3.GetComponent<HGButton>();
		((Button)component).onClick = new ButtonClickedEvent();
		TextMeshProUGUI componentInChildren = val3.GetComponentInChildren<TextMeshProUGUI>();
		if ((Object)(object)componentInChildren != (Object)null)
		{
			((TMP_Text)componentInChildren).text = "Risky Stats";
			LanguageTextMeshController component2 = ((Component)componentInChildren).GetComponent<LanguageTextMeshController>();
			if ((Object)(object)component2 != (Object)null)
			{
				Object.Destroy((Object)(object)component2);
			}
			LanguageTextMeshController component3 = val3.GetComponent<LanguageTextMeshController>();
			if ((Object)(object)component3 != (Object)null)
			{
				Object.Destroy((Object)(object)component3);
			}
		}
		Canvas componentInParent = ((Component)self).GetComponentInParent<Canvas>();
		Transform canvasTransform = (((Object)(object)componentInParent != (Object)null) ? ((Component)componentInParent).transform : ((Component)self).transform);
		((UnityEvent)((Button)component).onClick).AddListener((UnityAction)delegate
		{
			TogglePanel(canvasTransform);
			EventSystem.current.SetSelectedGameObject((GameObject)null);
		});
		Debug.Log((object)"========== CHILD ORDER ==========");
		for (int num = 0; num < parent2.childCount; num++)
		{
			Debug.Log((object)$"{num}: {((Object)parent2.GetChild(num)).name}");
		}
		Transform val4 = ((IEnumerable)parent2).Cast<Transform>().FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name.IndexOf("quit", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)t).name.IndexOf("exit", StringComparison.OrdinalIgnoreCase) >= 0));
		if ((Object)(object)val4 != (Object)null)
		{
			Debug.Log((object)("[RiskyStats] Found quit button: " + ((Object)val4).name));
			val3.transform.SetSiblingIndex(val4.GetSiblingIndex());
			Debug.Log((object)$"[RiskyStats] Inserted at index {val3.transform.GetSiblingIndex()}");
		}
		else
		{
			Debug.LogWarning((object)"[RiskyStats] Could not find Quit/Exit button, putting at end.");
			val3.transform.SetAsLastSibling();
		}
	}

	private static void TogglePanel(Transform canvasTransform)
	{
		rootCanvasTransform = canvasTransform;
		if ((Object)(object)panelObject == (Object)null)
		{
			BuildBackdrop(canvasTransform);
			BuildPanel(canvasTransform);
			BuildNavButton(canvasTransform);
		}
		else if (!panelObject.activeSelf && ((Object)(object)plusPanelObject == (Object)null || !plusPanelObject.activeSelf))
		{
			if ((Object)(object)backdropObject != (Object)null)
			{
				backdropObject.SetActive(true);
			}
			panelObject.SetActive(true);
			if ((Object)(object)plusPanelObject != (Object)null)
			{
				plusPanelObject.SetActive(false);
			}
			if ((Object)(object)navButtonObject != (Object)null)
			{
				navButtonObject.SetActive(true);
			}
			UpdateNavButtonLabel();
			SyncThankYouMessageVisibility();
		}
		else
		{
			if ((Object)(object)backdropObject != (Object)null)
			{
				backdropObject.SetActive(false);
			}
			panelObject.SetActive(false);
			if ((Object)(object)plusPanelObject != (Object)null)
			{
				plusPanelObject.SetActive(false);
			}
			if ((Object)(object)navButtonObject != (Object)null)
			{
				navButtonObject.SetActive(false);
			}
			SyncThankYouMessageVisibility();
		}
	}

	private static void BuildBackdrop(Transform parent)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		backdropObject = new GameObject("RiskyStatsBackdrop");
		backdropObject.transform.SetParent(parent, false);
		RectTransform val = backdropObject.AddComponent<RectTransform>();
		val.anchorMin = Vector2.zero;
		val.anchorMax = Vector2.one;
		val.offsetMin = Vector2.zero;
		val.offsetMax = Vector2.zero;
		Image val2 = backdropObject.AddComponent<Image>();
		((Graphic)val2).color = new Color(0f, 0f, 0f, 0.75f);
		((Graphic)val2).raycastTarget = true;
	}

	private static void BuildNavButton(Transform parent)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: 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_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: 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)
		//IL_00d0: Expected O, but got Unknown
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Expected O, but got Unknown
		navButtonObject = new GameObject("RiskyStatsNavButton");
		navButtonObject.transform.SetParent(parent, false);
		RectTransform val = navButtonObject.AddComponent<RectTransform>();
		val.anchorMin = new Vector2(1f, 0f);
		val.anchorMax = new Vector2(1f, 0f);
		val.pivot = new Vector2(1f, 0f);
		val.anchoredPosition = new Vector2(-40f, 40f);
		val.sizeDelta = new Vector2(140f, 36f);
		Image val2 = navButtonObject.AddComponent<Image>();
		((Graphic)val2).color = AccentColor;
		Button val3 = navButtonObject.AddComponent<Button>();
		((Selectable)val3).targetGraphic = (Graphic)(object)val2;
		GameObject val4 = new GameObject("Label");
		val4.transform.SetParent(navButtonObject.transform, false);
		RectTransform val5 = val4.AddComponent<RectTransform>();
		val5.anchorMin = Vector2.zero;
		val5.anchorMax = Vector2.one;
		val5.offsetMin = Vector2.zero;
		val5.offsetMax = Vector2.zero;
		TextMeshProUGUI val6 = val4.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val6).text = "Next";
		((TMP_Text)val6).alignment = (TextAlignmentOptions)514;
		((Graphic)val6).color = DarkTextColor;
		((TMP_Text)val6).fontStyle = (FontStyles)1;
		((TMP_Text)val6).fontSize = 16f;
		ButtonClickedEvent onClick = val3.onClick;
		object obj = <>c.<>9__30_0;
		if (obj == null)
		{
			UnityAction val7 = delegate
			{
				NavigateToggle();
				EventSystem.current.SetSelectedGameObject((GameObject)null);
			};
			<>c.<>9__30_0 = val7;
			obj = (object)val7;
		}
		((UnityEvent)onClick).AddListener((UnityAction)obj);
	}

	private static void NavigateToggle()
	{
		if ((Object)(object)plusPanelObject == (Object)null)
		{
			BuildPlusPanel(rootCanvasTransform);
		}
		bool activeSelf = panelObject.activeSelf;
		panelObject.SetActive(!activeSelf);
		plusPanelObject.SetActive(activeSelf);
		UpdateNavButtonLabel();
		SyncThankYouMessageVisibility();
	}

	private static void UpdateNavButtonLabel()
	{
		if (!((Object)(object)navButtonObject == (Object)null))
		{
			TextMeshProUGUI componentInChildren = navButtonObject.GetComponentInChildren<TextMeshProUGUI>();
			if (!((Object)(object)componentInChildren == (Object)null))
			{
				bool flag = (Object)(object)plusPanelObject != (Object)null && plusPanelObject.activeSelf;
				((TMP_Text)componentInChildren).text = (flag ? "Back" : "Next");
			}
		}
	}

	private static void SyncThankYouMessageVisibility()
	{
		if ((Object)(object)thankYouMessageObject != (Object)null)
		{
			thankYouMessageObject.SetActive((Object)(object)panelObject != (Object)null && panelObject.activeSelf);
		}
	}

	private static void BuildPanel(Transform parent)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: 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_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: 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)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Expected O, but got Unknown
		panelObject = new GameObject("RiskyStatsSettingsPanel");
		panelObject.transform.SetParent(parent, false);
		RectTransform val = panelObject.AddComponent<RectTransform>();
		val.anchorMin = new Vector2(0.5f, 0.5f);
		val.anchorMax = new Vector2(0.5f, 0.5f);
		val.pivot = new Vector2(0.5f, 0.5f);
		val.anchoredPosition = Vector2.zero;
		val.sizeDelta = new Vector2(560f, 100f);
		Image val2 = panelObject.AddComponent<Image>();
		((Graphic)val2).color = BackgroundColor;
		Outline val3 = panelObject.AddComponent<Outline>();
		((Shadow)val3).effectColor = BorderColor;
		((Shadow)val3).effectDistance = new Vector2(2f, -2f);
		VerticalLayoutGroup val4 = panelObject.AddComponent<VerticalLayoutGroup>();
		((LayoutGroup)val4).padding = new RectOffset(18, 18, 18, 18);
		((HorizontalOrVerticalLayoutGroup)val4).spacing = 6f;
		((LayoutGroup)val4).childAlignment = (TextAnchor)1;
		((HorizontalOrVerticalLayoutGroup)val4).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)val4).childControlHeight = true;
		((HorizontalOrVerticalLayoutGroup)val4).childForceExpandWidth = false;
		((HorizontalOrVerticalLayoutGroup)val4).childForceExpandHeight = false;
		ContentSizeFitter val5 = panelObject.AddComponent<ContentSizeFitter>();
		val5.horizontalFit = (FitMode)0;
		val5.verticalFit = (FitMode)2;
		CreateTitle(panelObject.transform, "RISKY STATS SETTINGS");
		CreateDivider(panelObject.transform);
		bool flag = false;
		string[] statOrder = StatOrder;
		foreach (string key in statOrder)
		{
			bool startValue = RSSettings.StatVisibility.ContainsKey(key) && RSSettings.StatVisibility[key];
			CreateToggleRow(panelObject.transform, key, StatLabels[key], flag, startValue, delegate(bool value)
			{
				RSSettings.SetVisibility(key, value);
			});
			flag = !flag;
		}
		CreateDivider(panelObject.transform);
		CreateSliderRow(panelObject.transform, "Size", 14f, 48f, RSSettings.StatFontSize, RSSettings.SetFontSize);
		CreateSliderRow(panelObject.transform, "Spacing", 5f, 100f, RSSettings.StatSpacing, RSSettings.SetSpacing);
		CreateAlignmentRow(panelObject.transform);
		if (RSSettings.Alignment == StatAlignment.Vertical)
		{
			CreateTextAlignRow(panelObject.transform);
		}
		CreateBottomButtonsRow(panelObject.transform);
		if (RSSettings.ShowThankYouMessage)
		{
			BuildThankYouMessage(parent);
		}
	}

	private static void BuildThankYouMessage(Transform parent)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: 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_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Expected O, but got Unknown
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Expected O, but got Unknown
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Expected O, but got Unknown
		//IL_0256: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Expected O, but got Unknown
		//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0333: Unknown result type (might be due to invalid IL or missing references)
		//IL_0338: Unknown result type (might be due to invalid IL or missing references)
		//IL_033e: Expected O, but got Unknown
		thankYouMessageObject = new GameObject("RiskyStatsThankYouMessage");
		thankYouMessageObject.transform.SetParent(parent, false);
		RectTransform val = thankYouMessageObject.AddComponent<RectTransform>();
		val.anchorMin = new Vector2(0f, 0.5f);
		val.anchorMax = new Vector2(0f, 0.5f);
		val.pivot = new Vector2(0f, 0.5f);
		val.anchoredPosition = new Vector2(60f, 0f);
		val.sizeDelta = new Vector2(380f, 10f);
		Image val2 = thankYouMessageObject.AddComponent<Image>();
		((Graphic)val2).color = ThankYouBackgroundColor;
		Outline val3 = thankYouMessageObject.AddComponent<Outline>();
		((Shadow)val3).effectColor = ThankYouOutlineColor;
		((Shadow)val3).effectDistance = new Vector2(2f, -2f);
		VerticalLayoutGroup val4 = thankYouMessageObject.AddComponent<VerticalLayoutGroup>();
		((LayoutGroup)val4).padding = new RectOffset(16, 16, 16, 16);
		((HorizontalOrVerticalLayoutGroup)val4).spacing = 10f;
		((LayoutGroup)val4).childAlignment = (TextAnchor)0;
		((HorizontalOrVerticalLayoutGroup)val4).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)val4).childControlHeight = true;
		((HorizontalOrVerticalLayoutGroup)val4).childForceExpandWidth = false;
		((HorizontalOrVerticalLayoutGroup)val4).childForceExpandHeight = false;
		ContentSizeFitter val5 = thankYouMessageObject.AddComponent<ContentSizeFitter>();
		val5.horizontalFit = (FitMode)0;
		val5.verticalFit = (FitMode)2;
		GameObject val6 = new GameObject("MessageText");
		val6.transform.SetParent(thankYouMessageObject.transform, false);
		TextMeshProUGUI val7 = val6.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val7).text = "Dear User,\n\nThis mod was originally a random personal project made just for fun. When I decided to publish it, I never expected it to reach more than a few downloads, let alone 1,000+ downloads.\nI am honored that you took the time to download and use this passion project. Thank you for being part of the journey.\n\n- A Software Engineer";
		((TMP_Text)val7).fontSize = 15f;
		((Graphic)val7).color = Color.white;
		((TMP_Text)val7).alignment = (TextAlignmentOptions)257;
		((TMP_Text)val7).enableWordWrapping = true;
		LayoutElement val8 = val6.AddComponent<LayoutElement>();
		val8.preferredWidth = 348f;
		val8.flexibleWidth = 0f;
		GameObject val9 = new GameObject("DismissButton");
		val9.transform.SetParent(thankYouMessageObject.transform, false);
		LayoutElement val10 = val9.AddComponent<LayoutElement>();
		val10.preferredHeight = 30f;
		val10.minHeight = 30f;
		val10.preferredWidth = 100f;
		val10.minWidth = 100f;
		val10.flexibleWidth = 0f;
		Image val11 = val9.AddComponent<Image>();
		((Graphic)val11).color = ThankYouDismissColor;
		Button val12 = val9.AddComponent<Button>();
		((Selectable)val12).targetGraphic = (Graphic)(object)val11;
		GameObject val13 = new GameObject("Label");
		val13.transform.SetParent(val9.transform, false);
		RectTransform val14 = val13.AddComponent<RectTransform>();
		val14.anchorMin = Vector2.zero;
		val14.anchorMax = Vector2.one;
		val14.offsetMin = Vector2.zero;
		val14.offsetMax = Vector2.zero;
		TextMeshProUGUI val15 = val13.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val15).text = "Dismiss";
		((TMP_Text)val15).alignment = (TextAlignmentOptions)514;
		((Graphic)val15).color = Color.white;
		((TMP_Text)val15).fontStyle = (FontStyles)1;
		((TMP_Text)val15).fontSize = 15f;
		ButtonClickedEvent onClick = val12.onClick;
		object obj = <>c.<>9__35_0;
		if (obj == null)
		{
			UnityAction val16 = delegate
			{
				RSSettings.DismissThankYouMessage();
				if ((Object)(object)thankYouMessageObject != (Object)null)
				{
					Object.DestroyImmediate((Object)(object)thankYouMessageObject);
					thankYouMessageObject = null;
				}
				EventSystem.current.SetSelectedGameObject((GameObject)null);
			};
			<>c.<>9__35_0 = val16;
			obj = (object)val16;
		}
		((UnityEvent)onClick).AddListener((UnityAction)obj);
	}

	private static void BuildPlusPanel(Transform parent)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: 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_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: 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)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Expected O, but got Unknown
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		//IL_0289: Expected O, but got Unknown
		plusPanelObject = new GameObject("RiskyStatsPlusSettingsPanel");
		plusPanelObject.transform.SetParent(parent, false);
		RectTransform val = plusPanelObject.AddComponent<RectTransform>();
		val.anchorMin = new Vector2(0.5f, 0.5f);
		val.anchorMax = new Vector2(0.5f, 0.5f);
		val.pivot = new Vector2(0.5f, 0.5f);
		val.anchoredPosition = Vector2.zero;
		val.sizeDelta = new Vector2(560f, 100f);
		Image val2 = plusPanelObject.AddComponent<Image>();
		((Graphic)val2).color = BackgroundColor;
		Outline val3 = plusPanelObject.AddComponent<Outline>();
		((Shadow)val3).effectColor = BorderColor;
		((Shadow)val3).effectDistance = new Vector2(2f, -2f);
		VerticalLayoutGroup val4 = plusPanelObject.AddComponent<VerticalLayoutGroup>();
		((LayoutGroup)val4).padding = new RectOffset(18, 18, 18, 18);
		((HorizontalOrVerticalLayoutGroup)val4).spacing = 6f;
		((LayoutGroup)val4).childAlignment = (TextAnchor)1;
		((HorizontalOrVerticalLayoutGroup)val4).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)val4).childControlHeight = true;
		((HorizontalOrVerticalLayoutGroup)val4).childForceExpandWidth = false;
		((HorizontalOrVerticalLayoutGroup)val4).childForceExpandHeight = false;
		ContentSizeFitter val5 = plusPanelObject.AddComponent<ContentSizeFitter>();
		val5.horizontalFit = (FitMode)0;
		val5.verticalFit = (FitMode)2;
		CreateTitle(plusPanelObject.transform, "RISKY STATS+ SETTINGS");
		CreateDivider(plusPanelObject.transform);
		bool flag = false;
		string[] plusStatOrder = PlusStatOrder;
		foreach (string key in plusStatOrder)
		{
			bool startValue = RSPlusSettings.StatVisibility.ContainsKey(key) && RSPlusSettings.StatVisibility[key];
			CreateToggleRow(plusPanelObject.transform, key, PlusStatLabels[key], flag, startValue, delegate(bool value)
			{
				RSPlusSettings.SetVisibility(key, value);
			});
			flag = !flag;
		}
		CreateDivider(plusPanelObject.transform);
		CreateSliderRow(plusPanelObject.transform, "Size", 14f, 48f, RSPlusSettings.StatFontSize, RSPlusSettings.SetFontSize);
		CreateSliderRow(plusPanelObject.transform, "Spacing", 5f, 100f, RSPlusSettings.StatSpacing, RSPlusSettings.SetSpacing);
		GameObject val6 = new GameObject("BottomSpacer");
		val6.transform.SetParent(plusPanelObject.transform, false);
		LayoutElement val7 = val6.AddComponent<LayoutElement>();
		val7.minHeight = 70f;
		val7.preferredHeight = 70f;
		val7.flexibleWidth = 1f;
		CreatePlusBottomButtonsRow(plusPanelObject.transform);
		plusPanelObject.SetActive(false);
	}

	private static void CreateTitle(Transform parent, string titleText)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("Title");
		val.transform.SetParent(parent, false);
		TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val2).text = titleText;
		((TMP_Text)val2).fontSize = 24f;
		((Graphic)val2).color = AccentColor;
		((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
		((TMP_Text)val2).fontStyle = (FontStyles)1;
		LayoutElement val3 = val.AddComponent<LayoutElement>();
		val3.minHeight = 30f;
		val3.preferredHeight = 30f;
		val3.flexibleWidth = 1f;
	}

	private static void CreateDivider(Transform parent)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("Divider");
		val.transform.SetParent(parent, false);
		Image val2 = val.AddComponent<Image>();
		((Graphic)val2).color = new Color(BorderColor.r, BorderColor.g, BorderColor.b, 0.35f);
		LayoutElement val3 = val.AddComponent<LayoutElement>();
		val3.minHeight = 2f;
		val3.preferredHeight = 2f;
		val3.flexibleWidth = 1f;
	}

	private static void CreateToggleRow(Transform parent, string key, string labelText, bool alt, bool startValue, Action<bool> onChanged)
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Expected O, but got Unknown
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: 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)
		//IL_00d1: Expected O, but got Unknown
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Expected O, but got Unknown
		//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("Row_" + key);
		val.transform.SetParent(parent, false);
		LayoutElement val2 = val.AddComponent<LayoutElement>();
		val2.minHeight = 32f;
		val2.preferredHeight = 32f;
		val2.flexibleWidth = 1f;
		HorizontalLayoutGroup val3 = val.AddComponent<HorizontalLayoutGroup>();
		((LayoutGroup)val3).padding = new RectOffset(12, 12, 4, 4);
		((LayoutGroup)val3).childAlignment = (TextAnchor)3;
		((HorizontalOrVerticalLayoutGroup)val3).spacing = 10f;
		((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = true;
		((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = false;
		((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = true;
		Image val4 = val.AddComponent<Image>();
		((Graphic)val4).color = (alt ? RowColorAlt : RowColor);
		GameObject val5 = new GameObject("Label");
		val5.transform.SetParent(val.transform, false);
		TextMeshProUGUI val6 = val5.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val6).text = labelText;
		((TMP_Text)val6).fontSize = 17f;
		((Graphic)val6).color = Color.white;
		((TMP_Text)val6).alignment = (TextAlignmentOptions)4097;
		LayoutElement val7 = val5.AddComponent<LayoutElement>();
		val7.flexibleWidth = 1f;
		GameObject val8 = new GameObject("Toggle");
		val8.transform.SetParent(val.transform, false);
		val8.AddComponent<RectTransform>();
		LayoutElement val9 = val8.AddComponent<LayoutElement>();
		val9.preferredWidth = 46f;
		val9.minWidth = 46f;
		val9.preferredHeight = 22f;
		val9.minHeight = 22f;
		val9.flexibleWidth = 0f;
		Image toggleBg = val8.AddComponent<Image>();
		((Graphic)toggleBg).color = (startValue ? AccentColor : OffColor);
		Toggle val10 = val8.AddComponent<Toggle>();
		((Selectable)val10).targetGraphic = (Graphic)(object)toggleBg;
		val10.isOn = startValue;
		((UnityEvent<bool>)(object)val10.onValueChanged).AddListener((UnityAction<bool>)delegate(bool value)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)toggleBg).color = (value ? AccentColor : OffColor);
			onChanged(value);
		});
	}

	private static void CreateSliderRow(Transform parent, string labelText, float min, float max, float startValue, Action<float> onChanged)
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Expected O, but got Unknown
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Expected O, but got Unknown
		//IL_0104: 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_014f: Expected O, but got Unknown
		//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Expected O, but got Unknown
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0219: Unknown result type (might be due to invalid IL or missing references)
		//IL_022f: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0246: Expected O, but got Unknown
		//IL_0270: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: Unknown result type (might be due to invalid IL or missing references)
		//IL_029e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: Expected O, but got Unknown
		//IL_02f6: 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_0324: Unknown result type (might be due to invalid IL or missing references)
		//IL_033a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0354: Unknown result type (might be due to invalid IL or missing references)
		//IL_035b: Expected O, but got Unknown
		//IL_037b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0388: Unknown result type (might be due to invalid IL or missing references)
		//IL_0395: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b9: Expected O, but got Unknown
		//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("SliderRow_" + labelText);
		val.transform.SetParent(parent, false);
		LayoutElement val2 = val.AddComponent<LayoutElement>();
		val2.minHeight = 44f;
		val2.preferredHeight = 44f;
		val2.flexibleWidth = 1f;
		VerticalLayoutGroup val3 = val.AddComponent<VerticalLayoutGroup>();
		((HorizontalOrVerticalLayoutGroup)val3).spacing = 4f;
		((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = true;
		((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = false;
		GameObject val4 = new GameObject("Label");
		val4.transform.SetParent(val.transform, false);
		TextMeshProUGUI label = val4.AddComponent<TextMeshProUGUI>();
		((TMP_Text)label).text = labelText + ": " + startValue.ToString("0");
		((TMP_Text)label).fontSize = 15f;
		((Graphic)label).color = SubTextColor;
		((TMP_Text)label).alignment = (TextAlignmentOptions)4097;
		LayoutElement val5 = val4.AddComponent<LayoutElement>();
		val5.minHeight = 18f;
		val5.preferredHeight = 18f;
		GameObject val6 = new GameObject("Slider");
		val6.transform.SetParent(val.transform, false);
		LayoutElement val7 = val6.AddComponent<LayoutElement>();
		val7.minHeight = 20f;
		val7.preferredHeight = 20f;
		val6.AddComponent<RectTransform>();
		Slider val8 = val6.AddComponent<Slider>();
		val8.minValue = min;
		val8.maxValue = max;
		val8.direction = (Direction)0;
		GameObject val9 = new GameObject("Background");
		val9.transform.SetParent(val6.transform, false);
		RectTransform val10 = val9.AddComponent<RectTransform>();
		val10.anchorMin = new Vector2(0f, 0.25f);
		val10.anchorMax = new Vector2(1f, 0.75f);
		val10.offsetMin = Vector2.zero;
		val10.offsetMax = Vector2.zero;
		Image val11 = val9.AddComponent<Image>();
		((Graphic)val11).color = RowColor;
		GameObject val12 = new GameObject("Fill Area");
		val12.transform.SetParent(val6.transform, false);
		RectTransform val13 = val12.AddComponent<RectTransform>();
		val13.anchorMin = new Vector2(0f, 0.25f);
		val13.anchorMax = new Vector2(1f, 0.75f);
		val13.offsetMin = new Vector2(5f, 0f);
		val13.offsetMax = new Vector2(-5f, 0f);
		GameObject val14 = new GameObject("Fill");
		val14.transform.SetParent(val12.transform, false);
		RectTransform val15 = val14.AddComponent<RectTransform>();
		val15.anchorMin = new Vector2(0f, 0f);
		val15.anchorMax = new Vector2(0f, 1f);
		val15.sizeDelta = new Vector2(10f, 0f);
		Image val16 = val14.AddComponent<Image>();
		((Graphic)val16).color = AccentColor;
		val8.fillRect = val15;
		GameObject val17 = new GameObject("Handle Slide Area");
		val17.transform.SetParent(val6.transform, false);
		RectTransform val18 = val17.AddComponent<RectTransform>();
		val18.anchorMin = Vector2.zero;
		val18.anchorMax = Vector2.one;
		val18.offsetMin = Vector2.zero;
		val18.offsetMax = Vector2.zero;
		GameObject val19 = new GameObject("Handle");
		val19.transform.SetParent(val17.transform, false);
		RectTransform val20 = val19.AddComponent<RectTransform>();
		val20.sizeDelta = new Vector2(14f, 22f);
		Image val21 = val19.AddComponent<Image>();
		((Graphic)val21).color = Color.white;
		val8.handleRect = val20;
		((Selectable)val8).targetGraphic = (Graphic)(object)val21;
		val8.value = startValue;
		((UnityEvent<float>)(object)val8.onValueChanged).AddListener((UnityAction<float>)delegate(float value)
		{
			((TMP_Text)label).text = labelText + ": " + value.ToString("0");
			onChanged(value);
		});
	}

	private static void CreateAlignmentRow(Transform parent)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Expected O, but got Unknown
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Expected O, but got Unknown
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Expected O, but got Unknown
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Expected O, but got Unknown
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: Unknown result type (might be due to invalid IL or missing references)
		//IL_028b: Expected O, but got Unknown
		GameObject val = new GameObject("AlignmentRow");
		val.transform.SetParent(parent, false);
		LayoutElement val2 = val.AddComponent<LayoutElement>();
		val2.minHeight = 36f;
		val2.preferredHeight = 36f;
		val2.flexibleWidth = 1f;
		HorizontalLayoutGroup val3 = val.AddComponent<HorizontalLayoutGroup>();
		((LayoutGroup)val3).padding = new RectOffset(12, 12, 4, 4);
		((LayoutGroup)val3).childAlignment = (TextAnchor)3;
		((HorizontalOrVerticalLayoutGroup)val3).spacing = 10f;
		((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = true;
		((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = false;
		((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = true;
		Image val4 = val.AddComponent<Image>();
		((Graphic)val4).color = RowColor;
		GameObject val5 = new GameObject("Label");
		val5.transform.SetParent(val.transform, false);
		TextMeshProUGUI val6 = val5.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val6).text = "Alignment";
		((TMP_Text)val6).fontSize = 17f;
		((Graphic)val6).color = Color.white;
		((TMP_Text)val6).alignment = (TextAlignmentOptions)4097;
		LayoutElement val7 = val5.AddComponent<LayoutElement>();
		val7.flexibleWidth = 1f;
		GameObject val8 = new GameObject("AlignmentButton");
		val8.transform.SetParent(val.transform, false);
		val8.AddComponent<RectTransform>();
		LayoutElement val9 = val8.AddComponent<LayoutElement>();
		val9.preferredWidth = 130f;
		val9.minWidth = 130f;
		val9.preferredHeight = 26f;
		val9.minHeight = 26f;
		val9.flexibleWidth = 0f;
		Image val10 = val8.AddComponent<Image>();
		((Graphic)val10).color = AccentColor;
		Button val11 = val8.AddComponent<Button>();
		((Selectable)val11).targetGraphic = (Graphic)(object)val10;
		GameObject val12 = new GameObject("Label");
		val12.transform.SetParent(val8.transform, false);
		RectTransform val13 = val12.AddComponent<RectTransform>();
		val13.anchorMin = Vector2.zero;
		val13.anchorMax = Vector2.one;
		val13.offsetMin = Vector2.zero;
		val13.offsetMax = Vector2.zero;
		TextMeshProUGUI val14 = val12.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val14).alignment = (TextAlignmentOptions)514;
		((Graphic)val14).color = DarkTextColor;
		((TMP_Text)val14).fontSize = 15f;
		((TMP_Text)val14).fontStyle = (FontStyles)1;
		((TMP_Text)val14).text = ((RSSettings.Alignment == StatAlignment.Horizontal) ? "Horizontal" : "Vertical");
		ButtonClickedEvent onClick = val11.onClick;
		object obj = <>c.<>9__41_0;
		if (obj == null)
		{
			UnityAction val15 = delegate
			{
				StatAlignment alignment = ((RSSettings.Alignment == StatAlignment.Horizontal) ? StatAlignment.Vertical : StatAlignment.Horizontal);
				RSSettings.SetAlignment(alignment);
				if ((Object)(object)thankYouMessageObject != (Object)null)
				{
					Object.DestroyImmediate((Object)(object)thankYouMessageObject);
					thankYouMessageObject = null;
				}
				Transform parent2 = panelObject.transform.parent;
				Object.DestroyImmediate((Object)(object)panelObject);
				BuildPanel(parent2);
				SyncThankYouMessageVisibility();
			};
			<>c.<>9__41_0 = val15;
			obj = (object)val15;
		}
		((UnityEvent)onClick).AddListener((UnityAction)obj);
	}

	private static void CreateTextAlignRow(Transform parent)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Expected O, but got Unknown
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Expected O, but got Unknown
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Expected O, but got Unknown
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Expected O, but got Unknown
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_020e: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: Expected O, but got Unknown
		GameObject val = new GameObject("TextAlignRow");
		val.transform.SetParent(parent, false);
		LayoutElement val2 = val.AddComponent<LayoutElement>();
		val2.minHeight = 36f;
		val2.preferredHeight = 36f;
		val2.flexibleWidth = 1f;
		HorizontalLayoutGroup val3 = val.AddComponent<HorizontalLayoutGroup>();
		((LayoutGroup)val3).padding = new RectOffset(12, 12, 4, 4);
		((LayoutGroup)val3).childAlignment = (TextAnchor)3;
		((HorizontalOrVerticalLayoutGroup)val3).spacing = 10f;
		((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = true;
		((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = false;
		((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = true;
		Image val4 = val.AddComponent<Image>();
		((Graphic)val4).color = RowColor;
		GameObject val5 = new GameObject("Label");
		val5.transform.SetParent(val.transform, false);
		TextMeshProUGUI val6 = val5.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val6).text = "Text Align";
		((TMP_Text)val6).fontSize = 17f;
		((Graphic)val6).color = Color.white;
		((TMP_Text)val6).alignment = (TextAlignmentOptions)4097;
		LayoutElement val7 = val5.AddComponent<LayoutElement>();
		val7.flexibleWidth = 1f;
		GameObject val8 = new GameObject("TextAlignButton");
		val8.transform.SetParent(val.transform, false);
		val8.AddComponent<RectTransform>();
		LayoutElement val9 = val8.AddComponent<LayoutElement>();
		val9.preferredWidth = 130f;
		val9.minWidth = 130f;
		val9.preferredHeight = 26f;
		val9.minHeight = 26f;
		val9.flexibleWidth = 0f;
		Image val10 = val8.AddComponent<Image>();
		((Graphic)val10).color = AccentColor;
		Button val11 = val8.AddComponent<Button>();
		((Selectable)val11).targetGraphic = (Graphic)(object)val10;
		GameObject val12 = new GameObject("Label");
		val12.transform.SetParent(val8.transform, false);
		RectTransform val13 = val12.AddComponent<RectTransform>();
		val13.anchorMin = Vector2.zero;
		val13.anchorMax = Vector2.one;
		val13.offsetMin = Vector2.zero;
		val13.offsetMax = Vector2.zero;
		TextMeshProUGUI buttonLabel = val12.AddComponent<TextMeshProUGUI>();
		((TMP_Text)buttonLabel).alignment = (TextAlignmentOptions)514;
		((Graphic)buttonLabel).color = DarkTextColor;
		((TMP_Text)buttonLabel).fontSize = 15f;
		((TMP_Text)buttonLabel).fontStyle = (FontStyles)1;
		((TMP_Text)buttonLabel).text = ((RSSettings.TextAlign == StatTextAlign.Center) ? "Center" : "Left");
		((UnityEvent)val11.onClick).AddListener((UnityAction)delegate
		{
			StatTextAlign statTextAlign = ((RSSettings.TextAlign == StatTextAlign.Center) ? StatTextAlign.Left : StatTextAlign.Center);
			RSSettings.SetTextAlign(statTextAlign);
			((TMP_Text)buttonLabel).text = ((statTextAlign == StatTextAlign.Center) ? "Center" : "Left");
		});
	}

	private static void CreateBottomButtonsRow(Transform parent)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		GameObject val = new GameObject("BottomButtonsWrapper");
		val.transform.SetParent(parent, false);
		LayoutElement val2 = val.AddComponent<LayoutElement>();
		val2.minHeight = 40f;
		val2.preferredHeight = 40f;
		val2.flexibleWidth = 1f;
		HorizontalLayoutGroup val3 = val.AddComponent<HorizontalLayoutGroup>();
		((HorizontalOrVerticalLayoutGroup)val3).spacing = 12f;
		((LayoutGroup)val3).childAlignment = (TextAnchor)4;
		((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = true;
		((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = false;
		((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = false;
		CreateBottomButton(val.transform, "Reset to Default", ResetColor, Color.white, delegate
		{
			RSSettings.ResetToDefault();
			if ((Object)(object)thankYouMessageObject != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)thankYouMessageObject);
				thankYouMessageObject = null;
			}
			Transform parent2 = panelObject.transform.parent;
			Object.DestroyImmediate((Object)(object)panelObject);
			BuildPanel(parent2);
			if ((Object)(object)plusPanelObject != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)plusPanelObject);
				plusPanelObject = null;
			}
			UpdateNavButtonLabel();
			SyncThankYouMessageVisibility();
		});
		CreateBottomButton(val.transform, "Close", AccentColor, DarkTextColor, delegate
		{
			panelObject.SetActive(false);
			if ((Object)(object)navButtonObject != (Object)null)
			{
				navButtonObject.SetActive(false);
			}
			if ((Object)(object)backdropObject != (Object)null)
			{
				backdropObject.SetActive(false);
			}
			SyncThankYouMessageVisibility();
		});
	}

	private static void CreatePlusBottomButtonsRow(Transform parent)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		GameObject val = new GameObject("BottomButtonsWrapper");
		val.transform.SetParent(parent, false);
		LayoutElement val2 = val.AddComponent<LayoutElement>();
		val2.minHeight = 40f;
		val2.preferredHeight = 40f;
		val2.flexibleWidth = 1f;
		HorizontalLayoutGroup val3 = val.AddComponent<HorizontalLayoutGroup>();
		((HorizontalOrVerticalLayoutGroup)val3).spacing = 12f;
		((LayoutGroup)val3).childAlignment = (TextAnchor)4;
		((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = true;
		((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = false;
		((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = false;
		CreateBottomButton(val.transform, "Reset to Default", ResetColor, Color.white, delegate
		{
			RSSettings.ResetToDefault();
			if ((Object)(object)thankYouMessageObject != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)thankYouMessageObject);
				thankYouMessageObject = null;
			}
			Transform parent2 = panelObject.transform.parent;
			Object.DestroyImmediate((Object)(object)panelObject);
			BuildPanel(parent2);
			Object.DestroyImmediate((Object)(object)plusPanelObject);
			plusPanelObject = null;
			UpdateNavButtonLabel();
			SyncThankYouMessageVisibility();
		});
		CreateBottomButton(val.transform, "Close", AccentColor, DarkTextColor, delegate
		{
			plusPanelObject.SetActive(false);
			if ((Object)(object)navButtonObject != (Object)null)
			{
				navButtonObject.SetActive(false);
			}
			if ((Object)(object)backdropObject != (Object)null)
			{
				backdropObject.SetActive(false);
			}
			SyncThankYouMessageVisibility();
		});
	}

	private static void CreateBottomButton(Transform parent, string text, Color bgColor, Color textColor, Action onClick)
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Expected O, but got Unknown
		//IL_0088: 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_00ac: Expected O, but got Unknown
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Expected O, but got Unknown
		GameObject val = new GameObject(text.Replace(" ", "") + "Button");
		val.transform.SetParent(parent, false);
		LayoutElement val2 = val.AddComponent<LayoutElement>();
		val2.preferredHeight = 34f;
		val2.minHeight = 34f;
		val2.preferredWidth = 140f;
		val2.minWidth = 140f;
		val2.flexibleWidth = 0f;
		Image val3 = val.AddComponent<Image>();
		((Graphic)val3).color = bgColor;
		Button val4 = val.AddComponent<Button>();
		((Selectable)val4).targetGraphic = (Graphic)(object)val3;
		GameObject val5 = new GameObject("Label");
		val5.transform.SetParent(val.transform, false);
		RectTransform val6 = val5.AddComponent<RectTransform>();
		val6.anchorMin = Vector2.zero;
		val6.anchorMax = Vector2.one;
		val6.offsetMin = Vector2.zero;
		val6.offsetMax = Vector2.zero;
		TextMeshProUGUI val7 = val5.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val7).text = text;
		((TMP_Text)val7).alignment = (TextAlignmentOptions)514;
		((Graphic)val7).color = textColor;
		((TMP_Text)val7).fontStyle = (FontStyles)1;
		((TMP_Text)val7).fontSize = 15f;
		((UnityEvent)val4.onClick).AddListener((UnityAction)delegate
		{
			onClick();
			EventSystem.current.SetSelectedGameObject((GameObject)null);
		});
	}
}
[BepInPlugin("com.shadowblade.riskystats", "Risky Stats", "1.2.2")]
public class RiskyStatsPlugin : BaseUnityPlugin
{
	private const string CurrentConfigVersion = "1.2.2";

	private GameObject statsObject;

	private HorizontalOrVerticalLayoutGroup mainLayoutGroup;

	private GameObject armorCritContainer;

	private readonly Dictionary<string, TextMeshProUGUI> statTexts = new Dictionary<string, TextMeshProUGUI>();

	private readonly Dictionary<string, GameObject> statObjects = new Dictionary<string, GameObject>();

	private readonly string[] statKeys = new string[9] { "AttackSpeed", "Armor", "Crit", "Healing", "Damage", "Streak", "DamageTaken", "DamageTakenStreak", "Speed" };

	private readonly string[] containerStats = new string[3] { "AttackSpeed", "Armor", "Crit" };

	private float lastDamage;

	private float lastDamageTaken;

	private float damageStreak;

	private float damageTakenStreak;

	private float healingStreak;

	private bool lastDamageCrit;

	private float lastDamageTime;

	private float lastTakenTime;

	private float lastHealingTime;

	private float statsUpdateTimer;

	private const float StatsUpdateInterval = 0.1f;

	private GameObject statsPlusObject;

	private VerticalLayoutGroup plusLayoutGroup;

	private readonly Dictionary<string, TextMeshProUGUI> plusStatTexts = new Dictionary<string, TextMeshProUGUI>();

	private readonly Dictionary<string, GameObject> plusStatObjects = new Dictionary<string, GameObject>();

	private readonly string[] plusStatKeys = new string[5] { "Jumps", "MountainShrines", "Drones", "Luck", "Kills" };

	private int mountainShrinesActivated;

	private int monstersKilled;

	private float plusStatsUpdateTimer;

	private const float PlusStatsUpdateInterval = 0.1f;

	private void Awake()
	{
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Expected O, but got Unknown
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Expected O, but got Unknown
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Expected O, but got Unknown
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Risky Stats loaded!");
		MigrateConfigIfNeeded();
		RSSettings.Init(((BaseUnityPlugin)this).Config);
		((Component)this).gameObject.AddComponent<RSSettingsUI>();
		RSPlusSettings.Init(((BaseUnityPlugin)this).Config);
		ProgressSettings.Init(((BaseUnityPlugin)this).Config);
		((Component)this).gameObject.AddComponent<RunProgressUI>();
		GlobalEventManager.onServerDamageDealt += DamageDealt;
		HealthComponent.TakeDamage += new hook_TakeDamage(DamageTaken);
		HealthComponent.Heal += new hook_Heal(Healing);
		PurchaseInteraction.OnInteractionBegin += new hook_OnInteractionBegin(ShrineActivated);
		GlobalEventManager.onCharacterDeathGlobal += MonsterKilled;
		Run.onRunStartGlobal += OnRunStart;
		RSSettings.OnSettingsChanged += RefreshUI;
		RSPlusSettings.OnSettingsChanged += RefreshPlusUI;
	}

	private void MigrateConfigIfNeeded()
	{
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Invalid comparison between Unknown and I4
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Invalid comparison between Unknown and I4
		ConfigEntry<string> val = ((BaseUnityPlugin)this).Config.Bind<string>("Internal", "Config Version", "0.0.0", "Do not edit. Used internally to migrate settings between updates.");
		if (!(val.Value == "1.2.2"))
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)("[RiskyStats] Migrating config from " + val.Value + " to 1.2.2."));
			ConfigEntry<KeyCode> val2 = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Toggle Key", (KeyCode)118, "Key used to show/hide the stats panel");
			ConfigEntry<KeyCode> val3 = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Progress Toggle Key", (KeyCode)98, "Key to hold to show the run progress panel");
			if ((int)val2.Value == 0)
			{
				val2.Value = (KeyCode)118;
			}
			if ((int)val3.Value == 0)
			{
				val3.Value = (KeyCode)98;
			}
			val.Value = "1.2.2";
			((BaseUnityPlugin)this).Config.Save();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[RiskyStats] Config migration complete.");
		}
	}

	private void OnDestroy()
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		RSSettings.OnSettingsChanged -= RefreshUI;
		RSPlusSettings.OnSettingsChanged -= RefreshPlusUI;
		PurchaseInteraction.OnInteractionBegin -= new hook_OnInteractionBegin(ShrineActivated);
		GlobalEventManager.onCharacterDeathGlobal -= MonsterKilled;
		Run.onRunStartGlobal -= OnRunStart;
	}

	private void Update()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		if (UnityInput.Current.GetKeyDown(RSSettings.ToggleKey) && (Object)(object)statsObject != (Object)null)
		{
			bool active = !statsObject.activeSelf;
			statsObject.SetActive(active);
			if ((Object)(object)statsPlusObject != (Object)null)
			{
				statsPlusObject.SetActive(active);
			}
		}
		HUD val = null;
		if ((Object)(object)statsObject == (Object)null || (Object)(object)statsPlusObject == (Object)null)
		{
			val = Object.FindObjectOfType<HUD>();
		}
		if ((Object)(object)statsObject == (Object)null && (Object)(object)val != (Object)null)
		{
			CreateUI(val);
		}
		if ((Object)(object)statsPlusObject == (Object)null && (Object)(object)val != (Object)null)
		{
			CreatePlusUI(val);
		}
		bool flag = (Object)(object)statsObject != (Object)null && statsObject.activeSelf;
		bool flag2 = (Object)(object)statsPlusObject != (Object)null;
		CharacterBody body = null;
		if (flag || flag2)
		{
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			body = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
		}
		if (flag)
		{
			statsUpdateTimer += Time.deltaTime;
			if (statsUpdateTimer >= 0.1f)
			{
				statsUpdateTimer = 0f;
				UpdateStats(body);
			}
		}
		if (flag2)
		{
			plusStatsUpdateTimer += Time.deltaTime;
			if (plusStatsUpdateTimer >= 0.1f)
			{
				plusStatsUpdateTimer = 0f;
				UpdatePlusStats(body);
			}
		}
	}

	private void CreateUI(HUD hud)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		statsObject = new GameObject("RiskyStatsPanel");
		statsObject.transform.SetParent(hud.mainContainer.transform, false);
		RectTransform val = statsObject.AddComponent<RectTransform>();
		val.anchorMin = new Vector2(0f, 1f);
		val.anchorMax = new Vector2(0f, 1f);
		val.pivot = new Vector2(0f, 1f);
		val.anchoredPosition = new Vector2(20f, -160f);
		val.sizeDelta = new Vector2(1700f, 130f);
		BuildUI();
		ApplySettings();
	}

	private void BuildUI()
	{
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Expected O, but got Unknown
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Expected O, but got Unknown
		if ((Object)(object)mainLayoutGroup != (Object)null)
		{
			Object.DestroyImmediate((Object)(object)mainLayoutGroup);
			mainLayoutGroup = null;
		}
		List<Transform> list = new List<Transform>();
		foreach (Transform item2 in statsObject.transform)
		{
			Transform item = item2;
			list.Add(item);
		}
		foreach (Transform item3 in list)
		{
			Object.DestroyImmediate((Object)(object)((Component)item3).gameObject);
		}
		armorCritContainer = null;
		statTexts.Clear();
		statObjects.Clear();
		if (RSSettings.Alignment == StatAlignment.Horizontal)
		{
			mainLayoutGroup = (HorizontalOrVerticalLayoutGroup)(object)statsObject.AddComponent<HorizontalLayoutGroup>();
		}
		else
		{
			mainLayoutGroup = (HorizontalOrVerticalLayoutGroup)(object)statsObject.AddComponent<VerticalLayoutGroup>();
		}
		mainLayoutGroup.spacing = RSSettings.StatSpacing;
		((LayoutGroup)mainLayoutGroup).childAlignment = (TextAnchor)3;
		mainLayoutGroup.childControlWidth = true;
		mainLayoutGroup.childForceExpandWidth = false;
		mainLayoutGroup.childControlHeight = true;
		mainLayoutGroup.childForceExpandHeight = false;
		if (RSSettings.Alignment == StatAlignment.Horizontal)
		{
			armorCritContainer = new GameObject("ArmorCritContainer");
			armorCritContainer.transform.SetParent(statsObject.transform, false);
			VerticalLayoutGroup val = armorCritContainer.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val).spacing = 4f;
			((LayoutGroup)val).childAlignment = (TextAnchor)4;
			((HorizontalOrVerticalLayoutGroup)val).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)val).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)val).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)val).childForceExpandHeight = false;
			LayoutElement val2 = armorCritContainer.AddComponent<LayoutElement>();
			val2.minWidth = 0f;
			val2.preferredWidth = -1f;
		}
		string[] array = statKeys;
		foreach (string key in array)
		{
			TextMeshProUGUI val3 = CreateText(parent: (RSSettings.Alignment != StatAlignment.Horizontal || !Array.Exists(containerStats, (string s) => s == key)) ? statsObject.transform : armorCritContainer.transform, initialText: GetStatLabel(key) + ": 0");
			statTexts[key] = val3;
			statObjects[key] = ((Component)val3).gameObject;
		}
		ContentSizeFitter val4 = statsObject.GetComponent<ContentSizeFitter>();
		if ((Object)(object)val4 == (Object)null)
		{
			val4 = statsObject.AddComponent<ContentSizeFitter>();
		}
		val4.horizontalFit = (FitMode)2;
		val4.verticalFit = (FitMode)2;
	}

	private TextMeshProUGUI CreateText(string initialText, Transform parent)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("StatText");
		val.transform.SetParent(parent, false);
		TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val2).text = initialText;
		((TMP_Text)val2).fontSize = RSSettings.StatFontSize;
		((Graphic)val2).color = Color.white;
		((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
		((TMP_Text)val2).enableWordWrapping = false;
		((TMP_Text)val2).overflowMode = (TextOverflowModes)0;
		LayoutElement val3 = val.AddComponent<LayoutElement>();
		val3.minWidth = 0f;
		val3.preferredWidth = -1f;
		val3.flexibleWidth = 1f;
		return val2;
	}

	private void RefreshUI()
	{
		if (!((Object)(object)statsObject == (Object)null))
		{
			if ((RSSettings.Alignment == StatAlignment.Horizontal && mainLayoutGroup is VerticalLayoutGroup) || (RSSettings.Alignment == StatAlignment.Vertical && mainLayoutGroup is HorizontalLayoutGroup))
			{
				BuildUI();
			}
			else
			{
				mainLayoutGroup.spacing = RSSettings.StatSpacing;
			}
			ApplySettings();
		}
	}

	private void ApplySettings()
	{
		//IL_001d: 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)
		TextAlignmentOptions alignment = (TextAlignmentOptions)((RSSettings.Alignment == StatAlignment.Vertical && RSSettings.TextAlign == StatTextAlign.Left) ? 4097 : 514);
		foreach (KeyValuePair<string, TextMeshProUGUI> statText in statTexts)
		{
			((TMP_Text)statText.Value).fontSize = RSSettings.StatFontSize;
			((TMP_Text)statText.Value).alignment = alignment;
		}
		string[] array = statKeys;
		foreach (string key in array)
		{
			bool active = RSSettings.StatVisibility.ContainsKey(key) && RSSettings.StatVisibility[key];
			if (statObjects.TryGetValue(key, out var value))
			{
				value.SetActive(active);
			}
		}
	}

	private static void SetTextIfChanged(TextMeshProUGUI text, string value)
	{
		if (((TMP_Text)text).text != value)
		{
			((TMP_Text)text).text = value;
		}
	}

	private void UpdateStats(CharacterBody body)
	{
		if (!((Object)(object)body == (Object)null))
		{
			if (Time.time - lastDamageTime > 5f)
			{
				damageStreak = 0f;
			}
			if (Time.time - lastTakenTime > 5f)
			{
				damageTakenStreak = 0f;
			}
			if (Time.time - lastHealingTime > 3f)
			{
				healingStreak = 0f;
			}
			if (statObjects["Armor"].activeSelf)
			{
				SetTextIfChanged(statTexts["Armor"], $"Armor: <color=#4A90E2>{body.armor:0}</color>");
			}
			if (statObjects["Healing"].activeSelf)
			{
				SetTextIfChanged(statTexts["Healing"], "Healing: <color=#90EE90>" + FormatNumber(healingStreak) + "</color>");
			}
			if (statObjects["Damage"].activeSelf)
			{
				SetTextIfChanged(statTexts["Damage"], "Damage: <color=#" + (lastDamageCrit ? "FF0000" : "FFFFFF") + ">" + FormatNumber(lastDamage) + "</color>");
			}
			if (statObjects["Streak"].activeSelf)
			{
				SetTextIfChanged(statTexts["Streak"], "Streak: <color=#FFFF00>" + FormatNumber(damageStreak) + "</color>");
			}
			if (statObjects["DamageTaken"].activeSelf)
			{
				SetTextIfChanged(statTexts["DamageTaken"], "Damage Taken: <color=#FF0000>" + FormatNumber(lastDamageTaken) + "</color>");
			}
			if (statObjects["DamageTakenStreak"].activeSelf)
			{
				SetTextIfChanged(statTexts["DamageTakenStreak"], "Damage Taken Streak: <color=#FF0000>" + FormatNumber(damageTakenStreak) + "</color>");
			}
			if (statObjects["Speed"].activeSelf)
			{
				SetTextIfChanged(statTexts["Speed"], $"Speed: <color=#00FFFF>{((Vector3)(ref body.characterMotor.velocity)).magnitude:0.0} m/s</color>");
			}
			if (statObjects["AttackSpeed"].activeSelf)
			{
				SetTextIfChanged(statTexts["AttackSpeed"], $"Attack Speed: <color=#90EE90>{body.attackSpeed:0.0}</color>");
			}
			if (statObjects["Crit"].activeSelf)
			{
				SetTextIfChanged(statTexts["Crit"], $"Crit: <color=#8B0000>{body.crit:0}%</color>");
			}
		}
	}

	private void DamageDealt(DamageReport report)
	{
		LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
		CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
		if (!((Object)(object)val == (Object)null) && !((Object)(object)report.attackerBody != (Object)(object)val))
		{
			lastDamage = report.damageDealt;
			lastDamageCrit = report.damageInfo.crit;
			damageStreak += report.damageDealt;
			lastDamageTime = Time.time;
		}
	}

	private void DamageTaken(orig_TakeDamage orig, HealthComponent self, DamageInfo info)
	{
		orig.Invoke(self, info);
		LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
		CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
		if (!((Object)(object)val == (Object)null) && !((Object)(object)self.body != (Object)(object)val))
		{
			lastDamageTaken = info.damage;
			damageTakenStreak += info.damage;
			lastTakenTime = Time.time;
		}
	}

	private float Healing(orig_Heal orig, HealthComponent self, float amount, ProcChainMask procChainMask, bool nonRegen)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		float num = orig.Invoke(self, amount, procChainMask, nonRegen);
		LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
		CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
		if ((Object)(object)val != (Object)null && (Object)(object)self.body == (Object)(object)val)
		{
			healingStreak += num;
			lastHealingTime = Time.time;
		}
		return num;
	}

	private string FormatNumber(float number)
	{
		if (number >= 1E+12f)
		{
			return (number / 1E+12f).ToString("0.0") + "t";
		}
		if (number >= 1E+09f)
		{
			return (number / 1E+09f).ToString("0.0") + "b";
		}
		if (number >= 1000000f)
		{
			return (number / 1000000f).ToString("0.0") + "m";
		}
		if (number >= 1000f)
		{
			return (number / 1000f).ToString("0.0") + "k";
		}
		return number.ToString("0");
	}

	private string GetStatLabel(string key)
	{
		return key switch
		{
			"AttackSpeed" => "Attack Speed", 
			"DamageTaken" => "Damage Taken", 
			"DamageTakenStreak" => "Damage Taken Streak", 
			_ => key, 
		};
	}

	private void CreatePlusUI(HUD hud)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		statsPlusObject = new GameObject("RiskyStatsPlusPanel");
		statsPlusObject.transform.SetParent(hud.mainContainer.transform, false);
		RectTransform val = statsPlusObject.AddComponent<RectTransform>();
		val.anchorMin = new Vector2(1f, 0f);
		val.anchorMax = new Vector2(1f, 0f);
		val.pivot = new Vector2(1f, 0f);
		val.anchoredPosition = new Vector2(-30f, 230f);
		val.sizeDelta = new Vector2(400f, 130f);
		BuildPlusUI();
		ApplyPlusSettings();
		if ((Object)(object)statsObject != (Object)null)
		{
			statsPlusObject.SetActive(statsObject.activeSelf);
		}
	}

	private void BuildPlusUI()
	{
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Expected O, but got Unknown
		if ((Object)(object)plusLayoutGroup != (Object)null)
		{
			Object.DestroyImmediate((Object)(object)plusLayoutGroup);
			plusLayoutGroup = null;
		}
		List<Transform> list = new List<Transform>();
		foreach (Transform item2 in statsPlusObject.transform)
		{
			Transform item = item2;
			list.Add(item);
		}
		foreach (Transform item3 in list)
		{
			Object.DestroyImmediate((Object)(object)((Component)item3).gameObject);
		}
		plusStatTexts.Clear();
		plusStatObjects.Clear();
		plusLayoutGroup = statsPlusObject.AddComponent<VerticalLayoutGroup>();
		((HorizontalOrVerticalLayoutGroup)plusLayoutGroup).spacing = RSPlusSettings.StatSpacing;
		((LayoutGroup)plusLayoutGroup).childAlignment = (TextAnchor)8;
		((HorizontalOrVerticalLayoutGroup)plusLayoutGroup).childControlWidth = true;
		((HorizontalOrVerticalLayoutGroup)plusLayoutGroup).childForceExpandWidth = false;
		((HorizontalOrVerticalLayoutGroup)plusLayoutGroup).childControlHeight = true;
		((HorizontalOrVerticalLayoutGroup)plusLayoutGroup).childForceExpandHeight = false;
		string[] array = plusStatKeys;
		foreach (string key in array)
		{
			TextMeshProUGUI val = CreateText(GetPlusStatLabel(key) + ": 0", statsPlusObject.transform);
			((TMP_Text)val).alignment = (TextAlignmentOptions)4100;
			plusStatTexts[key] = val;
			plusStatObjects[key] = ((Component)val).gameObject;
		}
		ContentSizeFitter val2 = statsPlusObject.GetComponent<ContentSizeFitter>();
		if