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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CharactherCloner")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("3.0.7.0")]
[assembly: AssemblyInformationalVersion("3.0.7+ceff78b393bae6f42e3e550e9b9fc0f5802577d9")]
[assembly: AssemblyProduct("CharactherCloner")]
[assembly: AssemblyTitle("CharactherCloner")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.0.7.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.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]
[Microsoft.CodeAnalysis.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]
[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 CharactherCloner
{
public class Cloner
{
[CompilerGenerated]
private sealed class <WaitForCharacterAndRejoin>d__2 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public ulong serverId;
private float <connectionTimeout>5__1;
private float <timer>5__2;
private float <playerInitTimeout>5__3;
private float <initTimer>5__4;
private string <newCloneId>5__5;
private Player <newCloneInstance>5__6;
private CSteamID <lobbyId>5__7;
private Exception <e>5__8;
private string <resolvedName>5__9;
private string <displayName>5__10;
private ulong <localSteamIdUlong>5__11;
private string <localSteamIdString>5__12;
private int <sameSteamIdCount>5__13;
private List<string> <allPlayerIds>5__14;
private List<string>.Enumerator <>s__15;
private string <playerId>5__16;
private GameObject <playerObject>5__17;
private Player <playerComponent>5__18;
private string <errorMessage>5__19;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForCharacterAndRejoin>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<newCloneId>5__5 = null;
<newCloneInstance>5__6 = null;
<e>5__8 = null;
<resolvedName>5__9 = null;
<displayName>5__10 = null;
<localSteamIdString>5__12 = null;
<allPlayerIds>5__14 = null;
<>s__15 = default(List<string>.Enumerator);
<playerId>5__16 = null;
<playerObject>5__17 = null;
<playerComponent>5__18 = null;
<errorMessage>5__19 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Expected O, but got Unknown
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
((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;
<>2__current = (object)new WaitUntil((Func<bool>)(() => Hook.iplayerselected));
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
Debug.Log((object)$"[CLONER] Character {ProfileDataManager._current.SelectedFileIndex} selected. Rejoining lobby...");
try
{
<lobbyId>5__7 = new CSteamID(serverId);
SteamLobby._current.JoinLobby(<lobbyId>5__7);
Hook.iplayerselected = false;
}
catch (Exception ex)
{
<e>5__8 = ex;
Debug.LogError((object)("[CLONER] Failed to rejoin lobby: " + <e>5__8.Message));
return false;
}
Debug.Log((object)"[CLONER] Cloning... Waiting for connection to complete.");
Game.Console("[CLONER] Cloning...");
<connectionTimeout>5__1 = 15f;
<timer>5__2 = 0f;
goto IL_0167;
case 2:
<>1__state = -1;
goto IL_0167;
case 3:
{
<>1__state = -1;
break;
}
IL_0167:
if (!NetworkClient.isConnected && <timer>5__2 < <connectionTimeout>5__1)
{
<timer>5__2 += Time.deltaTime;
<>2__current = null;
<>1__state = 2;
return true;
}
if (!NetworkClient.isConnected)
{
Debug.LogError((object)"[CLONER] Connection timed out. Cloning failed.");
Game.Console("[CLONER] Connection failed. Could not complete cloning.");
return false;
}
Debug.Log((object)"[CLONER] Connection complete. Waiting for player object to initialize...");
<playerInitTimeout>5__3 = 5f;
<initTimer>5__4 = 0f;
<newCloneId>5__5 = null;
break;
}
if (string.IsNullOrEmpty(<newCloneId>5__5) && <initTimer>5__4 < <playerInitTimeout>5__3)
{
<newCloneId>5__5 = SafeGetPlayerNID();
<initTimer>5__4 += Time.deltaTime;
<>2__current = null;
<>1__state = 3;
return true;
}
<newCloneInstance>5__6 = Player.GetPlayer();
if ((Object)(object)<newCloneInstance>5__6 != (Object)null && !string.IsNullOrEmpty(<newCloneId>5__5))
{
<resolvedName>5__9 = Player.ResolvePlayersNames(<newCloneId>5__5);
<displayName>5__10 = (string.IsNullOrEmpty(<resolvedName>5__9) ? <newCloneId>5__5 : <resolvedName>5__9);
Debug.Log((object)("[CLONER] Found new clone instance: '" + <displayName>5__10 + "' (" + <newCloneId>5__5 + ")"));
<localSteamIdUlong>5__11 = Player.GetPlayerSTID();
<localSteamIdString>5__12 = <localSteamIdUlong>5__11.ToString();
<sameSteamIdCount>5__13 = 0;
<allPlayerIds>5__14 = Player.GetAllPlayers();
<>s__15 = <allPlayerIds>5__14.GetEnumerator();
try
{
while (<>s__15.MoveNext())
{
<playerId>5__16 = <>s__15.Current;
<playerObject>5__17 = Player.FindOtherPlayersNID(<playerId>5__16);
if ((Object)(object)<playerObject>5__17 != (Object)null)
{
<playerComponent>5__18 = <playerObject>5__17.GetComponent<Player>();
if ((Object)(object)<playerComponent>5__18 != (Object)null && <playerComponent>5__18._steamID == <localSteamIdString>5__12)
{
<sameSteamIdCount>5__13++;
}
<playerComponent>5__18 = null;
}
<playerObject>5__17 = null;
<playerId>5__16 = null;
}
}
finally
{
((IDisposable)<>s__15).Dispose();
}
<>s__15 = default(List<string>.Enumerator);
if (<sameSteamIdCount>5__13 >= 6)
{
<errorMessage>5__19 = $"CRITICAL: Detected {<sameSteamIdCount>5__13} players from your Steam account in the scene. Shutting down.";
Debug.LogError((object)("[SECURITY] " + <errorMessage>5__19));
Game.Console("[SECURITY] " + <errorMessage>5__19);
CoroutineHelper.InitiateEmergencyShutdown();
return false;
}
CloneManager.RegisterClone(<newCloneInstance>5__6, <newCloneId>5__5);
Debug.Log((object)("[CLONER] Done! Successfully connected as '" + <displayName>5__10 + "'."));
Game.Console("[CLONER] Character '" + <displayName>5__10 + "' has been successfully cloned!");
<resolvedName>5__9 = null;
<displayName>5__10 = null;
<localSteamIdString>5__12 = null;
<allPlayerIds>5__14 = null;
}
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.");
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
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.");
}
}
[IteratorStateMachine(typeof(<WaitForCharacterAndRejoin>d__2))]
private static IEnumerator WaitForCharacterAndRejoin(ulong serverId)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForCharacterAndRejoin>d__2(0)
{
serverId = serverId
};
}
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 (!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
{
[CompilerGenerated]
private sealed class <ShutdownCoroutine>d__6 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
private int <i>5__1;
private string <message>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ShutdownCoroutine>d__6(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<message>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<i>5__1 = 10;
break;
case 1:
<>1__state = -1;
<message>5__2 = null;
<i>5__1--;
break;
}
if (<i>5__1 > 0)
{
<message>5__2 = $"[SECURITY] CLONE LIMIT EXCEEDED! Forcing game closure in {<i>5__1} seconds...";
Debug.LogError((object)<message>5__2);
Game.Console(<message>5__2);
Console.Beep();
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
}
Debug.LogError((object)"[SECURITY] SHUTTING DOWN NOW.");
Game.Console("[SECURITY] SHUTTING DOWN NOW.");
Application.Quit();
Process.GetCurrentProcess().Kill();
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
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());
}
}
[IteratorStateMachine(typeof(<ShutdownCoroutine>d__6))]
private static IEnumerator ShutdownCoroutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ShutdownCoroutine>d__6(0);
}
}
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("s0apy", "CharactherCloner", "3.0.7")]
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
public class Main : BaseUnityPlugin
{
private readonly Harmony _harmony = new Harmony("s0apy");
private bool _isMenuVisible = false;
private Rect _windowRect = new Rect(20f, 20f, 250f, 150f);
public Main()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
Debug.Log((object)"CharactherCloner constructed!");
}
private void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Patching with Harmony ID: s0apy");
_harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Harmony patching complete.");
CoroutineHelper instance = CoroutineHelper.Instance;
((BaseUnityPlugin)this).Logger.LogInfo((object)"CoroutineHelper initialized.");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin CharactherCloner is loaded!");
((BaseUnityPlugin)this).Logger.LogInfo((object)"i built the foundation im on my foundation sh*t again");
}
private Texture2D MakeTex(int width, int height, Color col)
{
//IL_0011: 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)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
Color[] array = (Color[])(object)new Color[width * height];
for (int i = 0; i < array.Length; i++)
{
array[i] = col;
}
Texture2D val = new Texture2D(width, height);
val.SetPixels(array);
val.Apply();
return val;
}
private void Update()
{
if (Input.GetKeyDown((KeyCode)278))
{
_isMenuVisible = !_isMenuVisible;
}
}
private void OnGUI()
{
//IL_0020: 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_0040: Expected O, but got Unknown
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
if (_isMenuVisible)
{
GUI.skin.window.fontStyle = (FontStyle)1;
_windowRect = GUILayout.Window(0, _windowRect, new WindowFunction(DrawMenuWindow), "Character Cloner Menu", Array.Empty<GUILayoutOption>());
}
}
private void DrawMenuWindow(int windowID)
{
//IL_005d: 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 = "s0apy";
public const string NAME = "CharactherCloner";
public const string VERSION = "3.0.7";
}
}
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;
}
}
}
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)
{
}
}
}