Please disclose if your mod was created primarily 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 DayUtil v1.1.4
DayUtil.dll
Decompiled a year agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ValheimDayReset")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ValheimDayReset")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("0606acb2-7d2d-4a74-b00a-992acf2051d0")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] [BepInPlugin("com.acesgaminguk.valheim.resetday", "DayUtil", "1.1.2")] public class DayUtil : BaseUnityPlugin { private ConfigEntry<bool> cfgShowHud; private ConfigEntry<int> cfgFontSize; private ConfigEntry<float> cfgFontWeight; private ConfigEntry<float> cfgFontScale; private ConfigEntry<Color> cfgTextColor; private ConfigEntry<bool> cfgShadow; private ConfigEntry<bool> cfgShowBackground; private ConfigEntry<int> cfgPadding; private static FieldInfo totalSecondsField; private GUIStyle _textStyle; private Rect _hudPosition; private bool isDragging; private Vector2 dragOffset; private void Awake() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Expected O, but got Unknown //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: 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_01fe: Expected O, but got Unknown //IL_01f9: 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_0223: Expected O, but got Unknown //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Expected O, but got Unknown //IL_0243: Unknown result type (might be due to invalid IL or missing references) totalSecondsField = typeof(EnvMan).GetField("m_totalSeconds", BindingFlags.Instance | BindingFlags.NonPublic); cfgShowHud = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowHud", true, "Show the in-game day/time HUD"); cfgFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("Text", "FontSize", 18, new ConfigDescription("Font size of the HUD", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 40), Array.Empty<object>())); cfgFontWeight = ((BaseUnityPlugin)this).Config.Bind<float>("Text", "FontWeight", 1f, new ConfigDescription("Multiplier for text boldness (1.0 = normal)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 3f), Array.Empty<object>())); cfgFontScale = ((BaseUnityPlugin)this).Config.Bind<float>("Text", "FontScale", 1f, new ConfigDescription("Scale multiplier for the HUD text", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>())); cfgTextColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Text", "TextColor", new Color(1f, 0.64f, 0f), "Text color of the HUD label"); cfgShadow = ((BaseUnityPlugin)this).Config.Bind<bool>("Text", "Shadow", true, "Draw a shadow under the HUD text"); cfgShowBackground = ((BaseUnityPlugin)this).Config.Bind<bool>("Box", "ShowBackground", false, "Draw a background box behind the text"); cfgPadding = ((BaseUnityPlugin)this).Config.Bind<int>("Box", "Padding", 4, new ConfigDescription("Padding inside the background box", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), Array.Empty<object>())); float @float = PlayerPrefs.GetFloat("DayUtil_HUD_X", ((float)Screen.width - 600f) / 2f); float float2 = PlayerPrefs.GetFloat("DayUtil_HUD_Y", 30f); _hudPosition = new Rect(@float, float2, 600f, 40f); new ConsoleCommand("SetDay", "Sets the in-game day to the specified number", new ConsoleEvent(SetDayCommand), false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); new ConsoleCommand("GetDay", "Shows the current in-game day", new ConsoleEvent(GetDayCommand), false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); new ConsoleCommand("DayUtilHud", "Enable or disable the day/time HUD (DayUtilHud on/off)", new ConsoleEvent(HudToggleCommand), false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } private void SetDayCommand(ConsoleEventArgs args) { if (args.Length < 2 || !int.TryParse(args[1], out var result)) { Console.instance.Print("Usage: SetDay <dayNumber>"); return; } float num = 1200f; float num2 = Mathf.Max(0f, (float)(result - 1) * num); if ((Object)(object)EnvMan.instance != (Object)null && totalSecondsField != null) { totalSecondsField.SetValue(EnvMan.instance, num2); typeof(EnvMan).GetMethod("Update", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(EnvMan.instance, null); } if ((Object)(object)ZNet.instance != (Object)null) { FieldInfo field = typeof(ZNet).GetField("m_netTime", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { field.SetValue(ZNet.instance, (double)num2); Console.instance.Print($"ZNet netTime set to {num2} (Day {result})"); } } } private void GetDayCommand(ConsoleEventArgs args) { if ((Object)(object)EnvMan.instance != (Object)null && totalSecondsField != null) { int num = Mathf.FloorToInt(Convert.ToSingle(totalSecondsField.GetValue(EnvMan.instance)) / 1200f) + 1; Console.instance.Print($"Current in-game day: {num}"); } } private void HudToggleCommand(ConsoleEventArgs args) { if (args.Length >= 2) { cfgShowHud.Value = args[1].ToLower() == "on"; } } private void OnGUI() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_007c: 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) //IL_008a: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00a5: Expected O, but got Unknown //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Invalid comparison between Unknown and I4 //IL_014e: 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_01ec: Invalid comparison between Unknown and I4 //IL_0167: 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_0187: 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_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0256: 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_027c: 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_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: 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_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Expected O, but got Unknown //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_046f: 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_0494: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Expected O, but got Unknown //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) if (!cfgShowHud.Value || !Object.op_Implicit((Object)(object)Player.m_localPlayer) || (Object)(object)EnvMan.instance == (Object)null || totalSecondsField == null) { return; } if (_textStyle == null) { Font font = Font.CreateDynamicFontFromOSFont("AveriaSerifLibre-Bold", cfgFontSize.Value); _textStyle = new GUIStyle(GUI.skin.label) { font = font, fontSize = cfgFontSize.Value, fontStyle = (FontStyle)0, alignment = (TextAnchor)1, normal = new GUIStyleState { textColor = Color.black } }; } else if (_textStyle.fontSize != cfgFontSize.Value) { _textStyle.fontSize = cfgFontSize.Value; } float num = Convert.ToSingle(totalSecondsField.GetValue(EnvMan.instance)); int num2 = Mathf.FloorToInt(num / 1200f) + 1; float num3 = num % 1200f / 50f; int num4 = Mathf.FloorToInt(num3); int num5 = Mathf.FloorToInt((num3 - (float)num4) * 60f); string text = $"\ud83d\udd52 Day {num2} | {num4:00}:{num5:00}"; if ((int)Event.current.type == 0 && ((Rect)(ref _hudPosition)).Contains(Event.current.mousePosition)) { isDragging = true; dragOffset = Event.current.mousePosition - new Vector2(((Rect)(ref _hudPosition)).x, ((Rect)(ref _hudPosition)).y); Event.current.Use(); } else if ((int)Event.current.type == 3 && isDragging) { ((Rect)(ref _hudPosition)).position = Event.current.mousePosition - dragOffset; Event.current.Use(); } else if ((int)Event.current.type == 1 && isDragging) { isDragging = false; PlayerPrefs.SetFloat("DayUtil_HUD_X", ((Rect)(ref _hudPosition)).x); PlayerPrefs.SetFloat("DayUtil_HUD_Y", ((Rect)(ref _hudPosition)).y); PlayerPrefs.Save(); } float value = cfgFontScale.Value; Vector2 val = new Vector2(((Rect)(ref _hudPosition)).width, ((Rect)(ref _hudPosition)).height) * value; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(((Rect)(ref _hudPosition)).x, ((Rect)(ref _hudPosition)).y); Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(val2, val); if (cfgShowBackground.Value) { GUI.Box(new Rect(((Rect)(ref val3)).x - (float)cfgPadding.Value, ((Rect)(ref val3)).y - (float)cfgPadding.Value, ((Rect)(ref val3)).width + (float)(cfgPadding.Value * 2), ((Rect)(ref val3)).height + (float)(cfgPadding.Value * 2)), GUIContent.none); } Vector2[] array; if (cfgShadow.Value) { array = (Vector2[])(object)new Vector2[4] { new Vector2(1f, 1f), new Vector2(1f, -1f), new Vector2(-1f, 1f), new Vector2(-1f, -1f) }; foreach (Vector2 val4 in array) { GUIStyle val5 = new GUIStyle(_textStyle); val5.normal.textColor = Color.black; GUI.Label(new Rect(((Rect)(ref val3)).x + val4.x, ((Rect)(ref val3)).y + val4.y, ((Rect)(ref val3)).width, ((Rect)(ref val3)).height), text, val5); } } array = (Vector2[])(object)new Vector2[4] { new Vector2(-1f, 0f), new Vector2(1f, 0f), new Vector2(0f, -1f), new Vector2(0f, 1f) }; foreach (Vector2 val6 in array) { GUIStyle val7 = new GUIStyle(_textStyle); val7.normal.textColor = Color.black; GUI.Label(new Rect(((Rect)(ref val3)).x + val6.x, ((Rect)(ref val3)).y + val6.y, ((Rect)(ref val3)).width, ((Rect)(ref val3)).height), text, val7); } _textStyle.normal.textColor = cfgTextColor.Value; GUI.Label(val3, text, _textStyle); } }