Decompiled source of FreeFlyCommand v1.0.10

Landoria.FreeFlyCommand.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Landoria.SharedLib;
using Splatform;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Landoria.FreeFlyCommand")]
[assembly: AssemblyDescription("Allows server-authorized native free-camera commands within a limited range.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Landoria")]
[assembly: AssemblyProduct("Landoria.FreeFlyCommand")]
[assembly: AssemblyCopyright("Copyright © 2026 End3rbyte")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("037059B7-0C09-4B60-A05B-62627829B3D8")]
[assembly: AssemblyFileVersion("1.0.10")]
[assembly: AssemblyInformationalVersion("1.0.10")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = "")]
[assembly: AssemblyVersion("1.0.10.14009")]
namespace Landoria.FreeFlyCommand
{
	internal static class FreeFlyAuthorization
	{
		private const string RequestRpc = "Landoria_FreeFlyCommand_Request";

		private const string ResponseRpc = "Landoria_FreeFlyCommand_Response";

		private static ZRoutedRpc _registeredRpc;

		private static ZNetPeer _serverPeer;

		private static bool _requestSent;

		internal static bool IsAuthorized { get; private set; }

		internal static void Update()
		{
			RegisterRpcs();
			if ((Object)(object)ZNet.instance == (Object)null || ZRoutedRpc.instance == null)
			{
				ResetConnection();
			}
			else if (ZNet.instance.IsServer())
			{
				UpdateServerAuthorization();
			}
			else
			{
				UpdateClientAuthorization();
			}
		}

		internal static void ResetSession()
		{
			ResetConnection();
		}

		internal static void RequestOnSpawn()
		{
			RegisterRpcs();
			if (!((Object)(object)ZNet.instance == (Object)null) && !ZNet.instance.IsServer() && ZRoutedRpc.instance != null && !_requestSent)
			{
				_serverPeer = ZNet.instance.GetServerPeer();
				if (_serverPeer != null)
				{
					_requestSent = true;
					ZRoutedRpc.instance.InvokeRoutedRPC(_serverPeer.m_uid, "Landoria_FreeFlyCommand_Request", Array.Empty<object>());
				}
			}
		}

		private static void RegisterRpcs()
		{
			ZRoutedRpc instance = ZRoutedRpc.instance;
			if (instance != null && instance != _registeredRpc)
			{
				instance.Register("Landoria_FreeFlyCommand_Request", (Action<long>)ReceiveRequest);
				instance.Register<bool>("Landoria_FreeFlyCommand_Response", (Action<long, bool>)ReceiveResponse);
				_registeredRpc = instance;
			}
		}

		private static void UpdateServerAuthorization()
		{
			if (!ServerRole.IsDedicatedServer)
			{
				SetAuthorized(allowed: false);
				return;
			}
			FreeFlyCommandPlugin.InitializeDedicatedServerSettings();
			SetAuthorized(FreeFlyCommandPlugin.ServerEnabled);
		}

		private static void UpdateClientAuthorization()
		{
			if (!IsAuthorized)
			{
				FreeFlyController.Disable();
			}
			ZNetPeer serverPeer = ZNet.instance.GetServerPeer();
			if (serverPeer != _serverPeer)
			{
				ResetConnection();
				_serverPeer = serverPeer;
			}
		}

		private static void ReceiveRequest(long sender)
		{
			if (ServerRole.IsDedicatedServer && ZNet.instance.GetPeer(sender) != null && ZRoutedRpc.instance != null)
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(sender, "Landoria_FreeFlyCommand_Response", new object[1] { FreeFlyCommandPlugin.ServerEnabled });
			}
		}

		private static void ReceiveResponse(long sender, bool allowed)
		{
			if (!((Object)(object)ZNet.instance == (Object)null) && !ZNet.instance.IsServer() && _serverPeer != null && _serverPeer.m_uid == sender)
			{
				SetAuthorized(allowed);
			}
		}

		private static void ResetConnection()
		{
			_serverPeer = null;
			_requestSent = false;
			FreeFlyController.Disable();
			SetAuthorized(allowed: false);
		}

