using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using Valheim.SettingsGui;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Hygge")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Hygge")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e57e6cf6-5849-4472-8848-85950388f318")]
[assembly: AssemblyFileVersion("1.3.1")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.1.0")]
[module: UnverifiableCode]
namespace Hygge
{
public static class ComfortPanelManager
{
private static Piece lastPiece;
public static ComfortPanel ComfortPanel { get; private set; }
public static void ToggleOn(Piece piece)
{
if (!Object.op_Implicit((Object)(object)ComfortPanel?.Panel) && !InstantiateComfortPanel(piece))
{
ZLog.LogWarning((object)"Failed to instantiate comfort panel.");
}
else
{
ComfortPanel.Panel.SetActive(true);
}
}
public static void ToggleOff()
{
if (Object.op_Implicit((Object)(object)ComfortPanel?.Panel))
{
ComfortPanel.Panel.SetActive(false);
}
}
public static void Update(Piece piece)
{
ComfortPanel.Update(piece);
}
public static void DestroyPanel()
{
if (Object.op_Implicit((Object)(object)ComfortPanel?.Panel))
{
ComfortPanel.Panel.SetActive(false);
Object.Destroy((Object)(object)ComfortPanel.Panel);
ComfortPanel = null;
}
}
private static bool InstantiateComfortPanel(Piece piece)
{
ComfortPanel = ComfortPanel.CreateComfortPanel();
if (ComfortPanel == null)
{
return false;
}
ComfortPanel.Update(piece);
return true;
}
}
public static class GameObjectExtensions
{
public static RectTransform RectTransform(this GameObject gameObject)
{
return Object.op_Implicit((Object)(object)gameObject) ? gameObject.GetComponent<RectTransform>() : null;
}
}
public static class RectTransformExtensions
{
public static RectTransform SetAnchorMin(this RectTransform rectTransform, Vector2 anchorMin)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
rectTransform.anchorMin = anchorMin;
return rectTransform;
}
public static RectTransform SetAnchorMax(this RectTransform rectTransform, Vector2 anchorMax)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
rectTransform.anchorMax = anchorMax;
return rectTransform;
}
public static RectTransform SetPivot(this RectTransform rectTransform, Vector2 pivot)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
rectTransform.pivot = pivot;
return rectTransform;
}
public static RectTransform SetPosition(this RectTransform rectTransform, Vector2 position)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
rectTransform.anchoredPosition = position;
return rectTransform;
}
public static RectTransform SetSizeDelta(this RectTransform rectTransform, Vector2 sizeDelta)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
rectTransform.sizeDelta = sizeDelta;
return rectTransform;
}
public static RectTransform SetImage(this RectTransform rectTransform, Color color)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
Image val = ((Component)rectTransform).gameObject.AddComponent<Image>();
((Graphic)val).color = color;
return rectTransform;
}
}
[BepInPlugin("bruce.valheim.comfymods.hygge", "Hygge", "1.3.1")]
public class Hygge : BaseUnityPlugin
{
public const string PluginGuid = "bruce.valheim.comfymods.hygge";
public const string PluginName = "Hygge";
public const string PluginVersion = "1.3.1";
private Harmony _harmony;
private void Awake()
{
PluginConfig.BindConfig(((BaseUnityPlugin)this).Config);
_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "bruce.valheim.comfymods.hygge");
}
private void OnDestroy()
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
}
public class PluginConfig
{
public static ConfigEntry<bool> IsModEnabled { get; private set; }
public static void BindConfig(ConfigFile config)
{
IsModEnabled = config.Bind<bool>("_Global", "isModEnabled", true, "Globally enable or disable this mod.");
}
}
public class ComfortPanel
{
private Piece _currentPiece;
private RectTransform _titleLabel;
private RectTransform _groupLabel;
private RectTransform _valueLabel;
private RectTransform _nearestLabel;
private RectTransform _groupValue;
private RectTransform _valueValue;
private RectTransform _nearestValue;
private TMP_Text _groupValueText;
private TMP_Text _valueValueText;
private TMP_Text _nearestValueText;
private static float _fontSize = 0f;
private static float _labelSize = 24f;
private static float _titleSize = 48f;
private static int _maxComfortSearchRadius = 10;
private static readonly int _comfortMin = 1;
private static readonly float _alpha = 0.7f;
private static readonly Dictionary<ComfortGroup, Color> _groupColors = new Dictionary<ComfortGroup, Color>
{
{
(ComfortGroup)1,
new Color(0.54509807f, 0f, 0f, _alpha)
},
{
(ComfortGroup)6,
Color.blue
},
{
(ComfortGroup)3,
new Color(0.5019608f, 0f, 0.5019608f, _alpha)
},
{
(ComfortGroup)5,
Color.yellow
},
{
(ComfortGroup)2,
new Color(0.85490197f, 0.64705884f, 0.1254902f, _alpha)
},
{
(ComfortGroup)4,
new Color(0.6627451f, 0.6627451f, 0.6627451f, _alpha)
},
{
(ComfortGroup)0,
Color.cyan
}
};
private static readonly Dictionary<ComfortGroup, int> _groupMaxValue = new Dictionary<ComfortGroup, int>
{
{
(ComfortGroup)1,
2
},
{
(ComfortGroup)6,
1
},
{
(ComfortGroup)3,
1
},
{
(ComfortGroup)5,
2
},
{
(ComfortGroup)2,
2
},
{
(ComfortGroup)4,
3
},
{
(ComfortGroup)0,
6
}
};
public GameObject Panel { get; private set; }
public static ComfortPanel CreateComfortPanel()
{
Transform val = FindSelectedInfo();
if ((Object)(object)val == (Object)null)
{
ZLog.LogWarning((object)"Failed to find 'SelectedInfo' transform in build hud.");
return null;
}
return new ComfortPanel(val);
}
public ComfortPanel(Transform parentTransform)
{
CreateChildPanel(parentTransform);
}
private void CreateChildPanel(Transform parentTransform)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
Panel = new GameObject("ComfortPanel", new Type[1] { typeof(RectTransform) });
Panel.transform.SetParent(parentTransform, false);
FindFontSize();
ResizePanel();
CreateTitleLabel();
CreateGroupLabel();
CreateValueLabel();
CreateNearestLabel();
ResizeLabels();
CreateGroupValue();
CreateValueValue();
CreateNearestValue();
ResizeValues();
CanvasGroup val = Panel.AddComponent<CanvasGroup>();
val.blocksRaycasts = true;
}
public void Update(Piece piece)
{
_groupValueText.text = ((object)(ComfortGroup)(ref piece.m_comfortGroup)).ToString();
_valueValueText.text = piece.m_comfort.ToString();
_nearestValueText.text = FindNearestSimilarText(piece);
UpdateColor(piece);
}
private string FindNearestSimilarText(Piece piece)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: 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_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = ((Component)Player.m_localPlayer).transform.position;
float num = _maxComfortSearchRadius;
foreach (Piece s_allComfortPiece in Piece.s_allComfortPieces)
{
if (piece.m_comfortGroup == s_allComfortPiece.m_comfortGroup && ((Component)s_allComfortPiece).gameObject != Player.m_localPlayer.m_placementGhost && ((int)s_allComfortPiece.m_comfortGroup != 0 || !(((Object)s_allComfortPiece).name.Replace("(Clone)", "") != ((Object)piece).name)))
{
num = Mathf.Min(Vector3.Distance(position, ((Component)s_allComfortPiece).transform.position), num);
}
}
if (num == (float)_maxComfortSearchRadius)
{
return "None nearby";
}
return num.ToString("0.0") + "m";
}
private void ResizePanel()
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: 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_0111: Unknown result type (might be due to invalid IL or missing references)
RectTransform val = FindBkg();
if ((Object)(object)val == (Object)null)
{
ZLog.LogWarning((object)"Unable to resize Hygge comfort panel. bkg2 UI element not found.");
return;
}
RectTransform rectTransform = Panel.RectTransform().SetAnchorMin(new Vector2(0f, 0f)).SetAnchorMax(new Vector2(1f, 1f))
.SetPivot(new Vector2(0.5f, 0.5f));
float x = val.anchoredPosition.x;
Rect rect = val.rect;
float num = x + ((Rect)(ref rect)).width / 2f;
rect = val.rect;
rectTransform.SetPosition(new Vector2(num + ((Rect)(ref rect)).width / 4f + 5f, val.anchoredPosition.y)).SetImage(new Color(0f, 0f, 0f, 0.5f));
RectTransform obj = Panel.RectTransform();
rect = val.rect;
obj.SetSizeWithCurrentAnchors((Axis)0, ((Rect)(ref rect)).width / 2f);
RectTransform obj2 = Panel.RectTransform();
rect = val.rect;
obj2.SetSizeWithCurrentAnchors((Axis)1, ((Rect)(ref rect)).height);
Panel.SetActive(false);
}
private void ResizeLabels()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: 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_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: 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_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: 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_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_0245: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_02da: Unknown result type (might be due to invalid IL or missing references)
//IL_02df: Unknown result type (might be due to invalid IL or missing references)
//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
//IL_02f4: 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_0308: Unknown result type (might be due to invalid IL or missing references)
//IL_031d: Unknown result type (might be due to invalid IL or missing references)
//IL_0330: Unknown result type (might be due to invalid IL or missing references)
//IL_0335: Unknown result type (might be due to invalid IL or missing references)
//IL_0351: 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)
RectTransform val = Panel.RectTransform();
RectTransform rectTransform = _titleLabel.SetAnchorMin(new Vector2(0.5f, 0.5f)).SetAnchorMax(new Vector2(0.5f, 0.5f)).SetPivot(new Vector2(0.5f, 0.5f));
Rect rect = val.rect;
float num = ((Rect)(ref rect)).height / 2f + val.anchoredPosition.y;
rect = val.rect;
rectTransform.SetPosition(new Vector2(0f, num - ((Rect)(ref rect)).height / 6f));
RectTransform titleLabel = _titleLabel;
rect = val.rect;
titleLabel.SetSizeWithCurrentAnchors((Axis)0, ((Rect)(ref rect)).width);
RectTransform titleLabel2 = _titleLabel;
rect = val.rect;
titleLabel2.SetSizeWithCurrentAnchors((Axis)1, ((Rect)(ref rect)).height / 3f);
RectTransform rectTransform2 = _groupLabel.SetAnchorMin(new Vector2(0.5f, 0.5f)).SetAnchorMax(new Vector2(0.5f, 0.5f)).SetPivot(new Vector2(0.5f, 0.5f));
rect = val.rect;
float num2 = -1f * ((Rect)(ref rect)).width / 4f;
rect = val.rect;
float num3 = ((Rect)(ref rect)).height / 2f + val.anchoredPosition.y;
rect = val.rect;
rectTransform2.SetPosition(new Vector2(num2, num3 - ((Rect)(ref rect)).height / 2f));
RectTransform groupLabel = _groupLabel;
rect = val.rect;
groupLabel.SetSizeWithCurrentAnchors((Axis)0, ((Rect)(ref rect)).width / 2f);
RectTransform groupLabel2 = _groupLabel;
rect = val.rect;
groupLabel2.SetSizeWithCurrentAnchors((Axis)1, ((Rect)(ref rect)).height / 6f);
RectTransform rectTransform3 = _valueLabel.SetAnchorMin(new Vector2(0.5f, 0.5f)).SetAnchorMax(new Vector2(0.5f, 0.5f)).SetPivot(new Vector2(0.5f, 0.5f));
rect = val.rect;
float num4 = -1f * ((Rect)(ref rect)).width / 4f;
rect = val.rect;
float num5 = ((Rect)(ref rect)).height / 2f + val.anchoredPosition.y;
rect = val.rect;
rectTransform3.SetPosition(new Vector2(num4, num5 - ((Rect)(ref rect)).height * 4f / 6f));
RectTransform valueLabel = _valueLabel;
rect = val.rect;
valueLabel.SetSizeWithCurrentAnchors((Axis)0, ((Rect)(ref rect)).width / 2f);
RectTransform valueLabel2 = _valueLabel;
rect = val.rect;
valueLabel2.SetSizeWithCurrentAnchors((Axis)1, ((Rect)(ref rect)).height / 6f);
RectTransform rectTransform4 = _nearestLabel.SetAnchorMin(new Vector2(0.5f, 0.5f)).SetAnchorMax(new Vector2(0.5f, 0.5f)).SetPivot(new Vector2(0.5f, 0.5f));
rect = val.rect;
float num6 = -1f * ((Rect)(ref rect)).width / 4f;
rect = val.rect;
float num7 = ((Rect)(ref rect)).height / 2f;
rect = val.rect;
rectTransform4.SetPosition(new Vector2(num6, num7 - ((Rect)(ref rect)).height * 5f / 6f));
RectTransform nearestLabel = _nearestLabel;
rect = val.rect;
nearestLabel.SetSizeWithCurrentAnchors((Axis)0, ((Rect)(ref rect)).width / 2f);
RectTransform nearestLabel2 = _nearestLabel;
rect = val.rect;
nearestLabel2.SetSizeWithCurrentAnchors((Axis)1, ((Rect)(ref rect)).height / 6f);
}
private void ResizeValues()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: 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_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: 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: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: 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_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: 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_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: 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_0260: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
//IL_0281: Unknown result type (might be due to invalid IL or missing references)
RectTransform val = Panel.RectTransform();
RectTransform rectTransform = _groupValue.SetAnchorMin(new Vector2(0.5f, 0.5f)).SetAnchorMax(new Vector2(0.5f, 0.5f)).SetPivot(new Vector2(0.5f, 0.5f));
Rect rect = val.rect;
float num = ((Rect)(ref rect)).width / 4f;
rect = val.rect;
float num2 = ((Rect)(ref rect)).height / 2f + val.anchoredPosition.y;
rect = val.rect;
rectTransform.SetPosition(new Vector2(num, num2 - ((Rect)(ref rect)).height / 2f));
RectTransform groupValue = _groupValue;
rect = val.rect;
groupValue.SetSizeWithCurrentAnchors((Axis)0, ((Rect)(ref rect)).width / 2f);
RectTransform groupValue2 = _groupValue;
rect = val.rect;
groupValue2.SetSizeWithCurrentAnchors((Axis)1, ((Rect)(ref rect)).height / 6f);
RectTransform rectTransform2 = _valueValue.SetAnchorMin(new Vector2(0.5f, 0.5f)).SetAnchorMax(new Vector2(0.5f, 0.5f)).SetPivot(new Vector2(0.5f, 0.5f));
rect = val.rect;
float num3 = ((Rect)(ref rect)).width / 4f;
rect = val.rect;
float num4 = ((Rect)(ref rect)).height / 2f + val.anchoredPosition.y;
rect = val.rect;
rectTransform2.SetPosition(new Vector2(num3, num4 - ((Rect)(ref rect)).height * 4f / 6f));
RectTransform valueValue = _valueValue;
rect = val.rect;
valueValue.SetSizeWithCurrentAnchors((Axis)0, ((Rect)(ref rect)).width / 2f);
RectTransform valueValue2 = _valueValue;
rect = val.rect;
valueValue2.SetSizeWithCurrentAnchors((Axis)1, ((Rect)(ref rect)).height / 6f);
RectTransform rectTransform3 = _nearestValue.SetAnchorMin(new Vector2(0.5f, 0.5f)).SetAnchorMax(new Vector2(0.5f, 0.5f)).SetPivot(new Vector2(0.5f, 0.5f));
rect = val.rect;
float num5 = ((Rect)(ref rect)).width / 4f;
rect = val.rect;
float num6 = ((Rect)(ref rect)).height / 2f;
rect = val.rect;
rectTransform3.SetPosition(new Vector2(num5, num6 - ((Rect)(ref rect)).height * 5f / 6f));
RectTransform nearestValue = _nearestValue;
rect = val.rect;
nearestValue.SetSizeWithCurrentAnchors((Axis)0, ((Rect)(ref rect)).width / 2f);
RectTransform nearestValue2 = _nearestValue;
rect = val.rect;
nearestValue2.SetSizeWithCurrentAnchors((Axis)1, ((Rect)(ref rect)).height / 6f);
}
private void UpdateColor(Piece piece)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
((Graphic)_groupValueText).color = GetColorByGroup(piece.m_comfortGroup);
((Graphic)_valueValueText).color = GetColorByPercentMax(piece);
}
private Color GetColorByGroup(ComfortGroup comfortGroup)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
if (_groupColors.TryGetValue(comfortGroup, out var value))
{
return value;
}
return Color.white;
}
private Color GetColorByPercentMax(Piece piece)
{
//IL_0007: 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_002a: Invalid comparison between Unknown and I4
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: 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_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
if (!_groupMaxValue.TryGetValue(piece.m_comfortGroup, out var value))
{
return Color.white;
}
if ((int)piece.m_comfortGroup == 0)
{
return Color.white;
}
if (piece.m_comfort == value)
{
return Color.green;
}
if (piece.m_comfort == _comfortMin)
{
return Color.red;
}
return new Color(255f, 140f, 0f, _alpha);
}
private void CreateTitleLabel()
{
_titleLabel = CreateLabel("comfortTitle", "Comfort Info", GetTitleFontSize(), (TextAlignmentOptions)514);
}
private void CreateGroupLabel()
{
_groupLabel = CreateLabel("comfortGroup", "Comfort Group: ", GetLabelFontSize(), (TextAlignmentOptions)513);
}
private void CreateValueLabel()
{
_valueLabel = CreateLabel("comfortValue", "Comfort Value: ", GetLabelFontSize(), (TextAlignmentOptions)513);
}
private void CreateNearestLabel()
{
_nearestLabel = CreateLabel("nearestSimilar", "Nearest similar: ", GetLabelFontSize(), (TextAlignmentOptions)513);
}
private void CreateGroupValue()
{
_groupValue = CreateLabel("groupValue", "", GetLabelFontSize(), (TextAlignmentOptions)513);
_groupValueText = ((Component)_groupValue).GetComponent<TMP_Text>();
}
private void CreateValueValue()
{
_valueValue = CreateLabel("valueValue", "", GetLabelFontSize(), (TextAlignmentOptions)513);
_valueValueText = ((Component)_valueValue).GetComponent<TMP_Text>();
}
private void CreateNearestValue()
{
_nearestValue = CreateLabel("nearestValue", "", GetLabelFontSize(), (TextAlignmentOptions)513);
_nearestValueText = ((Component)_nearestValue).GetComponent<TMP_Text>();
}
private RectTransform CreateLabel(string objName, string text, float fontSize, TextAlignmentOptions alignment)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
GameObject val = new GameObject(objName, new Type[1] { typeof(RectTransform) });
val.transform.SetParent(Panel.transform);
TMP_Text val2 = (TMP_Text)(object)val.AddComponent<TextMeshProUGUI>();
val2.text = text;
val2.fontSize = fontSize;
val2.alignment = alignment;
return (RectTransform)val.transform;
}
private static Transform FindSelectedInfo()
{
return Hud.instance.m_buildHud.transform.Find("SelectedInfo");
}
private static void FindFontSize()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//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)
Resolution currentResolution = Screen.currentResolution;
_titleSize = 0.0124f * (float)((Resolution)(ref currentResolution)).width;
currentResolution = Screen.currentResolution;
_labelSize = 0.0062f * (float)((Resolution)(ref currentResolution)).width;
}
private static float GetLabelFontSize()
{
return _labelSize;
}
private static float GetTitleFontSize()
{
return _titleSize;
}
private static RectTransform FindBkg()
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
Transform val = Hud.instance.m_buildHud.transform.Find("SelectedInfo");
if ((Object)(object)val == (Object)null)
{
ZLog.LogWarning((object)"SelectedInfo transform not found building comfort panel.");
return null;
}
Transform val2 = val.Find("Bkg2");
if ((Object)(object)val2 == (Object)null)
{
ZLog.LogWarning((object)"Bkg2 not found building comfort panel.");
return null;
}
return (RectTransform)val2;
}
}
}
namespace Hygge.Patches
{
[HarmonyPatch(typeof(Hud))]
public class HudPatch
{
[HarmonyPostfix]
[HarmonyPatch("SetupPieceInfo")]
private static void SetupPieceInfoPostfix(ref Hud __instance, Piece piece)
{
if (PluginConfig.IsModEnabled.Value)
{
Piece val = default(Piece);
if (Object.op_Implicit((Object)(object)piece) && piece.m_comfort == 0)
{
ComfortPanelManager.ToggleOff();
}
else if (Object.op_Implicit((Object)(object)__instance.m_hoveredPiece) && __instance.m_hoveredPiece.m_comfort != 0)
{
ComfortPanelManager.ToggleOn(__instance.m_hoveredPiece);
ComfortPanelManager.Update(__instance.m_hoveredPiece);
}
else if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)Player.m_localPlayer.m_placementGhost) && Player.m_localPlayer.m_placementGhost.TryGetComponent<Piece>(ref val) && val.m_comfort != 0)
{
ComfortPanelManager.ToggleOn(val);
ComfortPanelManager.Update(val);
}
else
{
ComfortPanelManager.ToggleOff();
}
}
}
[HarmonyPostfix]
[HarmonyPatch("OnDestroy")]
private static void OnDestroyPostfix(ref Hud __instance)
{
if (PluginConfig.IsModEnabled.Value && Object.op_Implicit((Object)(object)ComfortPanelManager.ComfortPanel?.Panel))
{
ComfortPanelManager.DestroyPanel();
}
}
}
[HarmonyPatch(typeof(GraphicsSettings))]
internal static class SettingsPatch
{
[HarmonyPostfix]
[HarmonyPatch("ApplyResolution")]
public static void ApplyResolutionPostfix(ref GraphicsSettings __instance)
{
if (PluginConfig.IsModEnabled.Value && Object.op_Implicit((Object)(object)ComfortPanelManager.ComfortPanel?.Panel))
{
ComfortPanelManager.DestroyPanel();
}
}
}
}