using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
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: AssemblyTitle("CLLCVRFix")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CLLCVRFix")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4efe4d09-5f76-46c3-9dff-bfff704b49fb")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
public static class CLLCVRHUD
{
private static MethodInfo getExtraEffect;
private static MethodInfo getInfusion;
private static MethodInfo getBossAffix;
public static void Initialize(Harmony harmony)
{
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Expected O, but got Unknown
try
{
Type type = AccessTools.TypeByName("CreatureLevelControl.API, CreatureLevelControl");
if (type == null)
{
Debug.LogWarning((object)"CLLC VR Fix: CLLC API not found");
return;
}
getExtraEffect = AccessTools.Method(type, "GetExtraEffectCreature", (Type[])null, (Type[])null);
getInfusion = AccessTools.Method(type, "GetInfusionCreature", (Type[])null, (Type[])null);
getBossAffix = AccessTools.Method(type, "GetAffixBoss", (Type[])null, (Type[])null);
Type type2 = AccessTools.TypeByName("ValheimVRMod.VRCore.UI.EnemyHudManager, ValheimVRMod");
MethodInfo methodInfo = AccessTools.Method(type2, "UpdateName", (Type[])null, (Type[])null);
harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(CLLCVRHUD), "OnUpdateNamePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
catch (Exception arg)
{
Debug.LogError((object)$"CLLC VR Fix init error: {arg}");
}
}
private static void OnUpdateNamePostfix(object __instance, Character c)
{
if ((Object)(object)c == (Object)null)
{
return;
}
try
{
Type type = __instance.GetType();
object obj = AccessTools.Method(type, "getEnemyHud", (Type[])null, (Type[])null)?.Invoke(__instance, new object[1] { c });
if (obj != null)
{
object? obj2 = AccessTools.Field(obj.GetType(), "gui")?.GetValue(obj);
GameObject val = (GameObject)((obj2 is GameObject) ? obj2 : null);
if (!((Object)(object)val == (Object)null))
{
UpdateName(val, c);
UpdateStars(val, c);
}
}
}
catch
{
}
}
private static void UpdateName(GameObject gui, Character c)
{
Transform val = gui.transform.Find("Name");
if ((Object)(object)val == (Object)null)
{
return;
}
TextMeshProUGUI component = ((Component)val).GetComponent<TextMeshProUGUI>();
if ((Object)(object)component == (Object)null)
{
return;
}
string text = ((TMP_Text)component).text;
text = RemoveWords(text);
string text2 = null;
string text3 = "white";
if (c.IsBoss())
{
object obj = getBossAffix?.Invoke(null, new object[1] { c });
if (obj != null && obj.ToString() != "None")
{
text2 = obj.ToString();
text3 = "red";
}
}
if (text2 == null)
{
object obj2 = getInfusion?.Invoke(null, new object[1] { c });
if (obj2 != null && obj2.ToString() != "None")
{
text2 = obj2.ToString();
text3 = GetInfusionColorTag(text2);
}
}
if (text2 == null)
{
object obj3 = getExtraEffect?.Invoke(null, new object[1] { c });
if (obj3 != null && obj3.ToString() != "None")
{
text2 = obj3.ToString();
text3 = GetEffectColorTag(text2);
}
}
if (text2 == null)
{
((TMP_Text)component).text = text;
return;
}
string text4 = (CLLCVRMain.UseIcons.Value ? GetIcon(text2) : text2);
((TMP_Text)component).text = text + " <color=" + text3 + ">" + text4 + "</color>";
}
private static void UpdateStars(GameObject gui, Character c)
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
if (c.IsBoss() || c.GetLevel() <= 1)
{
return;
}
string effect = getExtraEffect?.Invoke(null, new object[1] { c })?.ToString();
Color effectColor = GetEffectColor(effect);
Transform[] componentsInChildren = gui.GetComponentsInChildren<Transform>();
foreach (Transform val in componentsInChildren)
{
if (((Object)val).name.StartsWith("star"))
{
Image componentInChildren = ((Component)val).GetComponentInChildren<Image>();
if ((Object)(object)componentInChildren != (Object)null)
{
((Graphic)componentInChildren).color = effectColor;
}
}
}
}
private static string RemoveWords(string text)
{
string[] array = new string[18]
{
"Aggressive", "Quick", "Regenerating", "Curious", "Splitting", "Armored", "Fire", "Frost", "Lightning", "Poison",
"Spirit", "Reflective", "Shielded", "Mending", "Summoner", "Elementalist", "Enraged", "Twin"
};
string[] array2 = array;
foreach (string oldValue in array2)
{
text = text.Replace(oldValue, "");
}
return text.Trim();
}
private static string GetEffectColorTag(string effect)
{
return effect switch
{
"Aggressive" => "red",
"Quick" => "magenta",
"Regenerating" => "green",
"Curious" => "cyan",
"Splitting" => "white",
"Armored" => "blue",
_ => "#FFD15C",
};
}
private static string GetInfusionColorTag(string infusion)
{
return infusion switch
{
"Fire" => "red",
"Frost" => "#80FFFF",
"Lightning" => "yellow",
"Poison" => "green",
"Spirit" => "white",
_ => "white",
};
}
private static Color GetEffectColor(string effect)
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: 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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: 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_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
return (Color)(effect switch
{
"Aggressive" => Color.red,
"Quick" => Color.magenta,
"Regenerating" => Color.green,
"Curious" => Color.cyan,
"Splitting" => Color.white,
"Armored" => Color.blue,
_ => new Color(1f, 0.817f, 0.338f),
});
}
private static string GetIcon(string name)
{
return name switch
{
"Aggressive" => "⚔",
"Quick" => "⚡",
"Regenerating" => "✚",
"Curious" => "\ud83d\udc41",
"Splitting" => "✦",
"Armored" => "\ud83d\udee1",
"Fire" => "\ud83d\udd25",
"Frost" => "❄",
"Lightning" => "⚡",
"Poison" => "☣",
"Spirit" => "✧",
"Reflective" => "\ud83d\udd01",
"Shielded" => "\ud83d\udee1",
"Mending" => "✚",
"Summoner" => "☠",
"Elementalist" => "⚡",
"Enraged" => "\ud83d\udd25",
"Twin" => "\ud83d\udc65",
_ => "?",
};
}
}
[BepInPlugin("geekstreet.cllcvrfix", "CLLC VR Fix", "2.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class CLLCVRMain : BaseUnityPlugin
{
public static ConfigEntry<bool> UseIcons;
private Harmony _harmony;
private void Awake()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
UseIcons = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UseIcons", false, "Show creature effects using icons instead of text");
_harmony = new Harmony("geekstreet.cllcvrfix");
CLLCVRHUD.Initialize(_harmony);
((BaseUnityPlugin)this).Logger.LogInfo((object)"CLLC VR Fix v2 loaded");
}
private void OnDestroy()
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
}