using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("HeatBar")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HeatBar")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0f22097d-9764-4668-9313-f2944b784f39")]
[assembly: AssemblyFileVersion("1.0.1")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
namespace HeatBar;
[BepInPlugin("org.ssmvc.heatbar", "HeatBar", "1.0.1")]
[BepInProcess("valheim.exe")]
public class HeatBar : BaseUnityPlugin
{
[HarmonyPatch(typeof(Character), "UpdateHeatDamage")]
private static class PlayerPatch
{
private static GuiBar _heatDisplay;
public static void Postfix(Character __instance)
{
if (__instance.IsPlayer())
{
if ((Object)(object)_heatDisplay == (Object)null)
{
Build();
return;
}
_heatDisplay.SetWidth(100f);
_heatDisplay.SetMaxValue(0.7f);
_heatDisplay.SetValue(__instance.m_lavaHeatLevel);
((Component)_heatDisplay).gameObject.SetActive(_heatDisplay.m_value > 0f || _heatDisplay.m_delayTimer > -1f);
}
}
private static void Build()
{
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Expected O, but got Unknown
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
Hud instance = Hud.instance;
if ((Object)(object)instance.m_staggerProgress == (Object)null)
{
return;
}
Transform[] array = (from t in Resources.FindObjectsOfTypeAll<Transform>()
where ((Object)t).name == "heatbar"
select t).ToArray();
foreach (Transform val in array)
{
if (((Object)val).name == "heatbar")
{
Object.Destroy((Object)(object)((Component)val).gameObject);
}
}
_heatDisplay = Object.Instantiate<GuiBar>(instance.m_staggerProgress, Hud.instance.m_rootObject.transform, true);
((Component)_heatDisplay).transform.Translate(0f, -30f, 0f);
((Object)_heatDisplay).name = "heatbar";
_heatDisplay.SetWidth(100f);
_heatDisplay.SetMaxValue(0.7f);
Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("HeatBar.image.png");
if (manifestResourceStream != null)
{
Image component = ((Component)((Component)_heatDisplay).transform.Find("StaggerIcon")).gameObject.GetComponent<Image>();
byte[] array2 = new byte[manifestResourceStream.Length];
manifestResourceStream.Read(array2, 0, array2.Length);
Texture2D val2 = new Texture2D(1, 1);
ImageConversion.LoadImage(val2, array2);
component.sprite = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), Vector2.zero);
}
}
}
public const string PluginGUID = "org.ssmvc.heatbar";
public const string PluginName = "HeatBar";
public const string PluginVersion = "1.0.1";
private static Harmony _harmony;
private void Awake()
{
_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "org.ssmvc.heatbar");
}
private void OnDestroy()
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
}