Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ValheimClock v1.1.1
ValheimClock.dll
Decompiled 21 minutes agousing System; 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.1.1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.1.1.0")] namespace ClockMod; [HarmonyPatch(typeof(Hud), "UpdateStatusEffects", new Type[] { typeof(List<StatusEffect>) })] public static class HudPatches { [HarmonyAfter(new string[] { "randyknapp.mods.minimalstatuseffects" })] [HarmonyPostfix] public static void Postfix(RectTransform ___m_statusEffectListRoot) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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) if (ClockPlugin.HasMSE && !((Object)(object)___m_statusEffectListRoot == (Object)null)) { float num = ClockPlugin.ConfigHeight.Value + 15f; ___m_statusEffectListRoot.anchoredPosition = new Vector2(___m_statusEffectListRoot.anchoredPosition.x, ___m_statusEffectListRoot.anchoredPosition.y - num); } } } [HarmonyPatch(typeof(Minimap))] public static class MinimapPatches { [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) { if (!((Object)(object)ClockUI.ClockText == (Object)null) && !((Object)(object)EnvMan.instance == (Object)null) && !((Object)(object)ZNet.instance == (Object)null)) { bool activeSelf = __instance.m_smallRoot.activeSelf; ClockUI.Panel.SetActive(activeSelf); if (activeSelf) { int day = EnvMan.instance.GetDay(ZNet.instance.GetTimeSeconds()); float dayFraction = EnvMan.instance.GetDayFraction(); int num = Mathf.FloorToInt(dayFraction * 24f); int num2 = Mathf.FloorToInt((dayFraction * 24f - (float)num) * 60f); string text = ((ClockPlugin.ConfigLayoutStyle.Value == TextLayoutStyle.Stacked) ? "\n" : " "); ClockUI.ClockText.text = $"Day {day}{text}{num:D2}:{num2:D2}"; } } } } public static class ClockUI { public static GameObject Panel { get; private set; } public static Text ClockText { 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_0043: 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_006c: 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_00ad: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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); RectTransform obj = Panel.AddComponent<RectTransform>(); obj.anchorMin = new Vector2(0.5f, 0f); obj.anchorMax = new Vector2(0.5f, 0f); obj.pivot = new Vector2(0.5f, 1f); ((Graphic)Panel.AddComponent<Image>()).color = new Color(0.05f, 0.05f, 0.05f, 0.95f); CreateBorder("TopTrim", new Vector2(0f, 1f), new Vector2(1f, 1f)); 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(); 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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<RectTransform>(); obj.anchorMin = Vector2.zero; obj.anchorMax = Vector2.one; obj.offsetMin = new Vector2(5f, 0f); obj.offsetMax = new Vector2(-5f, 0f); ClockText = val.AddComponent<Text>(); ClockText.alignment = (TextAnchor)4; ((Graphic)ClockText).color = Color.white; ClockText.lineSpacing = 0.9f; ClockText.text = "..."; Font val2 = ((IEnumerable<Font>)Resources.FindObjectsOfTypeAll<Font>()).FirstOrDefault((Func<Font, bool>)((Font f) => ((Object)f).name == "AveriaSerifLibre-Bold")); if ((Object)(object)val2 != (Object)null) { ClockText.font = val2; } Outline obj2 = val.AddComponent<Outline>(); ((Shadow)obj2).effectColor = Color.black; ((Shadow)obj2).effectDistance = new Vector2(1f, -1f); } private static void 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_0068: 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<RectTransform>(); obj.anchorMin = anchorMin; obj.anchorMax = anchorMax; obj.sizeDelta = new Vector2(0f, 2f); obj.anchoredPosition = Vector2.zero; ((Graphic)val.AddComponent<Image>()).color = new Color(0.85f, 0.65f, 0.2f, 1f); } 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_0068: 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<RectTransform>(); obj.anchorMin = anchorPosition; obj.anchorMax = anchorPosition; obj.sizeDelta = new Vector2(4f, 4f); obj.anchoredPosition = Vector2.zero; ((Graphic)val.AddComponent<Image>()).color = new Color(0.6f, 0.6f, 0.6f, 1f); } public static void ApplyConfigs() { //IL_003a: 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) if (!((Object)(object)Panel == (Object)null) && !((Object)(object)ClockText == (Object)null)) { RectTransform component = Panel.GetComponent<RectTransform>(); component.anchoredPosition = new Vector2(ClockPlugin.ConfigPosX.Value, ClockPlugin.ConfigPosY.Value); component.sizeDelta = new Vector2(ClockPlugin.ConfigWidth.Value, ClockPlugin.ConfigHeight.Value); ClockText.fontSize = ClockPlugin.ConfigFontSize.Value; } } } public enum TextLayoutStyle { SingleLine, Stacked } [BepInPlugin("com.orfox.valheimclock", "Valheim Clock", "1.1.1")] [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.1.1"; private readonly Harmony _harmony = new Harmony("com.orfox.valheimclock"); public static ConfigEntry<float> ConfigPosX; public static ConfigEntry<float> ConfigPosY; public static ConfigEntry<float> ConfigWidth; public static ConfigEntry<float> ConfigHeight; public static ConfigEntry<int> ConfigFontSize; public static ConfigEntry<TextLayoutStyle> ConfigLayoutStyle; public static bool HasMSE { get; private set; } private void Awake() { HasMSE = Chainloader.PluginInfos.ContainsKey("randyknapp.mods.minimalstatuseffects"); ConfigPosX = ((BaseUnityPlugin)this).Config.Bind<float>("1. Position", "Offset X", 0f, "Horizontal offset relative to the bottom center of the minimap."); ConfigPosY = ((BaseUnityPlugin)this).Config.Bind<float>("1. Position", "Offset Y", -10f, "Vertical offset relative to the bottom center of the minimap."); ConfigWidth = ((BaseUnityPlugin)this).Config.Bind<float>("2. Visuals", "Panel Width", 160f, "Width of the clock panel."); ConfigHeight = ((BaseUnityPlugin)this).Config.Bind<float>("2. Visuals", "Panel Height", 34f, "Height of the clock panel."); ConfigFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("2. Visuals", "Font Size", 18, "Size of the clock text."); ConfigLayoutStyle = ((BaseUnityPlugin)this).Config.Bind<TextLayoutStyle>("2. Visuals", "Text Layout", TextLayoutStyle.SingleLine, "Day and time arrangement."); _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 { } } }