Decompiled source of Lareins 48MinClock v1.0.1

plugins\Lareins_48MinClock\Lareins_48MinClock.dll

Decompiled 2 hours ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Lareins_Core;
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("Lareins_48MinClock")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Lareins_48MinClock")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("434499fc-d2bd-4367-980b-0f7793bb95e2")]
[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")]
namespace Lareins_48MinClock;

[BepInPlugin("com.lareins.clock48", "Lareins_48MinClock", "1.5.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class ClockPlugin : BaseUnityPlugin
{
	public const string ModGUID = "com.lareins.clock48";

	public const string ModName = "Lareins_48MinClock";

	public const string ModVersion = "1.5.0";

	public static ConfigEntry<bool> ModAktif;

	public static ConfigEntry<bool> SaatGoster;

	private static Texture2D arkaPlan;

	private static GUIStyle gunduzStil;

	private static GUIStyle geceStil;

	private static int sonDakika = -1;

	private static string onbellekMetin = "";

	private static bool sonGeceDurumu = false;

	private void Awake()
	{
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		ModAktif = ((BaseUnityPlugin)this).Config.Bind<bool>("Genel", "ModAktif", true, "48 dakikalik 24 saat (20s gunduz / 4s gece) dongusunu acar");
		SaatGoster = ((BaseUnityPlugin)this).Config.Bind<bool>("Arayuz", "SaatGoster", true, "Mini harita altinda dijital saati gosterir");
		CorePlugin.AyarEkle("48 Dakika Saat", "Mod Aktif", "1 oyun gununu 48 dakikaya cikarir (1 saat = 2 dk).", ModAktif);
		CorePlugin.AyarEkle("48 Dakika Saat", "Dijital Saati Goster", "Mini harita altinda canli SS:DD saatini gosterir.", SaatGoster);
		new Harmony("com.lareins.clock48").PatchAll(typeof(ClockPlugin));
	}

	[HarmonyPatch(typeof(EnvMan), "Awake")]
	[HarmonyPostfix]
	private static void GunUzunluguAwake(EnvMan __instance)
	{
		if (ModAktif.Value)
		{
			__instance.m_dayLengthSec = 2880L;
		}
	}

	[HarmonyPatch(typeof(EnvMan), "Update")]
	[HarmonyPrefix]
	private static void GunesDongusuPrefix(EnvMan __instance)
	{
		if (ModAktif.Value && __instance.m_dayLengthSec != 2880)
		{
			__instance.m_dayLengthSec = 2880L;
		}
	}

	[HarmonyPatch(typeof(EnvMan), "Update")]
	[HarmonyPostfix]
	private static void GunesDongusuPostfix(EnvMan __instance)
	{
		if (!ModAktif.Value || (Object)(object)ZNet.instance == (Object)null)
		{
			return;
		}
		float num = CanliSaatHesapla();
		float num3;
		if (num < 4f)
		{
			float num2 = num / 4f;
			num3 = 0.72f + num2 * 0.52f;
			if (num3 >= 1f)
			{
				num3 -= 1f;
			}
		}
		else
		{
			float num4 = (num - 4f) / 20f;
			num3 = 0.28f + num4 * 0.4f;
		}
		Traverse.Create((object)__instance).Field("m_smoothDayFraction").SetValue((object)num3);
	}

	[HarmonyPatch(typeof(EnvMan), "GetDayFraction")]
	[HarmonyPostfix]
	private static void GetDayFractionEsitle(ref float __result)
	{
		if (ModAktif.Value && !((Object)(object)ZNet.instance == (Object)null))
		{
			float num = CanliSaatHesapla();
			if (num < 4f)
			{
				float num2 = 0.72f + num / 4f * 0.52f;
				__result = ((num2 >= 1f) ? (num2 - 1f) : num2);
			}
			else
			{
				__result = 0.28f + (num - 4f) / 20f * 0.4f;
			}
		}
	}

	[HarmonyPatch(typeof(EnvMan), "IsNight")]
	[HarmonyPrefix]
	private static bool GeceKontrolu(ref bool __result)
	{
		if (!ModAktif.Value || (Object)(object)ZNet.instance == (Object)null)
		{
			return true;
		}
		float num = CanliSaatHesapla();
		__result = num >= 0f && num < 4f;
		return false;
	}

	[HarmonyPatch(typeof(EnvMan), "SkipToMorning")]
	[HarmonyPrefix]
	private static bool SabahaAtla()
	{
		if (!ModAktif.Value || (Object)(object)ZNet.instance == (Object)null)
		{
			return true;
		}
		double timeSeconds = ZNet.instance.GetTimeSeconds();
		double num = timeSeconds % 2880.0;
		double num2 = 480.0;
		double num3 = num2 - num;
		if (num3 <= 0.0)
		{
			num3 += 2880.0;
		}
		ZNet.instance.SetNetTime(timeSeconds + num3);
		return false;
	}

	private static float CanliSaatHesapla()
	{
		double timeSeconds = ZNet.instance.GetTimeSeconds();
		double num = timeSeconds % 2880.0 / 2880.0;
		if (num < 0.0)
		{
			num += 1.0;
		}
		return (float)(num * 24.0);
	}

	private void OnGUI()
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Invalid comparison between Unknown and I4
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Expected O, but got Unknown
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Expected O, but got Unknown
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Expected O, but got Unknown
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		if (ModAktif.Value && SaatGoster.Value && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)Hud.instance == (Object)null) && !((Object)(object)ZNet.instance == (Object)null) && (int)Event.current.type == 7)
		{
			if ((Object)(object)arkaPlan == (Object)null)
			{
				arkaPlan = new Texture2D(1, 1);
				arkaPlan.SetPixel(0, 0, new Color(0.08f, 0.08f, 0.1f, 0.78f));
				arkaPlan.Apply();
			}
			if (gunduzStil == null)
			{
				gunduzStil = new GUIStyle(GUI.skin.label)
				{
					fontSize = 15,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)4
				};
				gunduzStil.normal.textColor = new Color(1f, 0.92f, 0.65f);
				geceStil = new GUIStyle(GUI.skin.label)
				{
					fontSize = 15,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)4
				};
				geceStil.normal.textColor = new Color(0.55f, 0.78f, 1f);
			}
			float num = CanliSaatHesapla();
			int num2 = Mathf.FloorToInt(num) % 24;
			int num3 = Mathf.FloorToInt((num - (float)Mathf.FloorToInt(num)) * 60f);
			if (num3 != sonDakika)
			{
				sonDakika = num3;
				sonGeceDurumu = num2 >= 0 && num2 < 4;
				onbellekMetin = string.Format("{0:00}:{1:00}  ({2})", num2, num3, sonGeceDurumu ? "Gece" : "Gunduz");
			}
			Rect val = default(Rect);
			((Rect)(ref val))..ctor((float)(Screen.width - 230), 235f, 210f, 28f);
			GUI.DrawTexture(val, (Texture)(object)arkaPlan);
			GUI.Label(val, onbellekMetin, sonGeceDurumu ? geceStil : gunduzStil);
		}
	}
}