Decompiled source of HudStar v2.3.1

HudStar.dll

Decompiled 4 days 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 BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[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("HudStar")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HudStar")]
[assembly: AssemblyTitle("HudStar")]
[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 HudStar
{
	[BepInPlugin("Harchytek.HudStar", "HudStar", "2.3.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class HudStarPlugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(EnemyHud), "UpdateHuds")]
		public static class EnemyHud_UpdateHuds_Patch
		{
			[HarmonyPriority(0)]
			[HarmonyPostfix]
			private static void Postfix(EnemyHud __instance)
			{
				//IL_0176: Unknown result type (might be due to invalid IL or missing references)
				//IL_018f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0194: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b1: 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_015f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0168: Unknown result type (might be due to invalid IL or missing references)
				//IL_016d: Unknown result type (might be due to invalid IL or missing references)
				IDictionary value = Traverse.Create((object)__instance).Field("m_huds").GetValue<IDictionary>();
				if (value == null)
				{
					return;
				}
				foreach (DictionaryEntry item2 in value)
				{
					object value2 = item2.Value;
					Character value3 = Traverse.Create(value2).Field("m_character").GetValue<Character>();
					if ((Object)(object)value3 != (Object)null)
					{
						string item = ((Object)((Component)value3).gameObject).name.Replace("(Clone)", "").Trim();
						if (BossBlacklist.Contains(item))
						{
							continue;
						}
					}
					GameObject value4 = Traverse.Create(value2).Field("m_gui").GetValue<GameObject>();
					if ((Object)(object)value4 == (Object)null || !value4.activeInHierarchy)
					{
						continue;
					}
					for (int i = 0; i < value4.transform.childCount; i++)
					{
						Transform child = value4.transform.GetChild(i);
						string text = ((Object)child).name.ToLower();
						if (!text.Contains("level") && !text.Contains("star") && !text.Contains("darken") && !text.Contains("hc_"))
						{
							continue;
						}
						RectTransform component = ((Component)child).GetComponent<RectTransform>();
						if ((Object)(object)component != (Object)null)
						{
							HudStarMarker hudStarMarker = ((Component)child).GetComponent<HudStarMarker>();
							if ((Object)(object)hudStarMarker == (Object)null)
							{
								hudStarMarker = ((Component)child).gameObject.AddComponent<HudStarMarker>();
								hudStarMarker.originalPos = component.anchoredPosition;
								hudStarMarker.originalScale = ((Transform)component).localScale;
							}
							component.anchoredPosition = hudStarMarker.originalPos + new Vector2(OffsetX.Value, OffsetY.Value);
							((Transform)component).localScale = hudStarMarker.originalScale * Scale.Value;
						}
					}
				}
			}
		}

		public class HudStarMarker : MonoBehaviour
		{
			public Vector2 originalPos;

			public Vector3 originalScale;
		}

		public const string ModGUID = "Harchytek.HudStar";

		public const string ModName = "HudStar";

		public const string ModVersion = "2.3.1";

		public static ConfigEntry<float> OffsetX;

		public static ConfigEntry<float> OffsetY;

		public static ConfigEntry<float> Scale;

		private static readonly HashSet<string> BossBlacklist = new HashSet<string> { "Eikthyr", "gd_king", "Bonemass", "Dragon", "GoblinKing", "Queen", "SeekerQueen", "Fader" };

		private void Awake()
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			OffsetX = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "StarOffsetX", 0f, "Horizontal offset for all stars.");
			OffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "StarOffsetY", 0f, "Vertical offset for all stars.");
			Scale = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "StarScale", 1f, "Star size scale.");
			new Harmony("harchytek.hudstar").PatchAll();
		}
	}
}