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 LongerDaysReuploaded v1.4.0
BepInEx/plugins/Longer_Days.dll
Decompiled a month 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 BepInEx.Logging; using CSync.Extensions; using CSync.Lib; using HarmonyLib; using TMPro; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Longer_Days")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Longer_Days")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("a83ca510-7ea0-4ed4-8a23-a845522a8da2")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace Longer_Days; public class LongerDaysConfig : SyncedConfig2<LongerDaysConfig> { private const string DefaultTimeSpeedLabel = "0.5 (Half speed)"; private const string DefaultClockFormatLabel = "24 Hour"; private const bool DefaultShowClockIndoors = false; private const bool DefaultCompactClock = false; private const bool DefaultRaiseClock = false; private static readonly string[] TimeSpeedOptions = new string[10] { "0.1 (Very slow)", "0.2", "0.3", "0.4", "0.5 (Half speed)", "0.6", "0.7", "0.8", "0.9", "1.0 (Normal)" }; private static readonly string[] ClockFormatOptions = new string[2] { "12 Hour", "24 Hour" }; [SyncedEntryField] public SyncedEntry<string> TimeSpeed; public ConfigEntry<string> ClockFormat { get; private set; } public ConfigEntry<bool> ShowClockIndoors { get; private set; } public ConfigEntry<bool> CompactClock { get; private set; } public ConfigEntry<bool> RaiseClock { get; private set; } public LongerDaysConfig(ConfigFile cfg) : base("ElecTRiCbOi59.LongerDays") { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0041: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_007a: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_00a7: Expected O, but got Unknown //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown //IL_00d4: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_0101: Expected O, but got Unknown TimeSpeed = SyncedBindingExtensions.BindSyncedEntry<string>(cfg, new ConfigDefinition("Game Settings", "TimeSpeed"), "0.5 (Half speed)", new ConfigDescription("Controls how fast the in-game day passes.\n\nHOST ONLY: This value is controlled by the host and synced to all players.", (AcceptableValueBase)(object)new AcceptableValueList<string>(TimeSpeedOptions), Array.Empty<object>())); ClockFormat = cfg.Bind<string>(new ConfigDefinition("Display Settings", "ClockFormat"), "24 Hour", new ConfigDescription("Choose how the in-game clock is displayed.\n\nLOCAL: This setting only affects your own display.", (AcceptableValueBase)(object)new AcceptableValueList<string>(ClockFormatOptions), Array.Empty<object>())); ShowClockIndoors = cfg.Bind<bool>(new ConfigDefinition("Display Settings", "ShowClockIndoors"), false, new ConfigDescription("Show the clock inside the ship and buildings.\n\nLOCAL: This setting only affects your own display.\nDisabled = default game behaviour.", (AcceptableValueBase)null, Array.Empty<object>())); CompactClock = cfg.Bind<bool>(new ConfigDefinition("Display Settings", "CompactClock"), false, new ConfigDescription("Makes the clock more compact by shrinking the icon and tightening the layout.\n\nUseful if the default clock feels a bit bulky.\n\nLOCAL: This setting only affects your own display.", (AcceptableValueBase)null, Array.Empty<object>())); RaiseClock = cfg.Bind<bool>(new ConfigDefinition("Display Settings", "RaiseClock"), false, new ConfigDescription("Raises the clock a little higher on the screen while keeping some margin from the top.\n\nLOCAL: This setting only affects your own display.", (AcceptableValueBase)null, Array.Empty<object>())); ConfigManager.Register<LongerDaysConfig>((SyncedConfig2<LongerDaysConfig>)this); } } [BepInPlugin("ElecTRiCbOi59.LongerDays", "Longer Days", "1.4.0")] [BepInDependency("com.sigurd.csync", "5.0.1")] public class LongerDaysPlugin : BaseUnityPlugin { private sealed class ClockUiState { internal Transform Parent; internal RectTransform ParentRect; internal RectTransform IconRect; internal TMP_Text Text; internal Vector3 DefaultParentLocalPosition; internal Vector2 DefaultParentSizeDelta; internal Vector3 DefaultTextLocalPosition; internal Vector2 DefaultIconSizeDelta; internal Vector3 DefaultIconLocalPosition; internal bool DefaultWordWrapping; internal TextAlignmentOptions DefaultAlignment; internal bool DefaultsCaptured; } private const float RaisedClockYOffset = 28f; private const float CompactClockHeight = 50f; private const float CompactIconScale = 0.42f; private static readonly Vector3 Compact12HourTextOffset = new Vector3(-6f, -1f, 0f); private static readonly Vector3 Compact12HourIconOffset = new Vector3(-28f, -1f, 0f); private static readonly Vector3 Compact24HourIconOffset = new Vector3(-12f, -1f, 0f); internal static ManualLogSource log; internal static LongerDaysConfig Config; private Harmony harmony; private static ClockUiState clockUi; private static TimeOfDay currentTimeOfDay; private static float vanillaTimeSpeed = 1.4f; private void Awake() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown log = ((BaseUnityPlugin)this).Logger; Config = new LongerDaysConfig(((BaseUnityPlugin)this).Config); harmony = new Harmony("ElecTRiCbOi59.LongerDays"); harmony.PatchAll(); log.LogInfo((object)"Longer Days loaded (Sigurd-CSync)."); log.LogInfo((object)("Synced host TimeSpeed = " + Config.TimeSpeed.Value)); log.LogInfo((object)("Local ClockFormat = " + Config.ClockFormat.Value)); log.LogInfo((object)("Local ShowClockIndoors = " + Config.ShowClockIndoors.Value)); log.LogInfo((object)("Local CompactClock = " + Config.CompactClock.Value)); log.LogInfo((object)("Local RaiseClock = " + Config.RaiseClock.Value)); } internal static float GetConfiguredTimeScale() { switch (Config.TimeSpeed.Value) { case "0.1 (Very slow)": return 0.1f; case "0.2": return 0.2f; case "0.3": return 0.3f; case "0.4": return 0.4f; case "0.5 (Half speed)": return 0.5f; case "0.6": return 0.6f; case "0.7": return 0.7f; case "0.8": return 0.8f; case "0.9": return 0.9f; case "1.0 (Normal)": return 1f; default: log.LogWarning((object)("Unknown TimeSpeed value '" + Config.TimeSpeed.Value + "'. Falling back to 0.5.")); return 0.5f; } } internal static string FormatTime(int hour, int minute) { if (Config.ClockFormat.Value == "12 Hour") { string text = ((hour >= 12) ? "PM" : "AM"); int num = hour % 12; if (num == 0) { num = 12; } return num.ToString("00") + ":" + minute.ToString("00") + " " + text; } return hour.ToString("00") + ":" + minute.ToString("00"); } internal static void RefreshClockLayout() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) if (!BindClockUi()) { return; } CaptureClockDefaultsIfNeeded(); RestoreClockDefaults(); if (Config.RaiseClock.Value) { Transform parent = clockUi.Parent; parent.localPosition += new Vector3(0f, 28f, 0f); } if (Config.CompactClock.Value) { clockUi.ParentRect.sizeDelta = new Vector2(clockUi.ParentRect.sizeDelta.x, 50f); clockUi.Text.enableWordWrapping = false; clockUi.Text.alignment = (TextAlignmentOptions)514; clockUi.IconRect.sizeDelta = clockUi.DefaultIconSizeDelta * 0.42f; if (Config.ClockFormat.Value == "12 Hour") { Transform transform = clockUi.Text.transform; transform.localPosition += Compact12HourTextOffset; Transform transform2 = ((Component)clockUi.IconRect).transform; transform2.localPosition += Compact12HourIconOffset; } else { Transform transform3 = ((Component)clockUi.IconRect).transform; transform3.localPosition += Compact24HourIconOffset; } } } private static void CaptureClockDefaultsIfNeeded() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) if (!clockUi.DefaultsCaptured) { clockUi.DefaultParentLocalPosition = clockUi.Parent.localPosition; clockUi.DefaultParentSizeDelta = clockUi.ParentRect.sizeDelta; clockUi.DefaultTextLocalPosition = clockUi.Text.transform.localPosition; clockUi.DefaultIconSizeDelta = clockUi.IconRect.sizeDelta; clockUi.DefaultIconLocalPosition = ((Component)clockUi.IconRect).transform.localPosition; clockUi.DefaultWordWrapping = clockUi.Text.enableWordWrapping; clockUi.DefaultAlignment = clockUi.Text.alignment; clockUi.DefaultsCaptured = true; } } private static void RestoreClockDefaults() { //IL_0010: 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_0049: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) clockUi.Parent.localPosition = clockUi.DefaultParentLocalPosition; clockUi.ParentRect.sizeDelta = clockUi.DefaultParentSizeDelta; clockUi.Text.transform.localPosition = clockUi.DefaultTextLocalPosition; clockUi.IconRect.sizeDelta = clockUi.DefaultIconSizeDelta; ((Component)clockUi.IconRect).transform.localPosition = clockUi.DefaultIconLocalPosition; clockUi.Text.enableWordWrapping = clockUi.DefaultWordWrapping; clockUi.Text.alignment = clockUi.DefaultAlignment; } private static bool BindClockUi() { if ((Object)(object)HUDManager.Instance == (Object)null || (Object)(object)HUDManager.Instance.clockNumber == (Object)null || (Object)(object)HUDManager.Instance.clockIcon == (Object)null) { clockUi = null; return false; } if (clockUi != null && (Object)(object)clockUi.Parent != (Object)null && (Object)(object)clockUi.Text != (Object)null && (Object)(object)clockUi.IconRect != (Object)null) { return true; } TMP_Text clockNumber = (TMP_Text)(object)HUDManager.Instance.clockNumber; Transform parent = clockNumber.transform.parent; RectTransform val = (((Object)(object)parent != (Object)null) ? ((Component)parent).GetComponent<RectTransform>() : null); RectTransform component = ((Component)HUDManager.Instance.clockIcon).GetComponent<RectTransform>(); if ((Object)(object)parent == (Object)null || (Object)(object)val == (Object)null || (Object)(object)component == (Object)null) { return false; } clockUi = new ClockUiState { Parent = parent, ParentRect = val, IconRect = component, Text = clockNumber }; return true; } internal static void ApplyScaledTimeSpeed(TimeOfDay timeOfDay) { if ((Object)(object)currentTimeOfDay != (Object)(object)timeOfDay) { currentTimeOfDay = timeOfDay; vanillaTimeSpeed = timeOfDay.globalTimeSpeedMultiplier; } timeOfDay.globalTimeSpeedMultiplier = vanillaTimeSpeed * GetConfiguredTimeScale(); } } [HarmonyPatch(typeof(TimeOfDay), "Update")] internal class TimePatch { [HarmonyPostfix] private static void UpdatePostfix(TimeOfDay __instance) { LongerDaysPlugin.ApplyScaledTimeSpeed(__instance); } } [HarmonyPatch(typeof(HUDManager), "Awake")] internal class ClockLayoutPatch { [HarmonyPostfix] private static void AwakePostfix() { LongerDaysPlugin.RefreshClockLayout(); } } [HarmonyPatch(typeof(HUDManager), "SetClock")] internal class ClockPatch { [HarmonyPostfix] private static void SetClockPatch(float timeNormalized, float numberOfHours) { if (!((Object)(object)HUDManager.Instance == (Object)null) && !((Object)(object)HUDManager.Instance.clockNumber == (Object)null)) { int num = (int)(timeNormalized * (60f * numberOfHours)) + 360; int hour = num / 60; int minute = num % 60; ((TMP_Text)HUDManager.Instance.clockNumber).text = LongerDaysPlugin.FormatTime(hour, minute); LongerDaysPlugin.RefreshClockLayout(); } } } [HarmonyPatch(typeof(HUDManager), "Update")] internal class IndoorClockPatch { [HarmonyPrefix] private static void UpdatePrefix(ref HUDElement ___Clock) { if (LongerDaysPlugin.Config.ShowClockIndoors.Value) { ___Clock.targetAlpha = 1f; } } }