Decompiled source of Offline Mode v0.0.2

OfflineMode.dll

Decompiled 3 weeks 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 BepInEx;
using BepInEx.Logging;
using Gameplay.Chat;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using RSG;
using Steamworks;
using ToolClasses;
using UI.Matchmaking;
using UnityEngine;
using UnityEngine.UIElements;
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.2.0")]
[assembly: AssemblyInformationalVersion("0.0.2+ac8ef942e2b5af94ab5c83f870f7e5a949c0e8b8")]
[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.2.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
{
	[HarmonyPatch(typeof(MatchMakingMenu), "OnStartGameButtonPressed")]
	internal class AllowCreateRoom
	{
		private static bool Prefix(MatchMakingMenu __instance)
		{
			Singleton<SteamService>.I.CreateLobby().Then((Func<IPromise>)(() => PunSingleton<PhotonService>.I.CreateRoom(__instance.HostPublicGame))).Then((Action)delegate
			{
				PunSingleton<PhotonService>.I.SetCurrentRoomPlayerLimit(__instance._playerLimit.Value);
			})
				.Then((Action)delegate
				{
					PunSingleton<PhotonService>.I.SetCurrentRoomName(((BaseField<string>)(object)__instance._roomNameField).value);
				})
				.Then((Action)MatchMakingMenu.LaunchHub);
			return false;
		}
	}
	[HarmonyPatch(typeof(MainMenu), "SetPhotonConnectionStatus")]
	internal class FixTutorialStart
	{
		private static void Prefix(ref bool connected)
		{
			connected = true;
		}
	}
	[BepInPlugin("Dragon.OfflineMode", "Offline Mode", "0.0.2")]
	[BepInProcess("Void Crew.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	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 => "VoidCrewModdingTeam/Offline_Mode";

		public VoidManagerPlugin()
		{
			PhotonNetwork.PhotonServerSettings.StartInOfflineMode = true;
			BepinPlugin.Log.LogInfo((object)"Set StartInOfflineMode");
		}
	}
	[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(SteamService))]
	internal class DisableServiceConnections
	{
		[HarmonyPrefix]
		[HarmonyPatch("CreateLobby")]
		private static bool CreateLobbyPrefix(SteamService __instance, ref IPromise __result)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			__instance.createLobbyPromise = new Promise();
			__instance.createLobbyPromise.Resolve();
			__result = (IPromise)(object)__instance.createLobbyPromise;
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("Invite")]
		private static bool InvitePrefix()
		{
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("OnLobbyInvite")]
		private static bool OnLobbyInvitePrefix()
		{
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("OnRequestJoinLobby")]
		private static bool OnRequestJoinLobbyPrefix()
		{
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("LobbyLoggedIn")]
		private static bool LobbyLoggedInPrefix()
		{
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("CheckIfJoinOtherLobby")]
		private static bool CheckIfJoinOtherLobbyPrefix()
		{
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("LeaveLobby")]
		private static bool LeaveLobbyPrefix()
		{
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("AcceptGameJoin")]
		private static bool AcceptGameJoinPrefix()
		{
			return false;
		}
	}
	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.2";

		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 = "VoidCrewModdingTeam/Offline_Mode";
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class PhotonUserIDPatch
	{
		private static bool Prefix(ref string __result)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			CSteamID steamID = SteamUser.GetSteamID();
			__result = ((object)(CSteamID)(ref steamID)).ToString();
			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;
		}
	}
}