Decompiled source of SimpleEclipseDisplay v1.0.0

plugins/SimpleEclipseDisplay/SimpleEclipseDisplay.dll

Decompiled a year ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using On.RoR2.UI;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.ConVar;
using RoR2.UI;
using TMPro;
using UnityEngine;
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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("SimpleEclipseDisplay")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SimpleEclipseDisplay")]
[assembly: AssemblyTitle("SimpleEclipseDisplay")]
[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 SimpleEclipseDisplay
{
	[BepInPlugin("Bobot.SimpleEclipseDisplay", "SimpleEclipseDisplay", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class SimpleEclipseDisplay : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Rebuild <>9__12_0;

			internal void <Awake>b__12_0(orig_Rebuild orig, SurvivorIconController self)
			{
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Expected O, but got Unknown
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00be: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0119: Unknown result type (might be due to invalid IL or missing references)
				//IL_0126: Unknown result type (might be due to invalid IL or missing references)
				//IL_0133: Unknown result type (might be due to invalid IL or missing references)
				//IL_0140: Unknown result type (might be due to invalid IL or missing references)
				//IL_014d: Unknown result type (might be due to invalid IL or missing references)
				//IL_015a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0164: Unknown result type (might be due to invalid IL or missing references)
				//IL_017b: Unknown result type (might be due to invalid IL or missing references)
				orig.Invoke(self);
				if ((eclipseDisplayOnlyOnEclipseMenus.Value && ((BaseConVar)GameModeConVar.instance).GetString() == "EclipseRun") || !eclipseDisplayOnlyOnEclipseMenus.Value)
				{
					Transform val = ((Component)self).transform.Find("EclipseLevelDisplay");
					if ((Object)(object)val == (Object)null)
					{
						GameObject val2 = new GameObject("EclipseLevelDisplay");
						HGTextMeshProUGUI val3 = val2.AddComponent<HGTextMeshProUGUI>();
						((TMP_Text)val3).text = "-1";
						((Graphic)val3).color = Color.white;
						((Graphic)val3).color = eclipseDisplayColour.Value;
						((TMP_Text)val3).autoSizeTextContainer = true;
						((TMP_Text)val3).outlineWidth = 0.2f;
						((TMP_Text)val3).outlineColor = Color32.op_Implicit(Color.black);
						val = Object.Instantiate<GameObject>(val2, ((Component)self).transform).transform;
						val.localScale = Vector3.one;
						HGTextMeshProUGUI component = ((Component)val).GetComponent<HGTextMeshProUGUI>();
						((TMP_Text)component).alignment = (TextAlignmentOptions)1028;
						((TMP_Text)component).fontSize = 28f;
						RectTransform component2 = ((Component)val).GetComponent<RectTransform>();
						component2.anchoredPosition = Vector2.zero;
						component2.offsetMax = Vector2.zero;
						component2.offsetMin = Vector2.zero;
						component2.anchorMax = Vector2.one;
						component2.anchorMin = Vector2.zero;
						component2.sizeDelta = Vector2.one * 8f;
						component2.anchoredPosition = new Vector2(-6f, 4f);
						Object.Destroy((Object)(object)val2);
					}
					int localUserSurvivorCompletedEclipseLevel = EclipseRun.GetLocalUserSurvivorCompletedEclipseLevel(self.GetLocalUser(), self.survivorDef);
					HGTextMeshProUGUI component3 = ((Component)val).gameObject.GetComponent<HGTextMeshProUGUI>();
					((TMP_Text)component3).text = ((localUserSurvivorCompletedEclipseLevel == 8) ? "DONE" : (localUserSurvivorCompletedEclipseLevel + 1).ToString());
				}
			}
		}

		public const string PluginGUID = "Bobot.SimpleEclipseDisplay";

		public const string PluginAuthor = "Bobot";

		public const string PluginName = "SimpleEclipseDisplay";

		public const string PluginVersion = "1.0.0";

		public static ConfigEntry<Color> eclipseDisplayColour { get; set; }

		public static ConfigEntry<bool> eclipseDisplayOnlyOnEclipseMenus { get; set; }

		public void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			eclipseDisplayColour = ((BaseUnityPlugin)this).Config.Bind<Color>("Display", "Display Text Colour", Color.white, new ConfigDescription("Colour of the eclipse display number.", (AcceptableValueBase)null, Array.Empty<object>()));
			ModSettingsManager.AddOption((BaseOption)new ColorOption(eclipseDisplayColour));
			eclipseDisplayOnlyOnEclipseMenus = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "Only Display On Eclipse Menus", true, new ConfigDescription("Whether or not the eclipse level is displayed on all character select menus or just eclipse.", (AcceptableValueBase)null, Array.Empty<object>()));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(eclipseDisplayOnlyOnEclipseMenus));
			ModSettingsManager.SetModDescription("Displays Eclipse Level On Character Icon.");
			object obj = <>c.<>9__12_0;
			if (obj == null)
			{
				hook_Rebuild val = delegate(orig_Rebuild orig, SurvivorIconController self)
				{
					//IL_006a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0071: Expected O, but got Unknown
					//IL_0089: Unknown result type (might be due to invalid IL or missing references)
					//IL_009b: Unknown result type (might be due to invalid IL or missing references)
					//IL_00be: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
					//IL_0119: Unknown result type (might be due to invalid IL or missing references)
					//IL_0126: Unknown result type (might be due to invalid IL or missing references)
					//IL_0133: Unknown result type (might be due to invalid IL or missing references)
					//IL_0140: Unknown result type (might be due to invalid IL or missing references)
					//IL_014d: Unknown result type (might be due to invalid IL or missing references)
					//IL_015a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0164: Unknown result type (might be due to invalid IL or missing references)
					//IL_017b: Unknown result type (might be due to invalid IL or missing references)
					orig.Invoke(self);
					if ((eclipseDisplayOnlyOnEclipseMenus.Value && ((BaseConVar)GameModeConVar.instance).GetString() == "EclipseRun") || !eclipseDisplayOnlyOnEclipseMenus.Value)
					{
						Transform val2 = ((Component)self).transform.Find("EclipseLevelDisplay");
						if ((Object)(object)val2 == (Object)null)
						{
							GameObject val3 = new GameObject("EclipseLevelDisplay");
							HGTextMeshProUGUI val4 = val3.AddComponent<HGTextMeshProUGUI>();
							((TMP_Text)val4).text = "-1";
							((Graphic)val4).color = Color.white;
							((Graphic)val4).color = eclipseDisplayColour.Value;
							((TMP_Text)val4).autoSizeTextContainer = true;
							((TMP_Text)val4).outlineWidth = 0.2f;
							((TMP_Text)val4).outlineColor = Color32.op_Implicit(Color.black);
							val2 = Object.Instantiate<GameObject>(val3, ((Component)self).transform).transform;
							val2.localScale = Vector3.one;
							HGTextMeshProUGUI component = ((Component)val2).GetComponent<HGTextMeshProUGUI>();
							((TMP_Text)component).alignment = (TextAlignmentOptions)1028;
							((TMP_Text)component).fontSize = 28f;
							RectTransform component2 = ((Component)val2).GetComponent<RectTransform>();
							component2.anchoredPosition = Vector2.zero;
							component2.offsetMax = Vector2.zero;
							component2.offsetMin = Vector2.zero;
							component2.anchorMax = Vector2.one;
							component2.anchorMin = Vector2.zero;
							component2.sizeDelta = Vector2.one * 8f;
							component2.anchoredPosition = new Vector2(-6f, 4f);
							Object.Destroy((Object)(object)val3);
						}
						int localUserSurvivorCompletedEclipseLevel = EclipseRun.GetLocalUserSurvivorCompletedEclipseLevel(self.GetLocalUser(), self.survivorDef);
						HGTextMeshProUGUI component3 = ((Component)val2).gameObject.GetComponent<HGTextMeshProUGUI>();
						((TMP_Text)component3).text = ((localUserSurvivorCompletedEclipseLevel == 8) ? "DONE" : (localUserSurvivorCompletedEclipseLevel + 1).ToString());
					}
				};
				<>c.<>9__12_0 = val;
				obj = (object)val;
			}
			SurvivorIconController.Rebuild += (hook_Rebuild)obj;
		}
	}
}