using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ValheimClock")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ValheimClock")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("18563418-e175-483a-8c43-8b1defa61eca")] [assembly: AssemblyFileVersion("1.5.2.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.5.2.0")] namespace ClockMod; [HarmonyPatch(typeof(Hud), "UpdateStatusEffects", new Type[] { typeof(List) })] public static class HudPatches { [HarmonyAfter(new string[] { "randyknapp.mods.minimalstatuseffects" })] [HarmonyPostfix] public static void Postfix(RectTransform ___m_statusEffectListRoot) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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) if (ClockPlugin.HasMSE && !((Object)(object)___m_statusEffectListRoot == (Object)null) && !(Mathf.Abs(ClockPlugin.ConfigPosX.Value) > 100f)) { float num = ClockPlugin.ConfigHeight.Value; if (ClockPlugin.ConfigLayoutStyle.Value == TextLayoutStyle.Stacked) { num += 20f; } if (ClockPlugin.ConfigShowWeather.Value) { num += 20f; } if (ClockPlugin.ConfigShowTimeSlider.Value) { num += 18f; } float num2 = Mathf.Abs(ClockPlugin.ConfigPosY.Value); float num3 = num + num2 + 15f; ___m_statusEffectListRoot.anchoredPosition = new Vector2(___m_statusEffectListRoot.anchoredPosition.x, ___m_statusEffectListRoot.anchoredPosition.y - num3); } } } [HarmonyPatch(typeof(Minimap))] public static class MinimapPatches { private static int _cachedDisplayDay = -1; private static int _cachedHours = -1; private static int _cachedMinutes = -1; private static TextLayoutStyle _cachedLayout = TextLayoutStyle.SingleLine; private static bool _cached12HourFormat = false; private static bool _cachedShowWeather = false; private static string _cachedWeather = ""; private static int _cachedWeatherFontSize = -1; private static int _cachedMainFontSize = -1; private static ClockTheme _cachedTheme = ClockTheme.Valheim; [HarmonyPatch("Start")] [HarmonyPostfix] public static void Start_Postfix(Minimap __instance) { if (!((Object)(object)__instance.m_smallRoot == (Object)null)) { ClockUI.Build(__instance.m_smallRoot.transform); } } [HarmonyPatch("Update")] [HarmonyPostfix] public static void Update_Postfix(Minimap __instance) { //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: 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_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ClockUI.ClockText == (Object)null || (Object)(object)EnvMan.instance == (Object)null || (Object)(object)ZNet.instance == (Object)null) { return; } bool activeSelf = __instance.m_smallRoot.activeSelf; ClockUI.Panel.SetActive(activeSelf); if (!activeSelf) { return; } double timeSeconds = ZNet.instance.GetTimeSeconds(); long dayLengthSec = EnvMan.instance.m_dayLengthSec; int day = EnvMan.instance.GetDay(timeSeconds); float num = (float)(timeSeconds % (double)dayLengthSec) / (float)dayLengthSec; int num2 = Mathf.FloorToInt(num * 24f); int num3 = Mathf.FloorToInt((num * 24f - (float)num2) * 60f); TextLayoutStyle value = ClockPlugin.ConfigLayoutStyle.Value; bool value2 = ClockPlugin.ConfigUse12HourFormat.Value; bool value3 = ClockPlugin.ConfigShowWeather.Value; int value4 = ClockPlugin.ConfigWeatherFontSize.Value; int value5 = ClockPlugin.ConfigFontSize.Value; ClockTheme value6 = ClockPlugin.ConfigTheme.Value; string internalName = ((!value3) ? "" : (EnvMan.instance.GetCurrentEnvironment()?.m_name ?? "")); internalName = TranslateWeather(internalName); if (day == _cachedDisplayDay && num2 == _cachedHours && num3 == _cachedMinutes && value == _cachedLayout && value2 == _cached12HourFormat && value3 == _cachedShowWeather && internalName == _cachedWeather && value4 == _cachedWeatherFontSize && value5 == _cachedMainFontSize && value6 == _cachedTheme) { return; } _cachedDisplayDay = day; _cachedHours = num2; _cachedMinutes = num3; _cachedLayout = value; _cached12HourFormat = value2; _cachedShowWeather = value3; _cachedWeather = internalName; _cachedWeatherFontSize = value4; _cachedMainFontSize = value5; _cachedTheme = value6; string text = ((value == TextLayoutStyle.Stacked) ? "\n" : " "); string text2; if (value2) { string arg = ((num2 >= 12) ? "PM" : "AM"); int num4 = num2 % 12; if (num4 == 0) { num4 = 12; } text2 = $"{num4:D2}:{num3:D2} {arg}"; } else { text2 = $"{num2:D2}:{num3:D2}"; } if (ClockPlugin.ConfigShowTimeSlider.Value && (Object)(object)ClockUI.TimeSlider != (Object)null) { ClockUI.TimeSlider.value = num; Color dayColor = ThemeManager.GetDayColor(value6); Color nightColor = ThemeManager.GetNightColor(value6); Color dayIconColor = ThemeManager.GetDayIconColor(value6); Color nightIconColor = ThemeManager.GetNightIconColor(value6); float num5 = Mathf.Abs(num - 0.5f) * 2f; num5 = Mathf.SmoothStep(0f, 1f, num5); ((Graphic)ClockUI.SliderFill).color = Color.Lerp(dayColor, nightColor, num5); if ((Object)(object)ClockUI.SliderIconText != (Object)null) { bool flag = num >= 0.25f && num < 0.75f; ClockUI.SliderIconText.text = (flag ? "☀" : "☾"); ((Graphic)ClockUI.SliderIconText).color = Color.Lerp(dayIconColor, nightIconColor, num5); } } string text3 = ((value3 && !string.IsNullOrEmpty(internalName)) ? ("\n" + internalName) : ""); ClockUI.ClockText.text = $"Day {day}{text}{text2}{text3}"; } private static string TranslateWeather(string internalName) { //IL_0644: 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) switch (internalName) { case "Clear": return "Clear Skies"; case "LightRain": return "Light Rain"; case "Rain": return "Raining"; case "ThunderStorm": return "Thunderstorm"; case "Snow": return "Snowing"; case "WarmSnow": return "Warm Snow"; case "WarmSnowStorm": return "Warm Snowstorm"; case "SnowStorm": return "Blizzard"; case "Ashlands_ashrain": return "Ash Rain"; case "Ashlands_ashrain_clear": return "Ash Clear"; case "Ashlands_CinderRain": return "Cinder Rain"; case "Ashlands_meteorshower": return "Meteor Shower"; case "Ashlands_misty": return "Ashlands Fog"; case "Ashlands_storm": return "Ashlands Storm"; case "Ashlands_SeaStorm": return "Ashlands Seastorm"; case "Darklands_dark": return "Mistlands Dark"; case "Mistlands_clear": return "Mislands Clear"; case "Mistlands_rain": return "Mistlands Rain"; case "Mistlands_thunder": return "Mistlands Thunder"; case "Twilight_Clear": return "Twilight Clear"; case "Twilight_Snow": return "Twilight Snow"; case "Twilight_SnowStorm": return "Twilight Snowstorm"; case "Heath_clear": return "Clear Skies"; case "DeepForest Mist": return "Black Forest Fog"; case "SwampRain": return "Swamp Rain"; case "Caves": return "Freezing"; case "CavesHildir": return "Freezing"; case "SunkenCrypt": return "Sunken Crypt"; case "Crypt": return "Crypt"; case "CryptHildir": return "Crypt Hildir"; case "InfectedMine": return "Infected Mine"; case "NightFrost": return "Night Frost"; case "Queen": return "Queen's Jam"; case "Eikthyr": return "Eikthyr's Thunderstorm"; case "GDKing": return "The Elder's Haze"; case "Bonemass": return "Bonemass' Downpour"; case "Moder": return "Moder's Vortex"; case "GoblinKing": return "Yagluth's Magic Blizzard"; case "Misty": { object obj; if (!((Object)(object)Player.m_localPlayer != (Object)null)) { obj = ""; } else { Biome currentBiome = Player.m_localPlayer.GetCurrentBiome(); obj = ((object)(Biome)(ref currentBiome)).ToString(); } string text = (string)obj; if (text == "Plains") { return "Plains Fog"; } if (text == "Ocean") { return "Ocean Fog"; } return "Fog"; } default: return internalName; } } } public static class ClockUI { private static Sprite _uiSprite; private static Sprite _knobSprite; public static GameObject Panel { get; private set; } public static Text ClockText { get; private set; } public static Slider TimeSlider { get; private set; } public static Image SliderFill { get; private set; } public static GameObject SliderRoot { get; private set; } public static Text SliderIconText { get; private set; } public static Image TopTrim { get; private set; } public static Image BottomTrim { get; private set; } public static void Build(Transform parentRoot) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_017c: 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_01ae: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Panel != (Object)null)) { Panel = new GameObject("ClockUI"); Panel.transform.SetParent(parentRoot, false); _uiSprite = ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)((Sprite s) => ((Object)s).name == "UISprite" || ((Object)s).name == "Background")); _knobSprite = ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)((Sprite s) => ((Object)s).name == "Knob")); RectTransform obj = Panel.AddComponent(); obj.anchorMin = new Vector2(0.5f, 0f); obj.anchorMax = new Vector2(0.5f, 0f); obj.pivot = new Vector2(0.5f, 1f); ((Graphic)Panel.AddComponent()).color = new Color(0.05f, 0.05f, 0.05f, 0.95f); TopTrim = CreateBorder("TopTrim", new Vector2(0f, 1f), new Vector2(1f, 1f)); BottomTrim = CreateBorder("BottomTrim", new Vector2(0f, 0f), new Vector2(1f, 0f)); CreateRivet("TopLeftRivet", new Vector2(0f, 1f)); CreateRivet("TopRightRivet", new Vector2(1f, 1f)); CreateRivet("BottomLeftRivet", new Vector2(0f, 0f)); CreateRivet("BottomRightRivet", new Vector2(1f, 0f)); BuildTextElement(); BuildSliderElement(); ApplyConfigs(); } } private static void BuildTextElement() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0027: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ClockText"); val.transform.SetParent(Panel.transform, false); RectTransform obj = val.AddComponent(); obj.anchorMin = Vector2.zero; obj.anchorMax = Vector2.one; obj.offsetMin = new Vector2(5f, 0f); obj.offsetMax = new Vector2(-5f, 0f); ClockText = val.AddComponent(); ClockText.alignment = (TextAnchor)4; ((Graphic)ClockText).color = Color.white; ClockText.lineSpacing = 0.9f; ClockText.text = "..."; ClockText.supportRichText = true; ClockText.horizontalOverflow = (HorizontalWrapMode)0; ClockText.verticalOverflow = (VerticalWrapMode)0; ClockText.resizeTextForBestFit = true; ClockText.resizeTextMinSize = 8; ClockText.resizeTextMaxSize = 30; Font val2 = ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)((Font f) => ((Object)f).name == "AveriaSerifLibre-Bold")); if ((Object)(object)val2 != (Object)null) { ClockText.font = val2; } Outline obj2 = val.AddComponent(); ((Shadow)obj2).effectColor = Color.black; ((Shadow)obj2).effectDistance = new Vector2(1f, -1f); } private static void BuildSliderElement() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_003e: 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_007c: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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_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_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Expected O, but got Unknown //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0270: 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_0303: Unknown result type (might be due to invalid IL or missing references) SliderRoot = new GameObject("TimeSlider"); SliderRoot.transform.SetParent(Panel.transform, false); RectTransform obj = SliderRoot.AddComponent(); obj.anchorMin = new Vector2(0f, 0f); obj.anchorMax = new Vector2(1f, 0f); obj.offsetMin = new Vector2(10f, 8f); obj.offsetMax = new Vector2(-10f, 12f); GameObject val = new GameObject("Background"); val.transform.SetParent(SliderRoot.transform, false); Image val2 = val.AddComponent(); ((Graphic)val2).color = new Color(0.1f, 0.1f, 0.1f, 1f); if ((Object)(object)_uiSprite != (Object)null) { val2.sprite = _uiSprite; val2.type = (Type)1; } RectTransform component = val.GetComponent(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.sizeDelta = Vector2.zero; GameObject val3 = new GameObject("FillArea"); val3.transform.SetParent(SliderRoot.transform, false); RectTransform obj2 = val3.AddComponent(); obj2.anchorMin = Vector2.zero; obj2.anchorMax = Vector2.one; obj2.sizeDelta = Vector2.zero; GameObject val4 = new GameObject("Fill"); val4.transform.SetParent(val3.transform, false); SliderFill = val4.AddComponent(); ((Graphic)SliderFill).color = new Color(1f, 0.75f, 0.3f, 1f); if ((Object)(object)_uiSprite != (Object)null) { SliderFill.sprite = _uiSprite; SliderFill.type = (Type)1; } RectTransform component2 = val4.GetComponent(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.sizeDelta = Vector2.zero; GameObject val5 = new GameObject("HandleArea"); val5.transform.SetParent(SliderRoot.transform, false); RectTransform obj3 = val5.AddComponent(); obj3.anchorMin = Vector2.zero; obj3.anchorMax = Vector2.one; obj3.sizeDelta = Vector2.zero; GameObject val6 = new GameObject("Handle"); val6.transform.SetParent(val5.transform, false); RectTransform val7 = val6.AddComponent(); val7.sizeDelta = new Vector2(25f, 25f); SliderIconText = val6.AddComponent(); SliderIconText.alignment = (TextAnchor)4; SliderIconText.horizontalOverflow = (HorizontalWrapMode)1; SliderIconText.verticalOverflow = (VerticalWrapMode)1; SliderIconText.fontSize = 16; Font val8 = ((IEnumerable)Resources.FindObjectsOfTypeAll()).FirstOrDefault((Func)((Font f) => ((Object)f).name == "AveriaSerifLibre-Bold")); if ((Object)(object)val8 != (Object)null) { SliderIconText.font = val8; } Outline obj4 = val6.AddComponent(); ((Shadow)obj4).effectColor = Color.black; ((Shadow)obj4).effectDistance = new Vector2(1f, -1f); TimeSlider = SliderRoot.AddComponent(); ((Selectable)TimeSlider).interactable = false; ((Selectable)TimeSlider).transition = (Transition)0; TimeSlider.fillRect = component2; TimeSlider.handleRect = val7; TimeSlider.minValue = 0f; TimeSlider.maxValue = 1f; } private static Image CreateBorder(string name, Vector2 anchorMin, Vector2 anchorMax) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_005f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(Panel.transform, false); RectTransform obj = val.AddComponent(); obj.anchorMin = anchorMin; obj.anchorMax = anchorMax; obj.sizeDelta = new Vector2(0f, 2f); obj.anchoredPosition = Vector2.zero; Image obj2 = val.AddComponent(); ((Graphic)obj2).color = ThemeManager.GetBorderColor(ClockPlugin.ConfigTheme.Value); return obj2; } private static void CreateRivet(string name, Vector2 anchorPosition) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_006a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(Panel.transform, false); RectTransform obj = val.AddComponent(); obj.anchorMin = anchorPosition; obj.anchorMax = anchorPosition; obj.sizeDelta = new Vector2(8f, 8f); obj.anchoredPosition = Vector2.zero; Image val2 = val.AddComponent(); ((Graphic)val2).color = new Color(0.6f, 0.6f, 0.6f, 1f); if ((Object)(object)_knobSprite != (Object)null) { val2.sprite = _knobSprite; } } public static void ApplyConfigs() { //IL_0037: 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_005d: 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_0116: 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) if (!((Object)(object)Panel == (Object)null) && !((Object)(object)ClockText == (Object)null)) { if ((Object)(object)TopTrim != (Object)null) { ((Graphic)TopTrim).color = ThemeManager.GetBorderColor(ClockPlugin.ConfigTheme.Value); } if ((Object)(object)BottomTrim != (Object)null) { ((Graphic)BottomTrim).color = ThemeManager.GetBorderColor(ClockPlugin.ConfigTheme.Value); } RectTransform component = Panel.GetComponent(); component.anchoredPosition = new Vector2(ClockPlugin.ConfigPosX.Value, ClockPlugin.ConfigPosY.Value); float num = ClockPlugin.ConfigWidth.Value; float num2 = ClockPlugin.ConfigHeight.Value; if (ClockPlugin.ConfigUse12HourFormat.Value) { num += 20f; } if (ClockPlugin.ConfigLayoutStyle.Value == TextLayoutStyle.Stacked) { num2 += 20f; } if (ClockPlugin.ConfigShowWeather.Value) { num2 += 20f; } if (ClockPlugin.ConfigShowTimeSlider.Value) { num2 += 18f; SliderRoot.SetActive(true); ((Graphic)ClockText).rectTransform.offsetMin = new Vector2(5f, 18f); } else { SliderRoot.SetActive(false); ((Graphic)ClockText).rectTransform.offsetMin = new Vector2(5f, 0f); } component.sizeDelta = new Vector2(num, num2); ClockText.fontSize = ClockPlugin.ConfigWeatherFontSize.Value; ClockText.resizeTextMaxSize = ClockPlugin.ConfigWeatherFontSize.Value; } } } public enum ClockTheme { Valheim, Blood, Ocean, Nature, Monochrome } public enum TextLayoutStyle { SingleLine, Stacked } [BepInPlugin("com.orfox.valheimclock", "Valheim Clock", "1.5.2")] [BepInProcess("valheim.exe")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ClockPlugin : BaseUnityPlugin { public const string PluginGUID = "com.orfox.valheimclock"; public const string PluginName = "Valheim Clock"; public const string PluginVersion = "1.5.2"; private readonly Harmony _harmony = new Harmony("com.orfox.valheimclock"); public static ConfigEntry ConfigPosX; public static ConfigEntry ConfigPosY; public static ConfigEntry ConfigWidth; public static ConfigEntry ConfigHeight; public static ConfigEntry ConfigFontSize; public static ConfigEntry ConfigWeatherFontSize; public static ConfigEntry ConfigUse12HourFormat; public static ConfigEntry ConfigLayoutStyle; public static ConfigEntry ConfigShowWeather; public static ConfigEntry ConfigShowTimeSlider; public static ConfigEntry ConfigTheme; public static bool HasMSE { get; private set; } private void Awake() { HasMSE = Chainloader.PluginInfos.ContainsKey("randyknapp.mods.minimalstatuseffects"); ConfigPosX = ((BaseUnityPlugin)this).Config.Bind("Position", "Offset X", 0f, "Horizontal offset relative to the bottom center of the minimap."); ConfigPosY = ((BaseUnityPlugin)this).Config.Bind("Position", "Offset Y", -10f, "Vertical offset relative to the bottom center of the minimap."); ConfigWidth = ((BaseUnityPlugin)this).Config.Bind("Visuals", "Panel Width", 160f, "Width of the clock panel."); ConfigHeight = ((BaseUnityPlugin)this).Config.Bind("Visuals", "Panel Height", 34f, "Height of the clock panel."); ConfigFontSize = ((BaseUnityPlugin)this).Config.Bind("Visuals", "Font Size", 18, "Size of the clock text."); ConfigWeatherFontSize = ((BaseUnityPlugin)this).Config.Bind("Visuals", "Weather Font Size", 14, "Size of the weather text."); ConfigUse12HourFormat = ((BaseUnityPlugin)this).Config.Bind("General", "Use12HourFormat", false, "If true, displays the clock in a 12-hour format with AM/PM instead of 24-hour format time."); ConfigLayoutStyle = ((BaseUnityPlugin)this).Config.Bind("Visuals", "Text Layout", TextLayoutStyle.SingleLine, "Day and time arrangement."); ConfigShowWeather = ((BaseUnityPlugin)this).Config.Bind("General", "Show Weather", false, "If true, displays the current weather/environment alongside the time."); ConfigShowTimeSlider = ((BaseUnityPlugin)this).Config.Bind("General", "Show Time Slider", false, "If true, displays a progress bar at the bottom tracking the day/night cycle."); ConfigTheme = ((BaseUnityPlugin)this).Config.Bind("Visuals", "Theme", ClockTheme.Valheim, "Color theme of the clock UI and slider."); PropertyInfo property = typeof(ConfigFile).GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic); if (property != null) { (property.GetValue(((BaseUnityPlugin)this).Config, null) as IDictionary)?.Clear(); } _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"ClockMod initialized."); SetupConfigWatcher(); } private void SetupConfigWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, "com.orfox.valheimclock.cfg"); fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; fileSystemWatcher.Changed += ReloadConfig; fileSystemWatcher.Created += ReloadConfig; fileSystemWatcher.Renamed += ReloadConfig; } private void ReloadConfig(object sender, FileSystemEventArgs e) { if (!File.Exists(((BaseUnityPlugin)this).Config.ConfigFilePath)) { return; } try { ((BaseUnityPlugin)this).Config.Reload(); ClockUI.ApplyConfigs(); } catch { } } } public static class ThemeManager { public static Color GetBorderColor(ClockTheme theme) { //IL_002e: 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_0062: 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_0096: Unknown result type (might be due to invalid IL or missing references) return (Color)(theme switch { ClockTheme.Blood => new Color(0.6f, 0.1f, 0.1f, 1f), ClockTheme.Ocean => new Color(0.2f, 0.6f, 0.8f, 1f), ClockTheme.Nature => new Color(0.3f, 0.6f, 0.2f, 1f), ClockTheme.Monochrome => new Color(0.8f, 0.8f, 0.8f, 1f), _ => new Color(0.85f, 0.65f, 0.2f, 1f), }); } public static Color GetDayColor(ClockTheme theme) { //IL_002e: 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_0062: 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_0096: Unknown result type (might be due to invalid IL or missing references) return (Color)(theme switch { ClockTheme.Blood => new Color(0.8f, 0.2f, 0.2f, 1f), ClockTheme.Ocean => new Color(0.3f, 0.8f, 0.9f, 1f), ClockTheme.Nature => new Color(0.4f, 0.8f, 0.3f, 1f), ClockTheme.Monochrome => new Color(0.9f, 0.9f, 0.9f, 1f), _ => new Color(1f, 0.75f, 0.3f, 1f), }); } public static Color GetNightColor(ClockTheme theme) { //IL_002e: 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_0062: 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_0096: Unknown result type (might be due to invalid IL or missing references) return (Color)(theme switch { ClockTheme.Blood => new Color(0.3f, 0.05f, 0.05f, 1f), ClockTheme.Ocean => new Color(0.1f, 0.3f, 0.6f, 1f), ClockTheme.Nature => new Color(0.1f, 0.4f, 0.2f, 1f), ClockTheme.Monochrome => new Color(0.3f, 0.3f, 0.3f, 1f), _ => new Color(0.3f, 0.5f, 1f, 1f), }); } public static Color GetDayIconColor(ClockTheme theme) { //IL_002e: 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_0062: 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_0096: Unknown result type (might be due to invalid IL or missing references) return (Color)(theme switch { ClockTheme.Blood => new Color(1f, 0.4f, 0.4f, 1f), ClockTheme.Ocean => new Color(0.6f, 0.9f, 1f, 1f), ClockTheme.Nature => new Color(0.6f, 0.9f, 0.4f, 1f), ClockTheme.Monochrome => new Color(1f, 1f, 1f, 1f), _ => new Color(1f, 0.85f, 0.2f, 1f), }); } public static Color GetNightIconColor(ClockTheme theme) { //IL_002e: 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_0062: 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_0096: Unknown result type (might be due to invalid IL or missing references) return (Color)(theme switch { ClockTheme.Blood => new Color(0.5f, 0.1f, 0.1f, 1f), ClockTheme.Ocean => new Color(0.2f, 0.4f, 0.8f, 1f), ClockTheme.Nature => new Color(0.2f, 0.5f, 0.3f, 1f), ClockTheme.Monochrome => new Color(0.5f, 0.5f, 0.5f, 1f), _ => new Color(0.6f, 0.8f, 1f, 1f), }); } }