using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using UnityEngine;
using UnityEngine.SceneManagement;
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("ClassLibrary1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ClassLibrary1")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("73fecea6-9f8c-46e8-b2b0-e09d41f18cfc")]
[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")]
[BepInPlugin("com.nitefury.unambiguousfrost", "Unambiguous Frost", "1.0.0")]
public class UnambiguousFrost : BaseUnityPlugin
{
private Text frostText;
private float lastFrost = 0f;
private bool phrostloomInstalled = false;
private bool phrostloomChecked = false;
private float hideThreshold = 0f;
private float hideTimer = 0f;
private void Start()
{
CreateUI();
AttachEvent();
SceneManager.sceneLoaded += OnSceneLoaded;
}
private void OnDestroy()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
if ((Object)(object)HeroController.SilentInstance != (Object)null)
{
HeroController.SilentInstance.FrostAmountUpdated -= OnFrostAmountUpdated;
}
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
AttachEvent();
if (!phrostloomChecked && IsGameplayScene(((Scene)(ref scene)).name))
{
phrostloomChecked = true;
DetectPhrostloom();
hideThreshold = (phrostloomInstalled ? 0.04f : 0f);
}
}
private bool IsGameplayScene(string sceneName)
{
return !sceneName.Contains("Menu") && !sceneName.Contains("Title");
}
private void DetectPhrostloom()
{
foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
{
if (pluginInfo.Key == "com.sybv11.phrostloom")
{
phrostloomInstalled = true;
break;
}
}
}
private void AttachEvent()
{
if (!((Object)(object)HeroController.SilentInstance == (Object)null))
{
HeroController.SilentInstance.FrostAmountUpdated -= OnFrostAmountUpdated;
HeroController.SilentInstance.FrostAmountUpdated += OnFrostAmountUpdated;
UpdateUI(lastFrost);
}
}
private void OnFrostAmountUpdated(float frostAmount)
{
lastFrost = frostAmount;
UpdateUI(frostAmount);
}
private void UpdateUI(float frostAmount)
{
if (!((Object)(object)frostText == (Object)null))
{
if (frostAmount > 0f)
{
frostText.text = $"Frost: {Mathf.RoundToInt(frostAmount * 100f)}%";
}
if (frostAmount > hideThreshold)
{
((Behaviour)frostText).enabled = true;
hideTimer = 0f;
}
else if (hideTimer <= 0f)
{
hideTimer = 0.3f;
}
}
}
private void Update()
{
if (hideTimer > 0f)
{
hideTimer -= Time.deltaTime;
if (hideTimer <= 0f)
{
((Behaviour)frostText).enabled = false;
}
}
}
private void CreateUI()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("FrostCanvas");
Object.DontDestroyOnLoad((Object)(object)val);
Canvas val2 = val.AddComponent<Canvas>();
val2.renderMode = (RenderMode)0;
GameObject val3 = new GameObject("FrostText");
val3.transform.SetParent(((Component)val2).transform);
frostText = val3.AddComponent<Text>();
Font builtinResource = Resources.GetBuiltinResource<Font>("Arial.ttf");
frostText.font = builtinResource;
frostText.fontSize = 30;
frostText.alignment = (TextAnchor)0;
frostText.horizontalOverflow = (HorizontalWrapMode)1;
frostText.verticalOverflow = (VerticalWrapMode)1;
RectTransform rectTransform = ((Graphic)frostText).rectTransform;
rectTransform.anchorMin = new Vector2(0f, 1f);
rectTransform.anchorMax = new Vector2(0f, 1f);
rectTransform.pivot = new Vector2(0f, 1f);
rectTransform.anchoredPosition = new Vector2(20f, -20f);
rectTransform.sizeDelta = new Vector2(500f, 50f);
((Behaviour)frostText).enabled = false;
builtinResource.RequestCharactersInTexture("Frost: 0%", frostText.fontSize, (FontStyle)0);
}
}