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 Bifrost.ShopGroup;
using Dissonance;
using Dissonance.Audio.Playback;
using Dissonance.Integrations.FishNet;
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+6e7d840f1693656590a7291fe02ac5f61e6d615c")]
[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 VPlayer? GetVPlayerInRoom(IVroom? room, int actorID)
{
if (room == null)
{
return null;
}
return ((IEnumerable<VPlayer>)ReflectionHelper.GetFieldValue<Dictionary<int, VPlayer>>(room, "_vPlayerDict")?.Values).FirstOrDefault((Func<VPlayer, bool>)((VPlayer p) => ((VActor)p).ObjectID == actorID));
}
public static List<VPlayer> GetAllVPlayersInRoom(IVroom? room)
{
if (room == null)
{
return new List<VPlayer>();
}
return ReflectionHelper.GetFieldValue<Dictionary<int, VPlayer>>(room, "_vPlayerDict")?.Values.ToList() ?? new List<VPlayer>();
}
public static List<VPlayer> GetAlivePlayersInRoom(IVroom? room)
{
List<VPlayer> allVPlayersInRoom = GetAllVPlayersInRoom(room);
return allVPlayersInRoom.Where((VPlayer p) => p != null && ((VActor)p).IsAliveStatus()).ToList();
}
public static List<VPlayer> GetDeadPlayersInRoom(IVroom? room)
{
List<VPlayer> allVPlayersInRoom = GetAllVPlayersInRoom(room);
return allVPlayersInRoom.Where((VPlayer p) => p != null && !((VActor)p).IsAliveStatus()).ToList();
}
public static List<VActor> GetAllVActorsInRoom(IVroom? room)
{
if (room == null)
{
return new List<VActor>();
}
return ReflectionHelper.GetFieldValue<Dictionary<int, VActor>>(room, "_vActorDict")?.Values.ToList() ?? new List<VActor>();
}
public static VActor? GetVActorInRoom(IVroom? room, int actorID)
{
if (room == null)
{
return null;
}
Dictionary<int, VActor> fieldValue = ReflectionHelper.GetFieldValue<Dictionary<int, VActor>>(room, "_vActorDict");
if (fieldValue == null || !fieldValue.ContainsKey(actorID))
{
return null;
}
return fieldValue[actorID];
}
public static List<VActor> GetMonstersInRoom(IVroom? room)
{
List<VActor> allVActorsInRoom = GetAllVActorsInRoom(room);
return allVActorsInRoom.Where((VActor a) => a != null && a is VMonster).Cast<VActor>().ToList();
}
public static List<VActor> GetAliveMonstersInRoom(IVroom? room)
{
List<VActor> monstersInRoom = GetMonstersInRoom(room);
return monstersInRoom.Where((VActor m) => m != null && m.IsAliveStatus()).ToList();
}
public static List<VActor> GetDeadMonstersInRoom(IVroom? room)
{
List<VActor> monstersInRoom = GetMonstersInRoom(room);
return monstersInRoom.Where((VActor m) => m != null && !m.IsAliveStatus()).ToList();
}
public static List<VActor> GetLootingObjectsInRoom(IVroom? room)
{
List<VActor> allVActorsInRoom = GetAllVActorsInRoom(room);
return allVActorsInRoom.Where((VActor a) => a != null && a is VLootingObject).Cast<VActor>().ToList();
}
public static List<VActor> GetActorsByType<T>(IVroom? room) where T : VActor
{
List<VActor> allVActorsInRoom = GetAllVActorsInRoom(room);
return allVActorsInRoom.Where((VActor a) => a != null && a is T).Cast<VActor>().ToList();
}
public static bool HasAliveMonstersInRoom(IVroom? room)
{
return GetAliveMonstersInRoom(room).Any();
}
public static bool HasAlivePlayersInRoom(IVroom? room)
{
return GetAlivePlayersInRoom(room).Any();
}
}
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");
}
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");
}
public static TimeUtil? GetTimeUtil()
{
return GetManager<TimeUtil>("timeutil");
}
public static NavManager? GetNavManager()
{
return GetManager<NavManager>("navman");
}
public static DynamicDataManager? GetDynamicDataManager()
{
return GetManager<DynamicDataManager>("dynamicDataMan");
}
public static UIManager? GetUIManager()
{
return GetManager<UIManager>("uiman");
}
public static CameraManager? GetCameraManager()
{
return GetManager<CameraManager>("cameraman");
}
public static AudioManager? GetAudioManager()
{
return GetManager<AudioManager>("audioman");
}
public static InputManager? GetInputManager()
{
return GetManager<InputManager>("inputman");
}
public static NetworkManagerV2? GetNetworkManager()
{
return GetManager<NetworkManagerV2>("netman2");
}
public static APIRequestHandler? GetAPIHandler()
{
return GetManager<APIRequestHandler>("apihandler");
}
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
{
public static IVroom? GetRoom(long roomID)
{
IDictionary roomDictionary = GetRoomDictionary();
if (roomDictionary == null)
{
return null;
}
object? obj = roomDictionary[roomID];
return (IVroom?)((obj is IVroom) ? obj : null);
}
public static IVroom? GetCurrentRoom()
{
ProtoActor localPlayer = PlayerAPI.GetLocalPlayer();
if ((Object)(object)localPlayer == (Object)null)
{
return null;
}
IVroom[] allRooms = GetAllRooms();
return ((IEnumerable<IVroom>)allRooms).FirstOrDefault((Func<IVroom, bool>)((IVroom room) => room != null && IsRoomPlayable(room)));
}
public static IVroom[] GetAllRooms()
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Expected O, but got Unknown
IDictionary roomDictionary = GetRoomDictionary();
if (roomDictionary == null)
{
return (IVroom[])(object)new IVroom[0];
}
IVroom[] array = (IVroom[])(object)new IVroom[roomDictionary.Count];
int num = 0;
foreach (object value in roomDictionary.Values)
{
array[num++] = (IVroom)value;
}
return array;
}
public static List<IVroom> GetAllPlayableRooms()
{
return (from r in GetAllRooms()
where r != null && IsRoomPlayable(r)
select r).ToList();
}
public static long GetRoomID(IVroom? room)
{
if (room != null)
{
return ReflectionHelper.GetFieldValue<long>(room, "RoomID");
}
return 0L;
}
public static int GetRoomMasterID(IVroom? room)
{
if (room != null)
{
return ReflectionHelper.GetFieldValue<int>(room, "MasterID");
}
return 0;
}
public static bool IsRoomPlayable(IVroom? room)
{
if (room == null)
{
return false;
}
object obj = ReflectionHelper.InvokeMethod(room, "IsPlayable");
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 int GetCurrentGameDay(IVroom? room)
{
if (room != null)
{
return ReflectionHelper.GetFieldValue<int>(room, "_currentDay");
}
return 0;
}
public static int GetCurrentSessionCycle(IVroom? room)
{
if (room != null)
{
return ReflectionHelper.GetFieldValue<int>(room, "_currentSessionCount");
}
return 0;
}
public static Dictionary<int, ILevelObjectInfo>? GetRoomLevelObjects(IVroom? room)
{
if (room == null)
{
return new Dictionary<int, ILevelObjectInfo>();
}
return ReflectionHelper.GetFieldValue<Dictionary<int, ILevelObjectInfo>>(room, "_levelObjects") ?? new Dictionary<int, ILevelObjectInfo>();
}
public static List<VPlayer> GetRoomPlayers(IVroom? room)
{
if (room == null)
{
return new List<VPlayer>();
}
return ReflectionHelper.GetFieldValue<Dictionary<int, VPlayer>>(room, "_vPlayerDict")?.Values.ToList() ?? new List<VPlayer>();
}
public static List<VActor> GetRoomActors(IVroom? room)
{
if (room == null)
{
return new List<VActor>();
}
return ReflectionHelper.GetFieldValue<Dictionary<int, VActor>>(room, "_vActorDict")?.Values.ToList() ?? new List<VActor>();
}
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 IVroom[] GetAllRoomsOfType<T>() where T : IVroom
{
return (from r in GetAllRooms()
where r is T
select r).ToArray();
}
public static bool RoomExists(long roomID)
{
return GetRoom(roomID) != null;
}
public static int GetRoomMaxPlayers(IVroom? room)
{
if (room == null)
{
return 0;
}
return ReflectionHelper.GetFieldValue<int>(room, "_maxPlayers");
}
public static int GetRoomMaxPlayers(object? room)
{
if (room == null)
{
return 0;
}
return ReflectionHelper.GetFieldValue<int>(room, "_maxPlayers");
}
public static void SetRoomMaxPlayers(IVroom? room, int maxPlayers)
{
if (room != null)
{
ReflectionHelper.SetFieldValue(room, "_maxPlayers", maxPlayers);
}
}
public static void SetRoomMaxPlayers(object? room, int maxPlayers)
{
if (room != null)
{
ReflectionHelper.SetFieldValue(room, "_maxPlayers", maxPlayers);
}
}
public static string GetRoomName(IVroom? room)
{
if (room == null)
{
return "Unknown";
}
return ((object)room).GetType().Name;
}
public static int GetRoomPlayerCount(object? room)
{
if (room == null)
{
return 0;
}
return ServerNetworkAPI.GetRoomPlayerCount(room);
}
public static IDictionary? GetRoomPlayerDictionary(object? room)
{
if (room == null)
{
return null;
}
return ServerNetworkAPI.GetRoomPlayerDictionary(room);
}
private static IDictionary? GetRoomDictionary()
{
VRoomManager vRoomManager = CoreAPI.GetVRoomManager();
if (vRoomManager == null)
{
return null;
}
object fieldValue = ReflectionHelper.GetFieldValue(vRoomManager, "_roomDict");
return fieldValue as IDictionary;
}
}
public static class ServerNetworkAPI
{
private static object? _serverSocket;
private static Type? _serverSocketType;
private static Type? _ivroomType;
private static Type? _gameSessionInfoType;
public static object? GetServerSocket()
{
if (_serverSocket != null)
{
return _serverSocket;
}
try
{
Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name.Contains("FishySteamworks"));
if (assembly == null)
{
return null;
}
_serverSocketType = assembly.GetTypes().FirstOrDefault((Type t) => t.Name == "ServerSocket");
if (_serverSocketType == null)
{
return null;
}
FieldInfo field = _serverSocketType.GetField("instance", BindingFlags.Static | BindingFlags.Public);
if (field != null)
{
_serverSocket = field.GetValue(null);
return _serverSocket;
}
FieldInfo field2 = _serverSocketType.GetField("s", BindingFlags.Static | BindingFlags.Public);
if (field2 != null)
{
_serverSocket = field2.GetValue(null);
return _serverSocket;
}
}
catch
{
}
return null;
}
public static int GetMaximumClients()
{
object serverSocket = GetServerSocket();
if (serverSocket == null)
{
return 0;
}
object obj = ReflectionHelper.InvokeMethod(serverSocket, "GetMaximumClients");
if (obj is int)
{
return (int)obj;
}
return 0;
}
public static void SetMaximumClients(object serverSocket, int value)
{
if (serverSocket != null)
{
ReflectionHelper.SetFieldValue(serverSocket, "_maximumClients", value);
}
}
public static Type? GetIVroomType()
{
if (_ivroomType != null)
{
return _ivroomType;
}
_ivroomType = GetGameAssembly()?.GetType("IVroom");
return _ivroomType;
}
public static Type? GetGameSessionInfoType()
{
if (_gameSessionInfoType != null)
{
return _gameSessionInfoType;
}
_gameSessionInfoType = GetGameAssembly()?.GetType("GameSessionInfo");
return _gameSessionInfoType;
}
public static MethodBase? GetIVroomCanEnterChannel()
{
return GetIVroomType()?.GetMethod("CanEnterChannel", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
}
public static MethodBase? GetGameSessionInfoAddPlayerSteamID()
{
return GetGameSessionInfoType()?.GetMethod("AddPlayerSteamID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
}
public static bool IsPlayerInRoom(object room, long playerUID)
{
IDictionary roomPlayerDictionary = GetRoomPlayerDictionary(room);
if (roomPlayerDictionary == null)
{
return false;
}
foreach (object value in roomPlayerDictionary.Values)
{
long propertyValue = ReflectionHelper.GetPropertyValue<long>(value, "UID");
if (propertyValue == playerUID)
{
return true;
}
}
return false;
}
public static int GetCurrentClientCount()
{
object serverSocket = GetServerSocket();
if (serverSocket == null)
{
return 0;
}
object obj = ReflectionHelper.InvokeMethod(serverSocket, "GetClientCount");
if (obj is int)
{
return (int)obj;
}
return 0;
}
public static bool IsServerRunning()
{
return GetServerSocket() != null;
}
public static object? GetVRoomManager()
{
return CoreAPI.GetVRoomManager();
}
public static object? GetWaitingRoom()
{
object vRoomManager = GetVRoomManager();
if (vRoomManager == null)
{
return null;
}
object fieldValue = ReflectionHelper.GetFieldValue(vRoomManager, "_vrooms");
if (fieldValue == null)
{
return null;
}
if (!(fieldValue is IDictionary dictionary))
{
return null;
}
foreach (object value in dictionary.Values)
{
if (value.GetType().Name == "VWaitingRoom")
{
return value;
}
}
return null;
}
public static object? GetMaintenanceRoom()
{
object vRoomManager = GetVRoomManager();
if (vRoomManager == null)
{
return null;
}
object fieldValue = ReflectionHelper.GetFieldValue(vRoomManager, "_vrooms");
if (fieldValue == null)
{
return null;
}
if (!(fieldValue is IDictionary dictionary))
{
return null;
}
foreach (object value in dictionary.Values)
{
if (value.GetType().Name == "MaintenanceRoom")
{
return value;
}
}
return null;
}
public static int GetWaitingRoomMemberCount()
{
object waitingRoom = GetWaitingRoom();
if (waitingRoom == null)
{
return 0;
}
object obj = ReflectionHelper.InvokeMethod(waitingRoom, "GetMemberCount");
if (obj is int)
{
return (int)obj;
}
return 0;
}
public static int GetWaitingRoomMaxPlayers()
{
object waitingRoom = GetWaitingRoom();
if (waitingRoom == null)
{
return 0;
}
return ReflectionHelper.GetFieldValue<int>(waitingRoom, "_maxPlayers");
}
public static int GetMaintenanceRoomMemberCount()
{
object maintenanceRoom = GetMaintenanceRoom();
if (maintenanceRoom == null)
{
return 0;
}
object obj = ReflectionHelper.InvokeMethod(maintenanceRoom, "GetMemberCount");
if (obj is int)
{
return (int)obj;
}
return 0;
}
public static int GetMaintenanceRoomMaxPlayers()
{
object maintenanceRoom = GetMaintenanceRoom();
if (maintenanceRoom == null)
{
return 0;
}
return ReflectionHelper.GetFieldValue<int>(maintenanceRoom, "_maxPlayers");
}
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)
{
return false;
}
Type type = obj.GetType();
if (type.IsEnum)
{
string name = Enum.GetName(type, obj);
return name == "Success";
}
return false;
}
catch
{
return false;
}
}
public static List<object> GetAllConnectedPlayers()
{
List<object> list = new List<object>();
try
{
object serverSocket = GetServerSocket();
if (serverSocket == null)
{
return list;
}
FieldInfo field = serverSocket.GetType().GetField("_connections", BindingFlags.Instance | BindingFlags.NonPublic);
if (field == null)
{
return list;
}
object value = field.GetValue(serverSocket);
if (value is IDictionary dictionary)
{
list.AddRange(dictionary.Values.Cast<object>());
}
}
catch
{
}
return list;
}
public static Type? GetMsgErrorCodeType()
{
try
{
Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name.Contains("FishySteamworks"));
if (assembly == null)
{
return null;
}
return assembly.GetTypes().FirstOrDefault((Type t) => t.Name == "MsgErrorCode");
}
catch
{
return null;
}
}
public static object? CreateErrorCodeEnum(string value)
{
Type msgErrorCodeType = GetMsgErrorCodeType();
if (msgErrorCodeType == null || !msgErrorCodeType.IsEnum)
{
return null;
}
return Enum.Parse(msgErrorCodeType, value);
}
public static void SetRoomMaxPlayers(object? room, int maxPlayers)
{
if (room != null)
{
ReflectionHelper.SetFieldValue(room, "_maxPlayers", maxPlayers);
}
}
public static int GetRoomPlayerCount(object? room)
{
if (room == null)
{
return 0;
}
object fieldValue = ReflectionHelper.GetFieldValue(room, "_vPlayerDict");
if (fieldValue is IDictionary dictionary)
{
return dictionary.Count;
}
return 0;
}
public static IDictionary? GetRoomPlayerDictionary(object? room)
{
if (room == null)
{
return null;
}
return ReflectionHelper.GetFieldValue(room, "_vPlayerDict") as IDictionary;
}
public static Assembly? GetServerAssembly()
{
try
{
return AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name.Contains("FishySteamworks"));
}
catch
{
return null;
}
}
public static Assembly? GetGameAssembly()
{
try
{
return AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name == "Assembly-CSharp");
}
catch
{
return null;
}
}
public static Type? GetServerSocketType()
{
Assembly serverAssembly = GetServerAssembly();
if (serverAssembly == null)
{
return null;
}
return serverAssembly.GetTypes().FirstOrDefault((Type t) => t.Name == "ServerSocket");
}
}
public static class ShopAPI
{
public static ShopGroup_MasterData GetShopGroupData(int shopGroupID)
{
try
{
DataManager dataManager = ManagerAPI.GetDataManager();
if ((Object)(object)dataManager == (Object)null)
{
return null;
}
object fieldValue = ReflectionHelper.GetFieldValue(dataManager, "ExcelDataManager");
if (fieldValue == null)
{
return null;
}
Dictionary<int, ShopGroup_MasterData> fieldValue2 = ReflectionHelper.GetFieldValue<Dictionary<int, ShopGroup_MasterData>>(fieldValue, "ShopGroupDict");
if (fieldValue2 == null || !fieldValue2.ContainsKey(shopGroupID))
{
return null;
}
return fieldValue2[shopGroupID];
}
catch
{
return null;
}
}
public static List<ShopGroup_MasterData> GetAllShopGroups()
{
try
{
DataManager dataManager = ManagerAPI.GetDataManager();
if ((Object)(object)dataManager == (Object)null)
{
return new List<ShopGroup_MasterData>();
}
object fieldValue = ReflectionHelper.GetFieldValue(dataManager, "ExcelDataManager");
if (fieldValue == null)
{
return new List<ShopGroup_MasterData>();
}
Dictionary<int, ShopGroup_MasterData> fieldValue2 = ReflectionHelper.GetFieldValue<Dictionary<int, ShopGroup_MasterData>>(fieldValue, "ShopGroupDict");
if (fieldValue2 == null)
{
return new List<ShopGroup_MasterData>();
}
return fieldValue2.Values.ToList();
}
catch
{
return new List<ShopGroup_MasterData>();
}
}
public static bool AddShop(int shopGroupID, ShopGroup_MasterData shopData)
{
if (shopData == null)
{
return false;
}
try
{
DataManager dataManager = ManagerAPI.GetDataManager();
if ((Object)(object)dataManager == (Object)null)
{
return false;
}
object fieldValue = ReflectionHelper.GetFieldValue(dataManager, "ExcelDataManager");
if (fieldValue == null)
{
return false;
}
Dictionary<int, ShopGroup_MasterData> fieldValue2 = ReflectionHelper.GetFieldValue<Dictionary<int, ShopGroup_MasterData>>(fieldValue, "ShopGroupDict");
if (fieldValue2 == null)
{
return false;
}
if (fieldValue2.ContainsKey(shopGroupID))
{
return false;
}
fieldValue2[shopGroupID] = shopData;
return true;
}
catch
{
return false;
}
}
public static bool DeleteShop(int shopGroupID)
{
try
{
DataManager dataManager = ManagerAPI.GetDataManager();
if ((Object)(object)dataManager == (Object)null)
{
return false;
}
object fieldValue = ReflectionHelper.GetFieldValue(dataManager, "ExcelDataManager");
if (fieldValue == null)
{
return false;
}
Dictionary<int, ShopGroup_MasterData> fieldValue2 = ReflectionHelper.GetFieldValue<Dictionary<int, ShopGroup_MasterData>>(fieldValue, "ShopGroupDict");
if (fieldValue2 == null || !fieldValue2.ContainsKey(shopGroupID))
{
return false;
}
fieldValue2.Remove(shopGroupID);
return true;
}
catch
{
return false;
}
}
public static bool UpdateShop(int shopGroupID, ShopGroup_MasterData updatedData)
{
if (updatedData == null)
{
return false;
}
try
{
DataManager dataManager = ManagerAPI.GetDataManager();
if ((Object)(object)dataManager == (Object)null)
{
return false;
}
object fieldValue = ReflectionHelper.GetFieldValue(dataManager, "ExcelDataManager");
if (fieldValue == null)
{
return false;
}
Dictionary<int, ShopGroup_MasterData> fieldValue2 = ReflectionHelper.GetFieldValue<Dictionary<int, ShopGroup_MasterData>>(fieldValue, "ShopGroupDict");
if (fieldValue2 == null || !fieldValue2.ContainsKey(shopGroupID))
{
return false;
}
fieldValue2[shopGroupID] = updatedData;
return true;
}
catch
{
return false;
}
}
public static bool UpdateShopItem(int shopGroupID, int itemSlot, int itemMasterID, int itemPrice)
{
if (itemSlot < 1 || itemSlot > 9)
{
return false;
}
try
{
ShopGroup_MasterData shopGroupData = GetShopGroupData(shopGroupID);
if (shopGroupData == null)
{
return false;
}
string fieldName = $"item{itemSlot}_masterid";
string fieldName2 = $"item{itemSlot}_price";
ReflectionHelper.SetFieldValue(shopGroupData, fieldName, itemMasterID);
ReflectionHelper.SetFieldValue(shopGroupData, fieldName2, itemPrice);
return true;
}
catch
{
return false;
}
}
public static bool RemoveShopItem(int shopGroupID, int itemSlot)
{
if (itemSlot < 1 || itemSlot > 9)
{
return false;
}
try
{
ShopGroup_MasterData shopGroupData = GetShopGroupData(shopGroupID);
if (shopGroupData == null)
{
return false;
}
string fieldName = $"item{itemSlot}_masterid";
string fieldName2 = $"item{itemSlot}_price";
string fieldName3 = $"ShopGroup_item{itemSlot}_valval";
ReflectionHelper.SetFieldValue(shopGroupData, fieldName, 0);
ReflectionHelper.SetFieldValue(shopGroupData, fieldName2, 0);
object fieldValue = ReflectionHelper.GetFieldValue(shopGroupData, fieldName3);
if (fieldValue is IList list)
{
list.Clear();
}
return true;
}
catch
{
return false;
}
}
public static int GetShopItemMasterID(int shopGroupID, int itemSlot)
{
if (itemSlot < 1 || itemSlot > 9)
{
return 0;
}
try
{
ShopGroup_MasterData shopGroupData = GetShopGroupData(shopGroupID);
if (shopGroupData == null)
{
return 0;
}
string fieldName = $"item{itemSlot}_masterid";
return ReflectionHelper.GetFieldValue<int>(shopGroupData, fieldName);
}
catch
{
return 0;
}
}
public static int GetShopItemPrice(int shopGroupID, int itemSlot)
{
if (itemSlot < 1 || itemSlot > 9)
{
return 0;
}
try
{
ShopGroup_MasterData shopGroupData = GetShopGroupData(shopGroupID);
if (shopGroupData == null)
{
return 0;
}
string fieldName = $"item{itemSlot}_price";
return ReflectionHelper.GetFieldValue<int>(shopGroupData, fieldName);
}
catch
{
return 0;
}
}
public static List<int> GetAllShopItemMasterIDs(int shopGroupID)
{
List<int> list = new List<int>();
try
{
ShopGroup_MasterData shopGroupData = GetShopGroupData(shopGroupID);
if (shopGroupData == null)
{
return list;
}
for (int i = 1; i <= 9; i++)
{
int shopItemMasterID = GetShopItemMasterID(shopGroupID, i);
if (shopItemMasterID != 0)
{
list.Add(shopItemMasterID);
}
}
}
catch
{
}
return list;
}
public static bool ShopExists(int shopGroupID)
{
try
{
DataManager dataManager = ManagerAPI.GetDataManager();
if ((Object)(object)dataManager == (Object)null)
{
return false;
}
object fieldValue = ReflectionHelper.GetFieldValue(dataManager, "ExcelDataManager");
if (fieldValue == null)
{
return false;
}
return ReflectionHelper.GetFieldValue<Dictionary<int, ShopGroup_MasterData>>(fieldValue, "ShopGroupDict")?.ContainsKey(shopGroupID) ?? false;
}
catch
{
return false;
}
}
public static int GetShopCount()
{
try
{
DataManager dataManager = ManagerAPI.GetDataManager();
if ((Object)(object)dataManager == (Object)null)
{
return 0;
}
object fieldValue = ReflectionHelper.GetFieldValue(dataManager, "ExcelDataManager");
if (fieldValue == null)
{
return 0;
}
return ReflectionHelper.GetFieldValue<Dictionary<int, ShopGroup_MasterData>>(fieldValue, "ShopGroupDict")?.Count ?? 0;
}
catch
{
return 0;
}
}
public static ShopGroup_MasterData CreateNewShopGroup(int id)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Expected O, but got Unknown
try
{
ShopGroup_MasterData val = new ShopGroup_MasterData();
ReflectionHelper.SetFieldValue(val, "id", id);
for (int i = 1; i <= 9; i++)
{
string fieldName = $"item{i}_masterid";
string fieldName2 = $"item{i}_price";
string text = $"ShopGroup_item{i}_valval";
ReflectionHelper.SetFieldValue(val, fieldName, 0);
ReflectionHelper.SetFieldValue(val, fieldName2, 0);
}
return val;
}
catch
{
return null;
}
}
public static bool ClearShopItems(int shopGroupID)
{
try
{
ShopGroup_MasterData shopGroupData = GetShopGroupData(shopGroupID);
if (shopGroupData == null)
{
return false;
}
for (int i = 1; i <= 9; i++)
{
RemoveShopItem(shopGroupID, i);
}
return true;
}
catch
{
return false;
}
}
}
public static class VoiceAPI
{
private static Dictionary<string, float> _voicePitchCache = new Dictionary<string, float>();
public static bool AddVoicePitch(string playerId, float pitchValue)
{
if (string.IsNullOrEmpty(playerId))
{
return false;
}
UIManager uIManager = ManagerAPI.GetUIManager();
if ((Object)(object)uIManager == (Object)null)
{
return false;
}
try
{
DissonanceFishNetComms instance = DissonanceFishNetComms.Instance;
DissonanceComms val = ((instance != null) ? instance.Comms : null);
if ((Object)(object)val == (Object)null)
{
return false;
}
VoicePlayerState val2 = val.FindPlayer(playerId);
if (val2 == null)
{
return false;
}
IVoicePlayback playback = val2.Playback;
CustomVoicePlayback val3 = (CustomVoicePlayback)(object)((playback is CustomVoicePlayback) ? playback : null);
if ((Object)(object)((val3 != null) ? ((VoicePlayback)val3).AudioSource : null) == (Object)null)
{
return false;
}
if (!_voicePitchCache.ContainsKey(playerId))
{
_voicePitchCache[playerId] = ((VoicePlayback)val3).AudioSource.pitch;
}
AudioSource audioSource = ((VoicePlayback)val3).AudioSource;
audioSource.pitch += pitchValue;
return true;
}
catch
{
return false;
}
}
public static bool RemoveVoicePitch(string playerId)
{
if (string.IsNullOrEmpty(playerId))
{
return false;
}
try
{
DissonanceFishNetComms instance = DissonanceFishNetComms.Instance;
DissonanceComms val = ((instance != null) ? instance.Comms : null);
if ((Object)(object)val == (Object)null)
{
return false;
}
VoicePlayerState val2 = val.FindPlayer(playerId);
if (val2 == null)
{
return false;
}
IVoicePlayback playback = val2.Playback;
CustomVoicePlayback val3 = (CustomVoicePlayback)(object)((playback is CustomVoicePlayback) ? playback : null);
if ((Object)(object)((val3 != null) ? ((VoicePlayback)val3).AudioSource : null) == (Object)null || !_voicePitchCache.ContainsKey(playerId))
{
return false;
}
((VoicePlayback)val3).AudioSource.pitch = _voicePitchCache[playerId];
_voicePitchCache.Remove(playerId);
return true;
}
catch
{
return false;
}
}
public static float GetVoicePitchBefore(string playerId)
{
if (string.IsNullOrEmpty(playerId))
{
return 1f;
}
if (_voicePitchCache.TryGetValue(playerId, out var value))
{
return value;
}
return 1f;
}
public static float GetVoicePitchAfter(string playerId)
{
if (string.IsNullOrEmpty(playerId))
{
return 1f;
}
try
{
DissonanceFishNetComms instance = DissonanceFishNetComms.Instance;
DissonanceComms val = ((instance != null) ? instance.Comms : null);
if ((Object)(object)val == (Object)null)
{
return 1f;
}
VoicePlayerState val2 = val.FindPlayer(playerId);
if (val2 == null)
{
return 1f;
}
AudioSource fieldValue = ReflectionHelper.GetFieldValue<AudioSource>(val2.Playback, "AudioSource");
return (fieldValue != null) ? fieldValue.pitch : 1f;
}
catch
{
return 1f;
}
}
public static bool SetVoicePitch(string playerId, float pitchValue)
{
if (string.IsNullOrEmpty(playerId))
{
return false;
}
try
{
DissonanceFishNetComms instance = DissonanceFishNetComms.Instance;
DissonanceComms val = ((instance != null) ? instance.Comms : null);
if ((Object)(object)val == (Object)null)
{
return false;
}
VoicePlayerState val2 = val.FindPlayer(playerId);
if (val2 == null)
{
return false;
}
IVoicePlayback playback = val2.Playback;
CustomVoicePlayback val3 = (CustomVoicePlayback)(object)((playback is CustomVoicePlayback) ? playback : null);
if ((Object)(object)((val3 != null) ? ((VoicePlayback)val3).AudioSource : null) == (Object)null)
{
return false;
}
if (!_voicePitchCache.ContainsKey(playerId))
{
_voicePitchCache[playerId] = ((VoicePlayback)val3).AudioSource.pitch;
}
((VoicePlayback)val3).AudioSource.pitch = Mathf.Clamp(pitchValue, 0.1f, 3f);
return true;
}
catch
{
return false;
}
}
public static List<string> GetAllVoicePlayers()
{
List<string> list = new List<string>();
try
{
DissonanceFishNetComms instance = DissonanceFishNetComms.Instance;
DissonanceComms val = ((instance != null) ? instance.Comms : null);
if ((Object)(object)val == (Object)null)
{
return list;
}
Dictionary<string, VoicePlayerState> fieldValue = ReflectionHelper.GetFieldValue<Dictionary<string, VoicePlayerState>>(val, "_players");
if (fieldValue != null)
{
list.AddRange(fieldValue.Keys);
}
}
catch
{
}
return list;
}
public static bool IsVoicePitchModified(string playerId)
{
if (string.IsNullOrEmpty(playerId))
{
return false;
}
float voicePitchBefore = GetVoicePitchBefore(playerId);
float voicePitchAfter = GetVoicePitchAfter(playerId);
return !Mathf.Approximately(voicePitchBefore, voicePitchAfter);
}
public static void ClearVoicePitchCache()
{
_voicePitchCache.Clear();
}
}
public static class WeatherAPI
{
public static eWeatherPreset GetCurrentWeatherPreset(IVroom? room)
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: 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)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
if (room == null)
{
return (eWeatherPreset)0;
}
try
{
DungeonWeather fieldValue = ReflectionHelper.GetFieldValue<DungeonWeather>(room, "_dungeonWeather");
if (fieldValue == null)
{
return (eWeatherPreset)0;
}
TimeUtil timeUtil = ManagerAPI.GetTimeUtil();
if ((Object)(object)timeUtil == (Object)null)
{
return (eWeatherPreset)0;
}
int currentHour = GetCurrentHour(timeUtil);
return fieldValue.GetWeatherPreset(currentHour);
}
catch
{
return (eWeatherPreset)0;
}
}
public static int GetCurrentWeatherMasterID(IVroom? room)
{
if (room == null)
{
return 0;
}
try
{
DungeonWeather fieldValue = ReflectionHelper.GetFieldValue<DungeonWeather>(room, "_dungeonWeather");
if (fieldValue == null)
{
return 0;
}
TimeUtil timeUtil = ManagerAPI.GetTimeUtil();
if ((Object)(object)timeUtil == (Object)null)
{
return 0;
}
int currentHour = GetCurrentHour(timeUtil);
return fieldValue.GetWeatherMasterID(currentHour);
}
catch
{
return 0;
}
}
public static int GetWeatherForecastMasterID(IVroom? room)
{
if (room == null)
{
return 0;
}
try
{
DungeonWeather fieldValue = ReflectionHelper.GetFieldValue<DungeonWeather>(room, "_dungeonWeather");
if (fieldValue == null)
{
return 0;
}
TimeUtil timeUtil = ManagerAPI.GetTimeUtil();
if ((Object)(object)timeUtil == (Object)null)
{
return 0;
}
int currentHour = GetCurrentHour(timeUtil);
return fieldValue.GetWeatherForecastMasterID(currentHour);
}
catch
{
return 0;
}
}
public static bool UpdateWeather(IVroom? room, int newWeatherID, int startHour, int durationHour, bool forecast)
{
if (room == null)
{
return false;
}
try
{
DungeonWeather fieldValue = ReflectionHelper.GetFieldValue<DungeonWeather>(room, "_dungeonWeather");
if (fieldValue == null)
{
return false;
}
fieldValue.SetWeatherOverride(newWeatherID, startHour, durationHour, forecast);
return true;
}
catch
{
return false;
}
}
public static bool UpdateWeatherAll(IVroom? room, int newWeatherID)
{
if (room == null)
{
return false;
}
try
{
DungeonWeather fieldValue = ReflectionHelper.GetFieldValue<DungeonWeather>(room, "_dungeonWeather");
if (fieldValue == null)
{
return false;
}
fieldValue.SetWeatherOverrideAll(newWeatherID);
return true;
}
catch
{
return false;
}
}
public static float GetCurrentContaminationRate(IVroom? room)
{
if (room == null)
{
return 0f;
}
try
{
DungeonWeather fieldValue = ReflectionHelper.GetFieldValue<DungeonWeather>(room, "_dungeonWeather");
if (fieldValue == null)
{
return 0f;
}
TimeUtil timeUtil = ManagerAPI.GetTimeUtil();
if ((Object)(object)timeUtil == (Object)null)
{
return 0f;
}
int currentHour = GetCurrentHour(timeUtil);
return fieldValue.GetCurrentContaRate(currentHour);
}
catch
{
return 0f;
}
}
public static bool IsRandomWeatherOccurred(IVroom? room)
{
if (room == null)
{
return false;
}
try
{
DungeonWeather fieldValue = ReflectionHelper.GetFieldValue<DungeonWeather>(room, "_dungeonWeather");
if (fieldValue == null)
{
return false;
}
return fieldValue.IsRandomOccured;
}
catch
{
return false;
}
}
public static List<int> GetAllWeatherByHour(IVroom? room)
{
if (room == null)
{
return new List<int>();
}
try
{
DungeonWeather fieldValue = ReflectionHelper.GetFieldValue<DungeonWeather>(room, "_dungeonWeather");
if (fieldValue == null)
{
return new List<int>();
}
return fieldValue.GetAllWeather();
}
catch
{
return new List<int>();
}
}
private static int GetCurrentHour(TimeUtil timeUtil)
{
if (ReflectionHelper.GetFieldValue(timeUtil, "_currentTime") is long num)
{
return (int)(num / 1000 / 3600) % 24;
}
return 0;
}
}
}