Decompiled source of VikingClimate v0.2.2

VikingClimate.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Managers;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using VikingClimate.Configuration;
using VikingClimate.Core;
using VikingClimate.Features.Temperature;
using VikingClimate.Features.Temperature.Services;
using VikingClimate.UI;
using VikingLib.Stats;
using VikingLib.StatusEffects;
using VikingLib.UI;

[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("DigitalVikings")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.2.0")]
[assembly: AssemblyInformationalVersion("0.2.2+1099afe7f2ab8a59f1ade6e5b0ea9064a47cb772")]
[assembly: AssemblyProduct("VikingClimate")]
[assembly: AssemblyTitle("VikingClimate")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 VikingClimate
{
	[BepInPlugin("com.digitalvikings.vikingclimate", "VikingClimate", "0.2.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class VikingClimatePlugin : BaseUnityPlugin
	{
		public const string ModGuid = "com.digitalvikings.vikingclimate";

		public const string ModName = "VikingClimate";

		public const string ModVersion = "0.2.2";

		internal static ManualLogSource Log;

		private Harmony _harmony;

		public static VikingClimatePlugin Instance { get; private set; }

		private void Awake()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"VikingClimate v0.2.2 initializing...");
			ModConfig.Init(((BaseUnityPlugin)this).Config);
			SurvivalManager.Init();
			TemperatureSystem.Init();
			_harmony = new Harmony("com.digitalvikings.vikingclimate");
			_harmony.PatchAll();
			Log.LogInfo((object)"VikingClimate v0.2.2 loaded successfully. Thermal simulation active.");
			if (Chainloader.PluginInfos.ContainsKey("com.jotunn.jotunn"))
			{
				HookJotunnSync();
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private void HookJotunnSync()
		{
			SynchronizationManager.OnConfigurationSynchronized += delegate
			{
				Log.LogInfo((object)"Server configuration synchronized successfully.");
			};
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
}
namespace VikingClimate.UI
{
	public static class ClimateAssetLoader
	{
		private static readonly Dictionary<string, Sprite> s_spriteCache = new Dictionary<string, Sprite>(StringComparer.OrdinalIgnoreCase);

		private static readonly Dictionary<string, Texture2D> s_textureCache = new Dictionary<string, Texture2D>(StringComparer.OrdinalIgnoreCase);

		public static Sprite? GetIcon(string iconName)
		{
			return LoadSprite("icons/" + iconName);
		}

		public static Sprite? GetUISprite(string spriteName)
		{
			return LoadSprite("ui/" + spriteName);
		}

		public static Sprite? LoadSprite(string relativePath)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(relativePath))
			{
				return null;
			}
			if (s_spriteCache.TryGetValue(relativePath, out Sprite value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Texture2D val = LoadTexture(relativePath);
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
			((Object)val2).name = Path.GetFileNameWithoutExtension(relativePath);
			s_spriteCache[relativePath] = val2;
			return val2;
		}

		public static Texture2D? LoadTexture(string relativePath)
		{
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Expected O, but got Unknown
			if (string.IsNullOrEmpty(relativePath))
			{
				return null;
			}
			if (s_textureCache.TryGetValue(relativePath, out Texture2D value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			byte[] array = null;
			string text = relativePath.Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar);
			if (!text.EndsWith(".png", StringComparison.OrdinalIgnoreCase))
			{
				text += ".png";
			}
			try
			{
				string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "", "assets", text);
				if (File.Exists(path))
				{
					array = File.ReadAllBytes(path);
				}
				else
				{
					string currentDirectory = Directory.GetCurrentDirectory();
					string path2 = Path.Combine(currentDirectory, "assets", text);
					if (File.Exists(path2))
					{
						array = File.ReadAllBytes(path2);
					}
					else
					{
						string path3 = Path.Combine(currentDirectory, "VikingClimate", "assets", text);
						if (File.Exists(path3))
						{
							array = File.ReadAllBytes(path3);
						}
					}
				}
			}
			catch (Exception ex)
			{
				VikingClimatePlugin.Log.LogWarning((object)("[ClimateAssetLoader] Error reading disk asset '" + text + "': " + ex.Message));
			}
			if (array == null)
			{
				try
				{
					Assembly executingAssembly = Assembly.GetExecutingAssembly();
					string name = "VikingClimate.assets." + relativePath.Replace('/', '.').Replace('\\', '.') + ".png";
					using Stream stream = executingAssembly.GetManifestResourceStream(name);
					if (stream != null)
					{
						using MemoryStream memoryStream = new MemoryStream();
						stream.CopyTo(memoryStream);
						array = memoryStream.ToArray();
					}
				}
				catch (Exception ex2)
				{
					VikingClimatePlugin.Log.LogWarning((object)("[ClimateAssetLoader] Error reading embedded resource '" + relativePath + "': " + ex2.Message));
				}
			}
			if (array == null || array.Length == 0)
			{
				return null;
			}
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			if (ImageConversion.LoadImage(val, array))
			{
				((Object)val).name = Path.GetFileNameWithoutExtension(relativePath);
				s_textureCache[relativePath] = val;
				return val;
			}
			return null;
		}
	}
	public class HUDThermometer : MonoBehaviour
	{
		private static HUDThermometer? _instance;

		private static Sprite? _solidWhiteSprite;

		private static Sprite? _thermalIconSprite;

		private static Sprite? _arrowSprite;

		private RectTransform? _rootRect;

		private CanvasGroup? _canvasGroup;

		private Hud? _hud;

		private Image? _iconImage;

		private RectTransform? _bodyFillRect;

		private Image? _bodyFillImage;

		private TMP_Text? _bodyText;

		private RectTransform? _ambientMarkerRect;

		private Image? _ambientMarkerImage;

		private TMP_Text? _ambientBadgeText;

		private const float ColumnWidth = 36f;

		private const float ColumnHeight = 152f;

		private const float CavityInset = 2.5f;

		private const float CavityWidth = 31f;

		private const float CavityHeight = 147f;

		private const float IconCenterOffset = -21.8f;

		private const float MinTempScale = -12f;

		private const float MaxTempScale = 55f;

		private const float TempRange = 67f;

		public static void AttachToHud(Hud hud)
		{
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			if ((Object)(object)hud == (Object)null)
			{
				return;
			}
			if ((Object)(object)_instance != (Object)null && (Object)(object)((Component)_instance).gameObject != (Object)null)
			{
				if (!((Component)_instance).gameObject.activeSelf)
				{
					((Component)_instance).gameObject.SetActive(true);
				}
				return;
			}
			Transform val = (((Object)(object)hud.m_rootObject != (Object)null) ? hud.m_rootObject.transform : (((Object)(object)hud.m_gpRoot != (Object)null) ? ((Transform)hud.m_gpRoot).parent : null));
			if (!((Object)(object)val == (Object)null))
			{
				GameObject val2 = new GameObject("VikingClimate_DualThermometer", new Type[1] { typeof(RectTransform) });
				val2.transform.SetParent(val, false);
				int num = (((Object)(object)hud.m_rootObject != (Object)null) ? hud.m_rootObject.layer : LayerMask.NameToLayer("UI"));
				SetLayerRecursively(val2, num);
				_instance = val2.AddComponent<HUDThermometer>();
				_instance.Init(hud);
				VikingClimatePlugin.Log.LogInfo((object)$"[HUDThermometer] Attached 32px HP-style column to '{((Object)val).name}' on layer {num}.");
			}
		}

		private void Init(Hud hud)
		{
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Expected O, but got Unknown
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Expected O, but got Unknown
			//IL_048f: Unknown result type (might be due to invalid IL or missing references)
			//IL_049f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04af: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Expected O, but got Unknown
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Expected O, but got Unknown
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Expected O, but got Unknown
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Expected O, but got Unknown
			//IL_0440: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Expected O, but got Unknown
			//IL_0535: Unknown result type (might be due to invalid IL or missing references)
			//IL_0549: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_060c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0613: Unknown result type (might be due to invalid IL or missing references)
			//IL_061e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0629: Unknown result type (might be due to invalid IL or missing references)
			//IL_0634: Unknown result type (might be due to invalid IL or missing references)
			//IL_0649: Unknown result type (might be due to invalid IL or missing references)
			//IL_0658: Unknown result type (might be due to invalid IL or missing references)
			//IL_0666: Unknown result type (might be due to invalid IL or missing references)
			//IL_0684: Unknown result type (might be due to invalid IL or missing references)
			//IL_0769: Unknown result type (might be due to invalid IL or missing references)
			//IL_0770: Expected O, but got Unknown
			//IL_0796: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_081a: Unknown result type (might be due to invalid IL or missing references)
			//IL_083c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0843: Expected O, but got Unknown
			//IL_085f: Unknown result type (might be due to invalid IL or missing references)
			//IL_086a: Unknown result type (might be due to invalid IL or missing references)
			//IL_087f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0894: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06be: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_070d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0718: Unknown result type (might be due to invalid IL or missing references)
			//IL_0722: Unknown result type (might be due to invalid IL or missing references)
			//IL_0741: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_092c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0972: Unknown result type (might be due to invalid IL or missing references)
			//IL_0981: Unknown result type (might be due to invalid IL or missing references)
			//IL_09aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a07: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a27: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a59: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a68: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a91: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0acf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aee: Unknown result type (might be due to invalid IL or missing references)
			_hud = hud;
			_rootRect = ((Component)this).GetComponent<RectTransform>();
			if (!((Object)(object)_rootRect == (Object)null))
			{
				_canvasGroup = ((Component)this).gameObject.AddComponent<CanvasGroup>();
				_canvasGroup.alpha = 0f;
				_canvasGroup.blocksRaycasts = false;
				_canvasGroup.interactable = false;
				Sprite whiteSprite = GetWhiteSprite();
				Sprite sprite = ClimateAssetLoader.GetIcon("se_warm") ?? GetThermalIconSprite();
				Sprite uISprite = ClimateAssetLoader.GetUISprite("thermometer_back");
				Sprite uISprite2 = ClimateAssetLoader.GetUISprite("thermometer_glass");
				Sprite uISprite3 = ClimateAssetLoader.GetUISprite("thermometer_mercury");
				Sprite uISprite4 = ClimateAssetLoader.GetUISprite("thermometer_needle");
				Sprite uISprite5 = ClimateAssetLoader.GetUISprite("thermometer_plaque");
				((Transform)_rootRect).localScale = Vector3.one;
				((Transform)_rootRect).localRotation = Quaternion.identity;
				_rootRect.anchorMin = new Vector2(1f, 1f);
				_rootRect.anchorMax = new Vector2(1f, 1f);
				_rootRect.pivot = new Vector2(1f, 1f);
				_rootRect.sizeDelta = new Vector2(36f, 152f);
				_rootRect.anchoredPosition = new Vector2(ModConfig.ThermometerPositionX.Value, ModConfig.ThermometerPositionY.Value);
				((Transform)_rootRect).SetAsLastSibling();
				GameObject val = new GameObject("ThermalIcon", new Type[1] { typeof(RectTransform) });
				val.transform.SetParent(((Component)this).transform, false);
				RectTransform component = val.GetComponent<RectTransform>();
				((Transform)component).localScale = Vector3.one;
				((Transform)component).localRotation = Quaternion.identity;
				component.anchorMin = Vector2.zero;
				component.anchorMax = Vector2.zero;
				component.pivot = new Vector2(0.5f, 0.5f);
				component.sizeDelta = new Vector2(38f, 38f);
				component.anchoredPosition = new Vector2(18f, -21.8f);
				_iconImage = val.AddComponent<Image>();
				_iconImage.sprite = sprite;
				_iconImage.type = (Type)0;
				((Graphic)_iconImage).color = new Color(0.51f, 0.78f, 0.52f);
				((Graphic)_iconImage).raycastTarget = false;
				bool flag = (Object)(object)uISprite != (Object)null;
				Image obj = ((Component)this).gameObject.AddComponent<Image>();
				obj.sprite = uISprite ?? whiteSprite;
				obj.type = (Type)0;
				((Graphic)obj).color = (Color)(flag ? Color.white : new Color(0.18f, 0.16f, 0.14f, 0.95f));
				((Graphic)obj).raycastTarget = false;
				if (!flag)
				{
					GameObject val2 = new GameObject("Cavity", new Type[1] { typeof(RectTransform) });
					val2.transform.SetParent(((Component)this).transform, false);
					RectTransform component2 = val2.GetComponent<RectTransform>();
					((Transform)component2).localScale = Vector3.one;
					((Transform)component2).localRotation = Quaternion.identity;
					component2.anchorMin = Vector2.zero;
					component2.anchorMax = Vector2.one;
					component2.offsetMin = new Vector2(2.5f, 2.5f);
					component2.offsetMax = new Vector2(-2.5f, -2.5f);
					component2.pivot = new Vector2(0.5f, 0.5f);
					Image obj2 = val2.AddComponent<Image>();
					obj2.sprite = whiteSprite;
					obj2.type = (Type)0;
					((Graphic)obj2).color = new Color(0.05f, 0.06f, 0.08f, 0.95f);
					((Graphic)obj2).raycastTarget = false;
					CreateSegmentLine(val2, "Segment1", whiteSprite, 36.75f);
					CreateSegmentLine(val2, "Segment2", whiteSprite, 73.5f);
					CreateSegmentLine(val2, "Segment3", whiteSprite, 110.25f);
					float num = 0.17910448f;
					CreateReferenceLine(val2, "FreezingLine", whiteSprite, num * 147f, 31f, 1.5f, new Color(0.39f, 0.71f, 0.96f, 0.5f));
					float num2 = 0.4477612f;
					float num3 = 0.5671642f;
					CreateReferenceBand(val2, "ComfortBand", whiteSprite, num2 * 147f, (num3 - num2) * 147f, 31f, new Color(0.51f, 0.78f, 0.52f, 0.16f));
				}
				GameObject val3 = new GameObject("BodyFill", new Type[1] { typeof(RectTransform) });
				val3.transform.SetParent(((Component)this).transform, false);
				_bodyFillRect = val3.GetComponent<RectTransform>();
				((Transform)_bodyFillRect).localScale = Vector3.one;
				((Transform)_bodyFillRect).localRotation = Quaternion.identity;
				_bodyFillRect.anchorMin = Vector2.zero;
				_bodyFillRect.anchorMax = Vector2.zero;
				_bodyFillRect.pivot = new Vector2(0.5f, 0f);
				float num4 = (flag ? 17.307692f : 18f);
				float num5 = (flag ? 17.963636f : 2.5f);
				float num6 = (flag ? 113.30909f : 147f);
				float num7 = (flag ? 10.384615f : 31f);
				_bodyFillRect.anchoredPosition = new Vector2(num4, num5);
				_bodyFillRect.sizeDelta = new Vector2(num7, num6);
				_bodyFillImage = val3.AddComponent<Image>();
				_bodyFillImage.sprite = uISprite3 ?? whiteSprite;
				_bodyFillImage.type = (Type)3;
				_bodyFillImage.fillMethod = (FillMethod)1;
				_bodyFillImage.fillOrigin = 0;
				_bodyFillImage.fillAmount = 0.5f;
				((Graphic)_bodyFillImage).color = new Color(0.51f, 0.78f, 0.52f);
				((Graphic)_bodyFillImage).raycastTarget = false;
				if ((Object)(object)uISprite2 != (Object)null)
				{
					GameObject val4 = new GameObject("GlassCapillary", new Type[1] { typeof(RectTransform) });
					val4.transform.SetParent(((Component)this).transform, false);
					RectTransform component3 = val4.GetComponent<RectTransform>();
					((Transform)component3).localScale = Vector3.one;
					((Transform)component3).localRotation = Quaternion.identity;
					component3.anchorMin = Vector2.zero;
					component3.anchorMax = Vector2.zero;
					component3.pivot = new Vector2(0.5f, 0f);
					component3.anchoredPosition = new Vector2(num4, num5);
					component3.sizeDelta = new Vector2(num7, num6);
					Image obj3 = val4.AddComponent<Image>();
					obj3.sprite = uISprite2;
					obj3.type = (Type)0;
					((Graphic)obj3).color = Color.white;
					((Graphic)obj3).raycastTarget = false;
				}
				if ((Object)(object)uISprite5 != (Object)null)
				{
					GameObject val5 = new GameObject("PlaqueOverlay", new Type[1] { typeof(RectTransform) });
					val5.transform.SetParent(((Component)this).transform, false);
					RectTransform component4 = val5.GetComponent<RectTransform>();
					((Transform)component4).localScale = Vector3.one;
					((Transform)component4).localRotation = Quaternion.identity;
					component4.anchorMin = Vector2.zero;
					component4.anchorMax = Vector2.one;
					component4.pivot = new Vector2(0.5f, 0.5f);
					component4.offsetMin = Vector2.zero;
					component4.offsetMax = Vector2.zero;
					Image obj4 = val5.AddComponent<Image>();
					obj4.sprite = uISprite5;
					obj4.type = (Type)0;
					((Graphic)obj4).color = Color.white;
					((Graphic)obj4).raycastTarget = false;
				}
				GameObject val6 = new GameObject("AmbientIndicator", new Type[1] { typeof(RectTransform) });
				val6.transform.SetParent(((Component)this).transform, false);
				_ambientMarkerRect = val6.GetComponent<RectTransform>();
				((Transform)_ambientMarkerRect).localScale = Vector3.one;
				((Transform)_ambientMarkerRect).localRotation = Quaternion.identity;
				_ambientMarkerRect.anchorMin = Vector2.zero;
				_ambientMarkerRect.anchorMax = Vector2.zero;
				_ambientMarkerRect.pivot = new Vector2(0f, 0.5f);
				_ambientMarkerRect.sizeDelta = new Vector2(50f, 20f);
				_ambientMarkerRect.anchoredPosition = new Vector2(36f, num5 + num6 * 0.5f);
				GameObject val7 = new GameObject("Arrow", new Type[1] { typeof(RectTransform) });
				val7.transform.SetParent(val6.transform, false);
				RectTransform component5 = val7.GetComponent<RectTransform>();
				((Transform)component5).localScale = Vector3.one;
				((Transform)component5).localRotation = Quaternion.identity;
				component5.anchorMin = new Vector2(0f, 0.5f);
				component5.anchorMax = new Vector2(0f, 0.5f);
				component5.pivot = new Vector2(0f, 0.5f);
				component5.sizeDelta = (((Object)(object)uISprite4 != (Object)null) ? new Vector2(20f, 13f) : new Vector2(9f, 11f));
				component5.anchoredPosition = new Vector2(0f, 0f);
				_ambientMarkerImage = val7.AddComponent<Image>();
				_ambientMarkerImage.sprite = uISprite4 ?? GetArrowSprite();
				_ambientMarkerImage.type = (Type)0;
				((Graphic)_ambientMarkerImage).color = Color.white;
				((Graphic)_ambientMarkerImage).raycastTarget = false;
				TMP_Text fontSource = hud.m_healthText ?? hud.m_gpName ?? hud.m_actionName;
				_ambientBadgeText = CreateTextElement(val6, "AmbientBadge", fontSource, new Vector2(13f, 0f), new Vector2(46f, 20f), 13f);
				_ambientBadgeText.rectTransform.anchorMin = new Vector2(0f, 0.5f);
				_ambientBadgeText.rectTransform.anchorMax = new Vector2(0f, 0.5f);
				_ambientBadgeText.rectTransform.pivot = new Vector2(0f, 0.5f);
				_ambientBadgeText.rectTransform.anchoredPosition = new Vector2(13f, 0f);
				_ambientBadgeText.alignment = (TextAlignmentOptions)4097;
				_ambientBadgeText.margin = Vector4.zero;
				_ambientBadgeText.text = "17°";
				_bodyText = CreateTextElement(((Component)this).gameObject, "BodyText", fontSource, new Vector2(18f, 9f), new Vector2(70f, 24f), 17f);
				_bodyText.rectTransform.anchorMin = new Vector2(0.5f, 0f);
				_bodyText.rectTransform.anchorMax = new Vector2(0.5f, 0f);
				_bodyText.rectTransform.pivot = new Vector2(0.5f, 0.5f);
				_bodyText.rectTransform.anchoredPosition = new Vector2(0f, 9f);
				_bodyText.alignment = (TextAlignmentOptions)514;
				_bodyText.fontStyle = (FontStyles)1;
				_bodyText.text = "22°";
				SetLayerRecursively(((Component)this).gameObject, ((Component)this).gameObject.layer);
			}
		}

		private static void CreateSegmentLine(GameObject parent, string name, Sprite sprite, float yPos)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent.transform, false);
			RectTransform component = val.GetComponent<RectTransform>();
			((Transform)component).localScale = Vector3.one;
			((Transform)component).localRotation = Quaternion.identity;
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.zero;
			component.pivot = new Vector2(0f, 0.5f);
			component.anchoredPosition = new Vector2(0f, yPos);
			component.sizeDelta = new Vector2(31f, 1.5f);
			Image obj = val.AddComponent<Image>();
			obj.sprite = sprite;
			((Graphic)obj).color = new Color(0.12f, 0.11f, 0.1f, 0.65f);
			((Graphic)obj).raycastTarget = false;
		}

		private static void CreateReferenceLine(GameObject parent, string name, Sprite sprite, float yPos, float width, float height, Color color)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent.transform, false);
			RectTransform component = val.GetComponent<RectTransform>();
			((Transform)component).localScale = Vector3.one;
			((Transform)component).localRotation = Quaternion.identity;
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.zero;
			component.pivot = new Vector2(0f, 0.5f);
			component.anchoredPosition = new Vector2(0f, yPos);
			component.sizeDelta = new Vector2(width, height);
			Image obj = val.AddComponent<Image>();
			obj.sprite = sprite;
			((Graphic)obj).color = color;
			((Graphic)obj).raycastTarget = false;
		}

		private static void CreateReferenceBand(GameObject parent, string name, Sprite sprite, float yPos, float height, float width, Color color)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent.transform, false);
			RectTransform component = val.GetComponent<RectTransform>();
			((Transform)component).localScale = Vector3.one;
			((Transform)component).localRotation = Quaternion.identity;
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.zero;
			component.pivot = new Vector2(0f, 0f);
			component.anchoredPosition = new Vector2(0f, yPos);
			component.sizeDelta = new Vector2(width, height);
			Image obj = val.AddComponent<Image>();
			obj.sprite = sprite;
			((Graphic)obj).color = color;
			((Graphic)obj).raycastTarget = false;
		}

		private static TMP_Text CreateTextElement(GameObject parent, string name, TMP_Text? fontSource, Vector2 centerPos, Vector2 size, float fontSize)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent.transform, false);
			RectTransform component = val.GetComponent<RectTransform>();
			((Transform)component).localScale = Vector3.one;
			((Transform)component).localRotation = Quaternion.identity;
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.zero;
			component.pivot = new Vector2(0.5f, 0.5f);
			component.anchoredPosition = centerPos;
			component.sizeDelta = size;
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			if ((Object)(object)fontSource != (Object)null && (Object)(object)fontSource.font != (Object)null)
			{
				((TMP_Text)val2).font = fontSource.font;
				((TMP_Text)val2).fontMaterial = fontSource.fontMaterial;
			}
			((TMP_Text)val2).fontSize = fontSize;
			((TMP_Text)val2).enableAutoSizing = false;
			((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
			((TMP_Text)val2).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)val2).overflowMode = (TextOverflowModes)0;
			((MaskableGraphic)val2).maskable = false;
			((Graphic)val2).raycastTarget = false;
			((TMP_Text)val2).margin = Vector4.zero;
			((Graphic)val2).color = Color.white;
			return (TMP_Text)(object)val2;
		}

		private void LateUpdate()
		{
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0453: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			if (!ModConfig.ModEnabled.Value || !ModConfig.ShowThermometerHUD.Value)
			{
				if ((Object)(object)_canvasGroup != (Object)null)
				{
					_canvasGroup.alpha = 0f;
				}
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			Hud instance = Hud.instance;
			if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || (Object)(object)instance == (Object)null || !instance.IsVisible())
			{
				if ((Object)(object)_canvasGroup != (Object)null)
				{
					_canvasGroup.alpha = 0f;
				}
				return;
			}
			if ((Object)(object)_canvasGroup != (Object)null && _canvasGroup.alpha < 1f)
			{
				_canvasGroup.alpha = 1f;
			}
			if ((Object)(object)_rootRect != (Object)null)
			{
				_rootRect.anchoredPosition = new Vector2(ModConfig.ThermometerPositionX.Value, ModConfig.ThermometerPositionY.Value);
			}
			SurvivalState currentState = SurvivalManager.CurrentState;
			float bodyWarmth = currentState.BodyWarmth;
			Color temperatureColor = GetTemperatureColor(bodyWarmth);
			float fillAmount = Mathf.Clamp01((bodyWarmth - -12f) / 67f);
			bool flag = bodyWarmth < -12f || bodyWarmth > 55f;
			float num = (flag ? (0.4f + 0.6f * Mathf.Abs(Mathf.Sin(Time.time * 6f))) : 1f);
			if ((Object)(object)_bodyFillImage != (Object)null)
			{
				_bodyFillImage.fillAmount = fillAmount;
				((Graphic)_bodyFillImage).color = new Color(temperatureColor.r, temperatureColor.g, temperatureColor.b, num);
			}
			if ((Object)(object)_bodyText != (Object)null)
			{
				_bodyText.text = $"{bodyWarmth:F0}°";
				((Graphic)_bodyText).color = ((flag && num < 0.7f) ? temperatureColor : Color.white);
			}
			if ((Object)(object)_iconImage != (Object)null)
			{
				string iconName;
				Sprite icon;
				switch (TemperatureSystem.EvaluateThermalStatusTier(bodyWarmth))
				{
				case "SE_Chilly":
					iconName = "se_chilly";
					goto IL_0332;
				case "SE_BitterCold":
					iconName = "se_bitter_cold";
					goto IL_0332;
				case "SE_NumbingFrost":
					iconName = "se_numbing_frost";
					goto IL_0332;
				case "SE_Hypothermia":
					iconName = "se_hypothermia";
					goto IL_0332;
				case "SE_Warm":
					iconName = "se_warm";
					goto IL_0332;
				case "SE_HeatExhaustion":
					iconName = "se_heat_exhaustion";
					goto IL_0332;
				case "SE_SevereHyperthermia":
					iconName = "se_severe_hyperthermia";
					goto IL_0332;
				case "SE_CatastrophicScorching":
					iconName = "se_catastrophic_scorching";
					goto IL_0332;
				default:
					iconName = "se_warm";
					goto IL_0332;
				case null:
					{
						Sprite sprite = ClimateAssetLoader.GetIcon("se_warm") ?? GetThermalIconSprite();
						_iconImage.sprite = sprite;
						((Graphic)_iconImage).color = temperatureColor;
						break;
					}
					IL_0332:
					icon = ClimateAssetLoader.GetIcon(iconName);
					if ((Object)(object)icon != (Object)null)
					{
						_iconImage.sprite = icon;
						((Graphic)_iconImage).color = (Color)(flag ? new Color(1f, 1f, 1f, num) : Color.white);
					}
					else
					{
						((Graphic)_iconImage).color = (Color)(flag ? new Color(temperatureColor.r, temperatureColor.g, temperatureColor.b, num) : temperatureColor);
					}
					break;
				}
			}
			float ambientTemperature = currentState.AmbientTemperature;
			Color temperatureColor2 = GetTemperatureColor(ambientTemperature);
			float num2 = Mathf.Clamp01((ambientTemperature - -12f) / 67f);
			if ((Object)(object)_ambientMarkerRect != (Object)null)
			{
				float num3 = 113.30909f;
				float num4 = 17.963636f + num3 * num2;
				_ambientMarkerRect.anchoredPosition = new Vector2(36f, num4);
			}
			if ((Object)(object)_ambientMarkerImage != (Object)null)
			{
				((Graphic)_ambientMarkerImage).color = temperatureColor2;
			}
			if ((Object)(object)_ambientBadgeText != (Object)null)
			{
				_ambientBadgeText.text = "<color=#" + ColorUtility.ToHtmlStringRGB(temperatureColor2) + ">" + FormatTemp(ambientTemperature) + "</color>";
			}
		}

		private static string FormatTemp(float val)
		{
			if (val > 0.4f)
			{
				return $"+{val:F0}°";
			}
			if (val < -0.4f)
			{
				return $"{val:F0}°";
			}
			return "0°";
		}

		private static Color GetTemperatureColor(float temp)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return TemperatureSystem.GetTemperatureColor(temp);
		}

		private static Sprite GetWhiteSprite()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_solidWhiteSprite != (Object)null)
			{
				return _solidWhiteSprite;
			}
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			val.SetPixels((Color[])(object)new Color[4]
			{
				Color.white,
				Color.white,
				Color.white,
				Color.white
			});
			val.Apply();
			_solidWhiteSprite = Sprite.Create(val, new Rect(0f, 0f, 2f, 2f), new Vector2(0.5f, 0.5f), 100f);
			return _solidWhiteSprite;
		}

		private static Sprite GetArrowSprite()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_arrowSprite != (Object)null)
			{
				return _arrowSprite;
			}
			int num = 8;
			int num2 = 10;
			Texture2D val = new Texture2D(num, num2, (TextureFormat)4, false);
			Color[] array = (Color[])(object)new Color[num * num2];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = Color.clear;
			}
			float num3 = (float)(num2 - 1) * 0.5f;
			for (int j = 0; j < num; j++)
			{
				float num4 = (float)j / (float)(num - 1) * num3;
				for (int k = 0; k < num2; k++)
				{
					if (Mathf.Abs((float)k - num3) <= num4 + 0.35f)
					{
						array[k * num + j] = Color.white;
					}
				}
			}
			val.SetPixels(array);
			val.Apply();
			((Texture)val).filterMode = (FilterMode)1;
			((Texture)val).wrapMode = (TextureWrapMode)1;
			_arrowSprite = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num2), new Vector2(0f, 0.5f), 100f);
			return _arrowSprite;
		}

		private static Sprite GetThermalIconSprite()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_thermalIconSprite != (Object)null)
			{
				return _thermalIconSprite;
			}
			int num = 32;
			Texture2D val = new Texture2D(num, num, (TextureFormat)4, false);
			Color[] array = (Color[])(object)new Color[num * num];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = Color.clear;
			}
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor((float)num * 0.5f, (float)num * 0.5f);
			float num2 = 11.5f;
			for (int j = 0; j < num; j++)
			{
				for (int k = 0; k < num; k++)
				{
					float num3 = Vector2.Distance(new Vector2((float)k, (float)j), val2);
					if (num3 <= num2 && num3 >= num2 - 2.2f)
					{
						array[j * num + k] = Color.white;
					}
					if (Vector2.Distance(new Vector2((float)k, (float)j), new Vector2(16f, 10f)) <= 3.8f)
					{
						array[j * num + k] = Color.white;
					}
					if (k >= 14 && k <= 17 && j >= 10 && j <= 20)
					{
						array[j * num + k] = Color.white;
					}
					if (j >= 20 && j <= 23)
					{
						int num4 = 23 - j;
						if (Mathf.Abs((float)k - 15.5f) <= (float)num4)
						{
							array[j * num + k] = Color.white;
						}
					}
					if (num3 >= num2 - 0.5f && num3 <= num2 + 2f && (Mathf.Abs((float)k - 16f) <= 1.2f || Mathf.Abs((float)j - 16f) <= 1.2f))
					{
						array[j * num + k] = Color.white;
					}
				}
			}
			val.SetPixels(array);
			val.Apply();
			((Texture)val).filterMode = (FilterMode)1;
			((Texture)val).wrapMode = (TextureWrapMode)1;
			_thermalIconSprite = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), 100f);
			return _thermalIconSprite;
		}

		private static void SetLayerRecursively(GameObject obj, int layer)
		{
			if (!((Object)(object)obj == (Object)null))
			{
				obj.layer = layer;
				for (int i = 0; i < obj.transform.childCount; i++)
				{
					SetLayerRecursively(((Component)obj.transform.GetChild(i)).gameObject, layer);
				}
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)_instance == (Object)(object)this)
			{
				_instance = null;
			}
		}
	}
	public class ScreenFrostOverlay : MonoBehaviour
	{
		private static ScreenFrostOverlay? _instance;

		private static Sprite? _vignetteSprite;

		private Image? _overlayImage;

		private float _currentAlpha;

		public static void AttachToHud(Hud hud)
		{
			//IL_008f: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)hud == (Object)null)
			{
				return;
			}
			if ((Object)(object)_instance != (Object)null && (Object)(object)((Component)_instance).gameObject != (Object)null)
			{
				if (!((Component)_instance).gameObject.activeSelf)
				{
					((Component)_instance).gameObject.SetActive(true);
				}
				return;
			}
			Transform val = (((Object)(object)hud.m_rootObject != (Object)null) ? hud.m_rootObject.transform : ((Component)hud).transform);
			if (!((Object)(object)val == (Object)null))
			{
				GameObject val2 = new GameObject("VikingClimate_ScreenFrostOverlay", new Type[1] { typeof(RectTransform) });
				val2.transform.SetParent(val, false);
				int layer = (((Object)(object)hud.m_rootObject != (Object)null) ? hud.m_rootObject.layer : LayerMask.NameToLayer("UI"));
				val2.layer = layer;
				_instance = val2.AddComponent<ScreenFrostOverlay>();
				_instance.Init();
				VikingClimatePlugin.Log.LogInfo((object)("[ScreenFrostOverlay] Attached atmospheric frost vignette to '" + ((Object)val).name + "'."));
			}
		}

		private void Init()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = ((Component)this).GetComponent<RectTransform>();
			if (!((Object)(object)component == (Object)null))
			{
				((Transform)component).localScale = Vector3.one;
				((Transform)component).localRotation = Quaternion.identity;
				component.anchorMin = Vector2.zero;
				component.anchorMax = Vector2.one;
				component.pivot = new Vector2(0.5f, 0.5f);
				component.offsetMin = Vector2.zero;
				component.offsetMax = Vector2.zero;
				((Transform)component).SetAsFirstSibling();
				_overlayImage = ((Component)this).gameObject.AddComponent<Image>();
				_overlayImage.sprite = GetFrostVignetteSprite();
				_overlayImage.type = (Type)0;
				((Graphic)_overlayImage).color = new Color(0.88f, 0.94f, 1f, 0f);
				((Graphic)_overlayImage).raycastTarget = false;
				((Behaviour)_overlayImage).enabled = false;
			}
		}

		private void Update()
		{
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			if (!ModConfig.ModEnabled.Value || !ModConfig.EnableScreenVignettes.Value || (Object)(object)_overlayImage == (Object)null)
			{
				if ((Object)(object)_overlayImage != (Object)null && ((Behaviour)_overlayImage).enabled)
				{
					((Behaviour)_overlayImage).enabled = false;
				}
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || Hud.IsUserHidden())
			{
				if (((Behaviour)_overlayImage).enabled)
				{
					((Behaviour)_overlayImage).enabled = false;
				}
				return;
			}
			float bodyWarmth = SurvivalManager.CurrentState.BodyWarmth;
			float value = ModConfig.FrostVignetteStartTemp.Value;
			float value2 = ModConfig.FrostVignetteMaxAlpha.Value;
			float num = 0f;
			if (bodyWarmth < value && value2 > 0f)
			{
				float num2 = -20f;
				float num3 = Mathf.Clamp01((value - bodyWarmth) / Mathf.Max(0.1f, value - num2));
				num = Mathf.Lerp(0.02f, value2, num3);
				if (bodyWarmth < -12f)
				{
					num += Mathf.Sin(Time.time * 2.2f) * (value2 * 0.15f);
				}
			}
			_currentAlpha = Mathf.MoveTowards(_currentAlpha, num, Time.deltaTime * 0.35f);
			if (_currentAlpha > 0.003f)
			{
				((Behaviour)_overlayImage).enabled = true;
				((Graphic)_overlayImage).color = new Color(0.88f, 0.94f, 1f, _currentAlpha);
			}
			else
			{
				((Behaviour)_overlayImage).enabled = false;
			}
		}

		private static Sprite GetFrostVignetteSprite()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_vignetteSprite != (Object)null)
			{
				return _vignetteSprite;
			}
			Texture2D val = new Texture2D(256, 256, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)1
			};
			float num = 127.5f;
			Color[] array = (Color[])(object)new Color[65536];
			for (int i = 0; i < 256; i++)
			{
				float num2 = ((float)i - num) / num;
				for (int j = 0; j < 256; j++)
				{
					float num3 = ((float)j - num) / num;
					float num4 = Mathf.Sqrt(num3 * num3 + num2 * num2);
					float num5 = 0f;
					if (num4 > 0.82f)
					{
						float num6 = Mathf.Clamp01((num4 - 0.82f) / 0.45f);
						num5 = num6 * num6;
					}
					array[i * 256 + j] = new Color(1f, 1f, 1f, num5);
				}
			}
			val.SetPixels(array);
			val.Apply(false, true);
			_vignetteSprite = Sprite.Create(val, new Rect(0f, 0f, 256f, 256f), new Vector2(0.5f, 0.5f));
			return _vignetteSprite;
		}

		private void OnDestroy()
		{
			if ((Object)(object)_instance == (Object)(object)this)
			{
				_instance = null;
			}
		}
	}
	public class ScreenHeatOverlay : MonoBehaviour
	{
		private static ScreenHeatOverlay? _instance;

		private static Sprite? _vignetteSprite;

		private Image? _overlayImage;

		private float _currentAlpha;

		private float _currentCameraDistort;

		public static void AttachToHud(Hud hud)
		{
			//IL_008f: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)hud == (Object)null)
			{
				return;
			}
			if ((Object)(object)_instance != (Object)null && (Object)(object)((Component)_instance).gameObject != (Object)null)
			{
				if (!((Component)_instance).gameObject.activeSelf)
				{
					((Component)_instance).gameObject.SetActive(true);
				}
				return;
			}
			Transform val = (((Object)(object)hud.m_rootObject != (Object)null) ? hud.m_rootObject.transform : ((Component)hud).transform);
			if (!((Object)(object)val == (Object)null))
			{
				GameObject val2 = new GameObject("VikingClimate_ScreenHeatOverlay", new Type[1] { typeof(RectTransform) });
				val2.transform.SetParent(val, false);
				int layer = (((Object)(object)hud.m_rootObject != (Object)null) ? hud.m_rootObject.layer : LayerMask.NameToLayer("UI"));
				val2.layer = layer;
				_instance = val2.AddComponent<ScreenHeatOverlay>();
				_instance.Init();
				VikingClimatePlugin.Log.LogInfo((object)("[ScreenHeatOverlay] Attached atmospheric heat haze and distortion to '" + ((Object)val).name + "'."));
			}
		}

		private void Init()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = ((Component)this).GetComponent<RectTransform>();
			if (!((Object)(object)component == (Object)null))
			{
				((Transform)component).localScale = Vector3.one;
				((Transform)component).localRotation = Quaternion.identity;
				component.anchorMin = Vector2.zero;
				component.anchorMax = Vector2.one;
				component.pivot = new Vector2(0.5f, 0.5f);
				component.offsetMin = Vector2.zero;
				component.offsetMax = Vector2.zero;
				((Transform)component).SetAsFirstSibling();
				_overlayImage = ((Component)this).gameObject.AddComponent<Image>();
				_overlayImage.sprite = GetHeatVignetteSprite();
				_overlayImage.type = (Type)0;
				((Graphic)_overlayImage).color = new Color(1f, 0.85f, 0.65f, 0f);
				((Graphic)_overlayImage).raycastTarget = false;
				((Behaviour)_overlayImage).enabled = false;
			}
		}

		private void Update()
		{
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			bool num = !ModConfig.ModEnabled.Value || !ModConfig.EnableScreenVignettes.Value || (Object)(object)_overlayImage == (Object)null;
			Player localPlayer = Player.m_localPlayer;
			if (num || (Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || Hud.IsUserHidden())
			{
				ResetEffects();
				return;
			}
			float bodyWarmth = SurvivalManager.CurrentState.BodyWarmth;
			float value = ModConfig.HeatVignetteStartTemp.Value;
			float value2 = ModConfig.HeatVignetteMaxAlpha.Value;
			float num2 = 0f;
			float num3 = 0f;
			if (bodyWarmth > value && value2 > 0f)
			{
				float num4 = 55f;
				float num5 = Mathf.Clamp01((bodyWarmth - value) / Mathf.Max(0.1f, num4 - value));
				num2 = Mathf.Lerp(0.015f, value2, num5);
				num3 = Mathf.Lerp(0.05f, 0.3f, num5);
				if (bodyWarmth > 44f)
				{
					float num6 = Mathf.Sin(Time.time * 2f) * (value2 * 0.15f);
					num2 += num6;
					num3 += num6 * 0.5f;
				}
			}
			_currentAlpha = Mathf.MoveTowards(_currentAlpha, num2, Time.deltaTime * 0.35f);
			_currentCameraDistort = Mathf.MoveTowards(_currentCameraDistort, num3, Time.deltaTime * 0.4f);
			if ((Object)(object)_overlayImage != (Object)null)
			{
				if (_currentAlpha > 0.003f)
				{
					((Behaviour)_overlayImage).enabled = true;
					((Graphic)_overlayImage).color = new Color(1f, 0.85f, 0.65f, _currentAlpha);
				}
				else
				{
					((Behaviour)_overlayImage).enabled = false;
				}
			}
			UpdateCameraDistortion(_currentCameraDistort);
		}

		private void UpdateCameraDistortion(float intensity)
		{
			GameCamera instance = GameCamera.instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)instance.m_heatDistortImageEffect == (Object)null)
			{
				return;
			}
			HeatDistortImageEffect heatDistortImageEffect = instance.m_heatDistortImageEffect;
			if (intensity > 0.005f)
			{
				if (!((Behaviour)heatDistortImageEffect).enabled)
				{
					((Behaviour)heatDistortImageEffect).enabled = true;
				}
				heatDistortImageEffect.m_intensity = Mathf.Clamp01(intensity);
			}
			else
			{
				heatDistortImageEffect.m_intensity = 0f;
				if (((Behaviour)heatDistortImageEffect).enabled)
				{
					((Behaviour)heatDistortImageEffect).enabled = false;
				}
			}
		}

		private void ResetEffects()
		{
			_currentAlpha = 0f;
			_currentCameraDistort = 0f;
			if ((Object)(object)_overlayImage != (Object)null && ((Behaviour)_overlayImage).enabled)
			{
				((Behaviour)_overlayImage).enabled = false;
			}
			UpdateCameraDistortion(0f);
		}

		private static Sprite GetHeatVignetteSprite()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_vignetteSprite != (Object)null)
			{
				return _vignetteSprite;
			}
			Texture2D val = new Texture2D(256, 256, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)1
			};
			float num = 127.5f;
			Color[] array = (Color[])(object)new Color[65536];
			for (int i = 0; i < 256; i++)
			{
				float num2 = ((float)i - num) / num;
				for (int j = 0; j < 256; j++)
				{
					float num3 = ((float)j - num) / num;
					float num4 = Mathf.Sqrt(num3 * num3 + num2 * num2);
					float num5 = 0f;
					if (num4 > 0.82f)
					{
						float num6 = Mathf.Clamp01((num4 - 0.82f) / 0.45f);
						num5 = num6 * num6;
					}
					array[i * 256 + j] = new Color(1f, 1f, 1f, num5);
				}
			}
			val.SetPixels(array);
			val.Apply(false, true);
			_vignetteSprite = Sprite.Create(val, new Rect(0f, 0f, 256f, 256f), new Vector2(0.5f, 0.5f));
			return _vignetteSprite;
		}

		private void OnDestroy()
		{
			ResetEffects();
			if ((Object)(object)_instance == (Object)(object)this)
			{
				_instance = null;
			}
		}
	}
	public class ThermalPieceInspector : MonoBehaviour
	{
		private static ThermalPieceInspector? s_instance;

		private PieceThermalNode? m_activeHovered;

		private DwellingThermalProfile? m_activeDwellingProfile;

		private readonly List<PieceThermalNode> m_activeNeighbors = new List<PieceThermalNode>();

		private ActiveHeatSource? m_activeHeatSource;

		private readonly List<PieceThermalNode> m_activeFireImpacted = new List<PieceThermalNode>();

		private ActiveHeatSource? m_lockedHeatSource;

		private readonly List<PieceThermalNode> m_lockedFireImpacted = new List<PieceThermalNode>();

		private readonly HashSet<GameObject> m_highlightedObjects = new HashSet<GameObject>();

		private int m_emissionPropId;

		private int m_colorPropId;

		private GUIStyle? m_boxStyle;

		private GUIStyle? m_headerStyle;

		private GUIStyle? m_bodyStyle;

		public static ThermalPieceInspector? Instance => s_instance;

		private void Awake()
		{
			s_instance = this;
			m_emissionPropId = Shader.PropertyToID("_EmissionColor");
			m_colorPropId = Shader.PropertyToID("_Color");
		}

		private void OnDestroy()
		{
			ClearHighlights();
		}

		private void Update()
		{
			//IL_0005: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(ModConfig.TogglePieceHoverHotkey.Value))
			{
				ModConfig.ShowPieceHoverDebug.Value = !ModConfig.ShowPieceHoverDebug.Value;
				if (!ModConfig.ShowPieceHoverDebug.Value)
				{
					m_lockedHeatSource = null;
					m_lockedFireImpacted.Clear();
					ClearHighlights();
					m_activeHovered = null;
					m_activeNeighbors.Clear();
					m_activeHeatSource = null;
					m_activeFireImpacted.Clear();
				}
			}
			if (Input.GetKeyDown(ModConfig.LockHeatSourceHotkey.Value))
			{
				if (m_lockedHeatSource != null)
				{
					m_lockedHeatSource = null;
					m_lockedFireImpacted.Clear();
					ClearHighlights();
				}
				else if (m_activeHeatSource != null)
				{
					m_lockedHeatSource = m_activeHeatSource;
					m_lockedFireImpacted.Clear();
					m_lockedFireImpacted.AddRange(m_activeFireImpacted);
					ApplyHeatSourceHighlights(m_lockedHeatSource, m_lockedFireImpacted);
				}
			}
			if (Input.GetKeyDown(ModConfig.ToggleInspectionModeHotkey.Value))
			{
				ModConfig.InspectAggregatedGraph.Value = !ModConfig.InspectAggregatedGraph.Value;
			}
			PieceThermalNode hoveredNode;
			List<PieceThermalNode> connectedNeighbors;
			ActiveHeatSource hoveredHeatSource;
			List<PieceThermalNode> fireImpactedPieces;
			if (!ModConfig.ShowPieceHoverDebug.Value || (Object)(object)Player.m_localPlayer == (Object)null)
			{
				if (m_highlightedObjects.Count > 0)
				{
					ClearHighlights();
				}
				m_lockedHeatSource = null;
				m_lockedFireImpacted.Clear();
				m_activeHovered = null;
				m_activeNeighbors.Clear();
				m_activeHeatSource = null;
				m_activeFireImpacted.Clear();
			}
			else if (ThermalGraphManager.Instance.GetCrosshairPieceInfo(Player.m_localPlayer, out hoveredNode, out connectedNeighbors, out hoveredHeatSource, out fireImpactedPieces))
			{
				if (hoveredHeatSource != null)
				{
					m_activeHovered = null;
					m_activeNeighbors.Clear();
					m_activeHeatSource = hoveredHeatSource;
					m_activeFireImpacted.Clear();
					m_activeFireImpacted.AddRange(fireImpactedPieces);
					if (ModConfig.HighlightConnectedPieces.Value)
					{
						ApplyHeatSourceHighlights(hoveredHeatSource, fireImpactedPieces);
					}
				}
				else if (hoveredNode != null && (Object)(object)hoveredNode.PieceRef != (Object)null && (Object)(object)((Component)hoveredNode.PieceRef).gameObject != (Object)null)
				{
					m_activeHovered = hoveredNode;
					m_activeNeighbors.Clear();
					m_activeNeighbors.AddRange(connectedNeighbors);
					m_activeHeatSource = null;
					m_activeFireImpacted.Clear();
					if (ModConfig.InspectAggregatedGraph.Value)
					{
						float num = SurvivalManager.CurrentState.Breakdown.OutdoorAmbient;
						if (num == 0f)
						{
							num = SurvivalManager.CurrentState.AmbientTemperature;
						}
						DwellingThermalProfile dwellingProfile = ThermalGraphManager.Instance.GetDwellingProfile(hoveredNode, num);
						m_activeDwellingProfile = dwellingProfile;
					}
					else
					{
						m_activeDwellingProfile = null;
					}
					if (m_lockedHeatSource != null)
					{
						ApplyLockedAndHoverHighlights(m_lockedHeatSource, m_lockedFireImpacted, hoveredNode);
					}
					else if (ModConfig.InspectAggregatedGraph.Value)
					{
						if (ModConfig.HighlightConnectedPieces.Value && m_activeDwellingProfile.HasValue && m_activeDwellingProfile.Value.AllPieces != null)
						{
							ApplyDwellingHighlights(hoveredNode, m_activeDwellingProfile.Value.AllPieces);
						}
					}
					else if (ModConfig.HighlightConnectedPieces.Value)
					{
						ApplyPieceHighlights(hoveredNode, connectedNeighbors);
					}
				}
				else
				{
					ResetSelection();
				}
			}
			else
			{
				ResetSelection();
			}
		}

		private void ResetSelection()
		{
			m_activeHovered = null;
			m_activeNeighbors.Clear();
			m_activeHeatSource = null;
			m_activeFireImpacted.Clear();
			if (m_lockedHeatSource != null)
			{
				ApplyHeatSourceHighlights(m_lockedHeatSource, m_lockedFireImpacted);
				return;
			}
			if (m_highlightedObjects.Count > 0)
			{
				ClearHighlights();
			}
			m_activeHovered = null;
			m_activeDwellingProfile = null;
			m_activeNeighbors.Clear();
			m_activeHeatSource = null;
			m_activeFireImpacted.Clear();
		}

		private void ApplyDwellingHighlights(PieceThermalNode target, HashSet<PieceThermalNode> dwellingPieces)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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)
			HashSet<GameObject> hashSet = new HashSet<GameObject>();
			if ((Object)(object)target.PieceRef != (Object)null && (Object)(object)((Component)target.PieceRef).gameObject != (Object)null)
			{
				GameObject gameObject = ((Component)target.PieceRef).gameObject;
				hashSet.Add(gameObject);
				SetPieceHighlight(gameObject, new Color(1f, 0.65f, 0.15f) * 0.85f);
			}
			foreach (PieceThermalNode dwellingPiece in dwellingPieces)
			{
				if (dwellingPiece != target && (Object)(object)dwellingPiece.PieceRef != (Object)null && (Object)(object)((Component)dwellingPiece.PieceRef).gameObject != (Object)null)
				{
					GameObject gameObject2 = ((Component)dwellingPiece.PieceRef).gameObject;
					hashSet.Add(gameObject2);
					SetPieceHighlight(gameObject2, new Color(0.2f, 0.8f, 0.9f) * 0.4f);
				}
			}
			SyncHighlightedObjects(hashSet);
		}

		private void ApplyPieceHighlights(PieceThermalNode target, List<PieceThermalNode> neighbors)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			HashSet<GameObject> hashSet = new HashSet<GameObject>();
			if ((Object)(object)target.PieceRef != (Object)null && (Object)(object)((Component)target.PieceRef).gameObject != (Object)null)
			{
				GameObject gameObject = ((Component)target.PieceRef).gameObject;
				hashSet.Add(gameObject);
				SetPieceHighlight(gameObject, new Color(1f, 0.6f, 0.15f) * 0.75f);
			}
			for (int i = 0; i < neighbors.Count; i++)
			{
				PieceThermalNode pieceThermalNode = neighbors[i];
				if ((Object)(object)pieceThermalNode.PieceRef != (Object)null && (Object)(object)((Component)pieceThermalNode.PieceRef).gameObject != (Object)null)
				{
					GameObject gameObject2 = ((Component)pieceThermalNode.PieceRef).gameObject;
					hashSet.Add(gameObject2);
					SetPieceHighlight(gameObject2, new Color(0.2f, 0.85f, 0.65f) * 0.45f);
				}
			}
			SyncHighlightedObjects(hashSet);
		}

		private void ApplyHeatSourceHighlights(ActiveHeatSource heatSource, List<PieceThermalNode> impactedPieces)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: 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_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: 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_01bb: Unknown result type (might be due to invalid IL or missing references)
			HashSet<GameObject> hashSet = new HashSet<GameObject>();
			if (heatSource != null && (Object)(object)heatSource.GameObject != (Object)null)
			{
				GameObject gameObject = heatSource.GameObject;
				hashSet.Add(gameObject);
				SetPieceHighlight(gameObject, new Color(1f, 0.35f, 0.05f) * 0.9f);
			}
			float num = 0.001f;
			if (heatSource != null)
			{
				for (int i = 0; i < impactedPieces.Count; i++)
				{
					int instanceId = impactedPieces[i].InstanceId;
					if (heatSource.ImpactedEnergyPerNode.TryGetValue(instanceId, out var value) && value > num)
					{
						num = value;
					}
				}
			}
			for (int j = 0; j < impactedPieces.Count; j++)
			{
				PieceThermalNode pieceThermalNode = impactedPieces[j];
				if ((Object)(object)pieceThermalNode.PieceRef != (Object)null && (Object)(object)((Component)pieceThermalNode.PieceRef).gameObject != (Object)null)
				{
					GameObject gameObject2 = ((Component)pieceThermalNode.PieceRef).gameObject;
					hashSet.Add(gameObject2);
					float value2;
					float num2 = Mathf.Clamp01(((heatSource != null && heatSource.ImpactedEnergyPerNode.TryGetValue(pieceThermalNode.InstanceId, out value2)) ? value2 : 0f) / num);
					Color color;
					if (num2 < 0.5f)
					{
						float num3 = num2 / 0.5f;
						color = Color.Lerp(new Color(0.92f, 0.88f, 0.6f) * 0.35f, new Color(1f, 0.75f, 0.15f) * 0.65f, num3);
					}
					else
					{
						float num4 = (num2 - 0.5f) / 0.5f;
						color = Color.Lerp(new Color(1f, 0.75f, 0.15f) * 0.65f, new Color(1f, 0.2f, 0.02f) * 0.95f, num4);
					}
					SetPieceHighlight(gameObject2, color);
				}
			}
			SyncHighlightedObjects(hashSet);
		}

		private void ApplyLockedAndHoverHighlights(ActiveHeatSource heatSource, List<PieceThermalNode> impactedPieces, PieceThermalNode hoveredPiece)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: 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_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: 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_01bb: Unknown result type (might be due to invalid IL or missing references)
			HashSet<GameObject> hashSet = new HashSet<GameObject>();
			if (heatSource != null && (Object)(object)heatSource.GameObject != (Object)null)
			{
				GameObject gameObject = heatSource.GameObject;
				hashSet.Add(gameObject);
				SetPieceHighlight(gameObject, new Color(1f, 0.35f, 0.05f) * 0.9f);
			}
			float num = 0.001f;
			if (heatSource != null)
			{
				for (int i = 0; i < impactedPieces.Count; i++)
				{
					int instanceId = impactedPieces[i].InstanceId;
					if (heatSource.ImpactedEnergyPerNode.TryGetValue(instanceId, out var value) && value > num)
					{
						num = value;
					}
				}
			}
			for (int j = 0; j < impactedPieces.Count; j++)
			{
				PieceThermalNode pieceThermalNode = impactedPieces[j];
				if ((Object)(object)pieceThermalNode.PieceRef != (Object)null && (Object)(object)((Component)pieceThermalNode.PieceRef).gameObject != (Object)null)
				{
					GameObject gameObject2 = ((Component)pieceThermalNode.PieceRef).gameObject;
					hashSet.Add(gameObject2);
					float value2;
					float num2 = Mathf.Clamp01(((heatSource != null && heatSource.ImpactedEnergyPerNode.TryGetValue(pieceThermalNode.InstanceId, out value2)) ? value2 : 0f) / num);
					Color color;
					if (num2 < 0.5f)
					{
						float num3 = num2 / 0.5f;
						color = Color.Lerp(new Color(0.92f, 0.88f, 0.6f) * 0.35f, new Color(1f, 0.75f, 0.15f) * 0.65f, num3);
					}
					else
					{
						float num4 = (num2 - 0.5f) / 0.5f;
						color = Color.Lerp(new Color(1f, 0.75f, 0.15f) * 0.65f, new Color(1f, 0.2f, 0.02f) * 0.95f, num4);
					}
					SetPieceHighlight(gameObject2, color);
				}
			}
			if (hoveredPiece != null && (Object)(object)hoveredPiece.PieceRef != (Object)null && (Object)(object)((Component)hoveredPiece.PieceRef).gameObject != (Object)null)
			{
				GameObject gameObject3 = ((Component)hoveredPiece.PieceRef).gameObject;
				hashSet.Add(gameObject3);
				SetPieceHighlight(gameObject3, new Color(1f, 0.95f, 0.35f) * 0.9f);
			}
			SyncHighlightedObjects(hashSet);
		}

		private void SyncHighlightedObjects(HashSet<GameObject> currentSet)
		{
			List<GameObject> list = new List<GameObject>();
			foreach (GameObject highlightedObject in m_highlightedObjects)
			{
				if (!currentSet.Contains(highlightedObject))
				{
					ResetPieceHighlight(highlightedObject);
					list.Add(highlightedObject);
				}
			}
			for (int i = 0; i < list.Count; i++)
			{
				m_highlightedObjects.Remove(list[i]);
			}
			foreach (GameObject item in currentSet)
			{
				m_highlightedObjects.Add(item);
			}
		}

		private void SetPieceHighlight(GameObject go, Color color)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)go == (Object)null || (Object)(object)MaterialMan.instance == (Object)null)
			{
				return;
			}
			try
			{
				MaterialMan.instance.SetValue<Color>(go, m_emissionPropId, color, true);
			}
			catch
			{
			}
		}

		private void ResetPieceHighlight(GameObject go)
		{
			if ((Object)(object)go == (Object)null || (Object)(object)MaterialMan.instance == (Object)null)
			{
				return;
			}
			try
			{
				MaterialMan.instance.ResetValue(go, m_emissionPropId);
			}
			catch
			{
			}
		}

		private void ClearHighlights()
		{
			if ((Object)(object)MaterialMan.instance == (Object)null)
			{
				m_highlightedObjects.Clear();
				return;
			}
			foreach (GameObject highlightedObject in m_highlightedObjects)
			{
				if ((Object)(object)highlightedObject != (Object)null)
				{
					ResetPieceHighlight(highlightedObject);
				}
			}
			m_highlightedObjects.Clear();
		}

		private void OnGUI()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
			if (!ModConfig.ShowPieceHoverDebug.Value || (Object)(object)Player.m_localPlayer == (Object)null)
			{
				return;
			}
			InitStyles();
			string text = (ModConfig.InspectAggregatedGraph.Value ? "Connected Graph" : "Single Piece");
			string text2 = ((object)ModConfig.ToggleInspectionModeHotkey.Value/*cast due to .constrained prefix*/).ToString();
			string text3 = ((m_lockedHeatSource != null) ? (" <color=#81C784>[Locked to " + m_lockedHeatSource.DisplayName + "]</color>") : "");
			GUI.Label(new Rect(20f, (float)(Screen.height - 35), 550f, 25f), $"<color=#80CBC4>[{ModConfig.TogglePieceHoverHotkey.Value}: Thermal Inspection ON ({text} | [{text2}]: Toggle Mode)]</color>{text3}", m_bodyStyle);
			if (m_activeHeatSource != null && (Object)(object)m_activeHeatSource.GameObject != (Object)null)
			{
				RenderHeatSourceHUD();
			}
			else
			{
				if (m_activeHovered == null || (Object)(object)m_activeHovered.PieceRef == (Object)null)
				{
					return;
				}
				PieceThermalNode activeHovered = m_activeHovered;
				float num = SurvivalManager.CurrentState.Breakdown.OutdoorAmbient;
				if (num == 0f)
				{
					num = SurvivalManager.CurrentState.AmbientTemperature - SurvivalManager.CurrentState.FireWarmth;
				}
				if (m_activeDwellingProfile.HasValue && ModConfig.InspectAggregatedGraph.Value)
				{
					RenderInstantDwellingHUD(m_activeDwellingProfile.Value, activeHovered, num);
					return;
				}
				float num2 = activeHovered.CurrentTemperature - num;
				string text4 = ((num2 >= 0f) ? "+" : "");
				string text5 = ((activeHovered.CurrentTemperature >= 25f) ? "#FFA726" : ((activeHovered.CurrentTemperature >= 16f) ? "#81C784" : "#90CAF9"));
				string text6 = activeHovered.PieceName;
				if ((Object)(object)activeHovered.PieceRef != (Object)null && !string.IsNullOrEmpty(activeHovered.PieceRef.m_name))
				{
					text6 = activeHovered.PieceRef.m_name;
				}
				string text7 = ((Localization.instance != null) ? Localization.instance.Localize(text6) : text6);
				float directHeatFlux = activeHovered.DirectHeatFlux;
				float num3 = activeHovered.ActualConductiveInflux;
				float num4 = activeHovered.ActualConductiveOutflux;
				float num5 = 0f;
				int num6 = 0;
				for (int i = 0; i < activeHovered.Edges.Count; i++)
				{
					ThermalContactEdge thermalContactEdge = activeHovered.Edges[i];
					if ((Object)(object)thermalContactEdge.Target.PieceRef != (Object)null && (Object)(object)((Component)thermalContactEdge.Target.PieceRef).gameObject != (Object)null)
					{
						num6++;
						num5 += thermalContactEdge.Target.CurrentTemperature;
					}
				}
				if (num3 == 0f && num4 == 0f)
				{
					for (int j = 0; j < activeHovered.Edges.Count; j++)
					{
						ThermalContactEdge thermalContactEdge2 = activeHovered.Edges[j];
						if ((Object)(object)thermalContactEdge2.Target.PieceRef != (Object)null && (Object)(object)((Component)thermalContactEdge2.Target.PieceRef).gameObject != (Object)null)
						{
							float num7 = thermalContactEdge2.Target.CurrentTemperature - activeHovered.CurrentTemperature;
							float num8 = thermalContactEdge2.InterfaceConductivity * num7;
							if (num8 > 0f)
							{
								num3 += num8;
							}
							else
							{
								num4 += 0f - num8;
							}
						}
					}
				}
				float num9 = ((num6 > 0) ? (num5 / (float)num6) : activeHovered.CurrentTemperature);
				float effectiveAirLossRate = activeHovered.EffectiveAirLossRate;
				float num10 = effectiveAirLossRate * (num - activeHovered.CurrentTemperature);
				float num11 = num3 - num4;
				float num12 = directHeatFlux + num11 + num10;
				float num13 = Mathf.Abs(num12) / Mathf.Max(1f, activeHovered.HeatCapacity);
				string arg = ((Mathf.Abs(num12) < 0.25f) ? "<color=#81C784>Balanced (Equilibrium)</color>" : ((!(num12 > 0f)) ? $"<color=#90CAF9>Cooling (-{num13:F2}°C/s)</color>" : $"<color=#FFB74D>Warming (+{num13:F2}°C/s)</color>"));
				ThermalGraphManager.UpdateNodeCoverAndRoof(activeHovered);
				string text8 = ((activeHovered.MaterialType == "Stone") ? "Dense Heat Sink" : ((activeHovered.MaterialType == "CoreWood") ? "Heavy Timber" : "Wood"));
				int num14 = Mathf.RoundToInt(activeHovered.InsulationFactor * 100f);
				string text9 = (activeHovered.UnderRoof ? "Roofed" : "Open Sky");
				string text10 = ((num14 >= 70) ? "<color=#81C784>Enclosed</color>" : ((num14 >= 35) ? "<color=#FFB74D>Partial</color>" : "<color=#EF5350>Exposed</color>"));
				int num15 = 560;
				int num16 = 180;
				int num17 = Screen.width - num15 - 25 + (int)ModConfig.PieceHoverOffsetX.Value;
				int num18 = Screen.height - num16 - 35 - (int)ModConfig.PieceHoverOffsetY.Value;
				GUI.Box(new Rect((float)num17, (float)num18, (float)num15, (float)num16), GUIContent.none, m_boxStyle);
				GUILayout.BeginArea(new Rect((float)(num17 + 14), (float)(num18 + 12), (float)(num15 - 28), (float)(num16 - 24)));
				string text11 = $"+{directHeatFlux:F1}W";
				string text12 = ((num11 >= 0f) ? $"+{num11:F1}W" : $"-{Mathf.Abs(num11):F1}W");
				string text13 = ((num10 >= 0f) ? $"+{num10:F1}W" : $"-{Mathf.Abs(num10):F1}W");
				string text14 = ((num12 >= 0f) ? $"+{num12:F1}W" : $"-{Mathf.Abs(num12):F1}W");
				GUILayout.Label("<b><color=orange>[ THERMAL INSPECTION ]</color></b> <color=yellow><b>" + text7 + "</b></color> (" + activeHovered.MaterialType + ") <color=#B0BEC5>([" + text2 + "]: Graph Mode)</color>", m_headerStyle, Array.Empty<GUILayoutOption>());
				GUILayout.Label($"• Temperature: <color={text5}><b>{activeHovered.CurrentTemperature:F1}°C</b></color> (Outdoor Weather: {num:F1}°C | {text4}{num2:F1}°C)", m_bodyStyle, Array.Empty<GUILayoutOption>());
				GUILayout.Label($"• Material: Mass Capacity <b>{activeHovered.HeatCapacity:F0}</b> ({text8}) | Conduction <b>{activeHovered.MaterialConductivity:F1}</b> | Air Coeff <b>{effectiveAirLossRate:F3}</b> (Base {activeHovered.AirLossRate:F2})", m_bodyStyle, Array.Empty<GUILayoutOption>());
				GUILayout.Label($"• Shelter/Insulation: <b>{num14}%</b> ({text9} | {text10} | Cover {activeHovered.CoverPercentage * 100f:F0}%)", m_bodyStyle, Array.Empty<GUILayoutOption>());
				GUILayout.Label("• Energy: Fire <b>" + text11 + "</b> | Joints <b>" + text12 + "</b> | Air <b>" + text13 + "</b> (Net <b>" + text14 + "</b>)", m_bodyStyle, Array.Empty<GUILayoutOption>());
				GUILayout.Label($"• Dynamics: {arg} | Neighbors: <b>{num6} Connected Pieces</b> (Avg {num9:F1}°C)", m_bodyStyle, Array.Empty<GUILayoutOption>());
				GUILayout.EndArea();
			}
		}

		private void RenderInstantDwellingHUD(DwellingThermalProfile profile, PieceThermalNode targetNode, float outdoorWeather)
		{
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			float num = profile.UniformTemperature - outdoorWeather;
			string text = ((num >= 0f) ? "+" : "");
			string text2 = ((profile.UniformTemperature >= 25f) ? "#FFA726" : ((profile.UniformTemperature >= 16f) ? "#81C784" : "#90CAF9"));
			string text3 = targetNode.PieceName;
			if ((Object)(object)targetNode.PieceRef != (Object)null && !string.IsNullOrEmpty(targetNode.PieceRef.m_name))
			{
				text3 = targetNode.PieceRef.m_name;
			}
			string text4 = ((Localization.instance != null) ? Localization.instance.Localize(text3) : text3);
			List<string> list = new List<string>();
			if (profile.WoodCount > 0)
			{
				list.Add($"{profile.WoodCount} Wood");
			}
			if (profile.StoneCount > 0)
			{
				list.Add($"{profile.StoneCount} Stone");
			}
			if (profile.CoreWoodCount > 0)
			{
				list.Add($"{profile.CoreWoodCount} CoreWood");
			}
			if (profile.OtherCount > 0)
			{
				list.Add($"{profile.OtherCount} Other");
			}
			string arg = ((list.Count > 0) ? string.Join(", ", list) : "Mixed");
			string text5 = ((profile.NetFlux >= 0f) ? "+" : "");
			string arg2 = ((profile.NetFlux >= 0f) ? "+" : "-");
			string text6 = ((Mathf.Abs(profile.NetFlux) < 0.25f) ? "<color=#81C784>Equilibrium</color>" : ((!(profile.NetFlux > 0f)) ? $"<color=#90CAF9>Cooling ({arg2}{profile.ExpectedRateOfChange:F3}°C/s)</color>" : $"<color=#FFB74D>Warming ({arg2}{profile.ExpectedRateOfChange:F3}°C/s)</color>"));
			int num2 = 640;
			int num3 = 210;
			int num4 = Screen.width - num2 - 25 + (int)ModConfig.PieceHoverOffsetX.Value;
			int num5 = Screen.height - num3 - 35 - (int)ModConfig.PieceHoverOffsetY.Value;
			GUI.Box(new Rect((float)num4, (float)num5, (float)num2, (float)num3), GUIContent.none, m_boxStyle);
			GUILayout.BeginArea(new Rect((float)(num4 + 14), (float)(num5 + 12), (float)(num2 - 28), (float)(num3 - 24)));
			string text7 = ((object)ModConfig.ToggleInspectionModeHotkey.Value/*cast due to .constrained prefix*/).ToString();
			string text8 = ((ModConfig.DebugInstantConduction != null && ModConfig.DebugInstantConduction.Value) ? " <color=#FFB74D>[Instant Conduction]</color>" : "");
			GUILayout.Label("<b><color=#00E5FF>[ CONNECTED GRAPH PROFILE ]</color></b> <color=yellow><b>" + text4 + "</b></color>" + text8 + " <color=#B0BEC5>([" + text7 + "]: Single Piece)</color>", m_headerStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"• Uniform Temperature: <color={text2}><b>{profile.UniformTemperature:F1}°C</b></color> (Outdoor Weather: {outdoorWeather:F1}°C | {text}{num:F1}°C)", m_bodyStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"• Structure: <b>{profile.PieceCount} Connected Pieces</b> ({arg}) | Thermal Mass: <b>{profile.TotalHeatCapacity:F0} J/°C</b>", m_bodyStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"• Envelope & Cover: <b>{profile.RoofedCount}/{profile.PieceCount} Roofed</b> (Avg Cover {profile.AverageCoverPct * 100f:F0}%) | Total Air Loss Coeff: <b>{profile.TotalAirLossCoeff:F2} W/°C</b>", m_bodyStyle, Array.Empty<GUILayoutOption>());
			string text9 = ((profile.TotalAirGain > 0f) ? $"Gain <b>+{profile.TotalAirGain:F1}W</b> (Air)" : $"Loss <b>-{profile.TotalAirLoss:F1}W</b> (Air)");
			GUILayout.Label($"• Energy Exchange: Influx <b>+{profile.TotalFireInflux:F1}W</b> (Fires) | {text9} | Net <b>{text5}{profile.NetFlux:F1}W</b> ({text6})", m_bodyStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Label($"• Projected Equilibrium: <color=yellow><b>{profile.ExpectedEquilibriumTemp:F1}°C</b></color> (Steady-state target where Influx == Air Loss)", m_bodyStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Label("• Calibration: <color=#B0BEC5>Adjust Wood/Stone Air Loss in config to shift equilibrium target up or down</color>", m_bodyStyle, Array.Empty<GUILayoutOption>());
			GUILayout.EndArea();
		}

		private void RenderHeatSourceHUD()
		{
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			if (m_activeHeatSource != null && !((Object)(object)m_activeHeatSource.GameObject == (Object)null))
			{
				string displayName = m_activeHeatSource.DisplayName;
				bool isActive = m_activeHeatSource.IsActive;
				float num = (isActive ? m_activeHeatSource.Power : 0f);
				string arg = (isActive ? "#81C784" : "#EF5350");
				string arg2 = (isActive ? m_activeHeatSource.ActiveStatusText : m_activeHeatSource.InactiveStatusText);
				float num2 = (isActive ? m_activeHeatSource.AbsorbedStructureEnergy : 0f);
				float num3 = (isActive ? m_activeHeatSource.AbsorbedGroundEnergy : 0f);
				float num4 = (isActive ? m_activeHeatSource.EscapedAirEnergy : 0f);
				string text = ((object)ModConfig.LockHeatSourceHotkey.Value/*cast due to .constrained prefix*/).ToString();
				string text2 = ((m_lockedHeatSource != null && (Object)(object)m_lockedHeatSource.GameObject == (Object)(object)m_activeHeatSource.GameObject) ? ("<color=#81C784>Locked</color> ([" + text + "] to unlock)") : ("[" + text + "] to lock"));
				int num5 = 480;
				int num6 = 110;
				int num7 = Screen.width - num5 - 25 + (int)ModConfig.PieceHoverOffsetX.Value;
				int num8 = Screen.height - num6 - 35 - (int)ModConfig.PieceHoverOffsetY.Value;
				GUI.Box(new Rect((float)num7, (float)num8, (float)num5, (float)num6), GUIContent.none, m_boxStyle);
				GUILayout.BeginArea(new Rect((float)(num7 + 14), (float)(num8 + 12), (float)(num5 - 28), (float)(num6 - 24)));
				GUILayout.Label("<b><color=#FF7043>[ HEAT SOURCE INSPECTION ]</color></b> <color=yellow><b>" + displayName + "</b></color>", m_headerStyle, Array.Empty<GUILayoutOption>());
				GUILayout.Label($"• State: <color={arg}><b>{arg2}</b></color> | Output: <color=#FFA726><b>{num:F0}W</b></color>", m_bodyStyle, Array.Empty<GUILayoutOption>());
				GUILayout.Label($"• Absorption: <color=#FFD54F><b>{num2:F0}W Pieces</b></color> | <color=#90CAF9><b>{num4:F0}W Air</b></color> | <color=#BCAAA4><b>{num3:F0}W Ground</b></color>", m_bodyStyle, Array.Empty<GUILayoutOption>());
				GUILayout.Label("• Display: " + text2, m_bodyStyle, Array.Empty<GUILayoutOption>());
				GUILayout.EndArea();
			}
		}

		private void InitStyles()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			if (m_boxStyle == null)
			{
				Texture2D val = new Texture2D(1, 1);
				val.SetPixel(0, 0, new Color(0.08f, 0.08f, 0.11f, 0.88f));
				val.Apply();
				m_boxStyle = new GUIStyle(GUI.skin.box);
				m_boxStyle.normal.background = val;
				m_headerStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 13,
					fontStyle = (FontStyle)1
				};
				m_headerStyle.normal.textColor = Color.white;
				m_bodyStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 12,
					richText = true
				};
				m_bodyStyle.normal.textColor = new Color(0.88f, 0.88f, 0.88f);
			}
		}
	}
}
namespace VikingClimate.Patches
{
	public static class ComfortPatches
	{
		[HarmonyPatch(typeof(SE_Rested), "CalculateComfortLevel", new Type[] { typeof(Player) })]
		public static class SE_Rested_CalculateComfortLevel_Player_Patch
		{
			[HarmonyPrefix]
			public static bool Prefix(Player player, ref int __result)
			{
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				if (!ModConfig.ModEnabled.Value || !ModConfig.EnableStructureComfort.Value || ModConfig.ThermalMassSimulationMode.Value != ThermalMassMode.StructuralGraph || (Object)(object)player == (Object)null)
				{
					return true;
				}
				bool inShelter = player.InShelter() || ThermalGraphManager.IsInsideCompound(player);
				__result = ThermalGraphManager.Instance.CalculateDwellingComfort(player, inShelter, ((Component)player).transform.position);
				return false;
			}
		}

