// Consolidated decompiled source — Azumatt-DayAndNight v1.0.3 // Generated by Hexium's decompiled-source browser. Best-effort concatenation of every type in this // version's manifest — decompiler output isn't guaranteed to compile as-is. using System; using System.Runtime.CompilerServices; using Microsoft.CodeAnalysis; using System.IO; using System.Reflection; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using UnityEngine; using System.Linq; using Enviro; // ---- DayAndNight.dll :: Microsoft.CodeAnalysis.EmbeddedAttribute ---- namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } // ---- DayAndNight.dll :: System.Runtime.CompilerServices.NullableAttribute ---- namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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; } } } // ---- DayAndNight.dll :: System.Runtime.CompilerServices.NullableContextAttribute ---- namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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; } } } // ---- DayAndNight.dll :: DayAndNight.DayAndNightPlugin ---- namespace DayAndNight { [BepInPlugin("Azumatt.DayAndNight", "DayAndNight", "1.0.3")] public class DayAndNightPlugin : BaseUnityPlugin { public enum Toggle { On = 1, Off = 0 } private class ConfigurationManagerAttributes { [UsedImplicitly] public int? Order; [UsedImplicitly] public bool? Browsable; [UsedImplicitly] public string? Category; [UsedImplicitly] public Action? CustomDrawer; } private class AcceptableShortcuts : AcceptableValueBase { public AcceptableShortcuts() : base(typeof(KeyboardShortcut)) { } public override object Clamp(object value) { return value; } public override bool IsValid(object value) { return true; } public override string ToDescriptionString() { return "# Acceptable values: " + string.Join(", ", UnityInput.Current.SupportedKeyCodes); } } internal const string ModName = "DayAndNight"; internal const string ModVersion = "1.0.3"; internal const string Author = "Azumatt"; private const string ModGUID = "Azumatt.DayAndNight"; private static string ConfigFileName = "Azumatt.DayAndNight.cfg"; private static string ConfigFileFullPath; private readonly Harmony _harmony = new Harmony("Azumatt.DayAndNight"); public static readonly ManualLogSource DayAndNightLogger; internal static ConfigEntry FreezeTimeHotkey; internal static ConfigEntry FreezeTime; internal static ConfigEntry DayModifier; internal static ConfigEntry NightModifier; internal static ConfigEntry CycleLengthInMinutes; internal static ConfigEntry Seconds; internal static ConfigEntry Minutes; internal static ConfigEntry Hours; internal static ConfigEntry Days; internal static ConfigEntry Years; public void Awake() { FreezeTimeHotkey = base.Config.Bind("2 - Hotkeys", "Freeze Time Hotkey", new KeyboardShortcut(KeyCode.F, KeyCode.LeftControl), "This is the hotkey that will toggle the Freeze Time option. This will only work if the game is not paused."); FreezeTime = base.Config.Bind("1 - Freeze", "Freeze Time", Toggle.Off, "If on, the other values in this section take effect. They will control the time of day that is in the game."); Seconds = base.Config.Bind("1 - Freeze", "Seconds", 0, "If Freeze Time is on, this will control the seconds of the day. 0 is the default, 30 is half a minute, 60 is a minute."); Minutes = base.Config.Bind("1 - Freeze", "Minutes", 0, "If Freeze Time is on, this will control the minutes of the day. 0 is the default, 30 is half an hour, 60 is an hour."); Hours = base.Config.Bind("1 - Freeze", "Hours", 12, "If Freeze Time is on, this will control the hours of the day. 12 noon is the default, 0 is midnight, 24 is midnight"); Days = base.Config.Bind("1 - Freeze", "Days", 1, "If Freeze Time is on, this will control the days in your game. 1 is the default"); Years = base.Config.Bind("1 - Freeze", "Years", 1, "If Freeze Time is on, this will control the years of your game. 1 is the default."); DayModifier = base.Config.Bind("1 - Modifiers", "Day Modifier", -1f, "If this value is not -1, it will control the length of the day. 1 is normal, 2 is twice as long, 0.5 is half as long."); NightModifier = base.Config.Bind("1 - Modifiers", "Night Modifier", -1f, "If this value is not -1, it will control the length of the night. 1 is normal, 2 is twice as long, 0.5 is half as long."); CycleLengthInMinutes = base.Config.Bind("1 - Modifiers", "Cycle Length In Minutes", -1f, "If this value is not -1, it will control the cycle length of the day. The default for the game is 5 minutes. This will change the length of the day & night cycle. The game states this as the Full 24h cycle in realtime minutes."); Assembly executingAssembly = Assembly.GetExecutingAssembly(); _harmony.PatchAll(executingAssembly); SetupWatcher(); } private void Update() { if (FreezeTimeHotkey.Value.IsKeyDown()) { FreezeTime.Value = ((FreezeTime.Value != Toggle.On) ? Toggle.On : Toggle.Off); } } private void OnDestroy() { base.Config.Save(); } private void SetupWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName); fileSystemWatcher.Changed += ReadConfigValues; fileSystemWatcher.Created += ReadConfigValues; fileSystemWatcher.Renamed += ReadConfigValues; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } private void ReadConfigValues(object sender, FileSystemEventArgs e) { if (!File.Exists(ConfigFileFullPath)) { return; } try { DayAndNightLogger.LogDebug("ReadConfigValues called"); base.Config.Reload(); } catch { DayAndNightLogger.LogError("There was an issue loading your " + ConfigFileName); DayAndNightLogger.LogError("Please check your config entries for spelling and format!"); } } internal ConfigEntry TextEntryConfig(string group, string name, T value, string desc) { ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes { CustomDrawer = TextAreaDrawer }; return base.Config.Bind(group, name, value, new ConfigDescription(desc, null, configurationManagerAttributes)); } internal static void TextAreaDrawer(ConfigEntryBase entry) { GUILayout.ExpandHeight(expand: true); GUILayout.ExpandWidth(expand: true); entry.BoxedValue = GUILayout.TextArea((string)entry.BoxedValue, GUILayout.ExpandWidth(expand: true), GUILayout.ExpandHeight(expand: true)); } static DayAndNightPlugin() { string configPath = Paths.ConfigPath; char directorySeparatorChar = Path.DirectorySeparatorChar; ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName; DayAndNightLogger = BepInEx.Logging.Logger.CreateLogSource("DayAndNight"); FreezeTimeHotkey = null; FreezeTime = null; DayModifier = null; NightModifier = null; CycleLengthInMinutes = null; Seconds = null; Minutes = null; Hours = null; Days = null; Years = null; } } } // ---- DayAndNight.dll :: DayAndNight.KeyboardExtensions ---- namespace DayAndNight { public static class KeyboardExtensions { public static bool IsKeyDown(this KeyboardShortcut shortcut) { if (shortcut.MainKey != KeyCode.None && Input.GetKeyDown(shortcut.MainKey)) { return shortcut.Modifiers.All(Input.GetKey); } return false; } public static bool IsKeyHeld(this KeyboardShortcut shortcut) { if (shortcut.MainKey != KeyCode.None && Input.GetKey(shortcut.MainKey)) { return shortcut.Modifiers.All(Input.GetKey); } return false; } } } // ---- DayAndNight.dll :: DayAndNight.EnviroCoreUpdateTimePatch ---- namespace DayAndNight { [HarmonyPatch(typeof(EnviroTimeModule), "UpdateModule")] internal static class EnviroCoreUpdateTimePatch { private static void Prefix(EnviroTimeModule __instance) { if ((double)Math.Abs(DayAndNightPlugin.DayModifier.Value - -1f) > 0.001) { if ((double)DayAndNightPlugin.DayModifier.Value < 0.001) { DayAndNightPlugin.DayModifier.Value = 0.001f; } __instance.Settings.dayLengthModifier = DayAndNightPlugin.DayModifier.Value; } if ((double)Math.Abs(DayAndNightPlugin.NightModifier.Value - -1f) > 0.001) { if ((double)DayAndNightPlugin.NightModifier.Value < 0.001) { DayAndNightPlugin.NightModifier.Value = 0.001f; } __instance.Settings.nightLengthModifier = DayAndNightPlugin.NightModifier.Value; } if ((double)Math.Abs(DayAndNightPlugin.CycleLengthInMinutes.Value - -1f) > 0.001) { if ((double)DayAndNightPlugin.CycleLengthInMinutes.Value < 0.001) { DayAndNightPlugin.CycleLengthInMinutes.Value = 0.001f; } __instance.Settings.cycleLengthInMinutes = DayAndNightPlugin.CycleLengthInMinutes.Value; } if (DayAndNightPlugin.FreezeTime.Value == DayAndNightPlugin.Toggle.On) { __instance.Settings.simulate = false; __instance.Settings.secSerial = DayAndNightPlugin.Seconds.Value; __instance.Settings.minSerial = DayAndNightPlugin.Minutes.Value; __instance.Settings.hourSerial = DayAndNightPlugin.Hours.Value; __instance.Settings.daySerial = DayAndNightPlugin.Days.Value; __instance.Settings.yearSerial = DayAndNightPlugin.Years.Value; } else { __instance.Settings.simulate = true; } } } }