		private static void SetAuthorized(bool allowed)
		{
			if (IsAuthorized != allowed)
			{
				IsAuthorized = allowed;
				if (!allowed)
				{
					FreeFlyController.Disable();
				}
				FreeFlyCommandPlugin.ModLogger?.LogInfo($"Free-camera authorization is now {allowed}.");
			}
		}
	}
	internal static class FreeFlyCommands
	{
		private static ConsoleCommand _freeFlyCommand;

		private static ConsoleCommand _smoothCommand;

		internal static void Register()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_005a: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			_freeFlyCommand = new ConsoleCommand("freefly", "Toggles the server-authorized native free camera.", new ConsoleEventFailable(ToggleFreeFly), false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			_smoothCommand = new ConsoleCommand("ffsmooth", "[0-1] sets native free-camera smoothing.", new ConsoleEventFailable(SetSmoothness), false, false, false, false, false, false, new ConsoleOptionsFetcher(SmoothnessOptions), false, false, false);
		}

		internal static bool IsManaged(ConsoleCommand command)
		{
			if (command != _freeFlyCommand)
			{
				return command == _smoothCommand;
			}
			return true;
		}

		private static object ToggleFreeFly(ConsoleEventArgs args)
		{
			if (!FreeFlyAuthorization.IsAuthorized)
			{
				return "Free camera is not authorized by this server.";
			}
			FreeFlyController.Toggle();
			return true;
		}

		private static object SetSmoothness(ConsoleEventArgs args)
		{
			if (!FreeFlyAuthorization.IsAuthorized)
			{
				return "Free camera smoothing is not authorized by this server.";
			}
			if (args.Length != 2 || !float.TryParse(args[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) || result < 0f || result > 1f)
			{
				return "Use ffsmooth followed by a value from 0 to 1.";
			}
			GameCamera.instance.SetFreeFlySmoothness(result);
			return true;
		}

		private static List<string> SmoothnessOptions()
		{
			return new List<string> { "0", "0.25", "0.5", "0.75", "1" };
		}
	}
	internal static class FreeFlyController
	{
		internal const float MaximumDistance = 50f;

		internal const float MaximumSpeed = 20f;

		internal const float CollisionRadius = 1f;

		internal const float CollisionClearance = 0.05f;

		internal static float ClampSpeed(float speed)
		{
			return Mathf.Clamp(speed, 1f, 20f);
		}

		internal static void ClampFrameMovement(GameCamera camera, Vector3 origin, float deltaTime)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)camera).transform.position - origin;
			float num = 20f * deltaTime;
			if (((Vector3)(ref val)).sqrMagnitude > num * num)
			{
				((Component)camera).transform.position = origin + ((Vector3)(ref val)).normalized * num;
			}
		}

		internal static void ClampToCollision(GameCamera camera, Vector3 origin)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)camera).transform.position - origin;
			float magnitude = ((Vector3)(ref val)).magnitude;
			RaycastHit val2 = default(RaycastHit);
			if (!(magnitude <= 0.001f) && Physics.SphereCast(origin, 1f, val / magnitude, ref val2, magnitude, LayerMask.op_Implicit(camera.m_blockCameraMask), (QueryTriggerInteraction)1))
			{
				float num = Mathf.Max(0f, ((RaycastHit)(ref val2)).distance - 0.05f);
				((Component)camera).transform.position = origin + ((Vector3)(ref val)).normalized * num;
			}
		}

		internal static void Toggle()
		{
			if (FreeFlyAuthorization.IsAuthorized && !((Object)(object)GameCamera.instance == (Object)null))
			{
				GameCamera.instance.ToggleFreeFly();
			}
		}

		internal static void Disable()
		{
			if ((Object)(object)GameCamera.instance != (Object)null && GameCamera.InFreeFly())
			{
				GameCamera.instance.ToggleFreeFly();
			}
		}

		internal static void ClampToPlayer(GameCamera camera)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if (FreeFlyAuthorization.IsAuthorized && GameCamera.InFreeFly() && !((Object)(object)localPlayer == (Object)null))
			{
				Vector3 val = ((Component)camera).transform.position - ((Component)localPlayer).transform.position;
				if (((Vector3)(ref val)).sqrMagnitude > 2500f)
				{
					((Component)camera).transform.position = ((Component)localPlayer).transform.position + ((Vector3)(ref val)).normalized * 50f;
				}
			}
		}
	}
	[HarmonyPatch(typeof(Player), "OnSpawned")]
	internal static class FreeFlyAuthorizationOnSpawnPatch
	{
		private static void Postfix(Player __instance)
		{
			if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer)
			{
				FreeFlyAuthorization.RequestOnSpawn();
			}
		}
	}
	[HarmonyPatch(typeof(Terminal), "InitTerminal")]
	internal static class FreeFlyCommandRegistrationPatch
	{
		private static void Postfix()
		{
			FreeFlyCommands.Register();
		}
	}
	[HarmonyPatch(typeof(ConsoleCommand), "IsValid")]
	internal static class FreeFlyCommandValidationPatch
	{
		[HarmonyPriority(0)]
		private static void Postfix(ConsoleCommand __instance, ref bool __result)
		{
			if (FreeFlyCommands.IsManaged(__instance) && !FreeFlyAuthorization.IsAuthorized)
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch(typeof(GameCamera), "ToggleFreeFly")]
	internal static class UnauthorizedFreeFlyTogglePatch
	{
		private static bool Prefix()
		{
			if (!FreeFlyAuthorization.IsAuthorized)
			{
				return GameCamera.InFreeFly();
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(GameCamera), "UpdateFreeFly")]
	internal static class FreeFlyMovementPatch
	{
		private static void Prefix(GameCamera __instance, ref float ___m_freeFlySpeed, out Vector3 __state)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			___m_freeFlySpeed = FreeFlyController.ClampSpeed(___m_freeFlySpeed);
			__state = ((Component)__instance).transform.position;
		}

		private static void Postfix(GameCamera __instance, float dt, ref float ___m_freeFlySpeed, Vector3 __state)
		{
			//IL_000a: 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)
			___m_freeFlySpeed = FreeFlyController.ClampSpeed(___m_freeFlySpeed);
			FreeFlyController.ClampFrameMovement(__instance, __state, dt);
			FreeFlyController.ClampToCollision(__instance, __state);
			FreeFlyController.ClampToPlayer(__instance);
		}
	}
	[HarmonyPatch(typeof(ZNet), "OnDestroy")]
	internal static class FreeFlyDisconnectPatch
	{
		private static void Prefix()
		{
			FreeFlyAuthorization.ResetSession();
		}
	}
	[BepInPlugin("Landoria.FreeFlyCommand", "Landoria.FreeFlyCommand", "1.0.10")]
	public sealed class FreeFlyCommandPlugin : LandoriaPlugin
	{
		internal const string PluginGuid = "Landoria.FreeFlyCommand";

		internal const string PluginName = "Landoria.FreeFlyCommand";

		internal const string PluginVersion = "1.0.10";

		private const string EnabledArgument = "--freeflycommand";

		private static bool settingsInitialized;

		internal static ModLog ModLogger { get; private set; }

		internal static bool ServerEnabled { get; private set; }

		private void Awake()
		{
			ModLogger = InitializePlugin("Landoria.FreeFlyCommand");
			FreeFlyCommands.Register();
			ModLogger.LogInfo("Landoria.FreeFlyCommand 1.0.10 is loaded.");
		}

		internal static void InitializeDedicatedServerSettings()
		{
			if (!settingsInitialized && ServerRole.IsDedicatedServer)
			{
				ServerEnabled = ReadServerEnabled();
				settingsInitialized = true;
			}
		}

		private void Update()
		{
			FreeFlyAuthorization.Update();
		}

		private static bool ReadServerEnabled()
		{
			string[] commandLineArgs = Environment.GetCommandLineArgs();
			for (int i = 0; i < commandLineArgs.Length; i++)
			{
				if (string.Equals(commandLineArgs[i], "--freeflycommand", StringComparison.OrdinalIgnoreCase))
				{
					if (i + 1 < commandLineArgs.Length && bool.TryParse(commandLineArgs[i + 1], out var result))
					{
						return result;
					}
					ModLogger.LogWarning("Invalid --freeflycommand value; using true.");
					return true;
				}
			}
			return true;
		}

		private void OnDestroy()
		{
			FreeFlyAuthorization.ResetSession();
			ModLogger?.LogInfo("Landoria.FreeFlyCommand 1.0.10 is unloaded.");
			ShutdownPlugin();
			ServerEnabled = false;
			settingsInitialized = false;
			ModLogger = null;
		}
	}
}
namespace Landoria.SharedLib
{
	public abstract class LandoriaPlugin : BaseUnityPlugin
	{
		private Harmony _harmony;