		[HarmonyPatch(typeof(SE_Rested), "CalculateComfortLevel", new Type[]
		{
			typeof(bool),
			typeof(Vector3)
		})]
		public static class SE_Rested_CalculateComfortLevel_Pos_Patch
		{
			[HarmonyPrefix]
			public static bool Prefix(bool inShelter, Vector3 position, ref int __result)
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				if (!ModConfig.ModEnabled.Value || !ModConfig.EnableStructureComfort.Value || ModConfig.ThermalMassSimulationMode.Value != ThermalMassMode.StructuralGraph)
				{
					return true;
				}
				if ((Object)(object)Player.m_localPlayer != (Object)null && Vector3.Distance(position, ((Component)Player.m_localPlayer).transform.position) < 3f)
				{
					bool inShelter2 = inShelter || ThermalGraphManager.IsInsideCompound(Player.m_localPlayer);
					__result = ThermalGraphManager.Instance.CalculateDwellingComfort(Player.m_localPlayer, inShelter2, position);
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Bed), "CheckFire")]
		public static class Bed_CheckFire_Patch
		{
			[HarmonyPrefix]
			public static bool Prefix(Bed __instance, Player human, ref bool __result)
			{
				if (!ModConfig.ModEnabled.Value || !ModConfig.EnableThermalResting.Value || (Object)(object)human == (Object)null)
				{
					return true;
				}
				float bodyWarmth = SurvivalManager.CurrentState.BodyWarmth;
				float value = ModConfig.ComfortMinTemp.Value;
				float value2 = ModConfig.ComfortMaxTemp.Value;
				if (!ThermalGraphManager.IsInsideCompound(human) && !human.InShelter())
				{
					((Character)human).Message((MessageType)2, "$msg_bedneedroof", 0, (Sprite)null, false);
					__result = false;
					return false;
				}
				if (ModConfig.RequireWarmthToSleep.Value && bodyWarmth < value)
				{
					((Character)human).Message((MessageType)2, $"You are too cold to sleep ({bodyWarmth:F0}°C / Need {value:F0}°C)", 0, (Sprite)null, false);
					__result = false;
					return false;
				}
				if (bodyWarmth > value2)
				{
					((Character)human).Message((MessageType)2, $"You are too hot to sleep ({bodyWarmth:F0}°C)", 0, (Sprite)null, false);
					__result = false;
					return false;
				}
				__result = true;
				return false;
			}
		}

