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]
[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 HudStarHarchytek
{
[BepInPlugin("harchytek.hudstar", "HudStar", "2.2.0")]
public class HudStar : BaseUnityPlugin
{
[HarmonyPatch(typeof(EnemyHud), "UpdateHuds")]
public static class EnemyHud_UpdateHuds_Patch
{
[HarmonyPostfix]
private static void Postfix(EnemyHud __instance)
{
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Expected O, but got Unknown
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Expected O, but got Unknown
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;
}
Transform obj = value4.transform.Find("HudStar_Group");
GameObject val = ((obj != null) ? ((Component)obj).gameObject : null);
RectTransform component;
if ((Object)(object)val == (Object)null)
{
val = new GameObject("HudStar_Group", new Type[1] { typeof(RectTransform) });
val.transform.SetParent(value4.transform, false);
component = val.GetComponent<RectTransform>();
SetupRectTransform(component);
val.AddComponent<StarForceUpdater>();
}
else
{
component = val.GetComponent<RectTransform>();
}
ApplyInstantPosition(component);
foreach (Transform item3 in value4.transform)
{
Transform val2 = item3;
string text = ((Object)val2).name.ToLower();
if ((text.Contains("level") || text.Contains("star") || text.Contains("darken") || text.Contains("hc_")) && text != "hudstar_group")
{
val2.SetParent(val.transform, false);
}
}
}
}
private static void SetupRectTransform(RectTransform rt)
{
//IL_000b: 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_0035: Unknown result type (might be due to invalid IL or missing references)
rt.anchorMin = new Vector2(0.5f, 0.5f);
rt.anchorMax = new Vector2(0.5f, 0.5f);
rt.pivot = new Vector2(0.5f, 0.5f);
}
private static void ApplyInstantPosition(RectTransform rt)
{
//IL_0015: 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_002f: Unknown result type (might be due to invalid IL or missing references)
rt.anchoredPosition = new Vector2(OffsetX.Value, OffsetY.Value);
((Transform)rt).localScale = Vector3.one * Scale.Value;
}
}
public class StarForceUpdater : MonoBehaviour
{
private RectTransform rt;
private void Awake()
{
rt = ((Component)this).GetComponent<RectTransform>();
}
private void LateUpdate()
{
//IL_0036: 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_0055: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)rt == (Object)null) && ((Component)this).gameObject.activeInHierarchy)
{
rt.anchoredPosition = new Vector2(OffsetX.Value, OffsetY.Value);
((Transform)rt).localScale = Vector3.one * Scale.Value;
}
}
}
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();
}
}
}