		private bool _patchesApplied;

		protected ModLog InitializePlugin(string pluginGuid)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			ModLog modLog = new ModLog(((BaseUnityPlugin)this).Logger);
			Version version = ((object)this).GetType().Assembly.GetName().Version;
			modLog.LogInfo($"AssemblyVersion: {version}.");
			EnsureSharedPatches(modLog);
			_harmony = new Harmony(pluginGuid);
			PatchOwnNamespace(modLog);
			return modLog;
		}

		protected ModLog InitializePlugin(string pluginGuid, Type[] patchTypes)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			ModLog modLog = new ModLog(((BaseUnityPlugin)this).Logger);
			Version version = ((object)this).GetType().Assembly.GetName().Version;
			modLog.LogInfo($"AssemblyVersion: {version}.");
			EnsureSharedPatches(modLog);
			_harmony = new Harmony(pluginGuid);
			foreach (Type type in patchTypes)
			{
				_harmony.CreateClassProcessor(type).Patch();
				modLog.LogInfo("Server patch: " + type.Name);
			}
			_patchesApplied = true;
			return modLog;
		}

		private static void EnsureSharedPatches(ModLog log)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			lock (AppDomain.CurrentDomain)
			{
				if (AppDomain.CurrentDomain.GetData("Landoria.SharedLib.ConnectionFailureMenuPatch.v1") == null)
				{
					new Harmony("Landoria.SharedLib").CreateClassProcessor(typeof(ConnectionFailureMenuPatch)).Patch();
					AppDomain.CurrentDomain.SetData("Landoria.SharedLib.ConnectionFailureMenuPatch.v1", true);
					log.LogDebug("Shared connection failure menu patch was applied.");
				}
			}
		}

		protected void PatchOwnNamespace(ModLog log)
		{
			if (_patchesApplied)
			{
				log.LogDebug("Harmony patches are already active; skipping registration.");
				return;
			}
			string text = ((object)this).GetType().Namespace;
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			foreach (Type type in types)
			{
				if (type.Namespace == text)
				{
					_harmony.CreateClassProcessor(type).Patch();
				}
			}
			_patchesApplied = true;
			log.LogDebug("Harmony patches were applied for the plugin namespace.");
		}

		protected void ShutdownPlugin()
		{
			if (_patchesApplied)
			{
				Harmony harmony = _harmony;
				if (harmony != null)
				{
					harmony.UnpatchSelf();
				}
				_patchesApplied = false;
			}
		}
	}
	public static class ConnectionFailureMessages
	{
		private const string StateKey = "Landoria.SharedLib.ConnectionFailureMessages.v1";

		private static readonly ManualLogSource Log = Logger.CreateLogSource("Landoria.ConnectionFailureMessages");

		public static void Push(string source, string message)
		{
			Push(source, message, (string)null);
		}

		public static void Push(string source, string userMessage, string systemMessage)
		{
			Push(source, userMessage, systemMessage, null);
		}

		public static void Push(string source, string userMessage, Exception exception)
		{
			Push(source, userMessage, exception?.Message, exception);
		}

		public static void Push(string source, string userMessage, string systemMessage, Exception exception)
		{
			string text = DisplayMessage(userMessage, systemMessage ?? exception?.Message);
			if (string.IsNullOrWhiteSpace(source) || text == null)
			{
				return;
			}
			bool flag = false;
			lock (AppDomain.CurrentDomain)
			{
				Stack<Tuple<string, string, string>> messages = GetMessages();
				Tuple<string, string, string> item = Tuple.Create(source, text, systemMessage);
				if (!messages.Contains(item))
				{
					messages.Push(item);
					flag = true;
				}
			}
			if (flag)
			{
				LogQueued(source, text, systemMessage, exception);
			}
		}

		public static void Clear(string source)
		{
			if (string.IsNullOrWhiteSpace(source))
			{
				return;
			}
			lock (AppDomain.CurrentDomain)
			{
				Stack<Tuple<string, string, string>> messages = GetMessages();
				Stack<Tuple<string, string, string>> stack = new Stack<Tuple<string, string, string>>();
				while (messages.Count > 0)
				{
					Tuple<string, string, string> tuple = messages.Pop();
					if (tuple.Item1 != source)
					{
						stack.Push(tuple);
					}
				}
				while (stack.Count > 0)
				{
					messages.Push(stack.Pop());
				}
			}
		}

		internal static bool TryPopAll(out string message)
		{
			lock (AppDomain.CurrentDomain)
			{
				Stack<Tuple<string, string, string>> messages = GetMessages();
				if (messages.Count > 0)
				{
					List<string> list = new List<string>();
					while (messages.Count > 0)
					{
						list.Add(messages.Pop().Item2);
					}
					message = string.Join("\n", list);
					return true;
				}
			}
			message = null;
			return false;
		}

		private static Stack<Tuple<string, string, string>> GetMessages()
		{
			if (AppDomain.CurrentDomain.GetData("Landoria.SharedLib.ConnectionFailureMessages.v1") is Stack<Tuple<string, string, string>> result)
			{
				return result;
			}
			Stack<Tuple<string, string, string>> stack = new Stack<Tuple<string, string, string>>();
			AppDomain.CurrentDomain.SetData("Landoria.SharedLib.ConnectionFailureMessages.v1", stack);
			return stack;
		}

		private static string DisplayMessage(string userMessage, string systemMessage)
		{
			if (!string.IsNullOrWhiteSpace(userMessage))
			{
				return userMessage;
			}
			if (!string.IsNullOrWhiteSpace(systemMessage))
			{
				return systemMessage;
			}
			return null;
		}

		private static void LogQueued(string source, string userMessage, string systemMessage, Exception exception)
		{
			string text = exception?.ToString() ?? Environment.StackTrace;
			if (string.IsNullOrWhiteSpace(systemMessage) || systemMessage == userMessage)
			{
				Log.LogWarning((object)("Queued connection failure message from " + source + ": " + userMessage + "\nDiagnostic stack:\n" + text));
			}
			else
			{
				Log.LogWarning((object)("Queued connection failure message from " + source + ": userMessage=" + userMessage + "; systemMessage=" + systemMessage + "\nDiagnostic stack:\n" + text));
			}
		}
	}
	[HarmonyPatch]
	internal static class ConnectionFailureMenuPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(FejdStartup), "ShowConnectError")]
		private static void ShowConnectError(TMP_Text ___m_connectionFailedError)
		{
			if (ConnectionFailureMessages.TryPopAll(out var message))
			{
				___m_connectionFailedError.text = message;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(FejdStartup), "Start")]
		private static void Start(GameObject ___m_connectionFailedPanel, TMP_Text ___m_connectionFailedError)
		{
			ShowNext(___m_connectionFailedPanel, ___m_connectionFailedError);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(FejdStartup), "OnConnectionFailedOk")]
		private static void OnConnectionFailedOk(GameObject ___m_connectionFailedPanel, TMP_Text ___m_connectionFailedError)
		{
			ShowNext(___m_connectionFailedPanel, ___m_connectionFailedError);
		}

		private static void ShowNext(GameObject panel, TMP_Text text)
		{
			if (ConnectionFailureMessages.TryPopAll(out var message))
			{
				text.text = message;
				panel.SetActive(true);
			}
		}
	}
	public sealed class ModLog
	{
		private readonly ManualLogSource _logger;

		public ModLog(ManualLogSource logger)
		{
			_logger = logger;
		}

		public void LogFatal(object message)
		{
			Write((LogLevel)1, message);
		}

		public void LogError(object message)
		{
			Write((LogLevel)2, message);
		}

		public void LogWarning(object message)
		{
			Write((LogLevel)4, message);
		}

		public void LogMessage(object message)
		{
			Write((LogLevel)8, message);
		}

		public void LogInfo(object message)
		{
			Write((LogLevel)16, message);
		}

		public void LogDebug(object message)
		{
			Write((LogLevel)32, message);
		}

		public void Log(LogLevel level, object message)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			Write(level, message);
		}

		private void Write(LogLevel level, object message)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			string arg = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
			_logger.Log(level, (object)$"[{arg}] {message}");
		}
	}
	public static class PlatformPlayerIdentity
	{
		public unsafe static string Resolve(PlayerInfo player)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			string text = ((object)(*(PlatformUserID*)(&player.m_userInfo.m_id))/*cast due to .constrained prefix*/).ToString();
			if (!string.IsNullOrWhiteSpace(text))
			{
				return text;
			}
			ZNetPeer obj = FindPeer(player);
			if (obj == null)
			{
				return null;
			}
			ISocket socket = obj.m_socket;
			if (socket == null)
			{
				return null;
			}
			return socket.GetHostName();
		}

		public static ZNetPeer FindPeer(PlayerInfo player)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ZNet.instance == (Object)null || ((ZDOID)(ref player.m_characterID)).IsNone())
			{
				return null;
			}
			return ((IEnumerable<ZNetPeer>)ZNet.instance.GetPeers()).FirstOrDefault((Func<ZNetPeer, bool>)((ZNetPeer peer) => peer != null && ((ZDOID)(ref peer.m_characterID)).Equals(player.m_characterID)));
		}
	}
	public static class ServerRole
	{
		public static bool IsDedicatedServer
		{
			get
			{
				if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer())
				{
					return ZNet.instance.IsDedicated();
				}
				return false;
			}
		}
	}
}