Decompiled source of NekogiriPeakOffline v1.0.1

BepInEx/plugins/NekogiriPeakOffline.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.SceneManagement;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("NekogiriPeak")]
[assembly: AssemblyDescription("Make Peak run offline")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Kirigiri")]
[assembly: AssemblyProduct("NekogiriPeak")]
[assembly: AssemblyCopyright("Kirigiri ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("be8d4052-15e4-4cc0-8481-034b8dd0e20d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace NekogiriPeakOffline;

[BepInPlugin("kirigiri.peak.nekogirioffline", "NekogiriPeakOffline", "1.0.0.0")]
public class NekogiriPeakOffline : BaseUnityPlugin
{
	[HarmonyPatch(typeof(CloudAPI), "CheckVersion")]
	public class CloudAPICheckVersionPatch
	{
		private static readonly DateTime startDate = new DateTime(2025, 6, 14);

		[HarmonyPrefix]
		public static bool Prefix(Action<LoginResponse> response)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			Debug.Log((object)"[NekogiriPeak] Patching CloudAPI.CheckVersion");
			BuildVersion val = new BuildVersion(Application.version);
			DateTime now = DateTime.Now;
			TimeSpan timeSpan = now.Date.AddDays(1.0) - now;
			int days = (now.Date - startDate).Days;
			int levelIndex = Mathf.Max(1, days + 1);
			LoginResponse obj = ((!(val.BuildName == "beta")) ? new LoginResponse
			{
				VersionOkay = true,
				HoursUntilLevel = timeSpan.Hours,
				MinutesUntilLevel = timeSpan.Minutes,
				SecondsUntilLevel = timeSpan.Seconds,
				LevelIndex = levelIndex,
				Message = "Nekogiri is watching you :3"
			} : new LoginResponse
			{
				VersionOkay = true,
				HoursUntilLevel = timeSpan.Hours,
				MinutesUntilLevel = timeSpan.Minutes,
				SecondsUntilLevel = timeSpan.Seconds,
				LevelIndex = levelIndex,
				Message = "Nekogiri know that you are using a beta version of the game :3"
			});
			response?.Invoke(obj);
			return false;
		}
	}

	[HarmonyPatch(typeof(MapBaker), "GetLevel")]
	public static class OfflineLevelPatch
	{
		[HarmonyPrefix]
		public static bool Prefix(MapBaker __instance, ref string __result, int levelIndex)
		{
			//IL_0086: 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)
			if (__instance.AllLevels == null || __instance.AllLevels.Length == 0)
			{
				Debug.LogError((object)"No levels found, using WilIsland...");
				__result = "WilIsland";
				return false;
			}
			int num = -1;
			if (num < 0 || num >= __instance.AllLevels.Length)
			{
				DateTime dateTime = new DateTime(2025, 6, 14);
				num = Mathf.Abs((int)(DateTime.Now.Date - dateTime).TotalDays) % __instance.AllLevels.Length;
			}
			string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(__instance.AllLevels[num]);
			if (Application.isEditor)
			{
				Scene sceneByName = SceneManager.GetSceneByName(fileNameWithoutExtension);
				if (!((Scene)(ref sceneByName)).IsValid())
				{
					Debug.LogError((object)"Level not loaded, using WilIsland...");
					__result = "WilIsland";
					return false;
				}
			}
			__result = fileNameWithoutExtension;
			return false;
		}
	}

	private void Awake()
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		((BaseUnityPlugin)this).Logger.LogInfo((object)"\r\n ██ ▄█▀ ██▓ ██▀███   ██▓  ▄████  ██▓ ██▀███   ██▓\r\n ██▄█▒ ▓██▒▓██ ▒ ██▒▓██▒ ██▒ ▀█▒▓██▒▓██ ▒ ██▒▓██▒\r\n▓███▄░ ▒██▒▓██ ░▄█ ▒▒██▒▒██░▄▄▄░▒██▒▓██ ░▄█ ▒▒██▒\r\n▓██ █▄ ░██░▒██▀▀█▄  ░██░░▓█  ██▓░██░▒██▀▀█▄  ░██░\r\n▒██▒ █▄░██░░██▓ ▒██▒░██░░▒▓███▀▒░██░░██▓ ▒██▒░██░\r\n▒ ▒▒ ▓▒░▓  ░ ▒▓ ░▒▓░░▓   ░▒   ▒ ░▓  ░ ▒▓ ░▒▓░░▓  \r\n░ ░▒ ▒░ ▒ ░  ░▒ ░ ▒░ ▒ ░  ░   ░  ▒ ░  ░▒ ░ ▒░ ▒ ░\r\n░ ░░ ░  ▒ ░  ░░   ░  ▒ ░░ ░   ░  ▒ ░  ░░   ░  ▒ ░\r\n░  ░    ░     ░      ░        ░  ░     ░      ░  \r\n                                                 \r\n");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"NekogiriPeakOffline has loaded!");
		new Harmony("kirigiri.peak.nekogirioffline").PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Made with <3 By Kirigiri \nhttps://discord.gg/TBs8Te5nwn");
	}
}
[HarmonyPatch(typeof(NetworkConnector), "ConnectToPhoton")]
public class NetworkConnectorPatch
{
	[HarmonyPrefix]
	public static bool Prefix()
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		Debug.Log((object)"[NekogiriPeak] Patching NetworkConnector.ConnectToPhoton");
		PhotonNetwork.OfflineMode = true;
		BuildVersion version = new BuildVersion(Application.version);
		PhotonNetwork.AutomaticallySyncScene = true;
		PhotonNetwork.GameVersion = ((object)(BuildVersion)(ref version)).ToString();
		PhotonNetwork.PhotonServerSettings.AppSettings.AppVersion = ((BuildVersion)(ref version)).ToMatchmaking();
		MethodInfo method = typeof(NetworkConnector).GetMethod("PrepareSteamAuthTicket", BindingFlags.Static | BindingFlags.NonPublic);
		if (method != null)
		{
			method.Invoke(null, new object[1] { (Action)delegate
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				PhotonNetwork.ConnectUsingSettings();
				ClientState networkClientState = PhotonNetwork.NetworkClientState;
				Debug.Log((object)("Photon Start " + ((object)(ClientState)(ref networkClientState)).ToString() + " using app version: " + ((BuildVersion)(ref version)).ToMatchmaking()));
			} });
		}
		else
		{
			Debug.LogError((object)"[NekogiriPeak] Failed to find PrepareSteamAuthTicket via reflection");
		}
		return false;
	}
}
[HarmonyPatch(typeof(PhotonNetwork), "ConnectUsingSettings", new Type[]
{
	typeof(AppSettings),
	typeof(bool)
})]
public class PhotonNetworkPatch
{
	[HarmonyPrefix]
	public static bool Prefix(AppSettings appSettings, bool startInOfflineMode, ref bool __result)
	{
		Debug.Log((object)"[NekogiriPeak] Overriding PhotonNetwork.ConnectUsingSettings");
		if (startInOfflineMode || PhotonNetwork.OfflineMode)
		{
			PhotonNetwork.OfflineMode = true;
			Debug.LogWarning((object)"Kirigiri disabled the online mode, going offline !");
			__result = true;
			return false;
		}
		__result = false;
		return false;
	}
}