		[HarmonyPatch(typeof(SE_Cozy), "Setup")]
		public static class SE_Cozy_Setup_Patch
		{
			[HarmonyPostfix]
			public static void Postfix(SE_Cozy __instance)
			{
				if (ModConfig.ModEnabled.Value && ModConfig.EnableThermalResting.Value)
				{
					__instance.m_delay = Mathf.Max(5f, ModConfig.RestedDelaySeconds.Value);
				}
			}
		}
	}
	[HarmonyPatch]
	public static class PlayerPatches
	{
		[HarmonyPatch(typeof(Player), "UpdateEnvStatusEffects")]
		public static class Player_UpdateEnvStatusEffects_Patch
		{
			private static float s_comfortZoneTimer;

			[HarmonyTranspiler]
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Expected O, but got Unknown
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Expected O, but got Unknown
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Expected O, but got Unknown
				CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
				val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((OpCode?)OpCodes.Ldsfld, (object)AccessTools.Field(typeof(SEMan), "s_statusEffectResting"), (string)null)
				});
				if (!val.IsValid)
				{
					VikingClimatePlugin.Log.LogError((object)"Failed to locate s_statusEffectResting in Player.UpdateEnvStatusEffects transpiler!");
					return val.InstructionEnumeration();
				}
				val.MatchBack(false, (CodeMatch[])(object)new CodeMatch[1]
				{
					new CodeMatch((OpCode?)OpCodes.And, (object)null, (string)null)
				});
				if (!val.IsValid)
				{
					VikingClimatePlugin.Log.LogError((object)"Failed to locate OpCodes.And in Player.UpdateEnvStatusEffects transpiler!");
					return val.InstructionEnumeration();
				}
				val.Advance(-1);
				val.SetAndAdvance(OpCodes.Ldarg_0, (object)null);
				val.Set(OpCodes.Call, (object)AccessTools.Method(typeof(Player_UpdateEnvStatusEffects_Patch), "EvaluateRestingCondition", (Type[])null, (Type[])null));
				return val.InstructionEnumeration();
			}

			public static bool EvaluateRestingCondition(bool vanillaBaseCondition, Player player)
			{
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
				if (!ModConfig.ModEnabled.Value || !ModConfig.EnableThermalResting.Value || (Object)(object)player != (Object)(object)Player.m_localPlayer)
				{
					if (vanillaBaseCondition)
					{
						SEMan sEMan = ((Character)player).GetSEMan();
						if (sEMan == null || !sEMan.HaveStatusEffect(SEMan.s_statusEffectCampFire))
						{
							return Object.op_Implicit((Object)(object)EffectArea.IsPointInsideArea(((Component)player).transform.position, (Type)1, 1f));
						}
						return true;
					}
					return false;
				}
				SEMan sEMan2 = ((Character)player).GetSEMan();
				if (sEMan2 == null)
				{
					return false;
				}
				if (player.IsSensed() || sEMan2.HaveStatusEffect(SEMan.s_statusEffectBurning))
				{
					s_comfortZoneTimer = 0f;
					return false;
				}
				if (sEMan2.HaveStatusEffect(SEMan.s_statusEffectWet) && !Object.op_Implicit((Object)(object)EffectArea.IsPointInsideArea(((Component