Decompiled source of CharactherCloner v3.1.4

CharactherCloner.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using CharactherCloner.HarmonyPatches;
using CharactherCloner.Wrappers;
using CharactherCloner.Wrappers.Handler;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mirror;
using Mirror.FizzySteam;
using Steamworks;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("s0apy")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("3.1.4.0")]
[assembly: AssemblyInformationalVersion("3.1.4+ceff78b393bae6f42e3e550e9b9fc0f5802577d9")]
[assembly: AssemblyProduct("CharactherCloner")]
[assembly: AssemblyTitle("CharactherCloner")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.1.4.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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 CharactherCloner
{
	public class Cloner
	{
		private const int SameSteamIdShutdownThreshold = 6;

		public static void AttemptCloningReconnect()
		{
			if (NetworkClient.isConnected)
			{
				ulong serverID = Server.ServerID;
				CoroutineHelper.RunCoroutine(WaitForCharacterAndRejoin(serverID));
			}
			else
			{
				Debug.LogWarning((object)"[CLONER] Not connected to a server, cannot start cloning reconnect process.");
			}
		}

		private static IEnumerator WaitForCharacterAndRejoin(ulong serverId)
		{
			((NetworkManager)AtlyssNetworkManager._current).StopClient();
			Game.Console("[CLONER] Please select a character to complete the cloning process.");
			Debug.Log((object)"[CLONER] Client disconnected. Waiting for user to select a character.");
			Hook.iplayerselected = false;
			yield return (object)new WaitUntil((Func<bool>)(() => Hook.iplayerselected));
			Debug.Log((object)$"[CLONER] Character {ProfileDataManager._current.SelectedFileIndex} selected. Rejoining lobby...");
			try
			{
				CSteamID lobbyId = new CSteamID(serverId);
				SteamLobby._current.JoinLobby(lobbyId);
				Hook.iplayerselected = false;
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[CLONER] Failed to rejoin lobby: " + ex.Message));
				yield break;
			}
			Debug.Log((object)"[CLONER] Cloning... Waiting for connection to complete.");
			Game.Console("[CLONER] Cloning...");
			float connectionTimeout = 15f;
			float timer = 0f;
			while (!NetworkClient.isConnected && timer < connectionTimeout)
			{
				timer += Time.deltaTime;
				yield return null;
			}
			if (!NetworkClient.isConnected)
			{
				Debug.LogError((object)"[CLONER] Connection timed out. Cloning failed.");
				Game.Console("[CLONER] Connection failed. Could not complete cloning.");
				yield break;
			}
			Debug.Log((object)"[CLONER] Connection complete. Waiting for player object to initialize...");
			float playerInitTimeout = 5f;
			float initTimer = 0f;
			string newCloneId = null;
			while (string.IsNullOrEmpty(newCloneId) && initTimer < playerInitTimeout)
			{
				newCloneId = SafeGetPlayerNID();
				initTimer += Time.deltaTime;
				yield return null;
			}
			Player newCloneInstance = Player.GetPlayer();
			if ((Object)(object)newCloneInstance != (Object)null && !string.IsNullOrEmpty(newCloneId))
			{
				string resolvedName = Player.ResolvePlayersNames(newCloneId);
				string displayName = (string.IsNullOrEmpty(resolvedName) ? newCloneId : resolvedName);
				Debug.Log((object)("[CLONER] Found new clone instance: '" + displayName + "' (" + newCloneId + ")"));
				string localSteamIdString = Player.GetPlayerSTID().ToString();
				int sameSteamIdCount = 0;
				List<string> allPlayerIds = Player.GetAllPlayers();
				foreach (string playerId in allPlayerIds)
				{
					GameObject playerObject = Player.FindOtherPlayersNID(playerId);
					if ((Object)(object)playerObject != (Object)null)
					{
						Player playerComponent = playerObject.GetComponent<Player>();
						if ((Object)(object)playerComponent != (Object)null && playerComponent._steamID == localSteamIdString)
						{
							sameSteamIdCount++;
						}
					}
				}
				if (sameSteamIdCount >= 6)
				{
					string errorMessage = $"CRITICAL: Detected {sameSteamIdCount} players from your Steam account in the scene. Shutting down.";
					Debug.LogError((object)("[SECURITY] " + errorMessage));
					Game.Console("[SECURITY] " + errorMessage);
					CoroutineHelper.InitiateEmergencyShutdown();
				}
				else
				{
					CloneManager.RegisterClone(newCloneInstance, newCloneId);
					Debug.Log((object)("[CLONER] Done! Successfully connected as '" + displayName + "'."));
					Game.Console("[CLONER] Character '" + displayName + "' has been successfully cloned!");
				}
			}
			else
			{
				Debug.LogError((object)"[CLONER] Timed out waiting for player object to initialize after reconnecting!");
				Game.Console("[CLONER] Cloning failed: Player object did not initialize in time.");
			}
		}

		private static string SafeGetPlayerNID()
		{
			Player mainPlayer = Player._mainPlayer;
			return ((Object)(object)mainPlayer == (Object)null || (Object)(object)((NetworkBehaviour)mainPlayer).netIdentity == (Object)null) ? null : ((Object)((NetworkBehaviour)mainPlayer).netIdentity).name;
		}

		public static void DisconnectCloner()
		{
			if (Main.IsExpired)
			{
				Debug.LogError((object)"[CLONER] This mod has reached End of Support and must be uninstalled.");
				return;
			}
			if (!NetworkClient.active)
			{
				Debug.LogError((object)"[CLONER] Your not connected!");
				return;
			}
			Server.FindAndStoreClientConnectionInfo();
			string grabbedSteamID = Server.grabbedSteamID64;
			InitiateCustomConnection(grabbedSteamID);
		}

		public static void InitiateCustomConnection(string hostSteamId)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			if (!ulong.TryParse(hostSteamId, out var result))
			{
				Debug.LogError((object)("[CLONER] Could not parse the input '" + hostSteamId + "' as a valid ulong."));
				return;
			}
			try
			{
				Transport active = Transport.active;
				FizzySteamworks val = (FizzySteamworks)(object)((active is FizzySteamworks) ? active : null);
				if (val == null)
				{
					Debug.LogError((object)"[CLONER] Active transport is not FizzySteamworks. Cannot proceed.");
					return;
				}
				object value = Reflection.GetValue(val, "client");
				if (value == null)
				{
					Debug.LogError((object)"[CLONER] Reflection failed: The 'client' field is null or was not found.");
					return;
				}
				CSteamID val2 = default(CSteamID);
				((CSteamID)(ref val2))..ctor(result);
				Reflection.SetValue(value, "hostSteamID", val2);
				Reflection.InvokeMethod(value, "Connect", hostSteamId);
				Debug.Log((object)"[CLONER] Successfully invoked private connect sequence via custom wrapper.");
				AttemptCloningReconnect();
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"[CLONER] An exception occurred while using the reflection wrapper: {arg}");
			}
		}
	}
	public class CoroutineHelper : MonoBehaviour
	{
		private static CoroutineHelper _instance;

		private static bool _isShuttingDown;

		public static CoroutineHelper Instance
		{
			get
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				if ((Object)(object)_instance == (Object)null)
				{
					GameObject val = new GameObject("CoroutineHelper");
					_instance = val.AddComponent<CoroutineHelper>();
					Object.DontDestroyOnLoad((Object)(object)val);
				}
				return _instance;
			}
		}

		public static Coroutine RunCoroutine(IEnumerator routine)
		{
			return ((MonoBehaviour)Instance).StartCoroutine(routine);
		}

		public static void InitiateEmergencyShutdown()
		{
			if (!_isShuttingDown)
			{
				_isShuttingDown = true;
				((MonoBehaviour)Instance).StartCoroutine(ShutdownCoroutine());
			}
		}

		private static IEnumerator ShutdownCoroutine()
		{
			for (int i = 10; i > 0; i--)
			{
				string message = $"[SECURITY] CLONE LIMIT EXCEEDED! Forcing game closure in {i} seconds...";
				Debug.LogError((object)message);
				Game.Console(message);
				Console.Beep();
				yield return (object)new WaitForSeconds(1f);
			}
			Debug.LogError((object)"[SECURITY] SHUTTING DOWN NOW.");
			Game.Console("[SECURITY] SHUTTING DOWN NOW.");
			Application.Quit();
			Process.GetCurrentProcess().Kill();
		}
	}
	public static class CloneManager
	{
		public const int MaxClonesAllowed = 5;

		public static readonly Dictionary<string, Player> ClonesById = new Dictionary<string, Player>();

		public static void RegisterClone(Player clonePlayer, string cloneId)
		{
			if ((Object)(object)clonePlayer == (Object)null || string.IsNullOrEmpty(cloneId) || ClonesById.ContainsKey(cloneId))
			{
				Debug.LogWarning((object)("[CLONE_MANAGER] Attempted to register a null, duplicate, or invalid ID clone: " + cloneId));
				return;
			}
			ClonesById[cloneId] = clonePlayer;
			CloneTracker cloneTracker = ((Component)clonePlayer).gameObject.AddComponent<CloneTracker>();
			cloneTracker.CloneId = cloneId;
			Debug.Log((object)$"[CLONE_MANAGER] New clone registered with ID '{cloneId}'. Total local clones: {ClonesById.Count}");
			if (ClonesById.Count > 5)
			{
				Debug.LogError((object)$"[SECURITY] CRITICAL: Local clone limit of {5} exceeded. Initiating emergency shutdown.");
				CoroutineHelper.InitiateEmergencyShutdown();
			}
		}

		public static void UnregisterClone(string cloneId)
		{
			if (!string.IsNullOrEmpty(cloneId) && ClonesById.Remove(cloneId))
			{
				Debug.Log((object)$"[CLONE_MANAGER] Clone with ID '{cloneId}' was destroyed. Total active local clones: {ClonesById.Count - 1}");
			}
		}

		public static GameObject GetCloneGameObject(string cloneId)
		{
			if (ClonesById.TryGetValue(cloneId, out Player value) && (Object)(object)value != (Object)null)
			{
				return ((Component)value).gameObject;
			}
			return null;
		}
	}
	public class CloneTracker : MonoBehaviour
	{
		public string CloneId { get; set; }

		private void OnDestroy()
		{
			if (!string.IsNullOrEmpty(CloneId))
			{
				CloneManager.UnregisterClone(CloneId);
			}
		}
	}
	[BepInPlugin("com.s0apy.CharactherCloner", "CharactherCloner", "3.1.4")]
	public class Main : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("com.s0apy.CharactherCloner");

		private bool _isMenuVisible = false;

		private Rect _windowRect = new Rect(20f, 20f, 250f, 150f);

		internal static readonly DateTime EndOfSupportUtc = new DateTime(2026, 11, 30, 0, 0, 0, DateTimeKind.Utc);

		private const string DevPing = "@runeaphobia";

		private const string DevContact = "ping @runeaphobia in the Atlyss Modding Central or runem0dz Discord server";

		private const string RunemodzInvite = "https://discord.gg/ePhX4Fb2we";

		private const string ModdingCentralInvite = "https://discord.gg/CqdS3aZJZn";

		private const string NotifyChannelUrl = "https://discord.com/channels/1395549829962137690/1395556467083575447";

		private bool _expiredHandled = false;

		private Rect _noticeRect;

		internal static bool IsExpired => DateTime.UtcNow >= EndOfSupportUtc;

		private void HandleExpiry()
		{
			_expiredHandled = true;
			_isMenuVisible = false;
			_harmony.UnpatchSelf();
			((BaseUnityPlugin)this).Logger.LogError((object)string.Format("[{0} v{1}] This mod is DEPRECATED. It reached End of Support on {2:yyyy-MM-dd HH:mm} UTC and has been disabled.", "CharactherCloner", "3.1.4", EndOfSupportUtc));
			((BaseUnityPlugin)this).Logger.LogError((object)"[CharactherCloner] To avoid conflicts in the future, it MUST be uninstalled: delete the Characther Cloner .dll from BepInEx/plugins.");
			((BaseUnityPlugin)this).Logger.LogError((object)"[CharactherCloner] Please also notify the developer: ping @runeaphobia in the Atlyss Modding Central or runem0dz Discord server. Channel: https://discord.com/channels/1395549829962137690/1395556467083575447");
		}

		private void DrawExpiryNotice(int id)
		{
			GUILayout.Label("This mod has reached its End of Support date and no longer functions.", Array.Empty<GUILayoutOption>());
			GUILayout.Space(8f);
			GUILayout.Label("Please REMOVE it (delete the Characther Cloner .dll from BepInEx/plugins).", Array.Empty<GUILayoutOption>());
			GUILayout.Space(8f);
			GUILayout.Label("You must also notify the developer: ping @runeaphobia in the notification channel of the Atlyss Modding Central server (or the runem0dz server) to confirm you've seen this notice.", Array.Empty<GUILayoutOption>());
			GUILayout.Space(8f);
			if (GUILayout.Button("Open notification channel (Atlyss Modding Central)", Array.Empty<GUILayoutOption>()))
			{
				Application.OpenURL("https://discord.com/channels/1395549829962137690/1395556467083575447");
			}
			if (GUILayout.Button("Join Atlyss Modding Central", Array.Empty<GUILayoutOption>()))
			{
				Application.OpenURL("https://discord.gg/CqdS3aZJZn");
			}
			if (GUILayout.Button("Join runem0dz", Array.Empty<GUILayoutOption>()))
			{
				Application.OpenURL("https://discord.gg/ePhX4Fb2we");
			}
			if (GUILayout.Button("Copy @runeaphobia to clipboard", Array.Empty<GUILayoutOption>()))
			{
				GUIUtility.systemCopyBuffer = "@runeaphobia";
			}
			GUI.DragWindow();
		}

		private void Awake()
		{
			if (IsExpired)
			{
				HandleExpiry();
				return;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Patching with Harmony ID: com.s0apy.CharactherCloner");
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Harmony patching complete.");
			CoroutineHelper instance = CoroutineHelper.Instance;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"CoroutineHelper initialized.");
			int num = (int)(EndOfSupportUtc - DateTime.UtcNow).TotalDays;
			((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("Plugin {0} is loaded! Support ends in {1} day(s).", "CharactherCloner", num));
		}

		private void Update()
		{
			if (!_expiredHandled && IsExpired)
			{
				HandleExpiry();
			}
			if (!_expiredHandled && Input.GetKeyDown((KeyCode)278))
			{
				_isMenuVisible = !_isMenuVisible;
			}
		}

		private void OnGUI()
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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)
			//IL_0079: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if (_expiredHandled)
			{
				if (((Rect)(ref _noticeRect)).width == 0f)
				{
					_noticeRect = new Rect((float)(Screen.width - 460) / 2f, (float)(Screen.height - 340) / 2f, 460f, 340f);
				}
				_noticeRect = GUI.Window(1, _noticeRect, new WindowFunction(DrawExpiryNotice), "Character Cloner - End of Support");
			}
			else if (_isMenuVisible)
			{
				_windowRect = GUILayout.Window(0, _windowRect, new WindowFunction(DrawMenuWindow), "Character Cloner Menu", Array.Empty<GUILayoutOption>());
			}
		}

		private void DrawMenuWindow(int windowID)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.Space(15f);
			if (GUILayout.Button("Start Cloning", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) }))
			{
				Cloner.DisconnectCloner();
			}
			GUILayout.FlexibleSpace();
			GUILayout.Label("Press [HOME] to toggle menu", Array.Empty<GUILayoutOption>());
			GUI.DragWindow(new Rect(0f, 0f, 10000f, 25f));
		}
	}
	internal static class ModInfo
	{
		public const string GUID = "com.s0apy.CharactherCloner";

		public const string NAME = "CharactherCloner";

		public const string VERSION = "3.1.4";
	}
}
namespace CharactherCloner.Wrappers
{
	public class Game
	{
		internal static void Console(string msg)
		{
			HostConsole._current.Init_NetworkStatusMessage(msg);
		}
	}
	public class Player
	{
		internal static Player GetPlayer()
		{
			return Player._mainPlayer;
		}

