Decompiled source of LongerDays v1.0.1

BepInEx/plugins/Longer_Days.dll

Decompiled 18 hours ago
using System;
using System.Collections.Generic;
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 HarmonyLib;

[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;

[BepInPlugin("ElecTRiCbOi59.LongerDays", "Longer Days", "1.0.0")]
public class LongerDaysPlugin : BaseUnityPlugin
{
	internal static ManualLogSource log;

	internal static ConfigEntry<string> TimeSpeed;

	private Harmony harmony;

	private const string DefaultTimeSpeedLabel = "0.5 (Half speed)";

	private static readonly Dictionary<string, float> TimeSpeedMap = new Dictionary<string, float>
	{
		{ "0.1 (Very slow)", 0.1f },
		{ "0.2", 0.2f },
		{ "0.3", 0.3f },
		{ "0.4", 0.4f },
		{ "0.5 (Half speed)", 0.5f },
		{ "0.6", 0.6f },
		{ "0.7", 0.7f },
		{ "0.8", 0.8f },
		{ "0.9", 0.9f },
		{ "1.0 (Normal)", 1f }
	};

	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 void Awake()
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Expected O, but got Unknown
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Expected O, but got Unknown
		log = ((BaseUnityPlugin)this).Logger;
		TimeSpeed = ((BaseUnityPlugin)this).Config.Bind<string>("General", "TimeSpeed", "0.5 (Half speed)", new ConfigDescription("Controls how fast the in-game day passes.", (AcceptableValueBase)(object)new AcceptableValueList<string>(TimeSpeedOptions), Array.Empty<object>()));
		if (!TimeSpeedMap.ContainsKey(TimeSpeed.Value))
		{
			log.LogWarning((object)("Invalid TimeSpeed config value found: " + TimeSpeed.Value + ". Resetting to 0.5 (Half speed)"));
			TimeSpeed.Value = "0.5 (Half speed)";
		}
		log.LogInfo((object)("Longer Days loaded. TimeSpeed = " + TimeSpeed.Value + " -> " + GetSafeTimeSpeed()));
		harmony = new Harmony("ElecTRiCbOi59.LongerDays");
		harmony.PatchAll();
	}

	internal static float GetSafeTimeSpeed()
	{
		if (TimeSpeedMap.TryGetValue(TimeSpeed.Value, out var value))
		{
			return value;
		}
		log.LogWarning((object)("Unknown TimeSpeed value: " + TimeSpeed.Value + ". Falling back to 0.5 (Half speed)"));
		return 0.5f;
	}
}
[HarmonyPatch(typeof(TimeOfDay), "Start")]
internal class TimeOfDayStartPatch
{
	[HarmonyPostfix]
	private static void StartPostfix(TimeOfDay __instance)
	{
		float safeTimeSpeed = LongerDaysPlugin.GetSafeTimeSpeed();
		LongerDaysPlugin.log.LogInfo((object)("Applying TimeSpeed = " + safeTimeSpeed));
		__instance.globalTimeSpeedMultiplier = safeTimeSpeed;
	}
}
[HarmonyPatch(typeof(TimeOfDay), "Update")]
internal class TimeOfDayUpdatePatch
{
	[HarmonyPostfix]
	private static void UpdatePostfix(TimeOfDay __instance)
	{
		__instance.globalTimeSpeedMultiplier = LongerDaysPlugin.GetSafeTimeSpeed();
	}
}