Decompiled source of StageRanking v1.0.0

plugins/StageRanking.dll

Decompiled 3 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using LeTai.Asset.TranslucentImage;
using Microsoft.CodeAnalysis;
using On.RoR2;
using On.RoR2.Networking;
using R2API;
using R2API.Utils;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Audio;
using RoR2.ContentManagement;
using RoR2.HudOverlay;
using RoR2.UI;
using RoR2BepInExPack.GameAssetPaths.Version_1_39_0;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("StageRanking")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+3beafc1b70950fef6bd95e0dcbf8525a84f7f837")]
[assembly: AssemblyProduct("StageRanking")]
[assembly: AssemblyTitle("StageRanking")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace StageRanking
{
	internal static class Assets
	{
		public static string AddressablesDirectory;

		public static GameObject panelPrefab;

		public static GameObject scoreStripPrefab;

		public static LoopSoundDef tallyLoopSoundDef;

		public static RankingVisual dRanking;

		public static RankingVisual cRanking;

		public static RankingVisual bRanking;

		public static RankingVisual aRanking;

		public static RankingVisual sRanking;

		public static AssetReferenceT<GameObject> panelAsset = new AssetReferenceT<GameObject>("b1d1223b357e72f4da52ba905c9d3ca9");

		public static AssetReferenceSprite dRankingSprite = new AssetReferenceSprite("eeab231232620244a83e8fff99f26271");

		public static AssetReferenceSprite cRankingSprite = new AssetReferenceSprite("88bd72cc3cf158f45a92008d679ece3a");

		public static AssetReferenceSprite bRankingSprite = new AssetReferenceSprite("b5a33a91a6f7a9845913b0fcc0d35913");

		public static AssetReferenceSprite aRankingSprite = new AssetReferenceSprite("ee8acb6cef497bd4d919e1ae27fb891e");

		public static AssetReferenceSprite sRankingSprite = new AssetReferenceSprite("2d827acc23a9baa4bbc476a98c26c8cd");

		public static AssetReferenceSprite modIconSprite = new AssetReferenceSprite("a9559615091d45340be2eb3ce501d8d0");

		internal static void Initialize()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: 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_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: 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_033d: 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_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_041f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0434: Unknown result type (might be due to invalid IL or missing references)
			//IL_0439: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_044f: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_046a: Expected O, but got Unknown
			AddressablesDirectory = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)StageRankingPlugin.instance).Info.Location), "Addressables");
			Addressables.LoadContentCatalogAsync(Path.Combine(AddressablesDirectory, "catalog.json"), (string)null).WaitForCompletion();
			panelPrefab = Addressables.LoadAssetAsync<GameObject>((object)panelAsset).WaitForCompletion();
			StageRankingPanel panelComponent = panelPrefab.AddComponent<StageRankingPanel>();
			AsyncOperationHandle<MusicTrackDef> val = AssetAsyncReferenceManager<MusicTrackDef>.LoadAsset(new AssetReferenceT<MusicTrackDef>(RoR2_Base_Common_MusicTrackDefs.muNone_asset), (AsyncReferenceHandleUnloadType)2);
			val.Completed += delegate(AsyncOperationHandle<MusicTrackDef> x)
			{
				panelComponent.musicTrackOverride = panelPrefab.AddComponent<MusicTrackOverride>();
				panelComponent.musicTrackOverride.track = x.Result;
				((Behaviour)panelComponent.musicTrackOverride).enabled = false;
			};
			panelComponent.rankingBackground = ((Component)panelPrefab.transform.Find("RankingBackground")).GetComponent<Image>();
			panelComponent.rankingForeground = ((Component)((Component)panelComponent.rankingBackground).transform.GetChild(0)).GetComponent<Image>();
			ObjectScaleCurve val2 = ((Component)panelComponent.rankingForeground).gameObject.AddComponent<ObjectScaleCurve>();
			val2.useOverallCurveOnly = true;
			val2.overallCurve = AnimationCurve.EaseInOut(0f, 1.2f, 1f, 1f);
			val2.timeMax = 0.1f;
			Image scoreHeader = ((Component)panelPrefab.transform.Find("ScoreContainer/ScoreHeader")).GetComponent<Image>();
			TranslucentImage blurPanel = ((Component)panelPrefab.transform.Find("ScoreContainer/BlurPanel")).gameObject.AddComponent<TranslucentImage>();
			((Graphic)blurPanel).color = Color.black;
			Image scoreBody = ((Component)panelPrefab.transform.Find("ScoreContainer/ScoreBody")).GetComponent<Image>();
			panelComponent.scoreStripContainer = ((Component)scoreBody).transform.Find("ScoreStripContainer");
			Transform val3 = panelPrefab.transform.Find("ScoreContainer/ScoreBody/BarPanel");
			Image barPanel = ((Component)val3).GetComponent<Image>();
			Image barInterior = ((Component)val3.GetChild(0)).GetComponent<Image>();
			panelComponent.dBar = ((Component)val3.GetChild(0).GetChild(0)).GetComponent<Image>();
			panelComponent.cBar = ((Component)val3.GetChild(0).GetChild(1)).GetComponent<Image>();
			panelComponent.bBar = ((Component)val3.GetChild(0).GetChild(2)).GetComponent<Image>();
			panelComponent.aBar = ((Component)val3.GetChild(0).GetChild(3)).GetComponent<Image>();
			AsyncOperationHandle<GameObject> val4 = AssetAsyncReferenceManager<GameObject>.LoadAsset(new AssetReferenceT<GameObject>(RoR2_Base_UI.GameEndReportPanel_prefab), (AsyncReferenceHandleUnloadType)2);
			val4.Completed += delegate(AsyncOperationHandle<GameObject> x)
			{
				//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0211: Unknown result type (might be due to invalid IL or missing references)
				//IL_0223: Unknown result type (might be due to invalid IL or missing references)
				//IL_0235: Unknown result type (might be due to invalid IL or missing references)
				//IL_0256: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0308: Unknown result type (might be due to invalid IL or missing references)
				panelComponent.rankingBackground.sprite = ((Component)x.Result.transform.Find("SafeArea (JUICED)/HeaderArea/ResultArea/ResultIconBackground")).GetComponent<Image>().sprite;
				Transform val7 = x.Result.transform.Find("SafeArea (JUICED)/BodyArea/StatsAndChatArea/StatsContainer");
				scoreHeader.sprite = ((Component)val7.Find("Stats And Player Nav/Stats Header")).GetComponent<Image>().sprite;
				barPanel.sprite = scoreHeader.sprite;
				GameObject val8 = Object.Instantiate<GameObject>(((Component)val7.Find("Stats And Player Nav/Stats Header/InfoLabel")).gameObject);
				val8.GetComponent<LanguageTextMeshController>()._token = "DS_GAMING_STAGE_RANKING_SCORE";
				val8.transform.SetParent(((Component)scoreHeader).transform);
				val8.transform.localPosition = Vector3.zero;
				val8.transform.localEulerAngles = Vector3.zero;
				val8.transform.localScale = Vector3.one;
				HGTextMeshProUGUI component = val8.GetComponent<HGTextMeshProUGUI>();
				((TMP_Text)component).text = "Score";
				((TMP_Text)component).fontSizeMin = 12f;
				((TMP_Text)component).fontSize = 18f;
				((TMP_Text)component).fontSizeMax = 24f;
				((Component)panelPrefab.transform.Find("ScoreContainer/BorderImage")).GetComponent<Image>().sprite = ((Component)val7.Find("BorderImage")).GetComponent<Image>().sprite;
				scoreBody.sprite = ((Component)val7.Find("Stats Body")).GetComponent<Image>().sprite;
				barInterior.sprite = scoreBody.sprite;
				TranslucentImage component2 = ((Component)val7.Find("BlurPanel")).GetComponent<TranslucentImage>();
				((Graphic)blurPanel).material = ((Graphic)component2).material;
				((Image)blurPanel).sprite = ((Image)component2).sprite;
				Transform val9 = panelPrefab.transform.Find("ScoreContainer/ScoreFooter");
				GameObject val10 = Object.Instantiate<GameObject>(((Component)val7.Find("Stats Footer/TotalLabel")).gameObject);
				val10.transform.SetParent(((Component)val9).transform);
				val10.transform.localPosition = Vector3.zero;
				val10.transform.localEulerAngles = Vector3.zero;
				val10.transform.localScale = Vector3.one;
				Transform transform = val10.transform;
				((RectTransform)((transform is RectTransform) ? transform : null)).pivot = new Vector2(0.25f, 0.5f);
				HGTextMeshProUGUI component3 = val10.GetComponent<HGTextMeshProUGUI>();
				((TMP_Text)component3).fontSizeMin = 12f;
				((TMP_Text)component3).fontSize = 18f;
				((TMP_Text)component3).fontSizeMax = 24f;
				GameObject val11 = Object.Instantiate<GameObject>(((Component)val7.Find("Stats Footer/TotalPointsLabel")).gameObject);
				val11.transform.SetParent(((Component)val9).transform);
				val11.transform.localPosition = Vector3.zero;
				val11.transform.localEulerAngles = Vector3.zero;
				val11.transform.localScale = Vector3.one;
				Transform transform2 = val11.transform;
				((RectTransform)((transform2 is RectTransform) ? transform2 : null)).pivot = new Vector2(0.75f, 0.5f);
				panelComponent.totalPtsText = val11.GetComponent<HGTextMeshProUGUI>();
				((TMP_Text)panelComponent.totalPtsText).fontSizeMin = 12f;
				((TMP_Text)panelComponent.totalPtsText).fontSize = 18f;
				((TMP_Text)panelComponent.totalPtsText).fontSizeMax = 24f;
			};
			val4 = AssetAsyncReferenceManager<GameObject>.LoadAsset(new AssetReferenceT<GameObject>(RoR2_Base_UI.StatStripTemplate_prefab), (AsyncReferenceHandleUnloadType)2);
			val4.Completed += delegate(AsyncOperationHandle<GameObject> x)
			{
				scoreStripPrefab = PrefabAPI.InstantiateClone(x.Result, "StageRankingScoreStrip", false);
				scoreStripPrefab.GetComponent<LayoutElement>().preferredHeight = 18f;
			};
			AsyncOperationHandle<Material> val5 = Addressables.LoadAssetAsync<Material>((object)RoR2_Base_UI.matUIIconLoss_mat);
			val5.Completed += delegate(AsyncOperationHandle<Material> x)
			{
				((Graphic)panelComponent.rankingBackground).material = x.Result;
				((Graphic)((Component)((Component)panelComponent.rankingBackground).transform.GetChild(0)).GetComponent<Image>()).material = x.Result;
			};
			AsyncOperationHandle<Sprite> val6 = Addressables.LoadAssetAsync<Sprite>((object)RoR2_Base_UI.texUINonsegmentedHealthbar_png_texUINonsegmentedHealthbar_);
			val6.Completed += delegate(AsyncOperationHandle<Sprite> x)
			{
				panelComponent.dBar.sprite = x.Result;
				panelComponent.cBar.sprite = x.Result;
				panelComponent.bBar.sprite = x.Result;
				panelComponent.aBar.sprite = x.Result;
			};
			RankingVisual rankingVisual = default(RankingVisual);
			rankingVisual.foregroundColor = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)18));
			rankingVisual.foregroundSprite = dRankingSprite;
			rankingVisual.backgroundColor = new Color(0.4f, 0.4f, 0.5f);
			dRanking = rankingVisual;
			rankingVisual = default(RankingVisual);
			rankingVisual.foregroundColor = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)1));
			rankingVisual.foregroundSprite = cRankingSprite;
			rankingVisual.backgroundColor = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)18));
			cRanking = rankingVisual;
			rankingVisual = default(RankingVisual);
			rankingVisual.foregroundColor = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)2));
			rankingVisual.foregroundSprite = bRankingSprite;
			rankingVisual.backgroundColor = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)19));
			bRanking = rankingVisual;
			rankingVisual = default(RankingVisual);
			rankingVisual.foregroundColor = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)3));
			rankingVisual.foregroundSprite = aRankingSprite;
			rankingVisual.backgroundColor = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)20));
			aRanking = rankingVisual;
			rankingVisual = default(RankingVisual);
			rankingVisual.foregroundColor = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)13));
			rankingVisual.foregroundSprite = sRankingSprite;
			rankingVisual.backgroundColor = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)22));
			sRanking = rankingVisual;
			tallyLoopSoundDef = new LoopSoundDef
			{
				startSoundName = "Play_stageranking_tally",
				stopSoundName = "Stop_stageranking_tally"
			};
		}
	}
	public struct RankingVisual
	{
		public Color foregroundColor;

		public AssetReferenceSprite foregroundSprite;

		public Color backgroundColor;
	}
	public static class Config
	{
		public enum AnimationSpeed
		{
			Default,
			Short,
			Long
		}

		public static string[] stageBlacklist;

		public static string[] longStages;

		public static string[] veryLongStages;

		public static ConfigEntry<AnimationSpeed> AnimationDuration()
		{
			return ((BaseUnityPlugin)StageRankingPlugin.instance).Config.Bind<AnimationSpeed>("General", "Animation Duration", AnimationSpeed.Default, "How long it will take for the UI to tally up and display the final score.\n\nUsing the long animation while you're singleplayer/host may increase the time it takes for the teleporter to activate, giving the animation time to finish.\nWhen set to Default, it will attempt to play the long animation, but will fallback to the short one in multiplayer situations where the teleporter cannot be delayed.");
		}

		public static ConfigEntry<bool> PlayMusic()
		{
			return ((BaseUnityPlugin)StageRankingPlugin.instance).Config.Bind<bool>("General", "Enable Music", true, "Whether the ranking screen will play music.");
		}

		public static ConfigEntry<string> StageBlacklist()
		{
			return ((BaseUnityPlugin)StageRankingPlugin.instance).Config.Bind<string>("General", "Stage Blacklist", "bazaar, computationalexchange", "Stages that should never have a ranking. By default, this includes Newt's Bazaar and SPEX's Computational Exchange.\n\nYou must put in the internal name of the stage. Use scene_list in the console to see the internal names of stages.");
		}

		public static ConfigEntry<int> MaxTimeScore()
		{
			return ((BaseUnityPlugin)StageRankingPlugin.instance).Config.Bind<int>("Time Score", "Max Time Score", 20000, "The maximum amount of score you can get from beating the stage quickly. Setting this value to 0 will disable this score.");
		}

		public static ConfigEntry<int> TimeForMaxTimeScore()
		{
			return ((BaseUnityPlugin)StageRankingPlugin.instance).Config.Bind<int>("Time Score", "Best Time", 300, "How quickly the stage must be beaten to earn the maximum time score, measured in seconds.");
		}

		public static ConfigEntry<int> TimeForMinTimeScore()
		{
			return ((BaseUnityPlugin)StageRankingPlugin.instance).Config.Bind<int>("Time Score", "Worst Time", 1200, "How slowly the stage must be beaten to earn 0 time score, measured in seconds.");
		}

		public static ConfigEntry<string> LongStagesTimeScore()
		{
			return ((BaseUnityPlugin)StageRankingPlugin.instance).Config.Bind<string>("Time Score", "Long Stages", "rootjungle, dampcavesimple, shipgraveyard, repurposedcrater, tropics_wormsworms, tropicsnight_wormsworms", "Stages that are expected to take longer than normal, giving you more time to get a good time score. By default, this includes all stage 4s.\n\nYou must put in the internal name of the stage. Use scene_list in the console to see the internal names of stages.");
		}

		public static ConfigEntry<float> LongStageMultiplierTimeScore()
		{
			return ((BaseUnityPlugin)StageRankingPlugin.instance).Config.Bind<float>("Time Score", "Long Multiplier", 25f, "A multiplier for how much more time you have when on long stages.");
		}

		public static ConfigEntry<string> VeryLongStagesTimeScore()
		{
			return ((BaseUnityPlugin)StageRankingPlugin.instance).Config.Bind<string>("Time Score", "Very Long Stages", "conduitcanyon, moon, moon2", "Stages that are expected to take a lot longer than normal, giving you more time to get a good time score. By default, this includes Conduit Canyon and Commencement.\n\nYou must put in the internal name of the stage. Use scene_list in the console to see the internal names of stages.");
		}

		public static ConfigEntry<float> VeryLongStageMultiplierTimeScore()
		{
			return ((BaseUnityPlugin)StageRankingPlugin.instance).Config.Bind<float>("Time Score", "Very Long Multiplier", 50f, "A multiplier for how much more time you have when on very long stages.");
		}

		public static ConfigEntry<int> MaxLootScore()
		{
			return ((BaseUnityPlugin)StageRankingPlugin.instance).Config.Bind<int>("Loot Score", "Max Loot Score", 20000, "The maximum amount of score you can get from opening all chests in a stage. Setting this value to 0 will disable this score.");
		}

		public static ConfigEntry<int> ItemsPerStage()
		{
			return ((BaseUnityPlugin)StageRankingPlugin.instance).Config.Bind<int>("Loot Score", "Items Per Stage", 10, "A high estimate of the amount of items you're expected to get in a stage. Used for scenarios where the number of chests in the stage isn't a good indicator of the items you get, such as with Artifact of Sacrifice.");
		}

		public static ConfigEntry<int> ScorePerMountainShrine()
		{
			return ((BaseUnityPlugin)StageRankingPlugin.instance).Config.Bind<int>("Mountain Score", "Score Per Mountain Shrine", 2500, "The amount of score you get for the first mountain shrine stack you have. Subsequent mountain shrine stacks will gradually give less score. Setting this value to 0 will disable this score.");
		}

		public static ConfigEntry<float> SRankRequirement()
		{
			return ((BaseUnityPlugin)StageRankingPlugin.instance).Config.Bind<float>("Ranking", "S-Rank", 90f, "The percentage, out of all possible score you can get, that you must earn to achieve an S-rank.");
		}

		public static ConfigEntry<float> ARankRequirement()
		{
			return ((BaseUnityPlugin)StageRankingPlugin.instance).Config.Bind<float>("Ranking", "A-Rank", 84f, "The percentage, out of all possible score you can get, that you must earn to achieve an A-rank.");
		}

		public static ConfigEntry<float> BRankRequirement()
		{
			return ((BaseUnityPlugin)StageRankingPlugin.instance).Config.Bind<float>("Ranking", "B-Rank", 76f, "The percentage, out of all possible score you can get, that you must earn to achieve an B-rank.");
		}

		public static ConfigEntry<float> CRankRequirement()
		{
			return ((BaseUnityPlugin)StageRankingPlugin.instance).Config.Bind<float>("Ranking", "C-Rank", 70f, "The percentage, out of all possible score you can get, that you must earn to achieve an C-rank.");
		}

		public static void RiskOfOptionsSetup()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_008e: 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_009a: Expected O, but got Unknown
			//IL_00a0: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			//IL_00be: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			//IL_00dc: Expected O, but got Unknown
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			//IL_0143: 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_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Expected O, but got Unknown
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Expected O, but got Unknown
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Expected O, but got Unknown
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Expected O, but got Unknown
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Expected O, but got Unknown
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Expected O, but got Unknown
			//IL_01bb: Expected O, but got Unknown
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Expected O, but got Unknown
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Expected O, but got Unknown
			//IL_01d8: Expected O, but got Unknown
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Expected O, but got Unknown
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Expected O, but got Unknown
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Expected O, but got Unknown
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Expected O, but got Unknown
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Expected O, but got Unknown
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Expected O, but got Unknown
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Expected O, but got Unknown
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Expected O, but got Unknown
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Expected O, but got Unknown
			AsyncOperationHandle<Sprite> val = Addressables.LoadAssetAsync<Sprite>((object)Assets.modIconSprite);
			val.Completed += delegate(AsyncOperationHandle<Sprite> x)
			{
				ModSettingsManager.SetModIcon(x.Result);
			};
			ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)AnimationDuration()));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(PlayMusic()));
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(StageBlacklist()));
			StageBlacklist().SettingChanged += UpdateStageBlacklist;
			ConfigEntry<int> obj = MaxTimeScore();
			IntFieldConfig val2 = new IntFieldConfig();
			((NumericFieldConfig<int>)val2).Min = 0;
			ModSettingsManager.AddOption((BaseOption)new IntFieldOption(obj, val2));
			ConfigEntry<int> obj2 = TimeForMaxTimeScore();
			IntFieldConfig val3 = new IntFieldConfig();
			((NumericFieldConfig<int>)val3).Min = 60;
			ModSettingsManager.AddOption((BaseOption)new IntFieldOption(obj2, val3));
			ConfigEntry<int> obj3 = TimeForMinTimeScore();
			IntFieldConfig val4 = new IntFieldConfig();
			((NumericFieldConfig<int>)val4).Min = 60;
			ModSettingsManager.AddOption((BaseOption)new IntFieldOption(obj3, val4));
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(LongStagesTimeScore()));
			LongStagesTimeScore().SettingChanged += UpdateLongStagesList;
			VeryLongStagesTimeScore().SettingChanged += UpdateVeryLongStagesList;
			ModSettingsManager.AddOption((BaseOption)new SliderOption(LongStageMultiplierTimeScore(), new SliderConfig
			{
				min = 0f,
				max = 100f
			}));
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(VeryLongStagesTimeScore()));
			ModSettingsManager.AddOption((BaseOption)new SliderOption(VeryLongStageMultiplierTimeScore(), new SliderConfig
			{
				min = 0f,
				max = 100f
			}));
			ConfigEntry<int> obj4 = MaxLootScore();
			IntFieldConfig val5 = new IntFieldConfig();
			((NumericFieldConfig<int>)val5).Min = 0;
			ModSettingsManager.AddOption((BaseOption)new IntFieldOption(obj4, val5));
			ConfigEntry<int> obj5 = ScorePerMountainShrine();
			IntFieldConfig val6 = new IntFieldConfig();
			((NumericFieldConfig<int>)val6).Min = 0;
			ModSettingsManager.AddOption((BaseOption)new IntFieldOption(obj5, val6));
			ModSettingsManager.AddOption((BaseOption)new SliderOption(SRankRequirement(), new SliderConfig
			{
				min = 0f,
				max = 100f
			}));
			ModSettingsManager.AddOption((BaseOption)new SliderOption(ARankRequirement(), new SliderConfig
			{
				min = 0f,
				max = 100f
			}));
			ModSettingsManager.AddOption((BaseOption)new SliderOption(BRankRequirement(), new SliderConfig
			{
				min = 0f,
				max = 100f
			}));
			ModSettingsManager.AddOption((BaseOption)new SliderOption(CRankRequirement(), new SliderConfig
			{
				min = 0f,
				max = 100f
			}));
		}

		public static void UpdateLongStagesList(object sender, EventArgs args)
		{
			longStages = LongStagesTimeScore().Value.Split(", ").ToArray();
		}

		public static void UpdateVeryLongStagesList(object sender, EventArgs args)
		{
			veryLongStages = VeryLongStagesTimeScore().Value.Split(", ").ToArray();
		}

		public static void UpdateStageBlacklist(object sender, EventArgs args)
		{
			stageBlacklist = StageBlacklist().Value.Split(", ").ToArray();
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	public static class OnHooks
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Begin <0>__ShowRankingUI;

			public static hook_StartNewScenePreload_string_bool <1>__ShowRankingUI2;

			public static hook_SetState <2>__DelaySceneExit;
		}

		public static void Initialize()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			object obj = <>O.<0>__ShowRankingUI;
			if (obj == null)
			{
				hook_Begin val = ShowRankingUI;
				<>O.<0>__ShowRankingUI = val;
				obj = (object)val;
			}
			SceneExitController.Begin += (hook_Begin)obj;
			object obj2 = <>O.<1>__ShowRankingUI2;
			if (obj2 == null)
			{
				hook_StartNewScenePreload_string_bool val2 = ShowRankingUI2;
				<>O.<1>__ShowRankingUI2 = val2;
				obj2 = (object)val2;
			}
			NetworkPreloadManager.StartNewScenePreload_string_bool += (hook_StartNewScenePreload_string_bool)obj2;
			object obj3 = <>O.<2>__DelaySceneExit;
			if (obj3 == null)
			{
				hook_SetState val3 = DelaySceneExit;
				<>O.<2>__DelaySceneExit = val3;
				obj3 = (object)val3;
			}
			SceneExitController.SetState += (hook_SetState)obj3;
		}

		public static void ShowRankingUI(orig_Begin orig, SceneExitController self)
		{
			if (NetworkServer.active)
			{
				StageRankingTracker.CreateRanking(self);
			}
			orig.Invoke(self);
		}

		public static void ShowRankingUI2(orig_StartNewScenePreload_string_bool orig, string sceneName, bool idk)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Invalid comparison between Unknown and I4
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Invalid comparison between Unknown and I4
			if (!NetworkServer.active)
			{
				SceneDef val = SceneCatalog.FindSceneDef(sceneName);
				if (Object.op_Implicit((Object)(object)val) && (int)val.sceneType != -1 && (int)val.sceneType != 0 && (int)val.sceneType != 6 && (int)val.sceneType != 3)
				{
					StageRankingTracker.CreateRanking(null);
				}
			}
			orig.Invoke(sceneName, idk);
		}

		public static void DelaySceneExit(orig_SetState orig, SceneExitController self, ExitState newState)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (!Util.GetIsAnimationSpeedLong() || self.exitState == newState || (int)newState != 2 || !StageRankingPanel.panelActive)
			{
				orig.Invoke(self, newState);
			}
		}
	}
	public class StageRankingPanel : MonoBehaviour
	{
		public enum PanelState
		{
			BeforeStart,
			Start,
			Tallying,
			TallyFinished,
			Reveal,
			End
		}

		public static SceneExitController sceneExitController;

		private static OverlayController overlayController;

		public static List<Score> displayedScores;

		public static PanelMusicDefCombo defaultPanelMusicDef = new PanelMusicDefCombo(new PanelMusicDef("Play_stageranking_default_music", 4.8f, 7.5f), new PanelMusicDef("Play_stageranking_default_music_short", 2.1f, 4f));

		public static List<PanelMusicDefCombo> overridePanelMusicDefs = new List<PanelMusicDefCombo>();

		public const float panelStartPad = 0.5f;

		public const float tallyStartPadPercent = 0.2f;

		private float tallyStart;

		public const float tallyEndPad = 0.5f;

		private PanelState state;

		private PanelMusicDef panelMusicDef;

		private int totalScore;

		private int totalScoreRequirement;

		private float targetBarFill;

		private List<HGTextMeshProUGUI> ptsText;

		public HGTextMeshProUGUI totalPtsText;

		private float timer;

		public static bool panelActive;

		public static Action<Ranking> OnStageRankingPanelEnd;

		public Ranking ranking;

		public MusicTrackOverride musicTrackOverride;

		private SoundLoopPtr tallyLoopSound;

		private RankingVisual rankingVisual;

		public Image rankingForeground;

		public Image rankingBackground;

		public Image dBar;

		public Image cBar;

		public Image bBar;

		public Image aBar;

		public Transform scoreStripContainer;

		public static void CreatePanel(List<Score> scores)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if (!panelActive)
			{
				displayedScores = scores;
				OverlayCreationParams val = default(OverlayCreationParams);
				val.prefab = Assets.panelPrefab;
				val.childLocatorEntry = "CrosshairExtras";
				overlayController = HudOverlayManager.AddGlobalOverlay(val);
			}
		}

		public static void CreateDebugChatMessage(List<Score> scores)
		{
			Chat.AddMessage("==== Stage Ranking Panel ====");
			int num = 0;
			int num2 = 0;
			foreach (Score score in scores)
			{
				Chat.AddMessage(score.ToString());
				num += score.score;
				num2 += score.addedScoreRequirement;
			}
			Chat.AddMessage($"<size=110%>{Util.PointsTextFormat(num)} ==== </size><size=130%>{Util.GetRanking(num, num2)}</size>");
		}

		public void Start()
		{
			panelActive = true;
			Log.Message("Stage Ranking Panel Start");
			panelMusicDef = GetPanelMusicDef();
			tallyStart = (panelMusicDef.timeUntilRankReveal - 0.5f) * 0.2f;
			foreach (Score displayedScore in displayedScores)
			{
				totalScore += displayedScore.score;
				totalScoreRequirement += displayedScore.addedScoreRequirement;
			}
			ranking = Util.GetRanking(totalScore, totalScoreRequirement);
			((TMP_Text)totalPtsText).text = Util.PointsTextFormat(0);
			CalculateTargetBarFill();
			PrepareRanking(ranking);
		}

		public void Update()
		{
			timer += Time.deltaTime;
			switch (state)
			{
			case PanelState.BeforeStart:
				if (timer > 0.5f)
				{
					SetState(PanelState.Start);
				}
				break;
			case PanelState.Start:
				if (timer > 0.5f + tallyStart)
				{
					SetState(PanelState.Tallying);
				}
				break;
			case PanelState.Tallying:
			{
				float num = Mathf.Clamp01((timer - 0.5f - tallyStart) / (panelMusicDef.timeUntilRankReveal - 0.5f - 0.5f - tallyStart));
				SetBarFill(num);
				SetPtsValues(Mathf.Clamp01(num / targetBarFill));
				if (timer > panelMusicDef.timeUntilRankReveal || num >= targetBarFill)
				{
					SetState(PanelState.TallyFinished);
				}
				break;
			}
			case PanelState.TallyFinished:
				if (timer > panelMusicDef.timeUntilRankReveal + 0.5f)
				{
					SetState(PanelState.Reveal);
				}
				break;
			}
			if (timer > panelMusicDef.duration)
			{
				SetState(PanelState.End);
			}
		}

		public void SetState(PanelState newState)
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Invalid comparison between Unknown and I4
			if (state == newState)
			{
				return;
			}
			state = newState;
			switch (state)
			{
			case PanelState.BeforeStart:
				break;
			case PanelState.Start:
				if (Config.PlayMusic().Value)
				{
					Util.PlaySound(panelMusicDef.soundString, ((Component)this).gameObject);
					((Behaviour)musicTrackOverride).enabled = true;
				}
				break;
			case PanelState.Tallying:
				tallyLoopSound = LoopSoundManager.PlaySoundLoopLocal(((Component)this).gameObject, Assets.tallyLoopSoundDef);
				break;
			case PanelState.TallyFinished:
				SetBarFill(1f);
				SetPtsValues(1f);
				LoopSoundManager.StopSoundLoopLocal(tallyLoopSound);
				break;
			case PanelState.Reveal:
				((Graphic)rankingBackground).color = rankingVisual.backgroundColor;
				((Component)rankingForeground).gameObject.SetActive(true);
				Util.PlaySound("Play_stageranking_result", ((Component)this).gameObject);
				break;
			case PanelState.End:
				Log.Message("Stage Ranking Panel End");
				panelActive = false;
				OnStageRankingPanelEnd?.Invoke(ranking);
				if (Object.op_Implicit((Object)(object)sceneExitController) && (int)sceneExitController.exitState == 0)
				{
					sceneExitController.SetState((ExitState)2);
				}
				((Behaviour)musicTrackOverride).enabled = false;
				break;
			}
		}

		public void CalculateTargetBarFill()
		{
			if (ranking == Ranking.S)
			{
				targetBarFill = 1f;
				return;
			}
			float num = ((ranking != 0) ? ((float)Util.GetScoreRequirement(ranking - 1, totalScoreRequirement)) : 0f);
			float num2 = Util.GetScoreRequirement(ranking + 1, totalScoreRequirement);
			targetBarFill = (float)ranking * 0.25f + ((float)totalScore - num) / (num2 - num) * 0.25f;
		}

		public void SetBarFill(float totalFill)
		{
			float num = Mathf.Min(totalFill, targetBarFill);
			dBar.fillAmount = num * 4f;
			cBar.fillAmount = (num - 0.25f) * 4f;
			bBar.fillAmount = (num - 0.5f) * 4f;
			aBar.fillAmount = (num - 0.75f) * 4f;
		}

		public void SetPtsValues(float percentOfMax)
		{
			for (int i = 0; i < ptsText.Count; i++)
			{
				((TMP_Text)ptsText[i]).text = Util.PointsTextFormat(Math.Min((int)((float)displayedScores[i].score * percentOfMax), Math.Max(displayedScores[i].score, displayedScores[i].addedScoreRequirement)));
			}
			((TMP_Text)totalPtsText).text = Util.PointsTextFormat(Math.Min((int)((float)totalScore * percentOfMax), totalScore));
		}

		public void PrepareRanking(Ranking rank)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			rankingVisual = Util.GetRankingVisual(rank);
			((Graphic)rankingForeground).color = rankingVisual.foregroundColor;
			AsyncOperationHandle<Sprite> val = AssetAsyncReferenceManager<Sprite>.LoadAsset((AssetReferenceT<Sprite>)(object)rankingVisual.foregroundSprite, (AsyncReferenceHandleUnloadType)3);
			val.Completed += delegate(AsyncOperationHandle<Sprite> x)
			{
				rankingForeground.sprite = x.Result;
			};
			CreateScoreStrips();
		}

		private void CreateScoreStrips()
		{
			ptsText = new List<HGTextMeshProUGUI>();
			for (int i = 0; i < displayedScores.Count; i++)
			{
				GameObject val = Object.Instantiate<GameObject>(Assets.scoreStripPrefab, scoreStripContainer);
				((TMP_Text)((Component)val.transform.Find("StatNameLabel")).GetComponent<HGTextMeshProUGUI>()).text = Language.GetString(displayedScores[i].nameToken);
				HGTextMeshProUGUI component = ((Component)val.transform.Find("PointValueLabel")).GetComponent<HGTextMeshProUGUI>();
				((TMP_Text)component).text = Util.PointsTextFormat(0);
				ptsText.Add(component);
			}
		}

		public void OnDestroy()
		{
			HudOverlayManager.RemoveGlobalOverlay(overlayController);
			panelActive = false;
		}

		public static PanelMusicDef GetPanelMusicDef()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			if (overridePanelMusicDefs.Count > 0)
			{
				LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
				if (firstLocalUser != null && Object.op_Implicit((Object)(object)firstLocalUser.cachedMaster))
				{
					foreach (PanelMusicDefCombo overridePanelMusicDef in overridePanelMusicDefs)
					{
						if (overridePanelMusicDef.requiredSurvivorBodyName == null || overridePanelMusicDef.requiredSurvivorBodyName.Contains(BodyCatalog.GetBodyName(firstLocalUser.cachedMaster.backupBodyIndex)))
						{
							return Util.GetIsAnimationSpeedLong() ? overridePanelMusicDef.panelMusicDef : overridePanelMusicDef.shortPanelMusicDef;
						}
					}
				}
			}
			return Util.GetIsAnimationSpeedLong() ? defaultPanelMusicDef.panelMusicDef : defaultPanelMusicDef.shortPanelMusicDef;
		}
	}
	public struct PanelMusicDefCombo
	{
		public PanelMusicDef panelMusicDef;

		public PanelMusicDef shortPanelMusicDef;

		public string[] requiredSurvivorBodyName;

		public PanelMusicDefCombo(PanelMusicDef panelMusicDef, PanelMusicDef shortPanelMusicDef)
		{
			this.panelMusicDef = panelMusicDef;
			this.shortPanelMusicDef = shortPanelMusicDef;
			requiredSurvivorBodyName = null;
		}

		public PanelMusicDefCombo(PanelMusicDef panelMusicDef, PanelMusicDef shortPanelMusicDef, string requiredSurvivorBodyName)
		{
			this.panelMusicDef = panelMusicDef;
			this.shortPanelMusicDef = shortPanelMusicDef;
			this.requiredSurvivorBodyName = new string[1] { requiredSurvivorBodyName };
		}

		public PanelMusicDefCombo(PanelMusicDef panelMusicDef, PanelMusicDef shortPanelMusicDef, string[] requiredSurvivorBodyName)
		{
			this.panelMusicDef = panelMusicDef;
			this.shortPanelMusicDef = shortPanelMusicDef;
			this.requiredSurvivorBodyName = requiredSurvivorBodyName;
		}
	}
	public struct PanelMusicDef
	{
		public string soundString;

		public float timeUntilRankReveal;

		public float duration;

		public PanelMusicDef(string soundString, float timeUntilRankReveal, float duration)
		{
			this.soundString = soundString;
			this.timeUntilRankReveal = timeUntilRankReveal;
			this.duration = duration;
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.ds_gaming.StageRanking", "StageRanking", "1.0.0")]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class StageRankingPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.ds_gaming.StageRanking";

		public const string PluginAuthor = "ds_gaming";

		public const string PluginName = "StageRanking";

		public const string PluginVersion = "1.0.0";

		public static StageRankingPlugin instance;

		public void Awake()
		{
			instance = this;
			Log.Init(((BaseUnityPlugin)this).Logger);
			Assets.Initialize();
			StageRankingTracker.Initialize();
			OnHooks.Initialize();
			if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
			{
				Config.RiskOfOptionsSetup();
			}
		}
	}
	public static class StageRankingTracker
	{
		public delegate void StageRankingEventHandler(List<Score> scores);

		private static CharacterMaster master;

		private static int itemsOnStageStart;

		private static bool stageHasChests;

		public static event StageRankingEventHandler OnStageRankingGatherScores;

		public static void Initialize()
		{
			OnStageRankingGatherScores += DefaultScores;
			Stage.onStageStartGlobal += StageStart;
		}

		private static void StageStart(Stage stage)
		{
			stageHasChests = false;
			stageHasChests = StageHasChests();
			if (!Object.op_Implicit((Object)(object)master))
			{
				LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
				if (firstLocalUser != null && Object.op_Implicit((Object)(object)firstLocalUser.cachedMaster) && Object.op_Implicit((Object)(object)firstLocalUser.cachedMaster))
				{
					master = firstLocalUser.cachedMaster;
				}
			}
			if (stageHasChests && Object.op_Implicit((Object)(object)master) && Object.op_Implicit((Object)(object)master.inventory))
			{
				itemsOnStageStart = Util.GetItemCount(master.inventory);
			}
		}

		private static bool StageHasChests()
		{
			if (Object.op_Implicit((Object)(object)ClassicStageInfo.instance) && ClassicStageInfo.instance.sceneDirectorInteractibleCredits > 0 && Object.op_Implicit((Object)(object)ClassicStageInfo.instance.interactableCategories) && ClassicStageInfo.instance.interactableCategories.FindCategoryIndexByName("Chests") != -1)
			{
				return true;
			}
			PurchaseInteraction val = default(PurchaseInteraction);
			return Object.op_Implicit((Object)(object)((IEnumerable<ChestBehavior>)InstanceTracker.GetInstancesList<ChestBehavior>()).FirstOrDefault((Func<ChestBehavior, bool>)((ChestBehavior chest) => ((Component)chest).TryGetComponent<PurchaseInteraction>(ref val) && ((int)val.costType == 1 || (int)val.costType == 2))));
		}

		private static void DefaultScores(List<Score> scores)
		{
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Invalid comparison between Unknown and I4
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Invalid comparison between Unknown and I4
			if (Object.op_Implicit((Object)(object)Run.instance) && Object.op_Implicit((Object)(object)Stage.instance) && Stage.instance.entryStopwatchValue != Run.instance.GetRunStopwatch() && Config.MaxTimeScore().Value > 0)
			{
				if (Config.TimeForMaxTimeScore().Value < Config.TimeForMinTimeScore().Value)
				{
					if (Config.longStages == null)
					{
						Config.UpdateLongStagesList(null, null);
					}
					if (Config.veryLongStages == null)
					{
						Config.UpdateVeryLongStagesList(null, null);
					}
					float num = 1f;
					if (Config.veryLongStages.Contains(Stage.instance.sceneDef.cachedName))
					{
						num += Config.VeryLongStageMultiplierTimeScore().Value / 100f;
					}
					else if (Config.longStages.Contains(Stage.instance.sceneDef.cachedName))
					{
						num += Config.LongStageMultiplierTimeScore().Value / 100f;
					}
					scores.Add(new Score
					{
						nameToken = "DS_GAMING_STAGE_RANKING_TIME_SCORE",
						score = Util.ClampedNonlinearLerp(0, Config.MaxTimeScore().Value, 1f - (Run.instance.GetRunStopwatch() - Stage.instance.entryStopwatchValue - (float)Config.TimeForMaxTimeScore().Value * num) / ((float)Config.TimeForMinTimeScore().Value * num), 0.7f),
						addedScoreRequirement = Config.MaxTimeScore().Value
					});
				}
				else
				{
					Log.Error("Time Score's Worst Time cannot be lower than Best Time");
				}
			}
			if (!stageHasChests || Config.MaxLootScore().Value <= 0)
			{
				return;
			}
			int num2 = 0;
			int num3 = 0;
			PurchaseInteraction val = default(PurchaseInteraction);
			foreach (ChestBehavior instances in InstanceTracker.GetInstancesList<ChestBehavior>())
			{
				if (((Component)instances).TryGetComponent<PurchaseInteraction>(ref val) && ((int)val.costType == 1 || (int)val.costType == 2))
				{
					num2++;
					if (instances.isChestOpened)
					{
						num3++;
					}
				}
			}
			int num4 = 0;
			if (Object.op_Implicit((Object)(object)master) && Object.op_Implicit((Object)(object)master.inventory))
			{
				num4 = Util.GetItemCount(master.inventory);
			}
			int val2 = 0;
			int num5 = 0;
			if (num2 > 0)
			{
				val2 = Util.ClampedNonlinearLerp(0, Config.MaxLootScore().Value, (float)num3 / (float)num2, 1.5f);
			}
			if (num4 - itemsOnStageStart > 0)
			{
				num5 = Util.ClampedNonlinearLerp(0, Config.MaxLootScore().Value, (float)(num4 - itemsOnStageStart) / (float)Config.ItemsPerStage().Value, 0.8f);
			}
			if (num2 > 0 || num5 > 0)
			{
				scores.Add(new Score
				{
					nameToken = "DS_GAMING_STAGE_RANKING_LOOT_SCORE",
					score = Math.Max(num5, val2),
					addedScoreRequirement = Config.MaxLootScore().Value
				});
			}
			if ((Object.op_Implicit((Object)(object)TeleporterInteraction.instance) && TeleporterInteraction.instance.shrineBonusStacks > 0) || (TeleporterInteraction.instance.NetworkshowAccessCodesIndicator && Config.ScorePerMountainShrine().Value > 0))
			{
				scores.Add(new Score
				{
					nameToken = "DS_GAMING_STAGE_RANKING_MOUNTAIN_SHRINE_SCORE",
					score = (int)Math.Floor((float)(Config.ScorePerMountainShrine().Value * 3) * Util.Hyperbolic((float)(TeleporterInteraction.instance.shrineBonusStacks + (TeleporterInteraction.instance.NetworkshowAccessCodesIndicator ? 1 : 0)) / 2f)),
					addedScoreRequirement = 0
				});
			}
		}

		public static void CreateRanking(SceneExitController sceneExitController)
		{
			if (Config.stageBlacklist == null)
			{
				Config.UpdateStageBlacklist(null, null);
			}
			if (StageRankingPanel.panelActive || (Object.op_Implicit((Object)(object)Stage.instance) && Config.stageBlacklist.Contains(Stage.instance.sceneDef.cachedName)))
			{
				return;
			}
			List<Score> list = new List<Score>();
			if (StageRankingTracker.OnStageRankingGatherScores != null)
			{
				foreach (StageRankingEventHandler item in StageRankingTracker.OnStageRankingGatherScores.GetInvocationList().Cast<StageRankingEventHandler>())
				{
					try
					{
						item(list);
					}
					catch (Exception arg)
					{
						Log.Error($"Exception thrown by : {item.Method.DeclaringType.Name}.{item.Method.Name}:\n{arg}");
					}
				}
			}
			if (list.Count > 0)
			{
				StageRankingPanel.sceneExitController = (NetworkServer.active ? sceneExitController : null);
				StageRankingPanel.CreatePanel(list);
			}
		}
	}
	public struct Score : IComparable<Score>
	{
		public string nameToken;

		public int score;

		public int addedScoreRequirement;

		public int CompareTo(Score other)
		{
			int num = nameToken.CompareTo(other.nameToken);
			if (num == 0)
			{
				return score.CompareTo(other.score);
			}
			return num;
		}

		public override string ToString()
		{
			return Util.ScoreTextFormat(Language.GetString(nameToken, Language.currentLanguageName), score);
		}
	}
	public static class Util
	{
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static int ClampedNonlinearLerp(int min, int max, float t, float strength)
		{
			if (strength <= 0f)
			{
				return (int)Mathf.Lerp((float)min, (float)max, t);
			}
			return (int)Math.Clamp((1f + 1f / strength) * Util.Hyperbolic(t * strength) * (float)(max - min) + (float)min, min, max);
		}

		public static string ScoreTextFormat(string scoreName, int score)
		{
			return Language.GetStringFormatted("STAT_NAME_VALUE_FORMAT", new object[2]
			{
				Language.GetString(scoreName),
				score
			});
		}

		public static string PointsTextFormat(int points)
		{
			return Language.GetStringFormatted("STAT_POINTS_FORMAT", new object[1] { points });
		}

		public static Ranking GetRanking(int score, int scoreRequirement)
		{
			if ((float)score >= (float)scoreRequirement * (Config.SRankRequirement().Value / 100f))
			{
				return Ranking.S;
			}
			if ((float)score >= (float)scoreRequirement * (Config.ARankRequirement().Value / 100f))
			{
				return Ranking.A;
			}
			if ((float)score >= (float)scoreRequirement * (Config.BRankRequirement().Value / 100f))
			{
				return Ranking.B;
			}
			if ((float)score >= (float)scoreRequirement * (Config.CRankRequirement().Value / 100f))
			{
				return Ranking.C;
			}
			return Ranking.D;
		}

		public static int GetScoreRequirement(Ranking ranking, int scoreRequirement)
		{
			return ranking switch
			{
				Ranking.C => (int)((float)scoreRequirement * (Config.CRankRequirement().Value / 100f)), 
				Ranking.B => (int)((float)scoreRequirement * (Config.BRankRequirement().Value / 100f)), 
				Ranking.A => (int)((float)scoreRequirement * (Config.ARankRequirement().Value / 100f)), 
				Ranking.S => (int)((float)scoreRequirement * (Config.SRankRequirement().Value / 100f)), 
				_ => 0, 
			};
		}

		public static RankingVisual GetRankingVisual(Ranking ranking)
		{
			return ranking switch
			{
				Ranking.C => Assets.cRanking, 
				Ranking.B => Assets.bRanking, 
				Ranking.A => Assets.aRanking, 
				Ranking.S => Assets.sRanking, 
				_ => Assets.dRanking, 
			};
		}

		public static bool GetIsAnimationSpeedLong()
		{
			if (NetworkServer.active)
			{
				return Config.AnimationDuration().Value != Config.AnimationSpeed.Short;
			}
			return Config.AnimationDuration().Value == Config.AnimationSpeed.Long;
		}

		public static int GetItemCount(Inventory inventory)
		{
			//IL_0004: 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)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Invalid comparison between Unknown and I4
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Invalid comparison between Unknown and I4
			int num = 0;
			ItemIndex val = (ItemIndex)0;
			for (ItemIndex val2 = (ItemIndex)ItemCatalog.itemCount; val < val2; val = (ItemIndex)(val + 1))
			{
				ItemDef itemDef = ItemCatalog.GetItemDef(val);
				if (Object.op_Implicit((Object)(object)itemDef) && (int)itemDef.tier != 5 && (int)itemDef.tier != 3 && (int)itemDef.tier < 1000 && !itemDef.hidden)
				{
					num += inventory.GetItemCountPermanent(val);
				}
			}
			return num;
		}
	}
	public enum Ranking
	{
		D,
		C,
		B,
		A,
		S
	}
}