		internal static ulong GetPlayerSTID()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return SteamUser.GetSteamID().m_SteamID;
		}

		internal static string GetPlayerNID()
		{
			return ((Object)((NetworkBehaviour)Player._mainPlayer).netIdentity).name;
		}

		internal static GameObject FindOtherPlayersNID(string targetName)
		{
			GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
			int num = array.Length;
			for (int i = 0; i < num; i++)
			{
				GameObject val = array[i];
				NetworkIdentity componentInChildren = val.GetComponentInChildren<NetworkIdentity>();
				if ((Object)(object)componentInChildren != (Object)null && ((Object)componentInChildren).name == targetName)
				{
					return val;
				}
			}
			return null;
		}

		internal static string ResolvePlayersNames(string targetName)
		{
			GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
			int num = array.Length;
			for (int i = 0; i < num; i++)
			{
				GameObject val = array[i];
				Player componentInChildren = val.GetComponentInChildren<Player>();
				if ((Object)(object)componentInChildren != (Object)null && ((Object)componentInChildren).name == targetName)
				{
					return componentInChildren._nickname;
				}
			}
			return null;
		}

		internal static List<string> GetAllPlayers()
		{
			int num = LayerMask.NameToLayer("PlayerObject");
			GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
			List<string> list = new List<string>(array.Length);
			int num2 = array.Length;
			for (int i = 0; i < num2; i++)
			{
				GameObject val = array[i];
				if (val.layer == num && ((Object)val).name.Contains("_player"))
				{
					list.Add(((Object)val).name);
				}
			}
			return list;
		}
	}
	public class World
	{
		internal static string GetServerName()
		{
			return ServerInfoObject._current.Network_serverName;
		}

		internal static ulong GetServerID()
		{
			return SteamLobby._current._currentLobbyID;
		}
	}
}
namespace CharactherCloner.Wrappers.Handler
{
	public static class Reflection
	{
		private const BindingFlags DefaultBindingFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public;

