Decompiled source of Offline Mode v0.0.3

OfflineMode.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using Gameplay.Chat;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using PlatformAbstractionLayer;
using PlatformAbstractionLayer.Steam;
using Steamworks;
using ToolClasses;
using UI.Matchmaking;
using UnityEngine;
using VoidManager;
using VoidManager.MPModChecks;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("OfflineMode")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.3.0")]
[assembly: AssemblyInformationalVersion("0.0.3+481b864cbf10a1f24449229d11971a3dbc6bacfc")]
[assembly: AssemblyProduct("OfflineMode")]
[assembly: AssemblyTitle("Puts PhotonNetwork into OfflineMode, mitigating photon disconnects. Connection to steam and Unity still required.")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace OfflineMode
{
	[BepInPlugin("Dragon.OfflineMode", "Offline Mode", "0.0.3")]
	[BepInProcess("Void Crew.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInIncompatibility("NihilityShift.MaxPlayers")]
	public class BepinPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Dragon.OfflineMode is loaded!");
		}
	}
	public class VoidManagerPlugin : VoidPlugin
	{
		public override MultiplayerType MPType => (MultiplayerType)30;

		public override string Author => "Dragon";

		public override string Description => "Puts PhotonNetwork into OfflineMode, mitigating photon disconnects. Connection to steam and Unity still required.";

		public override string ThunderstoreID => "NihilityShift/Offline_Mode";

		public VoidManagerPlugin()
		{
			PhotonNetwork.PhotonServerSettings.StartInOfflineMode = true;
			PhotonService.OfflineMode = true;
			BepinPlugin.Log.LogInfo((object)"Set StartInOfflineMode");
		}
	}
	public class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Dragon.OfflineMode";

		public const string PLUGIN_NAME = "OfflineMode";

		public const string USERS_PLUGIN_NAME = "Offline Mode";

		public const string PLUGIN_VERSION = "0.0.3";

		public const string PLUGIN_DESCRIPTION = "Puts PhotonNetwork into OfflineMode, mitigating photon disconnects. Connection to steam and Unity still required.";

		public const string PLUGIN_ORIGINAL_AUTHOR = "Dragon";

		public const string PLUGIN_AUTHORS = "Dragon";

		public const string PLUGIN_THUNDERSTORE_ID = "NihilityShift/Offline_Mode";
	}
}
namespace OfflineMode.Patches
{
	[HarmonyPatch]
	internal class BypassVixoxMessaging
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(VivoxAdapter), "SendTextMessage")]
		private static bool SendText(string message)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)TextChat.Instance == (Object)null)
			{
				return false;
			}
			TextChat.Instance.AddLog(new Log("", message));
			return false;
		}
	}
	[HarmonyPatch(typeof(PhotonService), "OnConnectedToMaster")]
	internal class ConnectToLobbyPatch
	{
		private static void Postfix()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0036: Expected O, but got Unknown
			BepinPlugin.Log.LogMessage((object)"OnConnectedToMaster");
			PhotonNetwork.NetworkingClient.OnOperationResponse(new OperationResponse
			{
				OperationCode = 229,
				Parameters = new ParameterDictionary()
			});
		}
	}
	[HarmonyPatch(typeof(PhotonService), "SetCurrentRoomProperty")]
	internal class RoomPropertyServicePatch
	{
		private static bool Prefix()
		{
			return PhotonNetwork.CurrentRoom != null;
		}
	}
	[HarmonyPatch(typeof(PhotonService), "AutoConnectIfDisconnected")]
	internal class DisableAutoConnect
	{
		private static bool Prefix()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(PlatformService), "OnLobbyInvite")]
	internal class DisableInviteReceipt
	{
		private static void Prefix(UserID userID)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			MenuScreenController.Instance.ShowMessagePopup("Invite Recieved", "An invite has been recieved from " + PAL.UserRelations.GetFriendPersonaName(userID) + ", however you cannot join in offline mode.", (Action)null);
		}
	}
	[HarmonyPatch(typeof(MainMenu), "OnInvitePressed")]
	internal class DisableInviteSend
	{
		private static bool Prefix()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(SteamMatchmakingHandler))]
	internal class DisableServiceConnections
	{
		[HarmonyPrefix]
		[HarmonyPatch("CreateLobby")]
		private static bool CreateLobbyPrefix(SteamMatchmakingHandler __instance, ref TaskCompletionSource<bool> ____lobbyCreatedCompletionSource, ref Task<bool> __result)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			____lobbyCreatedCompletionSource = new TaskCompletionSource<bool>();
			SteamMatchmaking.CreateLobby((ELobbyType)1, 1);
			__result = ____lobbyCreatedCompletionSource.Task;
			return false;
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class PhotonUserIDPatch
	{
		private static bool Prefix(ref string __result)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			UserID userID = PAL.User.Result.UserID;
			__result = ((UserID)(ref userID)).Value;
			return false;
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class PlayFabIDBypass
	{
		private static bool Prefix(ref string __result)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			UserID userID = PAL.User.Result.UserID;
			__result = (__result = ((UserID)(ref userID)).Value);
			return false;
		}
	}
	[HarmonyPatch(typeof(PhotonNetwork), "RaiseEvent")]
	internal class RaiseEventPatches
	{
		private static void Prefix(ref RaiseEventOptions raiseEventOptions)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			if (raiseEventOptions == null)
			{
				raiseEventOptions = new RaiseEventOptions();
			}
		}
	}
	[HarmonyPatch(typeof(MatchmakingTerminal), "OnRoomPropertiesUpdate")]
	internal class RoomPropsChangePatch
	{
		private static bool Prefix()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(MatchMakingMenu), "OnStartGameButtonPressed")]
	internal class StartGamePatch
	{
		private static bool Prefix(MatchMakingMenu __instance)
		{
			__instance.HostPublicGame = false;
			PunSingleton<PhotonService>.I.CreateRoom(false, false).Then((Action)delegate
			{
				PAL.Matchmaking.CreateLobby(__instance.HostPublicGame);
			}).Then((Action)MatchMakingMenu.LaunchHub)
				.Catch((Action<Exception>)BepinPlugin.Log.LogError);
			return false;
		}
	}
	[HarmonyPatch(typeof(MatchMakingMenu), "OnSoloPlayButtonPressed")]
	internal class StartSoloGamePatch
	{
		private static bool Prefix(MatchMakingMenu __instance)
		{
			__instance.HostPublicGame = false;
			__instance.EnableCrossPlay = false;
			((Setting<int>)(object)SettingsManager.CurrentSettings.GeneralSettings.EnableCrossPlay).SetValue(0, false);
			PunSingleton<PhotonService>.I.CreateRoom(false, false).Then((Action)delegate
			{
				PAL.Matchmaking.CreateLobby(__instance.HostPublicGame);
			}).Then((Action)MatchMakingMenu.LaunchHub)
				.Catch((Action<Exception>)BepinPlugin.Log.LogError);
			return false;
		}
	}
	[HarmonyPatch(typeof(MainMenu), "OnTutorialButtonClicked")]
	internal class StartTutorialPatch
	{
		private static bool Prefix(MainMenu __instance)
		{
			PunSingleton<PhotonService>.I.CreateRoom(false, false).Then((Action)delegate
			{
				PAL.Matchmaking.CreateLobby(false);
			}).Then((Action)MainMenu.LaunchAwakening)
				.Catch((Action<Exception>)BepinPlugin.Log.LogError);
			return false;
		}
	}
	[HarmonyPatch(typeof(MainMenu), "SetPhotonConnectionStatus")]
	internal class FixTutorialStart
	{
		private static void Prefix(ref bool connected)
		{
			connected = true;
		}
	}
}