Decompiled source of MissingArtifactsTracker v1.5.0

MissingArtifactsTracker.dll

Decompiled 12 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using Microsoft.CodeAnalysis;
using RoR2;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MissingArtifactsTracker")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d1385ca53a70443a6295fa32e1699ea962771d19")]
[assembly: AssemblyProduct("MissingArtifactsTracker")]
[assembly: AssemblyTitle("MissingArtifactsTracker")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MissingArtifactsTracker
{
	[BepInPlugin("com.yourname.missingartifacts", "MissingArtifactsTracker", "1.5.0")]
	public class MissingArtifactsPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.yourname.missingartifacts";

		public const string PluginName = "MissingArtifactsTracker";

		public const string PluginVersion = "1.5.0";

		private static readonly Dictionary<string, string> ArtifactCodes = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
		{
			{ "Chaos", "● ▲ ● | ● ▲ ● | ● ▲ ●" },
			{ "Command", "■ ■ ■ | ■ ■ ■ | ▲ ▲ ▲" },
			{ "Death", "● ● ● | ■ ■ ■ | ● ● ●" },
			{ "Dissonance", "● ◆ ■ | ◆ ■ ◆ | ■ ◆ ●" },
			{ "Enigma", "◆ ■ ■ | ● ■ ▲ | ◆ ■ ■" },
			{ "Evolution", "◆ ◆ ◆ | ◆ ◆ ◆ | ◆ ◆ ◆" },
			{ "Frailty", "● ● ● | ● ▲ ● | ● ● ●" },
			{ "Glass", "◆ ◆ ◆ | ◆ ◆ ◆ | ◆ ◆ ◆" },
			{ "Honor", "■ ■ ■ | ■ ◆ ■ | ■ ■ ■" },
			{ "Kin", "● ▲ ▲ | ◆ ▲ ▲ | ■ ▲ ▲" },
			{ "Metamorphosis", "◆ ■ ● | ◆ ■ ● | ◆ ■ ●" },
			{ "Sacrifice", "▲ ▲ ▲ | ▲ ▲ ▲ | ▲ ◆ ▲" },
			{ "Soul", "● ■ ■ | ● ◆ ■ | ● ■ ■" },
			{ "Spite", "▲ ● ▲ | ● ● ● | ▲ ● ▲" },
			{ "Swarms", "● ● ▲ | ▲ ◆ ▲ | ▲ ● ●" },
			{ "Vengeance", "◆ ◆ ◆ | ◆ ■ ◆ | ◆ ◆ ◆" },
			{ "Rebirth", "◆ ▲ ■ | ● ◆ ▲ | ■ ● ◆" }
		};

		private List<string> cachedMissing = new List<string>();

		private string stageNotice = string.Empty;

		private float displayTimer;

		private const float DisplayDuration = 10f;

		private const float FadeDuration = 2f;

		private Texture2D panelTex;

		private GUIStyle panelStyle;

		private GUIStyle titleStyle;

		private GUIStyle itemStyle;

		private GUIStyle noticeStyle;

		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[MissingArtifactsTracker] UI Overlay v1.4.0 Initialized.");
			Stage.onStageStartGlobal += OnStageStart;
			InitTextures();
		}

		private void OnDestroy()
		{
			Stage.onStageStartGlobal -= OnStageStart;
		}

		private void InitTextures()
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			panelTex = new Texture2D(1, 1);
			panelTex.SetPixel(0, 0, new Color(0.06f, 0.08f, 0.11f, 0.9f));
			panelTex.Apply();
		}

		private void Update()
		{
			if (displayTimer > 0f)
			{
				displayTimer -= Time.deltaTime;
			}
			if (Input.GetKeyDown((KeyCode)290))
			{
				QueryMissingArtifacts();
				stageNotice = string.Empty;
				displayTimer = 10f;
			}
		}

		private void OnStageStart(Stage stage)
		{
			((MonoBehaviour)this).StartCoroutine(DelayedStageCheck());
		}

		private IEnumerator DelayedStageCheck()
		{
			yield return (object)new WaitForSeconds(2.5f);
			if ((Object)(object)Run.instance == (Object)null)
			{
				yield break;
			}
			bool num = Run.instance.stageClearCount == 0;
			Scene activeScene = SceneManager.GetActiveScene();
			string text = ((Scene)(ref activeScene)).name.ToLowerInvariant();
			bool flag = text.Contains("skymeadow");
			bool flag2 = text.Contains("lemuriantemple") || text.Contains("itgrovetime");
			SceneDef sceneDefFromSceneName = SceneCatalog.GetSceneDefFromSceneName(text);
			if ((Object)(object)sceneDefFromSceneName != (Object)null)
			{
				string text2 = Language.GetString(sceneDefFromSceneName.nameToken).ToLowerInvariant();
				if (text2.Contains("sky meadow"))
				{
					flag = true;
				}
				if (text2.Contains("helminth hatchery"))
				{
					flag2 = true;
				}
			}
			if (num || flag || flag2)
			{
				if (flag)
				{
					stageNotice = "SKY MEADOW: Compound Portal Available Below";
				}
				else if (flag2)
				{
					stageNotice = "HELMINTH HATCHERY: Check Hidden Switches";
				}
				else
				{
					stageNotice = string.Empty;
				}
				QueryMissingArtifacts();
				displayTimer = 10f;
			}
		}

		private void QueryMissingArtifacts()
		{
			cachedMissing.Clear();
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			if (firstLocalUser == null || firstLocalUser.userProfile == null)
			{
				return;
			}
			UserProfile userProfile = firstLocalUser.userProfile;
			int artifactCount = ArtifactCatalog.artifactCount;
			for (int i = 0; i < artifactCount; i++)
			{
				ArtifactDef artifactDef = ArtifactCatalog.GetArtifactDef((ArtifactIndex)i);
				if (!((Object)(object)artifactDef == (Object)null) && (Object)(object)artifactDef.unlockableDef != (Object)null && !userProfile.HasUnlockable(artifactDef.unlockableDef))
				{
					string text = Language.GetString(artifactDef.nameToken);
					if (string.IsNullOrEmpty(text) || text == artifactDef.nameToken)
					{
						text = artifactDef.cachedName;
					}
					string key = text.Replace("Artifact of ", "").Replace("Artifact of the ", "").Trim();
					string value;
					string text2 = (ArtifactCodes.TryGetValue(key, out value) ? ("  <color=#8FAEC2>[" + value + "]</color>") : "");
					cachedMissing.Add(text + text2);
				}
			}
		}

		private void EnsureStyles()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			if (panelStyle == null)
			{
				panelStyle = new GUIStyle(GUI.skin.box);
				panelStyle.normal.background = panelTex;
				panelStyle.padding = new RectOffset(18, 18, 16, 16);
				GUIStyle val = new GUIStyle(GUI.skin.label)
				{
					fontSize = 15,
					fontStyle = (FontStyle)1,
					richText = true
				};
				val.normal.textColor = new Color(0.95f, 0.78f, 0.35f, 1f);
				titleStyle = val;
				GUIStyle val2 = new GUIStyle(GUI.skin.label)
				{
					fontSize = 13,
					fontStyle = (FontStyle)1,
					richText = true
				};
				val2.normal.textColor = new Color(0.42f, 0.88f, 1f, 1f);
				noticeStyle = val2;
				GUIStyle val3 = new GUIStyle(GUI.skin.label)
				{
					fontSize = 13,
					richText = true
				};
				val3.normal.textColor = new Color(0.92f, 0.92f, 0.92f, 1f);
				itemStyle = val3;
			}
		}

		private void OnGUI()
		{
			//IL_0035: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			if (displayTimer <= 0f)
			{
				return;
			}
			EnsureStyles();
			float num = ((displayTimer < 2f) ? (displayTimer / 2f) : 1f);
			Color color = GUI.color;
			GUI.color = new Color(1f, 1f, 1f, num);
			bool flag = cachedMissing.Count > 8;
			float num2 = (flag ? 640f : 350f);
			int num3 = (flag ? Mathf.CeilToInt((float)cachedMissing.Count / 2f) : cachedMissing.Count);
			float num4 = 26f;
			float num5 = (string.IsNullOrEmpty(stageNotice) ? 0f : 28f);
			float num6 = 32f;
			float num7 = 32f + num5 + (float)Mathf.Max(num3, 1) * num4 + num6;
			float num8 = 28f;
			float num9 = Mathf.Max(20f, ((float)Screen.height - num7) * 0.5f);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(num8, num9, num2, num7);
			GUI.Box(val, GUIContent.none, panelStyle);
			GUILayout.BeginArea(new Rect(((Rect)(ref val)).x + 16f, ((Rect)(ref val)).y + 14f, num2 - 32f, num7 - 24f));
			if (!string.IsNullOrEmpty(stageNotice))
			{
				GUILayout.Label(stageNotice, noticeStyle, Array.Empty<GUILayoutOption>());
				GUILayout.Space(2f);
			}
			if (cachedMissing.Count == 0)
			{
				GUILayout.Label("ARTIFACTS COMPLETE (All Unlocked)", titleStyle, Array.Empty<GUILayoutOption>());
			}
			else
			{
				GUILayout.Label($"MISSING ARTIFACTS ({cachedMissing.Count})", titleStyle, Array.Empty<GUILayoutOption>());
				GUILayout.Space(6f);
				if (flag)
				{
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width((num2 - 48f) / 2f) });
					for (int i = 0; i < num3; i++)
					{
						GUILayout.Label(cachedMissing[i], itemStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num4 - 2f) });
					}
					GUILayout.EndVertical();
					GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width((num2 - 48f) / 2f) });
					for (int j = num3; j < cachedMissing.Count; j++)
					{
						GUILayout.Label(cachedMissing[j], itemStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num4 - 2f) });
					}
					GUILayout.EndVertical();
					GUILayout.EndHorizontal();
				}
				else
				{
					foreach (string item in cachedMissing)
					{
						GUILayout.Label(item, itemStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num4 - 2f) });
					}
				}
			}
			GUILayout.EndArea();
			GUI.color = color;
		}
	}
}