		public static object InvokeMethod(object obj, string methodName, params object[] parameters)
		{
			MethodInfo method = GetMethod(obj.GetType(), methodName, parameters.Select((object p) => p.GetType()).ToArray());
			if (method == null)
			{
				throw new MissingMethodException(obj.GetType().FullName, methodName);
			}
			return method.Invoke(obj, parameters);
		}

		public static object InvokeStaticMethod(Type type, string methodName, params object[] parameters)
		{
			MethodInfo method = GetMethod(type, methodName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, parameters);
			if (method == null)
			{
				throw new MissingMethodException(type.FullName, methodName);
			}
			return method.Invoke(null, parameters);
		}

		public static MethodInfo GetMethod(Type type, string methodName, params Type[] parameterTypes)
		{
			return type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, parameterTypes, null);
		}

		public static MethodInfo GetMethod(Type type, string methodName, BindingFlags bindingFlags, params object[] parameters)
		{
			Type[] types = parameters?.Select((object p) => p.GetType()).ToArray() ?? Type.EmptyTypes;
			return type.GetMethod(methodName, bindingFlags, null, types, null);
		}

		public static MethodInfo[] GetMethods(Type type)
		{
			return type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
		}

		public static object GetValue(object obj, string memberName)
		{
			MemberInfo memberInfo = obj.GetType().GetMember(memberName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault();
			MemberInfo memberInfo2 = memberInfo;
			MemberInfo memberInfo3 = memberInfo2;
			if (!(memberInfo3 is FieldInfo fieldInfo))
			{
				if (memberInfo3 is PropertyInfo propertyInfo)
				{
					return propertyInfo.GetValue(obj);
				}
				throw new ArgumentException("Member '" + memberName + "' not found.", "memberName");
			}
			return fieldInfo.GetValue(obj);
		}

