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 Microsoft.CodeAnalysis;
using Mimic;
using Mimic.Actors;
using Mimic.Audio;
using Mimic.InputSystem;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MimicAPI")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+26dc735b56e969c261319afae305cac1db508107")]
[assembly: AssemblyProduct("MimicAPI")]
[assembly: AssemblyTitle("MimicAPI")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
}
}
}
namespace MimicAPI.GameAPI
{
public static class ActorAPI
{
public static List<object> GetAllVPlayersInRoom(object? room)
{
if (room == null)
{
return new List<object>();
}
if (ReflectionHelper.GetFieldValue(room, "_vPlayerDict") is IDictionary dictionary)
{
return dictionary.Values.Cast<object>().ToList();
}
return new List<object>();
}
public static object? GetVPlayerInRoom(object? room, int actorID)
{
return GetAllVPlayersInRoom(room).FirstOrDefault((object p) => ReflectionHelper.GetFieldValue<int>(p, "ObjectID") == actorID);
}
public static List<object> GetAlivePlayersInRoom(object? room)
{
return (from p in GetAllVPlayersInRoom(room)
where IsAlive(p)
select p).ToList();
}
public static List<object> GetDeadPlayersInRoom(object? room)
{
return (from p in GetAllVPlayersInRoom(room)
where !IsAlive(p)
select p).ToList();
}
public static List<object> GetAllVActorsInRoom(object? room)
{
if (room == null)
{
return new List<object>();
}
if (ReflectionHelper.GetFieldValue(room, "_vActorDict") is IDictionary dictionary)
{
return dictionary.Values.Cast<object>().ToList();
}
return new List<object>();
}
public static object? GetVActorInRoom(object? room, int actorID)
{
return GetAllVActorsInRoom(room).FirstOrDefault((object a) => ReflectionHelper.GetFieldValue<int>(a, "ObjectID") == actorID);
}
public static List<object> GetMonstersInRoom(object? room)
{
return (from a in GetAllVActorsInRoom(room)
where a?.GetType().Name == "VMonster"
select a).ToList();
}
public static List<object> GetAliveMonstersInRoom(object? room)
{
return (from m in GetMonstersInRoom(room)
where IsAlive(m)
select m).ToList();
}
public static List<object> GetDeadMonstersInRoom(object? room)
{
return (from m in GetMonstersInRoom(room)
where !IsAlive(m)
select m).ToList();
}
public static List<object> GetLootingObjectsInRoom(object? room)
{
return (from a in GetAllVActorsInRoom(room)
where a?.GetType().Name == "VLootingObject"
select a).ToList();
}
public static List<object> GetActorsByTypeName(object? room, string typeName)
{
string typeName2 = typeName;
return (from a in GetAllVActorsInRoom(room)
where a?.GetType().Name == typeName2
select a).ToList();
}
public static bool HasAliveMonstersInRoom(object? room)
{
return GetAliveMonstersInRoom(room).Any();
}
public static bool HasAlivePlayersInRoom(object? room)
{
return GetAlivePlayersInRoom(room).Any();
}
private static bool IsAlive(object? actor)
{
bool flag = default(bool);
int num;
if (actor != null)
{
object obj = ReflectionHelper.InvokeMethod(actor, "IsAliveStatus");
if (obj is bool)
{
flag = (bool)obj;
num = 1;
}
else
{
num = 0;
}
}
else
{
num = 0;
}
return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
}
}
public static class CoreAPI
{
public static Hub GetHub()
{
return Hub.s;
}
public static VWorld? GetVWorld()
{
Hub hub = GetHub();
if (!((Object)(object)hub == (Object)null))
{
return ReflectionHelper.GetFieldValue<VWorld>(hub, "<vworld>k__BackingField");
}
return null;
}
public static VRoomManager? GetVRoomManager()
{
VWorld vWorld = GetVWorld();
if (vWorld != null)
{
return ReflectionHelper.GetFieldValue<VRoomManager>(vWorld, "_vRoomManager");
}
return null;
}
public static PersistentData? GetPersistentData()
{
Hub hub = GetHub();
if (!((Object)(object)hub == (Object)null))
{
return ReflectionHelper.GetFieldValue<PersistentData>(hub, "pdata");
}
return null;
}
}
public static class LootAPI
{
public static LootingLevelObject[] GetAllLoot()
{
return FilterLoot((LootingLevelObject l) => ((Component)l).gameObject.activeInHierarchy);
}
public static LootingLevelObject[] GetInactiveLoot()
{
return FilterLoot((LootingLevelObject l) => !((Component)l).gameObject.activeInHierarchy);
}
public static LootingLevelObject[] GetLootNearby(float maxDistance, Vector3? searchCenter = null)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: 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_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
Vector3 center = (searchCenter.HasValue ? searchCenter.Value : PlayerAPI.GetLocalPlayerPosition());
if (center == Vector3.zero && (Object)(object)PlayerAPI.GetLocalPlayer() == (Object)null)
{
center = Vector3.zero;
}
return FilterLoot((LootingLevelObject l) => ((Component)l).gameObject.activeInHierarchy && Vector3.Distance(((Component)l).transform.position, center) <= maxDistance);
}
public static LootingLevelObject[] GetLootByName(string name)
{
string name2 = name;
return FilterLoot((LootingLevelObject l) => ((Object)((Component)l).gameObject).name.Contains(name2));
}
public static LootingLevelObject? GetNearestLoot(Vector3? searchCenter = null)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: 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_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
Vector3 center = (searchCenter.HasValue ? searchCenter.Value : PlayerAPI.GetLocalPlayerPosition());
if (center == Vector3.zero && (Object)(object)PlayerAPI.GetLocalPlayer() == (Object)null)
{
center = Vector3.zero;
}
LootingLevelObject[] allLoot = GetAllLoot();
if (allLoot.Length == 0)
{
return null;
}
return allLoot.OrderBy((LootingLevelObject l) => Vector3.Distance(((Component)l).transform.position, center)).FirstOrDefault();
}
public static LootingLevelObject? GetNearestLootInRange(float maxDistance, Vector3? searchCenter = null)
{
return GetLootNearby(maxDistance, searchCenter).FirstOrDefault();
}
public static bool HasLoot()
{
return GetAllLoot().Length != 0;
}
public static bool HasLootNearby(float maxDistance, Vector3? searchCenter = null)
{
return GetLootNearby(maxDistance, searchCenter).Length != 0;
}
public static Vector3 GetLootPosition(LootingLevelObject loot)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)loot == (Object)null))
{
return ((Component)loot).transform.position;
}
return Vector3.zero;
}
public static float GetDistanceToLoot(LootingLevelObject loot, Vector3? center = null)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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_0028: 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_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)loot == (Object)null)
{
return 0f;
}
Vector3 val = (center.HasValue ? center.Value : PlayerAPI.GetLocalPlayerPosition());
if (val == Vector3.zero && (Object)(object)PlayerAPI.GetLocalPlayer() == (Object)null)
{
val = Vector3.zero;
}
return Vector3.Distance(((Component)loot).transform.position, val);
}
public static LootingLevelObject[] FilterLootByDistance(float minDistance, float maxDistance, Vector3? searchCenter = null)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: 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_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: 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)
Vector3 center = (searchCenter.HasValue ? searchCenter.Value : PlayerAPI.GetLocalPlayerPosition());
if (center == Vector3.zero && (Object)(object)PlayerAPI.GetLocalPlayer() == (Object)null)
{
center = Vector3.zero;
}
return FilterLoot(delegate(LootingLevelObject l)
{
//IL_0006: 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)
float num = Vector3.Distance(((Component)l).transform.position, center);
return ((Component)l).gameObject.activeInHierarchy && num >= minDistance && num <= maxDistance;
});
}
private static LootingLevelObject[] FilterLoot(Func<LootingLevelObject, bool> predicate)
{
Func<LootingLevelObject, bool> predicate2 = predicate;
return (from l in Object.FindObjectsByType<LootingLevelObject>((FindObjectsSortMode)0)
where (Object)(object)l != (Object)null && predicate2(l)
select l).ToArray();
}
}
public static class ManagerAPI
{
public static T? GetManager<T>(string fieldName) where T : class
{
Hub hub = CoreAPI.GetHub();
if (!((Object)(object)hub != (Object)null))
{
return null;
}
return ReflectionHelper.GetFieldValue<T>(hub, fieldName);
}
public static DataManager? GetDataManager()
{
return GetManager<DataManager>("<dataman>k__BackingField");
}
public static TimeUtil? GetTimeUtil()
{
return GetManager<TimeUtil>("<timeutil>k__BackingField");
}
public static NavManager? GetNavManager()
{
return GetManager<NavManager>("<navman>k__BackingField");
}
public static DynamicDataManager? GetDynamicDataManager()
{
return GetManager<DynamicDataManager>("<dynamicDataMan>k__BackingField");
}
public static UIManager? GetUIManager()
{
return GetManager<UIManager>("<uiman>k__BackingField");
}
public static CameraManager? GetCameraManager()
{
return GetManager<CameraManager>("<cameraman>k__BackingField");
}
public static AudioManager? GetAudioManager()
{
return GetManager<AudioManager>("<audioman>k__BackingField");
}
public static InputManager? GetInputManager()
{
return GetManager<InputManager>("<inputman>k__BackingField");
}
public static NetworkManagerV2? GetNetworkManager()
{
return GetManager<NetworkManagerV2>("<netman2>k__BackingField");
}
public static APIRequestHandler? GetAPIHandler()
{
return GetManager<APIRequestHandler>("<apihandler>k__BackingField");
}
public static L10NManager? GetLocalisationManager()
{
return GetManager<L10NManager>("lcman");
}
public static bool IsManagerAvailable<T>(string fieldName) where T : class
{
return GetManager<T>(fieldName) != null;
}
}
public static class PlayerAPI
{
public static ProtoActor? GetLocalPlayer()
{
return FindActorWhere((ProtoActor a) => a.AmIAvatar());
}
public static ProtoActor[]? GetAllPlayers()
{
return FindActorsWhere((ProtoActor a) => (Object)(object)a != (Object)null);
}
public static ProtoActor[]? GetOtherPlayers()
{
return FindActorsWhere((ProtoActor a) => !a.AmIAvatar());
}
public static ProtoActor? GetPlayerByName(string name)
{
string name2 = name;
return FindActorWhere((ProtoActor a) => ((Object)((Component)a).gameObject).name.Equals(name2, StringComparison.OrdinalIgnoreCase));
}
public static ProtoActor? GetPlayerByID(uint actorID)
{
return FindActorWhere((ProtoActor a) => a.ActorID == actorID);
}
public static bool IsPlayerValid(ProtoActor? actor)
{
if ((Object)(object)actor != (Object)null)
{
return ((Component)actor).gameObject.activeInHierarchy;
}
return false;
}
public static bool HasLocalPlayer()
{
return (Object)(object)GetLocalPlayer() != (Object)null;
}
public static StatManager? GetLocalStatManager()
{
ProtoActor localPlayer = GetLocalPlayer();
if (localPlayer == null)
{
return null;
}
return ((Component)localPlayer).GetComponent<StatManager>();
}
public static StatManager? GetStatManager(ProtoActor? actor)
{
if (actor == null)
{
return null;
}
return ((Component)actor).GetComponent<StatManager>();
}
public static MovementController? GetLocalMovementController()
{
ProtoActor localPlayer = GetLocalPlayer();
if (localPlayer == null)
{
return null;
}
return ((Component)localPlayer).GetComponent<MovementController>();
}
public static MovementController? GetMovementController(ProtoActor? actor)
{
if (actor == null)
{
return null;
}
return ((Component)actor).GetComponent<MovementController>();
}
public static object? GetLocalInventory()
{
ProtoActor localPlayer = GetLocalPlayer();
if (!((Object)(object)localPlayer != (Object)null))
{
return null;
}
return ReflectionHelper.GetFieldValue(localPlayer, "inventory");
}
public static object? GetInventory(ProtoActor? actor)
{
if (!((Object)(object)actor != (Object)null))
{
return null;
}
return ReflectionHelper.GetFieldValue(actor, "inventory");
}
public static List<InventoryItem> GetInventoryItems(ProtoActor? actor)
{
if ((Object)(object)actor == (Object)null)
{
return new List<InventoryItem>();
}
object inventory = GetInventory(actor);
if (inventory == null)
{
return new List<InventoryItem>();
}
return ReflectionHelper.GetFieldValue<List<InventoryItem>>(inventory, "SlotItems") ?? new List<InventoryItem>();
}
public static Vector3 GetPlayerPosition(ProtoActor? actor)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)actor == (Object)null))
{
return ((Component)actor).transform.position;
}
return Vector3.zero;
}
public static Vector3 GetLocalPlayerPosition()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
ProtoActor localPlayer = GetLocalPlayer();
return GetPlayerPosition(localPlayer);
}
public static float GetDistanceBetweenPlayers(ProtoActor? actor1, ProtoActor? actor2)
{
//IL_001e: 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)
if ((Object)(object)actor1 == (Object)null || (Object)(object)actor2 == (Object)null)
{
return 0f;
}
return Vector3.Distance(((Component)actor1).transform.position, ((Component)actor2).transform.position);
}
public static bool IsPlayerAlive(ProtoActor? actor)
{
if ((Object)(object)actor == (Object)null)
{
return false;
}
StatManager statManager = GetStatManager(actor);
if (statManager == null)
{
return false;
}
object obj = ReflectionHelper.InvokeMethod(statManager, "IsAliveStatus");
bool flag = default(bool);
int num;
if (obj is bool)
{
flag = (bool)obj;
num = 1;
}
else
{
num = 0;
}
return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
}
public static bool IsLocalPlayerAlive()
{
ProtoActor localPlayer = GetLocalPlayer();
return IsPlayerAlive(localPlayer);
}
public static List<ProtoActor> GetAlivePlayersInRange(float range, Vector3? center = null)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
Vector3 searchCenter = (center.HasValue ? center.Value : GetLocalPlayerPosition());
ProtoActor[] allPlayers = GetAllPlayers();
if (allPlayers == null)
{
return new List<ProtoActor>();
}
return allPlayers.Where((ProtoActor p) => (Object)(object)p != (Object)null && IsPlayerValid(p) && IsPlayerAlive(p) && Vector3.Distance(((Component)p).transform.position, searchCenter) <= range).ToList();
}
public static ProtoActor? GetNearestPlayer(Vector3? center = null)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
Vector3 searchCenter = (center.HasValue ? center.Value : GetLocalPlayerPosition());
ProtoActor[] allPlayers = GetAllPlayers();
if (allPlayers == null || allPlayers.Length == 0)
{
return null;
}
return (from p in allPlayers
where (Object)(object)p != (Object)null && IsPlayerValid(p)
orderby Vector3.Distance(((Component)p).transform.position, searchCenter)
select p).FirstOrDefault();
}
public static ProtoActor? GetNearestAlivePlayer(Vector3? center = null)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
Vector3 searchCenter = (center.HasValue ? center.Value : GetLocalPlayerPosition());
ProtoActor[] allPlayers = GetAllPlayers();
if (allPlayers == null || allPlayers.Length == 0)
{
return null;
}
return (from p in allPlayers
where (Object)(object)p != (Object)null && IsPlayerValid(p) && IsPlayerAlive(p)
orderby Vector3.Distance(((Component)p).transform.position, searchCenter)
select p).FirstOrDefault();
}
public static List<ProtoActor> GetPlayersInRange(float range, Vector3? center = null)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
Vector3 searchCenter = (center.HasValue ? center.Value : GetLocalPlayerPosition());
ProtoActor[] allPlayers = GetAllPlayers();
if (allPlayers == null)
{
return new List<ProtoActor>();
}
return allPlayers.Where((ProtoActor p) => (Object)(object)p != (Object)null && IsPlayerValid(p) && Vector3.Distance(((Component)p).transform.position, searchCenter) <= range).ToList();
}
public static string GetPlayerName(ProtoActor? actor)
{
if (!((Object)(object)actor == (Object)null))
{
return ((Object)((Component)actor).gameObject).name;
}
return "Unknown";
}
private static ProtoActor? FindActorWhere(Func<ProtoActor, bool> predicate)
{
try
{
ProtoActor[] source = Object.FindObjectsByType<ProtoActor>((FindObjectsSortMode)0);
return source.FirstOrDefault(predicate);
}
catch
{
return null;
}
}
private static ProtoActor[]? FindActorsWhere(Func<ProtoActor, bool> predicate)
{
try
{
ProtoActor[] source = Object.FindObjectsByType<ProtoActor>((FindObjectsSortMode)0);
return source.Where(predicate).ToArray();
}
catch
{
return (ProtoActor[]?)(object)new ProtoActor[0];
}
}
}
public static class ReflectionHelper
{
private const BindingFlags DefaultFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
public static object? GetFieldValue(object target, string fieldName)
{
return target?.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(target);
}
public static object? GetFieldValue(Type type, string fieldName)
{
return type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
}
public static T GetFieldValue<T>(object target, string fieldName)
{
object fieldValue = GetFieldValue(target, fieldName);
if (fieldValue == null)
{
return default(T);
}
return (T)fieldValue;
}
public static T GetFieldValue<T>(Type type, string fieldName)
{
object fieldValue = GetFieldValue(type, fieldName);
if (fieldValue == null)
{
return default(T);
}
return (T)fieldValue;
}
public static void SetFieldValue(object target, string fieldName, object value)
{
target?.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.SetValue(target, value);
}
public static void SetFieldValue(Type type, string fieldName, object value)
{
type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.SetValue(null, value);
}
public static object? InvokeMethod(object target, string methodName, params object[] parameters)
{
if (target == null)
{
return null;
}
MethodInfo method = target.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
if (method == null)
{
return null;
}
return method.Invoke(target, (parameters.Length != 0) ? parameters : null);
}
public static object? InvokeMethod(Type type, string methodName, params object[] parameters)
{
MethodInfo method = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
if (method == null)
{
return null;
}
return method.Invoke(null, (parameters.Length != 0) ? parameters : null);
}
public static T? InvokeMethod<T>(object target, string methodName, params object[] parameters) where T : class
{
object obj = InvokeMethod(target, methodName, parameters);
if (obj == null)
{
return null;
}
return (T)obj;
}
public static T? InvokeMethod<T>(Type type, string methodName, params object[] parameters) where T : class
{
object obj = InvokeMethod(type, methodName, parameters);
if (obj == null)
{
return null;
}
return (T)obj;
}
public static PropertyInfo? GetProperty(Type type, string propertyName)
{
return type.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
}
public static object? GetPropertyValue(object target, string propertyName)
{
if (target == null)
{
return null;
}
return GetProperty(target.GetType(), propertyName)?.GetValue(target);
}
public static T GetPropertyValue<T>(object target, string propertyName)
{
object propertyValue = GetPropertyValue(target, propertyName);
if (propertyValue == null)
{
return default(T);
}
return (T)propertyValue;
}
public static void SetPropertyValue(object target, string propertyName, object value)
{
if (target != null)
{
GetProperty(target.GetType(), propertyName)?.SetValue(target, value);
}
}
}
public static class RoomAPI
{
private static IDictionary? GetRoomDictionary()
{
VRoomManager vRoomManager = CoreAPI.GetVRoomManager();
if (vRoomManager == null)
{
return null;
}
return ReflectionHelper.GetFieldValue(vRoomManager, "_vrooms") as IDictionary;
}
public static object? GetRoom(long roomID)
{
IDictionary roomDictionary = GetRoomDictionary();
if (roomDictionary == null)
{
return null;
}
foreach (object key in roomDictionary.Keys)
{
if (key is long num && num == roomID)
{
return roomDictionary[key];
}
}
return null;
}
public static object[] GetAllRooms()
{
IDictionary roomDictionary = GetRoomDictionary();
if (roomDictionary == null)
{
return Array.Empty<object>();
}
object[] array = new object[roomDictionary.Count];
int num = 0;
foreach (object value in roomDictionary.Values)
{
array[num++] = value;
}
return array;
}
public static List<long> GetAllRoomIDs()
{
IDictionary roomDictionary = GetRoomDictionary();
if (roomDictionary == null)
{
return new List<long>();
}
List<long> list = new List<long>();
foreach (object key in roomDictionary.Keys)
{
if (key is long item)
{
list.Add(item);
}
}
return list;
}
public static bool RoomExists(long roomID)
{
return GetRoom(roomID) != null;
}
public static object? GetCurrentRoom()
{
return GetAllRooms().FirstOrDefault((object r) => r != null && IsRoomPlayable(r));
}
public static List<object> GetAllPlayableRooms()
{
return (from r in GetAllRooms()
where r != null && IsRoomPlayable(r)
select r).ToList();
}
public static long GetRoomID(object? room)
{
if (room != null)
{
return ReflectionHelper.GetFieldValue<long>(room, "RoomID");
}
return 0L;
}
public static int GetRoomMasterID(object? room)
{
if (room != null)
{
return ReflectionHelper.GetFieldValue<int>(room, "MasterID");
}
return 0;
}
public static string GetRoomName(object? room)
{
if (room != null)
{
return room.GetType().Name;
}
return "Unknown";
}
public static object? GetRoomType(object? room)
{
if (room != null)
{
return ReflectionHelper.InvokeMethod(room, "GetToMoveRoomType");
}
return null;
}
public static object? GetRoomProperty(object? room)
{
if (room != null)
{
return ReflectionHelper.InvokeMethod(room, "GetProperty");
}
return null;
}
public static bool IsRoomPlayable(object? room)
{
bool flag = default(bool);
int num;
if (room != null)
{
object obj = ReflectionHelper.InvokeMethod(room, "IsPlayable");
if (obj is bool)
{
flag = (bool)obj;
num = 1;
}
else
{
num = 0;
}
}
else
{
num = 0;
}
return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
}
public static int GetCurrentGameDay(object? room)
{
if (room != null)
{
return ReflectionHelper.GetFieldValue<int>(room, "_currentDay");
}
return 0;
}
public static int GetCurrentSessionCycle(object? room)
{
if (room != null)
{
return ReflectionHelper.GetFieldValue<int>(room, "_currentSessionCount");
}
return 0;
}
public static long GetCurrentTick(object? room)
{
if (room != null)
{
return ReflectionHelper.GetFieldValue<long>(room, "_currentTick");
}
return 0L;
}
public static bool IsAllPlayerDead(object? room)
{
bool flag = default(bool);
int num;
if (room != null)
{
object obj = ReflectionHelper.InvokeMethod(room, "IsAllPlayerDead");
if (obj is bool)
{
flag = (bool)obj;
num = 1;
}
else
{
num = 0;
}
}
else
{
num = 0;
}
return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
}
public static bool IsAllPlayerWastedOrDead(object? room)
{
bool flag = default(bool);
int num;
if (room != null)
{
object obj = ReflectionHelper.InvokeMethod(room, "IsAllPlayerWastedOrDead");
if (obj is bool)
{
flag = (bool)obj;
num = 1;
}
else
{
num = 0;
}
}
else
{
num = 0;
}
return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
}
public static int GetDeadPlayerCount(object? room)
{
if (room != null)
{
object obj = ReflectionHelper.InvokeMethod(room, "GetDeadPlayerCount");
if (obj is int)
{
return (int)obj;
}
return 0;
}
return 0;
}
public static int GetMemberCount(object? room)
{
if (room != null)
{
object obj = ReflectionHelper.InvokeMethod(room, "GetMemberCount");
if (obj is int)
{
return (int)obj;
}
return 0;
}
return 0;
}
public static List<object> GetRoomPlayers(object? room)
{
if (room == null)
{
return new List<object>();
}
if (!(ReflectionHelper.GetFieldValue(room, "_vPlayerDict") is IDictionary dictionary))
{
return new List<object>();
}
return dictionary.Values.Cast<object>().ToList();
}
public static List<object> GetRoomActors(object? room)
{
if (room == null)
{
return new List<object>();
}
if (!(ReflectionHelper.GetFieldValue(room, "_vActorDict") is IDictionary dictionary))
{
return new List<object>();
}
return dictionary.Values.Cast<object>().ToList();
}
public static IDictionary? GetRoomLevelObjects(object? room)
{
if (room == null)
{
return null;
}
return ReflectionHelper.GetFieldValue(room, "_levelObjects") as IDictionary;
}
public static int GetRoomCurrency(object? room)
{
if (room != null)
{
return ReflectionHelper.GetFieldValue<int>(room, "<Currency>k__BackingField");
}
return 0;
}
public static long GetContaRecoveryRate(object? room)
{
if (room != null)
{
object obj = ReflectionHelper.InvokeMethod(room, "GetContaRecoveryRate");
if (obj is long)
{
return (long)obj;
}
return 0L;
}
return 0L;
}
public static int GetRoomPlayerCount(object? room)
{
if (room != null)
{
return ServerNetworkAPI.GetRoomPlayerCount(room);
}
return 0;
}
public static IDictionary? GetRoomPlayerDictionary(object? room)
{
if (room != null)
{
return ServerNetworkAPI.GetRoomPlayerDictionary(room);
}
return null;
}
}
public static class ServerNetworkAPI
{
private static object? GetVWorld()
{
Hub hub = CoreAPI.GetHub();
if ((Object)(object)hub == (Object)null)
{
return null;
}
return ReflectionHelper.GetFieldValue(hub, "<vworld>k__BackingField");
}
private static object? GetSessionManager()
{
object vWorld = GetVWorld();
if (vWorld == null)
{
return null;
}
return ReflectionHelper.GetFieldValue(vWorld, "_sessionManager");
}
public static object? GetRudpServer()
{
object vWorld = GetVWorld();
if (vWorld == null)
{
return null;
}
return ReflectionHelper.GetFieldValue(vWorld, "_rudpServer");
}
public static object? GetSdrServer()
{
object vWorld = GetVWorld();
if (vWorld == null)
{
return null;
}
return ReflectionHelper.GetFieldValue(vWorld, "_sdrServer");
}
public static object? GetServerSocket()
{
return GetSdrServer() ?? GetRudpServer();
}
public static bool IsServerRunning()
{
return GetVWorld() != null;
}
public static int GetSessionCount()
{
object sessionManager = GetSessionManager();
if (sessionManager == null)
{
return 0;
}
if (!(ReflectionHelper.GetFieldValue(sessionManager, "m_Contexts") is IDictionary dictionary))
{
return 0;
}
return dictionary.Count;
}
public static int GetCurrentClientCount()
{
return GetSessionCount();
}
public static int GetMaximumClients()
{
VRoomManager vRoomManager = CoreAPI.GetVRoomManager();
if (vRoomManager == null)
{
return 0;
}
object obj = ReflectionHelper.InvokeMethod(vRoomManager, "GetPlayerCountInSession");
if (obj is int)
{
return (int)obj;
}
return 0;
}
public static void SetMaximumClients(object serverSocket, int value)
{
ReflectionHelper.SetFieldValue(serverSocket, "_maximumClients", value);
}
public static List<object> GetAllConnectedPlayers()
{
object sessionManager = GetSessionManager();
if (sessionManager == null)
{
return new List<object>();
}
if (!(ReflectionHelper.GetFieldValue(sessionManager, "m_Contexts") is IDictionary dictionary))
{
return new List<object>();
}
return dictionary.Values.Cast<object>().ToList();
}
public static object? GetWaitingRoom()
{
return RoomAPI.GetAllRooms().FirstOrDefault((object r) => r?.GetType().Name == "VWaitingRoom");
}
public static object? GetMaintenanceRoom()
{
return RoomAPI.GetAllRooms().FirstOrDefault((object r) => r?.GetType().Name == "MaintenanceRoom");
}
public static int GetWaitingRoomMemberCount()
{
return RoomAPI.GetMemberCount(GetWaitingRoom());
}
public static int GetWaitingRoomMaxPlayers()
{
return RoomAPI.GetMemberCount(GetWaitingRoom());
}
public static int GetMaintenanceRoomMemberCount()
{
return RoomAPI.GetMemberCount(GetMaintenanceRoom());
}
public static int GetMaintenanceRoomMaxPlayers()
{
return RoomAPI.GetMemberCount(GetMaintenanceRoom());
}
public static bool CanPlayerEnterWaitingRoom(long playerUID)
{
object waitingRoom = GetWaitingRoom();
if (waitingRoom == null)
{
return false;
}
try
{
object obj = ReflectionHelper.InvokeMethod(waitingRoom, "CanEnterChannel", playerUID);
if (obj != null && obj.GetType().IsEnum)
{
return Enum.GetName(obj.GetType(), obj) == "Success";
}
return false;
}
catch
{
return false;
}
}
public static bool IsPlayerInRoom(object room, long playerUID)
{
IDictionary roomPlayerDictionary = GetRoomPlayerDictionary(room);
if (roomPlayerDictionary == null)
{
return false;
}
foreach (object value in roomPlayerDictionary.Values)
{
if (ReflectionHelper.GetPropertyValue<long>(value, "UID") == playerUID)
{
return true;
}
}
return false;
}
public static int GetRoomPlayerCount(object? room)
{
if (room == null)
{
return 0;
}
if (!(ReflectionHelper.GetFieldValue(room, "_vPlayerDict") is IDictionary dictionary))
{
return 0;
}
return dictionary.Count;
}
public static IDictionary? GetRoomPlayerDictionary(object? room)
{
if (room == null)
{
return null;
}
return ReflectionHelper.GetFieldValue(room, "_vPlayerDict") as IDictionary;
}
public static Assembly? GetGameAssembly()
{
try
{
return AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name == "Assembly-CSharp");
}
catch
{
return null;
}
}
public static Type? GetIVroomType()
{
return GetGameAssembly()?.GetType("IVroom");
}
public static Type? GetGameSessionInfoType()
{
return GetGameAssembly()?.GetType("GameSessionInfo");
}
}
public static class ShopAPI
{
}
public static class VoiceAPI
{
}
public static class WeatherAPI
{
}
}