using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.Json; using BepInEx; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using BepInEx.Unity.IL2CPP.Utils.Collections; using FatedGates.Commands.Converters; using FatedGates.Services; using HarmonyLib; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Microsoft.CodeAnalysis; using ProjectM; using ProjectM.Network; using ProjectM.Physics; using ProjectM.Scripting; using ProjectM.Shared; using ProjectM.Shared.Systems; using ProjectM.Terrain; using Stunlock.Core; using Stunlock.Localization; using Stunlock.Network; using Unity.Collections; using Unity.Collections.LowLevel.Unsafe; using Unity.Entities; using Unity.Mathematics; using Unity.Scenes; using Unity.Transforms; using UnityEngine; using VampireCommandFramework; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("FatedGates")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Server-side V Rising mod for persistent public waygates and public reveal zones.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+6cc1dd7daf028ae1e39bb5e380493dffa817222f")] [assembly: AssemblyProduct("FatedGates")] [assembly: AssemblyTitle("FatedGates")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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 FatedGates { internal static class Core { private static MonoBehaviour monoBehaviour; private static bool _hasInitialized = false; public static World Server { get; } = GetWorld("Server") ?? throw new Exception("There is no Server world (yet). Did you install a server mod on the client?"); public static EntityManager EntityManager { get; } = Server.EntityManager; public static ChunkObjectManager ChunkObjectManager { get; } = Server.GetExistingSystemManaged(); public static PrefabCollectionSystem PrefabCollection { get; } = Server.GetExistingSystemManaged(); public static ServerGameSettingsSystem ServerGameSettingsSystem { get; internal set; } public static ServerScriptMapper ServerScriptMapper { get; internal set; } public static double ServerTime => ServerGameManager.ServerTime; public static ServerGameManager ServerGameManager => ServerScriptMapper.GetServerGameManager(); public static ManualLogSource Log { get; } = Plugin.LogInstance; public static LocalizationService LocalizationService { get; } = new LocalizationService(); public static MapIconService MapIconService { get; internal set; } public static PortalService PortalService { get; } = new PortalService(); public static WaygateService WaygateService { get; internal set; } public static RevealService RevealService { get; private set; } public static void LogException(Exception e, [CallerMemberName] string caller = null) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown ManualLogSource log = Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(51, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failure in "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(caller); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\nMessage: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(e.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Inner:"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(e.InnerException?.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\n\nStack: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(e.StackTrace); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\nInner Stack: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(e.InnerException?.StackTrace); } log.LogError(val); } internal static void InitializeAfterLoaded() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown if (!_hasInitialized) { ServerGameSettingsSystem = Server.GetExistingSystemManaged(); ServerScriptMapper = Server.GetExistingSystemManaged(); FoundWaygatePrefabConverter.Initialize(); MapIconService = new MapIconService(); WaygateService = new WaygateService(); RevealService = new RevealService(); _hasInitialized = true; ManualLogSource log = Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(26, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("KindredPortals initialized"); } log.LogInfo(val); } } private static World GetWorld(string name) { Enumerator enumerator = World.s_AllWorlds.GetEnumerator(); while (enumerator.MoveNext()) { World current = enumerator.Current; if (current.Name == name) { return current; } } return null; } public static Coroutine StartCoroutine(IEnumerator routine) { //IL_0012: 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_0027: Expected O, but got Unknown if ((Object)(object)monoBehaviour == (Object)null) { GameObject val = new GameObject("KindredExtract"); monoBehaviour = (MonoBehaviour)(object)val.AddComponent(); Object.DontDestroyOnLoad((Object)val); } return monoBehaviour.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(routine)); } public static void StopCoroutine(Coroutine coroutine) { if (!((Object)(object)monoBehaviour == (Object)null)) { monoBehaviour.StopCoroutine(coroutine); } } } public static class ECSExtensions { private static EntityManager EntityManager { get; } = Core.Server.EntityManager; public unsafe static void Write(this Entity entity, T componentData) where T : struct { //IL_0030: 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_0039: 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_003b: Unknown result type (might be due to invalid IL or missing references) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of(), (AccessMode)0); byte[] array = StructureToByteArray(componentData); int num = Marshal.SizeOf(); fixed (byte* ptr = array) { EntityManager entityManager = EntityManager; ((EntityManager)(ref entityManager)).SetComponentDataRaw(entity, val.TypeIndex, (void*)ptr, num); } } private static byte[] StructureToByteArray(T structure) where T : struct { int num = Marshal.SizeOf(structure); byte[] array = new byte[num]; IntPtr intPtr = Marshal.AllocHGlobal(num); Marshal.StructureToPtr(structure, intPtr, fDeleteOld: true); Marshal.Copy(intPtr, array, 0, num); Marshal.FreeHGlobal(intPtr); return array; } public unsafe static T Read(this Entity entity) where T : struct { //IL_000d: 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_0015: 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_0017: Unknown result type (might be due to invalid IL or missing references) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of(), (AccessMode)0); EntityManager entityManager = EntityManager; return Marshal.PtrToStructure(new IntPtr(((EntityManager)(ref entityManager)).GetComponentDataRawRO(entity, val.TypeIndex))); } public static DynamicBuffer ReadBuffer(this Entity entity) where T : struct { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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) EntityManager entityManager = Core.Server.EntityManager; return ((EntityManager)(ref entityManager)).GetBuffer(entity, false); } public static bool Has(this Entity entity) { //IL_000d: 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_0015: 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) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of(), (AccessMode)0); EntityManager entityManager = EntityManager; return ((EntityManager)(ref entityManager)).HasComponent(entity, val); } public static string LookupName(this PrefabGUID prefabGuid) { //IL_000a: 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) //IL_0012: 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_002a: Unknown result type (might be due to invalid IL or missing references) PrefabLookupMap prefabLookupMap = Core.Server.GetExistingSystemManaged()._PrefabLookupMap; string text = default(string); object obj; if (!((PrefabLookupMap)(ref prefabLookupMap)).TryGetName(prefabGuid, ref text)) { obj = "GUID Not Found"; } else { string text2 = text; PrefabGUID val = prefabGuid; obj = text2 + " " + ((object)(PrefabGUID)(ref val)).ToString(); } return obj.ToString(); } public static void Add(this Entity entity) { //IL_000d: 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_0015: 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) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of(), (AccessMode)0); EntityManager entityManager = EntityManager; ((EntityManager)(ref entityManager)).AddComponent(entity, val); } public static void Remove(this Entity entity) { //IL_000d: 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_0015: 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) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of(), (AccessMode)0); EntityManager entityManager = EntityManager; ((EntityManager)(ref entityManager)).RemoveComponent(entity, val); } public static TerrainChunk GetChunk(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) return entity.Read().Value.GetChunk(); } public static TerrainChunk GetChunk(this float3 pos) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_003c: Unknown result type (might be due to invalid IL or missing references) TerrainChunk result = default(TerrainChunk); result.X = (sbyte)((pos.x + 3200f) / 160f); result.Y = (sbyte)((pos.z + 3200f) / 160f); return result; } } [BepInPlugin("FatedGates", "FatedGates", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BasePlugin { private Harmony _harmony; public static Harmony Harmony { get; private set; } public static ManualLogSource LogInstance { get; private set; } public override void Load() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown ManualLogSource log = ((BasePlugin)this).Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("FatedGates"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("1.0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!"); } log.LogInfo(val); LogInstance = ((BasePlugin)this).Log; _harmony = new Harmony("FatedGates"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); Harmony = _harmony; CommandRegistry.RegisterAll(); } public override bool Unload() { CommandRegistry.UnregisterAssembly(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } return true; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "FatedGates"; public const string PLUGIN_NAME = "FatedGates"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace FatedGates.Services { internal class LocalizationService { private Dictionary localization = new Dictionary(); public LocalizationService() { LoadLocalization(); } private void LoadLocalization() { string name = "FatedGates.Localization.English.json"; Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(name); if (manifestResourceStream != null) { using (StreamReader streamReader = new StreamReader(manifestResourceStream)) { string json = streamReader.ReadToEnd(); localization = JsonSerializer.Deserialize>(json); return; } } Console.WriteLine("Resource not found!"); } public string GetLocalization(string guid) { if (localization.TryGetValue(guid, out var value)) { return value; } return ""; } } internal class MapIconService { private PrefabGUID mapIconProxyPrefabGUID; private Entity mapIconProxyPrefab; private EntityQuery mapIconProxyQuery; public MapIconService() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if (!Core.PrefabCollection._SpawnableNameToPrefabGuidDictionary.TryGetValue("MapIcon_ProxyObject_POI_Unknown", ref mapIconProxyPrefabGUID)) { Core.Log.LogError((object)"Failed to find MapIcon_ProxyObject_POI_Unknown PrefabGUID"); } if (!Core.PrefabCollection._PrefabGuidToEntityMap.TryGetValue(mapIconProxyPrefabGUID, ref mapIconProxyPrefab)) { Core.Log.LogError((object)"Failed to find MapIcon_ProxyObject_POI_Unknown Prefab entity"); } EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val = ((EntityQueryBuilder)(ref val)).AddAll(ComponentType.ReadOnly()); val = ((EntityQueryBuilder)(ref val)).AddAll(ComponentType.ReadOnly()); val = ((EntityQueryBuilder)(ref val)).AddNone(ComponentType.ReadOnly()); val = ((EntityQueryBuilder)(ref val)).AddNone(ComponentType.ReadOnly()); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).WithOptions((EntityQueryOptions)2); EntityManager entityManager = Core.EntityManager; mapIconProxyQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); } public void CreateMapIcon(Entity characterEntity, PrefabGUID mapIcon) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0049: 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) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) float3 value = characterEntity.Read().Value; EntityManager entityManager = Core.EntityManager; Entity val = ((EntityManager)(ref entityManager)).Instantiate(mapIconProxyPrefab); val.Write(new Translation { Value = value }); val.Add(); val.Write(new SpawnedBy { Value = characterEntity }); val.Remove(); val.Remove(); val.Remove(); entityManager = Core.EntityManager; DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(val, false); buffer.Clear(); buffer.Add(new AttachMapIconsToEntity { Prefab = mapIcon }); } public bool RemoveMapIcon(Entity characterEntity) { //IL_000e: 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) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) float3 pos = characterEntity.Read().Value; NativeArray val = ((EntityQuery)(ref mapIconProxyQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); Entity val2 = ((IEnumerable)(from x in ((IEnumerable)val.ToArray()).Where(delegate(Entity x) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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) if (x.Has()) { PrefabGUID val3 = x.Read(); return ((PrefabGUID)(ref val3)).Equals(mapIconProxyPrefabGUID); } return false; }) orderby math.distance(pos, x.Read().Value) select x)).FirstOrDefault((Func)((Entity x) => math.distance(pos, x.Read().Value) < 5f)); val.Dispose(); if (val2 == Entity.Null) { return false; } EntityManager entityManager; if (val2.Has()) { entityManager = Core.EntityManager; DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(val2, false); for (int i = 0; i < buffer.Length; i++) { Entity entity = buffer[i].Entity; if (!(entity == Entity.Null)) { entityManager = Core.EntityManager; ((EntityManager)(ref entityManager)).DestroyEntity(entity); } } } entityManager = Core.EntityManager; ((EntityManager)(ref entityManager)).DestroyEntity(val2); return true; } } [HarmonyPatch(typeof(MapIconSpawnSystem), "OnUpdate")] internal static class MapIconSpawnSystemPatch { public static void Prefix(MapIconSpawnSystem __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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) //IL_0014: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_002f: 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_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_003e: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) EntityQuery _query_1050583545_ = __instance.__query_1050583545_0; NativeArray val = ((EntityQuery)(ref _query_1050583545_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); Enumerator enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (current.Has()) { Entity parent = current.Read().Parent; if (!((Entity)(ref parent)).Equals(Entity.Null) && parent.Has()) { MapIconData componentData = current.Read(); componentData.RequiresReveal = false; componentData.AllySetting = (MapIconShowSettings)2; componentData.EnemySetting = (MapIconShowSettings)2; current.Write(componentData); } } } val.Dispose(); } } internal class PortalService { private Entity portalPrefab; private EntityQuery spawnedPortalQuery; private Dictionary portalStartPos = new Dictionary(); public PortalService() { //IL_003d: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) PrefabGUID val = default(PrefabGUID); if (!Core.PrefabCollection._SpawnableNameToPrefabGuidDictionary.TryGetValue("TM_General_Entrance_Gate", ref val)) { Core.Log.LogError((object)"Failed to find TM_General_Entrance_Gate PrefabGUID"); } if (!Core.PrefabCollection._PrefabGuidToEntityMap.TryGetValue(val, ref portalPrefab)) { Core.Log.LogError((object)"Failed to find TM_General_Entrance_Gate Prefab entity"); } EntityQueryBuilder val2 = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val2 = ((EntityQueryBuilder)(ref val2)).AddAll(ComponentType.ReadOnly()); val2 = ((EntityQueryBuilder)(ref val2)).AddAll(ComponentType.ReadOnly()); EntityQueryBuilder val3 = ((EntityQueryBuilder)(ref val2)).WithOptions((EntityQueryOptions)2); EntityManager entityManager = Core.EntityManager; spawnedPortalQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val3); ((EntityQueryBuilder)(ref val3)).Dispose(); } public bool StartPortal(Entity playerEntity, PrefabGUID mapIcon) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0030: 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) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) float3 value = playerEntity.Read().Value; TerrainChunk val = default(TerrainChunk); val.X = (sbyte)((value.x + 3200f) / 160f); val.Y = (sbyte)((value.z + 3200f) / 160f); TerrainChunk val2 = val; int nextAvailableIndex = GetNextAvailableIndex(val2); if (nextAvailableIndex >= 9) { return false; } portalStartPos[playerEntity] = (value, playerEntity.Read().Value, val2, nextAvailableIndex, mapIcon); return true; } public string EndPortal(Entity playerEntity, PrefabGUID endMapIcon) { //IL_0006: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_002c: 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) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) if (!portalStartPos.TryGetValue(playerEntity, out (float3, quaternion, TerrainChunk, int, PrefabGUID) value)) { return "Start portal hasn't been specified"; } float3 value2 = playerEntity.Read().Value; TerrainChunk val = default(TerrainChunk); val.X = (sbyte)((value2.x + 3200f) / 160f); val.Y = (sbyte)((value2.z + 3200f) / 160f); TerrainChunk val2 = val; int num = GetNextAvailableIndex(val2); if (val2 == value.Item3) { num++; } if (num >= 9) { return "Can't have more than 9 portals in a chunk"; } CreatePortal(playerEntity, value.Item1, value.Item2, value.Item3, value.Item4, value.Item5, val2, num); quaternion value3 = playerEntity.Read().Value; CreatePortal(playerEntity, value2, value3, val2, num, endMapIcon, value.Item3, value.Item4); portalStartPos.Remove(playerEntity); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(15, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Start: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(value.Item3); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(value.Item4); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" End: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(val2); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(num); } log.LogInfo(val3); return null; } private void CreatePortal(Entity creator, float3 pos, quaternion rot, TerrainChunk chunk, int index, PrefabGUID mapIcon, TerrainChunk toChunk, int toIndex) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_003c: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = Core.EntityManager; Entity val = ((EntityManager)(ref entityManager)).Instantiate(portalPrefab); val.Write(new Translation { Value = pos }); val.Write(new Rotation { Value = rot }); val.Add(); val.Write(new SpawnedBy { Value = creator }); entityManager = Core.EntityManager; DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(val, false); buffer.Clear(); if (!((PrefabGUID)(ref mapIcon)).Equals(PrefabGUID.Empty)) { buffer.Add(new AttachMapIconsToEntity { Prefab = mapIcon }); } val.Write(new ChunkPortal { FromChunk = chunk, FromChunkPortalIndex = index, ToChunk = toChunk, ToChunkPortalIndex = toIndex }); } private int GetNextAvailableIndex(TerrainChunk chunk) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_002a: Unknown result type (might be due to invalid IL or missing references) FixedList512Bytes val = default(FixedList512Bytes); if (!Core.ChunkObjectManager._ChunkPortals.TryGetValue(chunk, ref val)) { return 0; } for (int i = 0; i < val.Length; i++) { if (val[i].PortalEntity == Entity.Null) { return i; } } return val.Length; } public bool TeleportToClosestPortal(Entity playerEntity) { //IL_000d: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_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) //IL_004e: 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) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) NativeArray val = ((EntityQuery)(ref spawnedPortalQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); float3 pos = playerEntity.Read().Value; Entity val2 = ((IEnumerable)val.ToArray()).OrderBy((Entity x) => math.distance(pos, x.Read().Value)).FirstOrDefault(); val.Dispose(); if (val2 == Entity.Null) { return false; } float3 value = val2.Read().Value; quaternion value2 = val2.Read().Value; playerEntity.Write(new Translation { Value = value }); playerEntity.Write(new LastTranslation { Value = value }); playerEntity.Write(new Rotation { Value = value2 }); return true; } private Entity GetConnectedPortal(ChunkPortal chunkPortal) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) FixedList512Bytes val = default(FixedList512Bytes); if (!Core.ChunkObjectManager._ChunkPortals.TryGetValue(chunkPortal.ToChunk, ref val)) { return Entity.Null; } return val[chunkPortal.ToChunkPortalIndex].PortalEntity; } private void RemovePortalEntry(ChunkPortal chunkPortal) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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) //IL_0041: 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) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) FixedList512Bytes val = default(FixedList512Bytes); if (Core.ChunkObjectManager._ChunkPortals.TryGetValue(chunkPortal.FromChunk, ref val)) { val[chunkPortal.FromChunkPortalIndex] = default(ChunkPortalData); Core.ChunkObjectManager._ChunkPortals.Remove(chunkPortal.FromChunk); Core.ChunkObjectManager._ChunkPortals.Add(chunkPortal.FromChunk, val); } } public bool DestroyPortal(Entity senderCharacterEntity) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) float3 pos = senderCharacterEntity.Read().Value; NativeArray val = ((EntityQuery)(ref spawnedPortalQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); Entity val2 = ((IEnumerable)((IEnumerable)val.ToArray()).OrderBy((Entity x) => math.distance(pos, x.Read().Value))).FirstOrDefault((Func)((Entity x) => math.distance(pos, x.Read().Value) < 5f)); val.Dispose(); if (val2 == Entity.Null) { return false; } ChunkPortal chunkPortal = val2.Read(); Entity connectedPortal = GetConnectedPortal(chunkPortal); RemovePortalEntry(chunkPortal); EntityManager entityManager; if (val2.Has()) { entityManager = Core.EntityManager; DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(val2, false); for (int i = 0; i < buffer.Length; i++) { Entity entity = buffer[i].Entity; if (!(entity == Entity.Null)) { entityManager = Core.EntityManager; ((EntityManager)(ref entityManager)).DestroyEntity(entity); } } } entityManager = Core.EntityManager; ((EntityManager)(ref entityManager)).DestroyEntity(val2); if (connectedPortal != Entity.Null) { RemovePortalEntry(connectedPortal.Read()); if (connectedPortal.Has()) { entityManager = Core.EntityManager; DynamicBuffer buffer2 = ((EntityManager)(ref entityManager)).GetBuffer(connectedPortal, false); for (int j = 0; j < buffer2.Length; j++) { Entity entity2 = buffer2[j].Entity; if (!(entity2 == Entity.Null)) { entityManager = Core.EntityManager; ((EntityManager)(ref entityManager)).DestroyEntity(entity2); } } } entityManager = Core.EntityManager; ((EntityManager)(ref entityManager)).DestroyEntity(connectedPortal); } return true; } } internal class RevealService { public class PublicRevealZone { public string Name { get; set; } = "Public Reveal Zone"; public int X { get; set; } public int Y { get; set; } public int Radius { get; set; } = 1; } private readonly List publicRevealZones = new List(); private readonly string currentSaveName; private readonly string saveScopedConfigDir; private readonly string publicRevealZonesPath; public RevealService() { currentSaveName = GetCurrentSaveName(); saveScopedConfigDir = Path.Combine(Paths.ConfigPath, "FatedGates", currentSaveName); publicRevealZonesPath = Path.Combine(saveScopedConfigDir, "PublicRevealZones.json"); Directory.CreateDirectory(saveScopedConfigDir); LoadPublicRevealZones(); } private void LoadPublicRevealZones() { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown bool flag = default(bool); try { if (!File.Exists(publicRevealZonesPath)) { SavePublicRevealZones(); return; } List list = JsonSerializer.Deserialize>(File.ReadAllText(publicRevealZonesPath)); publicRevealZones.Clear(); if (list != null) { publicRevealZones.AddRange(list); } ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(28, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Loaded "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(publicRevealZones.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" public reveal zones."); } log.LogInfo(val); } catch (Exception ex) { ManualLogSource log2 = Core.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(36, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to load public reveal zones: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); } log2.LogError(val2); } } private void SavePublicRevealZones() { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown bool flag = default(bool); try { string directoryName = Path.GetDirectoryName(publicRevealZonesPath); if (!string.IsNullOrEmpty(directoryName)) { Directory.CreateDirectory(directoryName); } CompactPublicRevealZones(); string contents = JsonSerializer.Serialize(publicRevealZones, new JsonSerializerOptions { WriteIndented = true }); File.WriteAllText(publicRevealZonesPath, contents); ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Saved "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(publicRevealZones.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" public reveal zones."); } log.LogInfo(val); } catch (Exception ex) { ManualLogSource log2 = Core.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(36, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to save public reveal zones: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); } log2.LogError(val2); } } private void CompactPublicRevealZones() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown if (publicRevealZones.Count <= 1) { return; } List list = (from zone in publicRevealZones group zone by new { zone.X, zone.Y }).Select(group => { int radius = group.Max((PublicRevealZone zone) => zone.Radius); PublicRevealZone publicRevealZone = group.OrderByDescending((PublicRevealZone zone) => zone.Radius).First(); return new PublicRevealZone { Name = publicRevealZone.Name, X = publicRevealZone.X, Y = publicRevealZone.Y, Radius = radius }; }).ToList(); int num = publicRevealZones.Count - list.Count; if (num > 0) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(55, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Compacted public reveal zones: removed "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" duplicate entr"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted((num == 1) ? "y" : "ies"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogInfo(val); } publicRevealZones.Clear(); publicRevealZones.AddRange(list); } public bool RemovePublicRevealZone(Entity characterEntity, int index, out string message) { //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) if (publicRevealZones.Count == 0) { message = "No saved public reveal zones to remove."; return false; } if (index > 0) { int num = index - 1; if (num < 0 || num >= publicRevealZones.Count) { message = $"Invalid reveal zone index {index}. Use .waygate listrevealzones to see valid indexes."; return false; } PublicRevealZone publicRevealZone = publicRevealZones[num]; publicRevealZones.RemoveAt(num); SavePublicRevealZones(); message = $"Removed public reveal zone #{index}: {publicRevealZone.Name} at bitmap ({publicRevealZone.X}, {publicRevealZone.Y}), radius {publicRevealZone.Radius}."; return true; } if (!(characterEntity == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(characterEntity)) { float3 value = characterEntity.Read().Value; (int x, int y) tuple = WorldPositionToRevealBitmap(value); int item = tuple.x; int item2 = tuple.y; int num2 = -1; float num3 = float.MaxValue; for (int i = 0; i < publicRevealZones.Count; i++) { PublicRevealZone publicRevealZone2 = publicRevealZones[i]; int num4 = publicRevealZone2.X - item; int num5 = publicRevealZone2.Y - item2; int num6 = num4 * num4 + num5 * num5; if ((float)num6 < num3) { num3 = num6; num2 = i; } } if (num2 < 0) { message = "Could not find a closest public reveal zone."; return false; } float num7 = math.sqrt(num3); if (num7 > 10f) { message = $"Closest public reveal zone is {num7:F1} bitmap pixels away. Move closer or provide an index."; return false; } PublicRevealZone publicRevealZone3 = publicRevealZones[num2]; publicRevealZones.RemoveAt(num2); SavePublicRevealZones(); message = $"Removed closest public reveal zone #{num2 + 1}: {publicRevealZone3.Name} at bitmap ({publicRevealZone3.X}, {publicRevealZone3.Y}), radius {publicRevealZone3.Radius}."; return true; } } message = "Could not remove closest reveal zone; character entity is invalid."; return false; } public bool RevealMainMapPixelsForUser(Entity userEntity, int centerX, int centerY, int radius) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Invalid comparison between Unknown and I4 //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Expected O, but got Unknown //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) if (!(userEntity == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(userEntity)) { entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).HasBuffer(userEntity)) { Core.Log.LogWarning((object)"Reveal failed; user has no UserMapZoneElement buffer."); return false; } entityManager = Core.EntityManager; DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(userEntity, false); bool flag = default(bool); for (int i = 0; i < buffer.Length; i++) { UserMapZoneElement val = buffer[i]; if ((int)val.MapType != 1) { continue; } Entity entityOnServer = ((NetworkedEntity)(ref val.UserZoneEntity)).GetEntityOnServer(); if (!(entityOnServer == Entity.Null)) { entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(entityOnServer)) { entityManager = Core.EntityManager; if (!((EntityManager)(ref entityManager)).HasBuffer(entityOnServer)) { Core.Log.LogWarning((object)"Reveal failed; MainMap zone entity has no reveal buffer."); return false; } entityManager = Core.EntityManager; DynamicBuffer buffer2 = ((EntityManager)(ref entityManager)).GetBuffer(entityOnServer, false); HashSet hashSet = new HashSet(); for (int j = centerY - radius; j <= centerY + radius; j++) { for (int k = centerX - radius; k <= centerX + radius; k++) { if (k < 0 || k >= 256 || j < 0 || j >= 256) { continue; } int num = k - centerX; int num2 = j - centerY; if (num * num + num2 * num2 <= radius * radius) { int num3 = j * 32 + k / 8; int num4 = k % 8; byte b = (byte)(1 << num4); UserMapZonePackedRevealElement val2 = buffer2[num3]; byte packedPixel = val2.PackedPixel; val2.PackedPixel |= b; buffer2[num3] = val2; if (packedPixel != val2.PackedPixel) { hashSet.Add(num3); } } } } ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(65, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Revealed MainMap pixels around ("); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(centerX); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(centerY); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(") radius "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(radius); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" for "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(userEntity.Read().CharacterName); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(". Changed bytes: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(hashSet.Count); } log.LogInfo(val3); return true; } } Core.Log.LogWarning((object)"Reveal failed; MainMap UserZoneEntity is invalid."); return false; } Core.Log.LogWarning((object)"Reveal failed; no MainMap zone found."); return false; } } Core.Log.LogWarning((object)"Reveal failed; user entity is invalid."); return false; } public void AddPublicRevealZone(int x, int y, int radius = 1, string name = "Public Reveal Zone") { PublicRevealZone item = new PublicRevealZone { Name = name, X = x, Y = y, Radius = radius }; publicRevealZones.Add(item); SavePublicRevealZones(); } public void RevealPublicZoneForUser(Entity userEntity, PublicRevealZone zone) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) RevealMainMapPixelsForUser(userEntity, zone.X, zone.Y, zone.Radius); } public void RevealAllPublicZonesForUser(Entity userEntity) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) foreach (PublicRevealZone publicRevealZone in publicRevealZones) { RevealPublicZoneForUser(userEntity, publicRevealZone); } } public (int x, int y) WorldPositionToRevealBitmap(float3 worldPos) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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) float num = 0.08424167f * worldPos.x + 1.898E-05f * worldPos.z + 242.16705f; return new ValueTuple(item2: Mathf.RoundToInt(1.13E-05f * worldPos.x + 0.08437769f * worldPos.z + 201.91725f), item1: Mathf.RoundToInt(num)); } public bool AddRevealZoneAtClosestWaygate(Entity characterEntity, int radius = 1) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) if (!(characterEntity == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(characterEntity)) { float3 value = characterEntity.Read().Value; if (!Core.WaygateService.GetClosestSpawnedWaygate(value, out var closestWaygate, out var distance)) { Core.Log.LogWarning((object)"Could not add reveal zone at closest waygate; no nearby spawned waygate found."); return false; } float3 value2 = closestWaygate.Read().Value; var (num, num2) = WorldPositionToRevealBitmap(value2); AddPublicRevealZone(num, num2, radius, $"Reveal Zone {num},{num2} for a spawned waygate"); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(111, 7, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Added reveal zone at closest waygate. "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Waygate world pos X="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value2.x, "F4"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Y="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value2.y, "F4"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Z="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value2.z, "F4"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("bitmap ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") radius "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(radius); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("distance from player "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(distance, "F2"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogInfo(val); return true; } } Core.Log.LogWarning((object)"Could not add reveal zone at closest waygate; character entity is invalid."); return false; } public string GetPublicRevealZoneListText() { if (publicRevealZones.Count == 0) { return "No saved public reveal zones."; } List list = new List { $"Saved public reveal zones ({publicRevealZones.Count}):" }; for (int i = 0; i < publicRevealZones.Count; i++) { PublicRevealZone publicRevealZone = publicRevealZones[i]; list.Add($"{i + 1}. {publicRevealZone.Name} at bitmap ({publicRevealZone.X}, {publicRevealZone.Y}), radius {publicRevealZone.Radius}"); } return string.Join("\n", list); } private string GetCurrentSaveName() { string[] commandLineArgs = Environment.GetCommandLineArgs(); for (int i = 0; i < commandLineArgs.Length - 1; i++) { if (string.Equals(commandLineArgs[i], "-saveName", StringComparison.OrdinalIgnoreCase) || string.Equals(commandLineArgs[i], "-serverSaveName", StringComparison.OrdinalIgnoreCase)) { return SanitizeSaveName(commandLineArgs[i + 1]); } } string environmentVariable = Environment.GetEnvironmentVariable("VR_SAVE_NAME"); if (!string.IsNullOrWhiteSpace(environmentVariable)) { return SanitizeSaveName(environmentVariable); } Core.Log.LogWarning((object)"Could not determine active save name from command line or VR_SAVE_NAME. Using 'default'."); return "default"; } private string SanitizeSaveName(string saveName) { char[] invalidFileNameChars = Path.GetInvalidFileNameChars(); foreach (char oldChar in invalidFileNameChars) { saveName = saveName.Replace(oldChar, '_'); } saveName = saveName.Trim(); if (!string.IsNullOrWhiteSpace(saveName)) { return saveName; } return "default"; } } internal class WaygateService { public class PublicWaygate { public string Name { get; set; } = "Public Waygate"; public float WorldX { get; set; } public float WorldY { get; set; } public float WorldZ { get; set; } } private const float UnlockDistance = 25f; private readonly EntityQuery connectedUserQuery; private readonly EntityQuery waypointQuery; private readonly EntityQuery spawnedWaypointQuery; private readonly Dictionary> unlockedSpawnedWaypoints = new Dictionary>(); private readonly HashSet autoUnlockWaypoints = new HashSet(); private readonly string currentSaveName; private readonly string saveScopedConfigDir; private readonly string publicWaygatesPath; private readonly List publicWaygates = new List(); public WaygateService() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_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_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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val = ((EntityQueryBuilder)(ref val)).AddAll(ComponentType.ReadOnly()); val = ((EntityQueryBuilder)(ref val)).AddAll(ComponentType.ReadOnly()); EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).WithOptions((EntityQueryOptions)2); EntityManager entityManager = Core.EntityManager; spawnedWaypointQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2); ((EntityQueryBuilder)(ref val2)).Dispose(); val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val = ((EntityQueryBuilder)(ref val)).AddAll(ComponentType.ReadOnly()); EntityQueryBuilder val3 = ((EntityQueryBuilder)(ref val)).AddAll(ComponentType.ReadOnly()); entityManager = Core.EntityManager; connectedUserQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val3); ((EntityQueryBuilder)(ref val3)).Dispose(); val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2)); val = ((EntityQueryBuilder)(ref val)).AddAll(ComponentType.ReadOnly()); EntityQueryBuilder val4 = ((EntityQueryBuilder)(ref val)).WithOptions((EntityQueryOptions)2); entityManager = Core.EntityManager; waypointQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val4); ((EntityQueryBuilder)(ref val4)).Dispose(); currentSaveName = GetCurrentSaveName(); saveScopedConfigDir = Path.Combine(Paths.ConfigPath, "FatedGates", currentSaveName); publicWaygatesPath = Path.Combine(saveScopedConfigDir, "PublicWaygates.json"); Directory.CreateDirectory(saveScopedConfigDir); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(47, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Using save-scoped FatedGates config directory: "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(saveScopedConfigDir); } log.LogInfo(val5); LoadPublicWaygates(); if (!Core.ServerGameSettingsSystem.Settings.AllWaypointsUnlocked) { Core.StartCoroutine(ResolvePublicWaygatesWhenReady()); Core.StartCoroutine(CheckForWaypointUnlocks()); } } private void LoadPublicWaygates() { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown bool flag = default(bool); try { if (!File.Exists(publicWaygatesPath)) { SavePublicWaygates(); return; } List list = JsonSerializer.Deserialize>(File.ReadAllText(publicWaygatesPath)); publicWaygates.Clear(); if (list != null) { publicWaygates.AddRange(list); } ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(24, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Loaded "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(publicWaygates.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" public waygates."); } log.LogInfo(val); } catch (Exception ex) { ManualLogSource log2 = Core.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(32, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to load public waygates: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); } log2.LogError(val2); } } private void SavePublicWaygates() { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown bool flag = default(bool); try { string directoryName = Path.GetDirectoryName(publicWaygatesPath); if (!string.IsNullOrEmpty(directoryName)) { Directory.CreateDirectory(directoryName); } string contents = JsonSerializer.Serialize(publicWaygates, new JsonSerializerOptions { WriteIndented = true }); File.WriteAllText(publicWaygatesPath, contents); ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Saved "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(publicWaygates.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" public waygates."); } log.LogInfo(val); } catch (Exception ex) { ManualLogSource log2 = Core.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(32, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to save public waygates: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex); } log2.LogError(val2); } } public void SavePublicWaygate(Entity waygateEntity, string name = "Public Waygate") { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) float3 pos = waygateEntity.Read().Value; bool flag = default(bool); if (publicWaygates.Any((PublicWaygate existing) => math.distance(new float3(existing.WorldX, existing.WorldY, existing.WorldZ), pos) < 2f)) { ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(48, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Public waygate near X="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(pos.x, "F2"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Y="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(pos.y, "F2"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Z="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(pos.z, "F2"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is already saved."); } log.LogInfo(val); } else { publicWaygates.Add(new PublicWaygate { Name = name, WorldX = pos.x, WorldY = pos.y, WorldZ = pos.z }); SavePublicWaygates(); ManualLogSource log2 = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(38, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Saved public waygate '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' at X="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(pos.x, "F2"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Y="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(pos.y, "F2"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Z="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(pos.z, "F2"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log2.LogInfo(val); } NetworkId val2 = waygateEntity.Read(); if (val2 != NetworkId.Empty) { autoUnlockWaypoints.Add(val2); UnlockWaypointForAllConnectedUsers(val2); } } private IEnumerator ResolvePublicWaygatesWhenReady() { if (publicWaygates.Count == 0) { Core.Log.LogInfo((object)"No saved public waygates to resolve."); yield break; } WaitForSeconds wait = new WaitForSeconds(1f); bool flag = default(bool); for (int attempt = 1; attempt <= 10; attempt++) { EntityQuery val = spawnedWaypointQuery; NativeArray val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); int length = val2.Length; val2.Dispose(); BepInExInfoLogInterpolatedStringHandler val3; if (length > 0) { ManualLogSource log = Core.Log; val3 = new BepInExInfoLogInterpolatedStringHandler(68, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Resolving public waygates after "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(attempt); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" attempt(s); spawned waygate count="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(length); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("."); } log.LogInfo(val3); ResolvePublicWaygates(); yield break; } ManualLogSource log2 = Core.Log; val3 = new BepInExInfoLogInterpolatedStringHandler(63, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Public waygate resolve attempt "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(attempt); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": no spawned waygates found yet."); } log2.LogInfo(val3); yield return wait; } Core.Log.LogWarning((object)"Failed to resolve public waygates: no spawned waygates found after waiting."); } public void ResolvePublicWaygates() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Expected O, but got Unknown //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Expected O, but got Unknown autoUnlockWaypoints.Clear(); EntityQuery val = spawnedWaypointQuery; NativeArray val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); Il2CppArrayBase source = val2.ToArray(); List list = new List(); bool flag = default(bool); try { foreach (PublicWaygate publicWaygate in publicWaygates) { float3 savedPos = new float3(publicWaygate.WorldX, publicWaygate.WorldY, publicWaygate.WorldZ); Entity val3 = ((IEnumerable)source).OrderBy((Entity x) => math.distance(savedPos, x.Read().Value)).FirstOrDefault(); if (val3 == Entity.Null) { Core.Log.LogWarning((object)("Could not resolve public waygate '" + publicWaygate.Name + "'; no spawned waygates found. Removing stale public waygate entry.")); list.Add(publicWaygate); continue; } float num = math.distance(savedPos, val3.Read().Value); if (num > 10f) { Core.Log.LogWarning((object)($"Could not resolve public waygate '{publicWaygate.Name}'; closest spawned waygate was {num:F2} units away. " + "Removing stale public waygate entry.")); list.Add(publicWaygate); continue; } NetworkId val4 = val3.Read(); if (val4 == NetworkId.Empty) { Core.Log.LogWarning((object)("Could not resolve public waygate '" + publicWaygate.Name + "'; NetworkId was empty. Keeping entry for now; it may resolve later.")); continue; } autoUnlockWaypoints.Add(val4); ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(44, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Resolved public waygate '"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(publicWaygate.Name); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("' to "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(val4); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" at distance "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(num, "F2"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("."); } log.LogInfo(val5); } } finally { val2.Dispose(); } if (list.Count > 0) { foreach (PublicWaygate item in list) { publicWaygates.Remove(item); } SavePublicWaygates(); ManualLogSource log2 = Core.Log; BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(60, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Removed "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted(list.Count); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" stale public waygate entr"); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted((list.Count == 1) ? "y" : "ies"); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" from PublicWaygates.json."); } log2.LogInfo(val5); } UnlockAutoWaygatesForAllConnectedUsers(); } public bool GetClosestSpawnedWaygate(float3 position, out Entity closestWaygate, out float distance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) closestWaygate = Entity.Null; distance = float.MaxValue; EntityQuery val = spawnedWaypointQuery; NativeArray val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; float3 value = current.Read().Value; float num = math.distance(position, value); if (num < distance) { distance = num; closestWaygate = current; } } if (closestWaygate == Entity.Null) { return false; } return true; } finally { val2.Dispose(); } } private List InitializeUnlockedWaypoints(Entity userEntity) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0023: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) List list = new List(); unlockedSpawnedWaypoints.Add(userEntity, list); EntityManager entityManager = Core.EntityManager; DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(userEntity, false); EntityQuery val = spawnedWaypointQuery; NativeArray val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); Il2CppArrayBase source = val2.ToArray(); val2.Dispose(); Enumerator enumerator = buffer.GetEnumerator(); while (enumerator.MoveNext()) { UnlockedWaypointElement waypoint = enumerator.Current; if (((IEnumerable)source).Any((Entity x) => x.Read() == waypoint.Waypoint)) { list.Add(waypoint.Waypoint); } } return list; } public bool CreateWaygate(Entity character, PrefabGUID waypointPrefabGUID, bool autoUnlockForAllConnectedUsers = false, string publicWaygateName = "Public Waygate") { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) Entity val = default(Entity); if (!Core.PrefabCollection._PrefabGuidToEntityMap.TryGetValue(waypointPrefabGUID, ref val)) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(29, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to find "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(waypointPrefabGUID.LookupName()); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" Prefab entity"); } log.LogError(val2); return false; } float3 value = character.Read().Value; TerrainChunk chunk = value.GetChunk(); EntityQuery val3 = waypointQuery; NativeArray val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator enumerator = val4.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (!current.Has() && current.GetChunk() == chunk) { return false; } } } finally { val4.Dispose(); } quaternion value2 = character.Read().Value; EntityManager entityManager = Core.EntityManager; Entity val5 = ((EntityManager)(ref entityManager)).Instantiate(val); val5.Write(new Translation { Value = value }); val5.Write(new Rotation { Value = value2 }); val5.Add(); val5.Write(new SpawnedBy { Value = character }); if (autoUnlockForAllConnectedUsers) { Core.StartCoroutine(InitializeAutoUnlockWaygateAfterSpawn(val5, publicWaygateName)); } return true; } public bool TeleportToClosestWaygate(Entity character) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) float3 pos = character.Read().Value; EntityQuery val = spawnedWaypointQuery; NativeArray val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); Entity val3 = ((IEnumerable)val2.ToArray()).OrderBy((Entity x) => math.distance(pos, x.Read().Value)).FirstOrDefault(); val2.Dispose(); if (val3 == Entity.Null) { return false; } float3 value = val3.Read().Value; quaternion value2 = val3.Read().Value; character.Write(new Translation { Value = value }); character.Write(new LastTranslation { Value = value }); character.Write(new Rotation { Value = value2 }); return true; } public void UnlockWaypoint(Entity userEntity, NetworkId waypointNetworkId) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if (waypointNetworkId == NetworkId.Empty) { Core.Log.LogError((object)"Attempted to unlock an empty waypoint"); return; } if (!unlockedSpawnedWaypoints.TryGetValue(userEntity, out var value)) { value = InitializeUnlockedWaypoints(userEntity); } if (value.Contains(waypointNetworkId)) { return; } EntityManager entityManager = Core.EntityManager; DynamicBuffer buffer = ((EntityManager)(ref entityManager)).GetBuffer(userEntity, false); Enumerator enumerator = buffer.GetEnumerator(); while (enumerator.MoveNext()) { if (enumerator.Current.Waypoint == waypointNetworkId) { value.Add(waypointNetworkId); return; } } ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Waypoint "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(waypointNetworkId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" unlocked for "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(userEntity.Read().CharacterName); } log.LogInfo(val); buffer.Add(new UnlockedWaypointElement { Waypoint = waypointNetworkId }); value.Add(waypointNetworkId); } private IEnumerator CheckForWaypointUnlocks() { WaitForSeconds timeBetweenChecks = new WaitForSeconds(1f); while (true) { yield return timeBetweenChecks; EntityQuery val = spawnedWaypointQuery; NativeArray val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); if (val2.Length == 0) { val2.Dispose(); continue; } val = connectedUserQuery; NativeArray val3 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); Enumerator enumerator = val3.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; User val4 = current.Read(); if (!unlockedSpawnedWaypoints.TryGetValue(current, out var value)) { value = InitializeUnlockedWaypoints(current); } Entity entityOnServer = ((NetworkedEntity)(ref val4.LocalCharacter)).GetEntityOnServer(); if (entityOnServer == Entity.Null) { continue; } float3 value2 = entityOnServer.Read().Value; Enumerator enumerator2 = val2.GetEnumerator(); while (enumerator2.MoveNext()) { Entity current2 = enumerator2.Current; NetworkId val5 = current2.Read(); if (!value.Contains(val5)) { float3 value3 = current2.Read().Value; if (math.distance(value2, value3) < 25f) { UnlockWaypoint(current, val5); } } } } val3.Dispose(); val2.Dispose(); } } public bool DestroyWaygate(Entity senderCharacterEntity, int publicWaygateIndex = 0) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Expected O, but got Unknown Entity closestWaygate = Entity.Null; int num = -1; bool flag = default(bool); float3 value = default(float3); if (publicWaygateIndex > 0) { num = publicWaygateIndex - 1; if (num < 0 || num >= publicWaygates.Count) { ManualLogSource log = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(30, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Invalid public waygate index "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(publicWaygateIndex); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogWarning(val); return false; } PublicWaygate publicWaygate = publicWaygates[num]; ((float3)(ref value))..ctor(publicWaygate.WorldX, publicWaygate.WorldY, publicWaygate.WorldZ); } else { value = senderCharacterEntity.Read().Value; } GetClosestSpawnedWaygate(value, out closestWaygate, out var distance); if (closestWaygate == Entity.Null) { Core.Log.LogWarning((object)"Could not find spawned waygate to destroy."); return false; } if (distance > 10f) { ManualLogSource log2 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(54, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Closest spawned waygate "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(distance); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" away, move within "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(10f); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" to destroy"); } log2.LogWarning(val); return false; } if (publicWaygateIndex == 0) { float3 waypointPos = closestWaygate.Read().Value; num = publicWaygates.FindIndex((PublicWaygate saved) => math.distance(new float3(saved.WorldX, saved.WorldY, saved.WorldZ), waypointPos) < 2f); } NetworkId val2 = closestWaygate.Read(); if (val2 != NetworkId.Empty) { autoUnlockWaypoints.Remove(val2); } if (num >= 0) { PublicWaygate publicWaygate2 = publicWaygates[num]; publicWaygates.RemoveAt(num); SavePublicWaygates(); ManualLogSource log3 = Core.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(46, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Removed saved public waygate '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(publicWaygate2.Name); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' "); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("at X="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(publicWaygate2.WorldX, "F2"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", Y="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(publicWaygate2.WorldY, "F2"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", Z="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(publicWaygate2.WorldZ, "F2"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("."); } log3.LogInfo(val3); } DestroyUtility.Destroy(Core.EntityManager, closestWaygate, (DestroyDebugReason)0, (string)null, 0); return true; } public void UnlockWaypointForAllConnectedUsers(NetworkId waypointNetworkId) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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_0023: 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_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) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (waypointNetworkId == NetworkId.Empty) { Core.Log.LogWarning((object)"Attempted to unlock empty waypoint for connected users."); return; } EntityQuery val = connectedUserQuery; NativeArray val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (!(current == Entity.Null) && current.Has()) { UnlockWaypoint(current, waypointNetworkId); } } } finally { val2.Dispose(); } } public void UnlockAutoWaygatesForUser(Entity userEntity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) if (userEntity == Entity.Null) { Core.Log.LogWarning((object)"Attempted to unlock auto waygates for Entity.Null"); return; } bool flag = default(bool); if (!userEntity.Has()) { ManualLogSource log = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(54, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Attempted to unlock auto waygates for non-user entity "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(userEntity); } log.LogWarning(val); return; } ManualLogSource log2 = Core.Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(41, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Auto-unlock waygate count: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(autoUnlockWaypoints.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" for user for "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(userEntity.Read().CharacterName); } log2.LogInfo(val2); if (Core.ServerGameSettingsSystem.Settings.AllWaypointsUnlocked) { return; } foreach (NetworkId autoUnlockWaypoint in autoUnlockWaypoints) { ManualLogSource log3 = Core.Log; val2 = new BepInExInfoLogInterpolatedStringHandler(29, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Auto-unlocking waypoint "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(autoUnlockWaypoint); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" for "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(userEntity.Read().CharacterName); } log3.LogInfo(val2); UnlockWaypoint(userEntity, autoUnlockWaypoint); } } public void UnlockAutoWaygatesForAllConnectedUsers() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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) //IL_0014: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0028: Unknown result type (might be due to invalid IL or missing references) EntityQuery val = connectedUserQuery; NativeArray val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; UnlockAutoWaygatesForUser(current); } } finally { val2.Dispose(); } } private IEnumerator InitializeAutoUnlockWaygateAfterSpawn(Entity waygate, string name) { //IL_000e: 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) yield return (object)new WaitForSeconds(1f); if (!(waygate == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(waygate)) { if (!waygate.Has()) { Core.Log.LogWarning((object)"Auto-unlock waygate does not have NetworkId after creation delay."); yield break; } NetworkId val = waygate.Read(); if (val == NetworkId.Empty) { Core.Log.LogWarning((object)"Auto-unlock waygate still has empty NetworkId after creation delay."); yield break; } SavePublicWaygate(waygate, name); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(51, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Auto-unlock waygate registered: Entity="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(waygate); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", NetworkId="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(val); } log.LogInfo(val2); yield break; } } Core.Log.LogWarning((object)"Auto-unlock waygate no longer exists after creation delay."); } public string GetPublicWaygateListText() { if (publicWaygates.Count == 0) { return "No saved public waygates."; } List list = new List { $"Saved public waygates ({publicWaygates.Count}):" }; for (int i = 0; i < publicWaygates.Count; i++) { PublicWaygate publicWaygate = publicWaygates[i]; list.Add($"{i + 1}. {publicWaygate.Name} at X={publicWaygate.WorldX:F2}, Y={publicWaygate.WorldY:F2}, Z={publicWaygate.WorldZ:F2}"); } return string.Join("\n", list); } private string GetCurrentSaveName() { string[] commandLineArgs = Environment.GetCommandLineArgs(); for (int i = 0; i < commandLineArgs.Length - 1; i++) { if (string.Equals(commandLineArgs[i], "-saveName", StringComparison.OrdinalIgnoreCase) || string.Equals(commandLineArgs[i], "-serverSaveName", StringComparison.OrdinalIgnoreCase)) { return SanitizeSaveName(commandLineArgs[i + 1]); } } string environmentVariable = Environment.GetEnvironmentVariable("VR_SAVE_NAME"); if (!string.IsNullOrWhiteSpace(environmentVariable)) { return SanitizeSaveName(environmentVariable); } Core.Log.LogWarning((object)"Could not determine active save name from command line or VR_SAVE_NAME. Using 'default'."); return "default"; } private string SanitizeSaveName(string saveName) { char[] invalidFileNameChars = Path.GetInvalidFileNameChars(); foreach (char oldChar in invalidFileNameChars) { saveName = saveName.Replace(oldChar, '_'); } saveName = saveName.Trim(); if (!string.IsNullOrWhiteSpace(saveName)) { return saveName; } return "default"; } } } namespace FatedGates.Patches { [HarmonyPatch(typeof(SceneSectionStreamingSystem), "ShutdownAsynchrnonousStreamingSupport")] public static class InitializationPatch { [HarmonyPostfix] public static void OneShot_AfterLoad_InitializationPatch() { Core.InitializeAfterLoaded(); Plugin.Harmony.Unpatch((MethodBase)typeof(SceneSectionStreamingSystem).GetMethod("ShutdownAsynchrnonousStreamingSupport"), typeof(InitializationPatch).GetMethod("OneShot_AfterLoad_InitializationPatch")); } } [HarmonyPatch(typeof(ServerBootstrapSystem), "OnUserConnected")] public static class OnUserConnected_Patch { public static void Prefix(ServerBootstrapSystem __instance, NetConnectionId netConnectionId) { //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //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) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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) bool flag = default(bool); try { Core.Log.LogInfo((object)"OnUserConnected PREFIX fired."); if (!__instance._NetEndPointToApprovedUserIndex.ContainsKey(netConnectionId)) { Core.Log.LogInfo((object)"PREFIX: netConnectionId not found in _NetEndPointToApprovedUserIndex yet."); return; } int num = __instance._NetEndPointToApprovedUserIndex[netConnectionId]; Entity userEntity = ((Il2CppArrayBase)(object)__instance._ApprovedUsersLookup)[num].UserEntity; ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(29, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("PREFIX: resolved user entity "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(userEntity); } log.LogInfo(val); if (!(userEntity == Entity.Null)) { EntityManager entityManager = Core.EntityManager; if (((EntityManager)(ref entityManager)).Exists(userEntity)) { ManualLogSource log2 = Core.Log; val = new BepInExInfoLogInterpolatedStringHandler(41, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("PREFIX: applying public reveal zones for "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(userEntity.Read().CharacterName); } log2.LogInfo(val); Core.RevealService.RevealAllPublicZonesForUser(userEntity); return; } } Core.Log.LogInfo((object)"PREFIX: user entity is null or does not exist."); } catch (Exception ex) { ManualLogSource log3 = Core.Log; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(36, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("OnUserConnected PREFIX test failed: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } log3.LogWarning(val2); } } public static void Postfix(ServerBootstrapSystem __instance, NetConnectionId netConnectionId) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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) try { if (Core.WaygateService == null) { Core.InitializeAfterLoaded(); } int num = __instance._NetEndPointToApprovedUserIndex[netConnectionId]; Entity userEntity = ((Il2CppArrayBase)(object)__instance._ApprovedUsersLookup)[num].UserEntity; Core.WaygateService.UnlockAutoWaygatesForUser(userEntity); } catch (Exception ex) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(73, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failure in "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("OnUserConnected"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" waygate unlock patch\n"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Message: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Inner: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.InnerException?.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\n\n"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Stack: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.StackTrace); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\n"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Inner Stack: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.InnerException?.StackTrace); } log.LogError(val); } } } [HarmonyPatch(typeof(RegisterSpawnedChunkObjectsSystem), "OnUpdate")] internal class RegisterSpawnedChunkObjectsSystem_PersistenceLoadPatch { private static Dictionary entityChunkPortals = new Dictionary(); public static void Prefix() { //IL_0003: 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) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_003d: 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_0047: 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) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) EntityQueryBuilder val = default(EntityQueryBuilder); ((EntityQueryBuilder)(ref val))..ctor(AllocatorHandle.op_Implicit((Allocator)2)); ((EntityQueryBuilder)(ref val)).AddAll(ComponentType.ReadOnly()); ((EntityQueryBuilder)(ref val)).WithOptions((EntityQueryOptions)2); EntityManager entityManager = Core.EntityManager; EntityQuery val2 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val); ((EntityQueryBuilder)(ref val)).Dispose(); NativeArray val3 = ((EntityQuery)(ref val2)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); Enumerator enumerator = val3.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; ChunkPortal val4 = current.Read(); entityChunkPortals.Add(current, val4); val4.FromChunkPortalIndex = 0; current.Write(val4); } val3.Dispose(); ((EntityQuery)(ref val2)).Dispose(); } public static void Postfix() { //IL_0023: 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_0026: 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: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) FixedList512Bytes val5 = default(FixedList512Bytes); bool flag = default(bool); foreach (var (val3, val4) in entityChunkPortals) { if (!Core.ChunkObjectManager._ChunkPortals.TryGetValue(val4.FromChunk, ref val5)) { ManualLogSource log = Core.Log; BepInExErrorLogInterpolatedStringHandler val6 = new BepInExErrorLogInterpolatedStringHandler(29, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("Missing portalData for chunk "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted(val4.FromChunk); } log.LogError(val6); continue; } val3.Write(val4); ChunkPortalData val7 = default(ChunkPortalData); val7.PortalEntity = val3; val7.PortalPosition = val3.Read().Value; val7.PortalRotation = val3.Read().Value; val7.InPositionOffset = val4.InPositionOffset; val7.ToChunk = val4.ToChunk; val7.ToChunkPortalIndex = val4.ToChunkPortalIndex; ChunkPortalData val8 = val7; if (val4.FromChunkPortalIndex < val5.Length) { val5[val4.FromChunkPortalIndex] = val8; } else { val5.Length = (ushort)(val4.FromChunkPortalIndex + 1); val5[val4.FromChunkPortalIndex] = val8; } Core.ChunkObjectManager._ChunkPortals.Remove(val4.FromChunk); Core.ChunkObjectManager._ChunkPortals.Add(val4.FromChunk, val5); } entityChunkPortals.Clear(); } } [HarmonyPatch(typeof(RegisterSpawnedChunkObjectsSystem), "OnUpdate")] internal static class RegisterSpawnedChunkObjectsSystem_ReactToSpawnPatch { private static Dictionary initialList, List<(int, ChunkPortalData)> additions)> data = new Dictionary, List<(int, ChunkPortalData)>)>(); public static void Prefix(RegisterSpawnedChunkObjectsSystem __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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) //IL_0014: 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_001c: 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_002a: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) EntityQuery chunkPortalQuery = __instance._ChunkPortalQuery; NativeArray val = ((EntityQuery)(ref chunkPortalQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); Enumerator enumerator = val.GetEnumerator(); FixedList512Bytes item = default(FixedList512Bytes); while (enumerator.MoveNext()) { Entity current = enumerator.Current; ChunkPortal val2 = current.Read(); if (!data.TryGetValue(val2.FromChunk, out (FixedList512Bytes, List<(int, ChunkPortalData)>) value)) { value = default((FixedList512Bytes, List<(int, ChunkPortalData)>)); if (Core.ChunkObjectManager._ChunkPortals.TryGetValue(val2.FromChunk, ref item)) { value.Item1 = item; } value.Item2 = new List<(int, ChunkPortalData)>(); data.Add(val2.FromChunk, value); } value.Item2.Add((val2.FromChunkPortalIndex, new ChunkPortalData { PortalEntity = current, PortalPosition = current.Read().Value, PortalRotation = current.Read().Value, InPositionOffset = val2.InPositionOffset, ToChunk = val2.ToChunk, ToChunkPortalIndex = val2.ToChunkPortalIndex })); val2.FromChunkPortalIndex = 0; current.Write(val2); } val.Dispose(); } public static void Postfix(RegisterSpawnedChunkObjectsSystem __instance) { //IL_0025: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair, List<(int, ChunkPortalData)>)> datum in data) { datum.Deconstruct(out var key, out var value); (FixedList512Bytes, List<(int, ChunkPortalData)>) tuple = value; TerrainChunk val = key; FixedList512Bytes item = tuple.Item1; List<(int, ChunkPortalData)> item2 = tuple.Item2; FixedList512Bytes val2 = item; int num = item2.Select(((int, ChunkPortalData) x) => x.Item1).Max(); if (num >= val2.Length) { val2.length = (ushort)(num + 1); } foreach (var (num2, val3) in item2) { if (val3.PortalEntity.Has()) { val2[num2] = val3; ChunkPortal componentData = val3.PortalEntity.Read(); componentData.FromChunkPortalIndex = num2; val3.PortalEntity.Write(componentData); } } Core.ChunkObjectManager._ChunkPortals.Remove(val); Core.ChunkObjectManager._ChunkPortals.Add(val, val2); } } } [HarmonyPatch(typeof(TeleportationRequestSystem), "OnUpdate")] internal static class TeleportationRequestSystemPatch { public static void Prefix(TeleportationRequestSystem __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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) //IL_0014: 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_001c: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) EntityQuery teleportRequestQuery = __instance._TeleportRequestQuery; NativeArray val = ((EntityQuery)(ref teleportRequestQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); Enumerator enumerator = val.GetEnumerator(); bool flag = default(bool); while (enumerator.MoveNext()) { TeleportationRequest val2 = enumerator.Current.Read(); ManualLogSource log = Core.Log; BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(12, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Request "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(val2.PlayerEntity); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(val2.TeleportationType); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(val2.FromTarget); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(val2.ToTarget); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(val2.EnableCheatChecks); } log.LogDebug(val3); } val.Dispose(); } } } namespace FatedGates.Commands { [CommandGroup("mapicon", "mi")] internal class MapIconCommands { [Command("create", "c", null, "Creates a map icon at the player's location.", null, true)] public static void CreateMapIcon(ChatCommandContext ctx, FoundMapIcon foundMapIcon) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) Core.MapIconService.CreateMapIcon(ctx.Event.SenderCharacterEntity, foundMapIcon.Value); ctx.Reply("Map icon created"); } [Command("destroy", "d", null, "Destroys a map icon you're standing on", null, true)] public static void DestroyMapIcon(ChatCommandContext ctx) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (Core.MapIconService.RemoveMapIcon(ctx.Event.SenderCharacterEntity)) { ctx.Reply("Destroyed map icon"); } else { ctx.Reply("Not standing on a map icon"); } } [Command("list", "l", null, "Lists all map icon prefabs with text", null, true)] public static void ListMapIcons(ChatCommandContext ctx) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Map Icons:"); Entity entity = default(Entity); foreach (var (text, val) in FoundMapIconConverter.MapIconNames) { if (text.StartsWith("MapIcon_") && Core.PrefabCollection._PrefabGuidToEntityMap.TryGetValue(val, ref entity) && entity.Has()) { string text2 = text; int length = "MapIcon_".Length; string text3 = text2.Substring(length, text2.Length - length); string text4 = "" + text3 + " - "; MapIconData val2 = entity.Read(); if (!((LocalizationKey)(ref val2.HeaderLocalizedKey)).IsEmpty) { string text5 = text4; LocalizationService localizationService = Core.LocalizationService; AssetGuid guid = ((LocalizationKey)(ref val2.HeaderLocalizedKey)).GetGuid(); Guid val3 = ((AssetGuid)(ref guid)).ToGuid(); text4 = text5 + "" + localizationService.GetLocalization(((object)(Guid)(ref val3)).ToString()) + ""; } else { text4 += "No Label"; } if (stringBuilder.Length + text4.Length > 500) { ctx.Reply("\n" + stringBuilder.ToString()); stringBuilder.Clear(); } stringBuilder.AppendLine(text4); } } ctx.Reply("\n" + stringBuilder.ToString()); } } [CommandGroup("portal", "port")] internal static class PortalCommands { private static readonly PrefabGUID defaultMapIcon = PrefabGUID.Empty; private static Dictionary startPortalLocations = new Dictionary(); [Command("start", "s", null, "Starts creating a portal at the player's location. Needs a second location for the other end", null, true)] public static void StartPortal(ChatCommandContext ctx, FoundMapIcon icon = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (Core.PortalService.StartPortal(ctx.Event.SenderCharacterEntity, icon?.Value ?? defaultMapIcon)) { ctx.Reply("Portal connection started"); } else { ctx.Reply("Can't start a portal connection as this chunk already has 9 portals"); } } [Command("end", "e", null, "Connects the location started creating a portal.", null, true)] public static void EndPortal(ChatCommandContext ctx, FoundMapIcon icon = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) string text = Core.PortalService.EndPortal(ctx.Event.SenderCharacterEntity, icon?.Value ?? defaultMapIcon); if (text == null) { ctx.Reply("Portal connection has been created!"); } else { ctx.Reply("Failed to create portal connection because " + text); } } [Command("teleportclosest", "tc", null, "Teleports the player to the closest spawned portal.", null, true)] public static void TeleportToClosestPortal(ChatCommandContext ctx) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (Core.PortalService.TeleportToClosestPortal(ctx.Event.SenderCharacterEntity)) { ctx.Reply("Teleported to closest spawned portal"); } else { ctx.Reply("No spawned portals to teleport to"); } } [Command("destroy", "d", null, "Destroys a spawned portal you're standing near", null, true)] public static void DestroyPortal(ChatCommandContext ctx) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (Core.PortalService.DestroyPortal(ctx.Event.SenderCharacterEntity)) { ctx.Reply("Destroyed portal and connection. Reconnect to no longer see them."); } else { ctx.Reply("Not standing near a spawned portal"); } } } [CommandGroup("reveal", "rv")] internal class RevealCommands { [Command("zone", "z", null, "Adds a persistent public reveal zone by map bitmap coordinates.", null, true)] public static void AddRevealZone(ChatCommandContext ctx, int x, int y, int radius = 1) { Core.RevealService.AddPublicRevealZone(x, y, radius, $"Reveal Zone {x},{y}"); ctx.Reply($"Added public reveal zone at ({x}, {y}) radius {radius} and applied it to connected users."); } [Command("pos", "p", null, "Shows your world position and reveal bitmap position.", null, true)] public static void PrintPosition(ChatCommandContext ctx) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) float3 value = ctx.Event.SenderCharacterEntity.Read().Value; var (num, num2) = Core.RevealService.WorldPositionToRevealBitmap(value); ctx.Reply($"World position: X={value.x:F2}, Y={value.y:F2}, Z={value.z:F2}\nReveal bitmap position: X={num}, Y={num2}\nUse: \".rv zone {num} {num2} 1\" to reveal here with a radius of 1 unit\n" + "Or simply use \".rv here 1\" to reveal at current player location with a radius of 1"); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(53, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Position for "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ctx.Event.User.CharacterName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("World X="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value.x, "F4"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Y="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value.y, "F4"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Z="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value.z, "F4"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Reveal bitmap X="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Y="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num2); } log.LogInfo(val); } [Command("here", "h", null, "Adds a persistent public reveal zone centered on your current position.", null, true)] public static void AddRevealZoneHere(ChatCommandContext ctx, int radius = 1) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) float3 value = ctx.Event.SenderCharacterEntity.Read().Value; var (num, num2) = Core.RevealService.WorldPositionToRevealBitmap(value); Core.RevealService.AddPublicRevealZone(num, num2, radius, $"Reveal Zone {num},{num2}"); ctx.Reply($"Added public reveal zone at your position: bitmap ({num}, {num2}) radius {radius}."); } [Command("closest", "c", null, "Adds a persistent public reveal zone centered on the closest spawned waygate.", null, true)] public static void AddRevealZoneAtClosestWaygate(ChatCommandContext ctx, int radius = 1) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (Core.RevealService.AddRevealZoneAtClosestWaygate(ctx.Event.SenderCharacterEntity, radius)) { ctx.Reply($"Added public reveal zone at closest waygate with radius {radius}."); } else { ctx.Reply("Could not add reveal zone at closest waygate. Check BepInEx/LogOutput.log for details."); } } [Command("list", "l", null, "Lists saved public reveal zones.", null, true)] public static void ListRevealZones(ChatCommandContext ctx) { ctx.Reply(Core.RevealService.GetPublicRevealZoneListText()); } [Command("remove", "r", null, "Removes a saved public reveal zone by index, or the closest one if no index is provided.", null, true)] public static void RemoveRevealZone(ChatCommandContext ctx, int index = 0) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) Core.RevealService.RemovePublicRevealZone(ctx.Event.SenderCharacterEntity, index, out var message); ctx.Reply(message); } } [CommandGroup("waygate", "wg")] internal class WaygateCommands { private static readonly PrefabGUID defaultWaygate = new PrefabGUID(2107199037); [Command("create", "c", null, "Creates a discoverable waygate at the player's location.", null, true)] public static void CreateWaygate(ChatCommandContext ctx, FoundWaygatePrefab foundWaygatePrefab = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!Core.WaygateService.CreateWaygate(ctx.Event.SenderCharacterEntity, foundWaygatePrefab?.Value ?? defaultWaygate)) { ctx.Reply("Current chunk already has a waygate"); } else { ctx.Reply("Discoverable waygate created"); } } [Command("createpublic", "cp", null, "Creates a waygate and unlocks it for all connected users and future connecting users.", null, true)] public static void CreateUnlockedWaygate(ChatCommandContext ctx, string waygateName = "Public Waygate", FoundWaygatePrefab foundWaygatePrefab = null) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!Core.WaygateService.CreateWaygate(ctx.Event.SenderCharacterEntity, foundWaygatePrefab?.Value ?? defaultWaygate, autoUnlockForAllConnectedUsers: true, waygateName)) { ctx.Reply("Current chunk already has a waygate"); } else { ctx.Reply("Auto-unlocked waygate created and unlocked for all connected users"); } } [Command("teleportclosest", "tpc", null, "Teleports the player to the closest spawned waygate.", null, true)] public static void TeleportToClosestWaygate(ChatCommandContext ctx) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (Core.WaygateService.TeleportToClosestWaygate(ctx.Event.SenderCharacterEntity)) { ctx.Reply("Teleported to closest spawned waygate"); } else { ctx.Reply("No spawned waygate to teleport to"); } } [Command("destroy", "d", null, "Destroys the closest spawned waygate, or a saved public waygate by index.", null, true)] public static void DestroyWaygate(ChatCommandContext ctx, int publicWaygateIndex = 0) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (Core.WaygateService.DestroyWaygate(ctx.Event.SenderCharacterEntity, publicWaygateIndex)) { ctx.Reply((publicWaygateIndex > 0) ? $"Destroyed public waygate #{publicWaygateIndex}." : "Destroyed closest spawned waygate."); } else { ctx.Reply((publicWaygateIndex > 0) ? $"Could not destroy public waygate #{publicWaygateIndex}. Use .waygate listpublic to check indexes." : "Not standing near a spawned waygate."); } } [Command("listpublic", "lp", null, "Lists saved public waygates.", null, true)] public static void ListPublicWaygates(ChatCommandContext ctx) { ctx.Reply(Core.WaygateService.GetPublicWaygateListText()); } } } namespace FatedGates.Commands.Converters { public record FoundMapIcon(PrefabGUID Value) { [CompilerGenerated] protected virtual bool PrintMembers(StringBuilder builder) { //IL_0013: 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) RuntimeHelpers.EnsureSufficientExecutionStack(); builder.Append("Value = "); PrefabGUID value = Value; builder.Append(((object)(PrefabGUID)(ref value)).ToString()); return true; } } internal class FoundMapIconConverter : CommandArgumentConverter { private static Dictionary _mapIconNameToGuid = new Dictionary(StringComparer.OrdinalIgnoreCase); private static string[] excludedMapIcons = new string[16] { "CastleWaypoint_Active", "CharmedUnit", "DeathContainer", "LocalPlayer", "Mount", "Player", "PlayerCustomMarker", "PlayerCustomMarkerPathfindDot", "PlayerPathDot", "POI_Spawn_CoffinSelect", "POI_Spawn_CryptSelect", "POI_Spawn_WaypointSelect", "RecommendedTerritoryIcon", "StartGraveyardExit", "StoneCoffin", "WoodenCoffin" }; private static bool initialized = false; public static IEnumerable<(string, PrefabGUID)> MapIconNames => GetIconNames(); public static void Initialize() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_002d: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) Enumerator enumerator = Core.PrefabCollection._PrefabGuidToEntityMap.GetEnumerator(); Entity entity = default(Entity); while (enumerator.MoveNext()) { PrefabGUID key = enumerator.Current.Key; NativeParallelHashMap guidToEntityMap = Core.PrefabCollection._PrefabLookupMap.GuidToEntityMap; if (!guidToEntityMap.TryGetValue(key, ref entity)) { continue; } PrefabLookupMap prefabLookupMap = Core.PrefabCollection._PrefabLookupMap; string name = ((PrefabLookupMap)(ref prefabLookupMap)).GetName(key); if (name.StartsWith("MapIcon_")) { string[] source = excludedMapIcons; string text = name; if (!source.Contains(text.Substring(8, text.Length - 8)) && entity.Has()) { _mapIconNameToGuid[name] = key; } } } initialized = true; } private static IEnumerable<(string, PrefabGUID)> GetIconNames() { if (!initialized) { Initialize(); } return from x in _mapIconNameToGuid select (x.Key, x.Value) into x orderby x.Key select x; } public override FoundMapIcon Parse(ICommandContext ctx, string input) { //IL_0030: 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_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) if (!initialized) { Initialize(); } if (int.TryParse(input, out var result)) { PrefabLookupMap prefabLookupMap = Core.PrefabCollection._PrefabLookupMap; string text = default(string); if (!((PrefabLookupMap)(ref prefabLookupMap)).TryGetName(new PrefabGUID(result), ref text)) { throw ctx.Error("Invalid prefabGUID: " + input); } if (!text.StartsWith("MapIcon_")) { throw ctx.Error($"PrefabGUID({input}) is {text} not a MapIcon"); } string[] source = excludedMapIcons; string text2 = text; if (source.Contains(text2.Substring(8, text2.Length - 8))) { throw ctx.Error($"PrefabGUID({input}) is {text} not a Valid Visible MapIcon"); } return new FoundMapIcon(new PrefabGUID(result)); } if (_mapIconNameToGuid.TryGetValue(input, out var value)) { return new FoundMapIcon(value); } if (_mapIconNameToGuid.TryGetValue("MapIcon_" + input, out value)) { return new FoundMapIcon(value); } List> list = _mapIconNameToGuid.Where((KeyValuePair x) => x.Key.Contains(input, StringComparison.OrdinalIgnoreCase)).ToList(); if (list.Count == 1) { return new FoundMapIcon(list[0].Value); } throw ctx.Error("Multiple results be more specific\n" + string.Join("\n", list.Select((KeyValuePair x) => x.Key))); } } public record FoundWaygatePrefab(PrefabGUID Value) { [CompilerGenerated] protected virtual bool PrintMembers(StringBuilder builder) { //IL_0013: 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) RuntimeHelpers.EnsureSufficientExecutionStack(); builder.Append("Value = "); PrefabGUID value = Value; builder.Append(((object)(PrefabGUID)(ref value)).ToString()); return true; } } internal class FoundWaygatePrefabConverter : CommandArgumentConverter { private static Dictionary _waygateToGuid = new Dictionary(StringComparer.OrdinalIgnoreCase); public static void Initialize() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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) //IL_0012: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_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_0052: Unknown result type (might be due to invalid IL or missing references) NativeParallelHashMap guidToEntityMap = Core.PrefabCollection._PrefabLookupMap.GuidToEntityMap; Enumerator enumerator = guidToEntityMap.GetEnumerator(); while (enumerator.MoveNext()) { KeyValue current = enumerator.Current; PrefabLookupMap prefabLookupMap = Core.PrefabCollection._PrefabLookupMap; string name = ((PrefabLookupMap)(ref prefabLookupMap)).GetName(current.Key); if (name.StartsWith("TM_Workstation_Waypoint_World")) { _waygateToGuid[name] = current.Key; } } } public override FoundWaygatePrefab Parse(ICommandContext ctx, string input) { //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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) if (int.TryParse(input, out var result)) { PrefabLookupMap prefabLookupMap = Core.PrefabCollection._PrefabLookupMap; string text = default(string); if (!((PrefabLookupMap)(ref prefabLookupMap)).TryGetName(new PrefabGUID(result), ref text)) { throw ctx.Error("Invalid prefabGUID: " + input); } if (!text.StartsWith("TM_Workstation_Waypoint_World")) { throw ctx.Error($"PrefabGUID({input}) is {text} not a world waypoint"); } return new FoundWaygatePrefab(new PrefabGUID(result)); } if (input == "" && _waygateToGuid.TryGetValue("TM_Workstation_Waypoint_World", out var value)) { return new FoundWaygatePrefab(value); } if (_waygateToGuid.TryGetValue(input, out value)) { return new FoundWaygatePrefab(value); } if (_waygateToGuid.TryGetValue("TM_Workstation_Waypoint_World_" + input, out value)) { return new FoundWaygatePrefab(value); } List> list = _waygateToGuid.Where((KeyValuePair x) => x.Key.Contains(input, StringComparison.OrdinalIgnoreCase)).ToList(); if (list.Count == 1) { return new FoundWaygatePrefab(list[0].Value); } throw ctx.Error("Multiple results be more specific\n" + string.Join("\n", list.Select((KeyValuePair x) => x.Key))); } } }