		public static void SetValue(object obj, string memberName, object value)
		{
			MemberInfo memberInfo = obj.GetType().GetMember(memberName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault();
			MemberInfo memberInfo2 = memberInfo;
			MemberInfo memberInfo3 = memberInfo2;
			if (!(memberInfo3 is FieldInfo fieldInfo))
			{
				if (!(memberInfo3 is PropertyInfo propertyInfo))
				{
					throw new ArgumentException("Member '" + memberName + "' not found.", "memberName");
				}
				propertyInfo.SetValue(obj, value, null);
			}
			else
			{
				fieldInfo.SetValue(obj, value);
			}
		}

		public static object GetStaticValue(Type type, string memberName)
		{
			MemberInfo memberInfo = type.GetMember(memberName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault();
			MemberInfo memberInfo2 = memberInfo;
			MemberInfo memberInfo3 = memberInfo2;
			if (!(memberInfo3 is FieldInfo fieldInfo))
			{
				if (memberInfo3 is PropertyInfo propertyInfo)
				{
					return propertyInfo.GetValue(null);
				}
				throw new ArgumentException("Static member '" + memberName + "' not found in type '" + type.FullName + "'.", "memberName");
			}
			return fieldInfo.GetValue(null);
		}

		public static void SetStaticValue(Type type, string memberName, object value)
		{
			MemberInfo memberInfo = type.GetMember(memberName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault();
			MemberInfo memberInfo2 = memberInfo;
			MemberInfo memberInfo3 = memberInfo2;
			if (!(memberInfo3 is FieldInfo fieldInfo))
			{
				if (!(memberInfo3 is PropertyInfo propertyInfo))
				{
					throw new ArgumentException("Static member '" + memberName + "' not found in type '" + type.FullName + "'.", "memberName");
				}
				propertyInfo.SetValue(null, value);
			}
			else
			{
				fieldInfo.SetValue(null, value);
			}
		}
	}
	public class Server
	{
		public static string grabbedConnectionHandle;

		public static string grabbedSteamID64;

		public static string Ready2CopyInfo;

		public static string HostName { get; set; }

		public static string ServerName { get; private set; }

		public static ulong ServerID { get; private set; }

		public static void FindAndStoreClientConnectionInfo()
		{
			if (!NetworkClient.active || (Object)(object)Player.GetPlayer() == (Object)null)
			{
				return;
			}
			ServerName = World.GetServerName();
			ServerID = World.GetServerID();
			try
			{
				object staticValue = Reflection.GetStaticValue(typeof(FizzySteamworks), "client");
				if (staticValue != null)
				{
					object value = Reflection.GetValue(staticValue, "hostSteamID");
					if (value != null)
					{
						grabbedSteamID64 = Reflection.GetValue(value, "m_SteamID")?.ToString() ?? "N/A";
					}
					GatherInfoPrint();
				}
			}
			catch (Exception)
			{
			}
		}

		public static void GatherInfoPrint()
		{
			ulong serverID = ServerID;
		}
	}
	public static class ServerConnectionManager
	{
		private static bool _hasHostId;

		public static CSteamID CurrentHostSteamID { get; private set; }

		public static void SetHostSteamID(CSteamID hostID)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			CurrentHostSteamID = hostID;
			_hasHostId = true;
			Debug.Log((object)$"[ServerConnectionManager] Host Steam ID stored: {hostID}");
		}

		public static void ClearHostSteamID()
		{
			_hasHostId = false;
		}

		public static bool HasHostID()
		{
			return _hasHostId;
		}
	}
}
namespace CharactherCloner.HarmonyPatches
{
	[HarmonyPatch]
	internal static class Hook
	{
		private static string _lastPlayerName;

		private static string _lastMessage;

		private static DateTime _lastMessageTime;

		public static bool iplayerselected;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CharacterSelectManager), "Select_CharacterFile")]
		public static void AfterCharacterSelect()
		{
			iplayerselected = true;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}