Decompiled source of KindredPortals v1.0.1

KindredPortals.dll

Decompiled 3 days ago
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 HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using KindredPortals.Commands.Converters;
using KindredPortals.Services;
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 Unity.Collections;
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("KindredPortals")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Expand your V Rising fast travel options.")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+1.Branch.main.Sha.c33d0879382e1a0da34861ec55914ba7e637a80e.138941b6bc3ffd6e4943e2b9391267690dde2309")]
[assembly: AssemblyProduct("KindredPortals")]
[assembly: AssemblyTitle("KindredPortals")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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 KindredPortals
{
	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<ChunkObjectManager>();


		public static PrefabCollectionSystem PrefabCollection { get; } = Server.GetExistingSystemManaged<PrefabCollectionSystem>();


		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 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<string>(caller);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\nMessage: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.Message);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Inner:");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.InnerException?.Message);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\n\nStack: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.StackTrace);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\nInner Stack: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.InnerException?.StackTrace);
			}
			log.LogError(val);
		}

		internal static void InitializeAfterLoaded()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			if (!_hasInitialized)
			{
				ServerGameSettingsSystem = Server.GetExistingSystemManaged<ServerGameSettingsSystem>();
				ServerScriptMapper = Server.GetExistingSystemManaged<ServerScriptMapper>();
				FoundMapIconConverter.Initialize();
				FoundWaygatePrefabConverter.Initialize();
				MapIconService = new MapIconService();
				WaygateService = new WaygateService();
				_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<World> 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<IgnorePhysicsDebugSystem>();
				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<T>(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<T>(), (AccessMode)0);
			byte[] array = StructureToByteArray(componentData);
			int num = Marshal.SizeOf<T>();
			fixed (byte* ptr = array)
			{
				EntityManager entityManager = EntityManager;
				((EntityManager)(ref entityManager)).SetComponentDataRaw(entity, val.TypeIndex, (void*)ptr, num);
			}
		}

		private static byte[] StructureToByteArray<T>(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<T>(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<T>(), (AccessMode)0);
			EntityManager entityManager = EntityManager;
			return Marshal.PtrToStructure<T>(new IntPtr(((EntityManager)(ref entityManager)).GetComponentDataRawRO(entity, val.TypeIndex)));
		}

		public static DynamicBuffer<T> ReadBuffer<T>(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<T>(entity, false);
		}

		public static bool Has<T>(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<T>(), (AccessMode)0);
			EntityManager entityManager = EntityManager;
			return ((EntityManager)(ref entityManager)).HasComponent(entity, val);
		}

		public static string LookupName(this PrefabGUID prefabGuid)
		{
			//IL_0011: 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_0031: 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)
			PrefabCollectionSystem existingSystemManaged = Core.Server.GetExistingSystemManaged<PrefabCollectionSystem>();
			object obj;
			if (!existingSystemManaged.PrefabGuidToNameDictionary.ContainsKey(prefabGuid))
			{
				obj = "GUID Not Found";
			}
			else
			{
				string text = existingSystemManaged.PrefabGuidToNameDictionary[prefabGuid];
				PrefabGUID val = prefabGuid;
				obj = text + " " + ((object)(PrefabGUID)(ref val)).ToString();
			}
			return obj.ToString();
		}

		public static void Add<T>(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<T>(), (AccessMode)0);
			EntityManager entityManager = EntityManager;
			((EntityManager)(ref entityManager)).AddComponent(entity, val);
		}

		public static void Remove<T>(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<T>(), (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<Translation>().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("KindredPortals", "KindredPortals", "1.0.1")]
	[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<string>("KindredPortals");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.1");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val);
			LogInstance = ((BasePlugin)this).Log;
			_harmony = new Harmony("KindredPortals");
			_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 = "KindredPortals";

		public const string PLUGIN_NAME = "KindredPortals";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace KindredPortals.Services
{
	internal class LocalizationService
	{
		private struct Code
		{
			public string Key { get; set; }

			public string Value { get; set; }

			public string Description { get; set; }
		}

		private struct Node
		{
			public string Guid { get; set; }

			public string Text { get; set; }
		}

		private struct LocalizationFile
		{
			public Code[] Codes { get; set; }

			public Node[] Nodes { get; set; }
		}

		private Dictionary<string, string> localization = new Dictionary<string, string>();

		public LocalizationService()
		{
			LoadLocalization();
		}

		private void LoadLocalization()
		{
			string name = "KindredPortals.Localization.English.json";
			Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(name);
			if (manifestResourceStream != null)
			{
				using (StreamReader streamReader = new StreamReader(manifestResourceStream))
				{
					localization = JsonSerializer.Deserialize<LocalizationFile>(streamReader.ReadToEnd()).Nodes.ToDictionary((Node x) => x.Guid, (Node x) => x.Text);
					return;
				}
			}
			Console.WriteLine("Resource not found!");
		}

		public string GetLocalization(string guid)
		{
			if (localization.TryGetValue(guid, out var value))
			{
				return value;
			}
			return "<Localization not found!>";
		}
	}
	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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//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_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)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: 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)
			if (!Core.PrefabCollection._NameToPrefabGuidDictionary.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");
			}
			EntityManager entityManager = Core.EntityManager;
			EntityQueryDesc[] array = new EntityQueryDesc[1];
			EntityQueryDesc val = new EntityQueryDesc();
			val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[2]
			{
				ComponentType.ReadOnly<AttachMapIconsToEntity>(),
				ComponentType.ReadOnly<SpawnedBy>()
			});
			val.None = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[2]
			{
				ComponentType.ReadOnly<ChunkPortal>(),
				ComponentType.ReadOnly<ChunkWaypoint>()
			});
			val.Options = (EntityQueryOptions)2;
			array[0] = val;
			mapIconProxyQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)array);
		}

		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<Translation>().Value;
			EntityManager entityManager = Core.EntityManager;
			Entity val = ((EntityManager)(ref entityManager)).Instantiate(mapIconProxyPrefab);
			val.Write<Translation>(new Translation
			{
				Value = value
			});
			val.Add<SpawnedBy>();
			val.Write<SpawnedBy>(new SpawnedBy
			{
				Value = characterEntity
			});
			val.Remove<SyncToUserBitMask>();
			val.Remove<SyncToUserBuffer>();
			val.Remove<OnlySyncToUsersTag>();
			entityManager = Core.EntityManager;
			DynamicBuffer<AttachMapIconsToEntity> buffer = ((EntityManager)(ref entityManager)).GetBuffer<AttachMapIconsToEntity>(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<Translation>().Value;
			NativeArray<Entity> val = ((EntityQuery)(ref mapIconProxyQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			Entity val2 = ((IEnumerable<Entity>)(from x in ((IEnumerable<Entity>)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>())
					{
						PrefabGUID val3 = x.Read<PrefabGUID>();
						return ((PrefabGUID)(ref val3)).Equals(mapIconProxyPrefabGUID);
					}
					return false;
				})
				orderby math.distance(pos, x.Read<Translation>().Value)
				select x)).FirstOrDefault((Func<Entity, bool>)((Entity x) => math.distance(pos, x.Read<Translation>().Value) < 5f));
			val.Dispose();
			if (val2 == Entity.Null)
			{
				return false;
			}
			EntityManager entityManager;
			if (val2.Has<AttachedBuffer>())
			{
				entityManager = Core.EntityManager;
				DynamicBuffer<AttachedBuffer> buffer = ((EntityManager)(ref entityManager)).GetBuffer<AttachedBuffer>(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<Entity> val = ((EntityQuery)(ref _query_1050583545_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			Enumerator<Entity> enumerator = val.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				if (current.Has<Attach>())
				{
					Entity parent = current.Read<Attach>().Parent;
					if (!((Entity)(ref parent)).Equals(Entity.Null) && parent.Has<SpawnedBy>())
					{
						MapIconData componentData = current.Read<MapIconData>();
						componentData.RequiresReveal = false;
						componentData.AllySetting = (MapIconShowSettings)2;
						componentData.EnemySetting = (MapIconShowSettings)2;
						current.Write<MapIconData>(componentData);
					}
				}
			}
			val.Dispose();
		}
	}
	internal class PortalService
	{
		private Entity portalPrefab;

		private EntityQuery spawnedPortalQuery;

		private Dictionary<Entity, (float3 pos, quaternion rot, TerrainChunk chunk, int index, PrefabGUID mapIcon)> portalStartPos = new Dictionary<Entity, (float3, quaternion, TerrainChunk, int, PrefabGUID)>();

		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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//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_0093: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			PrefabGUID val = default(PrefabGUID);
			if (!Core.PrefabCollection._NameToPrefabGuidDictionary.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");
			}
			EntityManager entityManager = Core.EntityManager;
			EntityQueryDesc[] array = new EntityQueryDesc[1];
			EntityQueryDesc val2 = new EntityQueryDesc();
			val2.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[2]
			{
				ComponentType.ReadOnly<ChunkPortal>(),
				ComponentType.ReadOnly<SpawnedBy>()
			});
			val2.Options = (EntityQueryOptions)2;
			array[0] = val2;
			spawnedPortalQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)array);
		}

		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<Translation>().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<Rotation>().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<Translation>().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<Rotation>().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<TerrainChunk>(value.Item3);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(value.Item4);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" End: ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<TerrainChunk>(val2);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(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<Translation>(new Translation
			{
				Value = pos
			});
			val.Write<Rotation>(new Rotation
			{
				Value = rot
			});
			val.Add<SpawnedBy>();
			val.Write<SpawnedBy>(new SpawnedBy
			{
				Value = creator
			});
			entityManager = Core.EntityManager;
			DynamicBuffer<AttachMapIconsToEntity> buffer = ((EntityManager)(ref entityManager)).GetBuffer<AttachMapIconsToEntity>(val, false);
			buffer.Clear();
			if (!((PrefabGUID)(ref mapIcon)).Equals(PrefabGUID.Empty))
			{
				buffer.Add(new AttachMapIconsToEntity
				{
					Prefab = mapIcon
				});
			}
			val.Write<ChunkPortal>(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<ChunkPortalData> val = default(FixedList512Bytes<ChunkPortalData>);
			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_0047: 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_0056: 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_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_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_006f: 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_007a: 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_0087: 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_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_009f: 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)
			//IL_00aa: 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)
			NativeArray<Entity> val = ((EntityQuery)(ref spawnedPortalQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			float3 pos = playerEntity.Read<Translation>().Value;
			Entity val2 = ((IEnumerable<Entity>)val.ToArray()).OrderBy((Entity x) => math.distance(pos, x.Read<Translation>().Value)).FirstOrDefault();
			if (val2 == Entity.Null)
			{
				return false;
			}
			float3 value = val2.Read<Translation>().Value;
			quaternion value2 = val2.Read<Rotation>().Value;
			playerEntity.Write<Translation>(new Translation
			{
				Value = value
			});
			playerEntity.Write<LastTranslation>(new LastTranslation
			{
				Value = value
			});
			playerEntity.Write<Rotation>(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<ChunkPortalData> val = default(FixedList512Bytes<ChunkPortalData>);
			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<ChunkPortalData> val = default(FixedList512Bytes<ChunkPortalData>);
			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<Translation>().Value;
			NativeArray<Entity> val = ((EntityQuery)(ref spawnedPortalQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			Entity val2 = ((IEnumerable<Entity>)((IEnumerable<Entity>)val.ToArray()).OrderBy((Entity x) => math.distance(pos, x.Read<Translation>().Value))).FirstOrDefault((Func<Entity, bool>)((Entity x) => math.distance(pos, x.Read<Translation>().Value) < 5f));
			val.Dispose();
			if (val2 == Entity.Null)
			{
				return false;
			}
			ChunkPortal chunkPortal = val2.Read<ChunkPortal>();
			Entity connectedPortal = GetConnectedPortal(chunkPortal);
			RemovePortalEntry(chunkPortal);
			EntityManager entityManager;
			if (val2.Has<AttachedBuffer>())
			{
				entityManager = Core.EntityManager;
				DynamicBuffer<AttachedBuffer> buffer = ((EntityManager)(ref entityManager)).GetBuffer<AttachedBuffer>(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<ChunkPortal>());
				if (connectedPortal.Has<AttachedBuffer>())
				{
					entityManager = Core.EntityManager;
					DynamicBuffer<AttachedBuffer> buffer2 = ((EntityManager)(ref entityManager)).GetBuffer<AttachedBuffer>(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 WaygateService
	{
		private const float UnlockDistance = 25f;

		private readonly EntityQuery connectedUserQuery;

		private readonly EntityQuery waypointQuery;

		private readonly List<Entity> spawnedWaygates = new List<Entity>();

		private readonly Dictionary<Entity, List<Entity>> unlockedSpawnedWaypoints = new Dictionary<Entity, List<Entity>>();

		public WaygateService()
		{
			//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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//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_0064: 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_006d: 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_007f: 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_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_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_00c1: 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_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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_00f2: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: 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_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: 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_013f: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = Core.EntityManager;
			EntityQueryDesc[] array = new EntityQueryDesc[1];
			EntityQueryDesc val = new EntityQueryDesc();
			val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[2]
			{
				ComponentType.ReadOnly<SpawnedBy>(),
				ComponentType.ReadOnly<ChunkWaypoint>()
			});
			val.Options = (EntityQueryOptions)2;
			array[0] = val;
			EntityQuery val2 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)array);
			NativeArray<Entity> val3 = ((EntityQuery)(ref val2)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			Enumerator<Entity> enumerator = val3.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				spawnedWaygates.Add(current);
			}
			val3.Dispose();
			((EntityQuery)(ref val2)).Dispose();
			entityManager = Core.EntityManager;
			connectedUserQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[2]
			{
				ComponentType.ReadOnly<IsConnected>(),
				ComponentType.ReadOnly<User>()
			});
			val3 = ((EntityQuery)(ref connectedUserQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			enumerator = val3.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Entity current2 = enumerator.Current;
				InitializeUnlockedWaypoints(current2);
			}
			val3.Dispose();
			entityManager = Core.EntityManager;
			waypointQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<ChunkWaypoint>() });
			Core.StartCoroutine(CheckForWaypointUnlocks());
		}

		private void InitializeUnlockedWaypoints(Entity userEntity)
		{
			//IL_0006: 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_0016: 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_001b: 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_0028: 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_0067: 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_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_00b2: 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_00c7: 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_00d8: 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_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_00ec: Unknown result type (might be due to invalid IL or missing references)
			unlockedSpawnedWaypoints.Add(userEntity, new List<Entity>());
			EntityManager entityManager = Core.EntityManager;
			DynamicBuffer<UnlockedWaypointElement> buffer = ((EntityManager)(ref entityManager)).GetBuffer<UnlockedWaypointElement>(userEntity, false);
			Enumerator<UnlockedWaypointElement> enumerator = buffer.GetEnumerator();
			while (enumerator.MoveNext())
			{
				UnlockedWaypointElement waypoint = enumerator.Current;
				Entity[] array = spawnedWaygates.Where((Entity x) => x.Read<NetworkId>() == waypoint.Waypoint).ToArray();
				if (array.Length != 0)
				{
					unlockedSpawnedWaypoints[userEntity].Add(array[0]);
				}
			}
			if (!Core.ServerGameSettingsSystem.Settings.AllWaypointsUnlocked)
			{
				return;
			}
			foreach (Entity spawnedWaygate in spawnedWaygates)
			{
				if (!unlockedSpawnedWaypoints[userEntity].Contains(spawnedWaygate))
				{
					unlockedSpawnedWaypoints[userEntity].Add(spawnedWaygate);
					buffer.Add(new UnlockedWaypointElement
					{
						Waypoint = spawnedWaygate.Read<NetworkId>()
					});
				}
			}
		}

		public bool CreateWaygate(Entity character, PrefabGUID waypointPrefabGUID)
		{
			//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_0142: 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<string>(waypointPrefabGUID.LookupName());
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" Prefab entity");
				}
				log.LogError(val2);
				return false;
			}
			float3 value = character.Read<Translation>().Value;
			TerrainChunk chunk = value.GetChunk();
			EntityQuery val3 = waypointQuery;
			NativeArray<Entity> val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			try
			{
				Enumerator<Entity> enumerator = val4.GetEnumerator();
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					if (!current.Has<CastleWorkstation>() && current.GetChunk() == chunk)
					{
						return false;
					}
				}
			}
			finally
			{
				val4.Dispose();
			}
			quaternion value2 = character.Read<Rotation>().Value;
			EntityManager entityManager = Core.EntityManager;
			Entity val5 = ((EntityManager)(ref entityManager)).Instantiate(val);
			val5.Write<Translation>(new Translation
			{
				Value = value
			});
			val5.Write<Rotation>(new Rotation
			{
				Value = value2
			});
			val5.Add<SpawnedBy>();
			val5.Write<SpawnedBy>(new SpawnedBy
			{
				Value = character
			});
			spawnedWaygates.Add(val5);
			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_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_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_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_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_004f: 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_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_005e: 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_006c: 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_0076: 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_007f: 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_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_0096: 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)
			float3 pos = character.Read<Translation>().Value;
			Entity val = spawnedWaygates.OrderBy((Entity x) => math.distance(pos, x.Read<Translation>().Value)).FirstOrDefault();
			if (val == Entity.Null)
			{
				return false;
			}
			float3 value = val.Read<Translation>().Value;
			quaternion value2 = val.Read<Rotation>().Value;
			character.Write<Translation>(new Translation
			{
				Value = value
			});
			character.Write<LastTranslation>(new LastTranslation
			{
				Value = value
			});
			character.Write<Rotation>(new Rotation
			{
				Value = value2
			});
			return true;
		}

		public void UnlockWaypoint(Entity userEntity, Entity waypoint)
		{
			//IL_0006: 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_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_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_002d: 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_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_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_0011: 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_0062: 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_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_0075: Unknown result type (might be due to invalid IL or missing references)
			if (!unlockedSpawnedWaypoints.TryGetValue(userEntity, out var value))
			{
				InitializeUnlockedWaypoints(userEntity);
			}
			value.Add(waypoint);
			EntityManager entityManager = Core.EntityManager;
			DynamicBuffer<UnlockedWaypointElement> buffer = ((EntityManager)(ref entityManager)).GetBuffer<UnlockedWaypointElement>(userEntity, false);
			NetworkId val = waypoint.Read<NetworkId>();
			Enumerator<UnlockedWaypointElement> enumerator = buffer.GetEnumerator();
			while (enumerator.MoveNext())
			{
				if (enumerator.Current.Waypoint == val)
				{
					return;
				}
			}
			buffer.Add(new UnlockedWaypointElement
			{
				Waypoint = waypoint.Read<NetworkId>()
			});
		}

		private IEnumerator CheckForWaypointUnlocks()
		{
			WaitForSeconds timeBetweenChecks = new WaitForSeconds(0.1f);
			while (true)
			{
				EntityQuery val = connectedUserQuery;
				Enumerator<Entity> enumerator = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator();
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					User val2 = current.Read<User>();
					Entity entityOnServer = ((NetworkedEntity)(ref val2.LocalCharacter)).GetEntityOnServer();
					if (entityOnServer == Entity.Null)
					{
						continue;
					}
					if (!unlockedSpawnedWaypoints.TryGetValue(current, out var _))
					{
						InitializeUnlockedWaypoints(current);
					}
					if (Core.ServerGameSettingsSystem.Settings.AllWaypointsUnlocked)
					{
						yield return timeBetweenChecks;
						continue;
					}
					float3 value2 = entityOnServer.Read<Translation>().Value;
					foreach (Entity spawnedWaygate in spawnedWaygates)
					{
						if (!unlockedSpawnedWaypoints[current].Contains(spawnedWaygate))
						{
							float3 value3 = spawnedWaygate.Read<Translation>().Value;
							if (math.distance(value2, value3) < 25f)
							{
								UnlockWaypoint(current, spawnedWaygate);
							}
						}
					}
				}
				yield return timeBetweenChecks;
			}
		}

		public bool DestroyWaygate(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_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_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_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_0063: Unknown result type (might be due to invalid IL or missing references)
			float3 pos = senderCharacterEntity.Read<Translation>().Value;
			Entity val = ((IEnumerable<Entity>)spawnedWaygates.OrderBy((Entity x) => math.distance(pos, x.Read<Translation>().Value))).FirstOrDefault((Func<Entity, bool>)((Entity x) => math.distance(pos, x.Read<Translation>().Value) < 10f));
			if (val == Entity.Null)
			{
				return false;
			}
			DestroyUtility.Destroy(Core.EntityManager, val, (DestroyDebugReason)0, (string)null, 0);
			spawnedWaygates.Remove(val);
			return true;
		}
	}
}
namespace KindredPortals.Patches
{
	[HarmonyPatch(typeof(SceneSystem), "ShutdownStreamingSupport")]
	public static class InitializationPatch
	{
		[HarmonyPostfix]
		public static void OneShot_AfterLoad_InitializationPatch()
		{
			Core.InitializeAfterLoaded();
			Plugin.Harmony.Unpatch((MethodBase)typeof(SceneSystem).GetMethod("ShutdownStreamingSupport"), typeof(InitializationPatch).GetMethod("OneShot_AfterLoad_InitializationPatch"));
		}
	}
	[HarmonyPatch(typeof(RegisterSpawnedChunkObjectsSystem<LoadedTag>), "OnUpdate")]
	internal class RegisterSpawnedChunkObjectsSystem_PersistenceLoadPatch
	{
		private static Dictionary<Entity, ChunkPortal> entityChunkPortals = new Dictionary<Entity, ChunkPortal>();

		public static void Prefix()
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//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_003c: 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_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_004f: 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_0057: 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_0062: 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_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_0072: 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_0083: 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)
			EntityManager entityManager = Core.EntityManager;
			EntityQueryDesc[] array = new EntityQueryDesc[1];
			EntityQueryDesc val = new EntityQueryDesc();
			val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<ChunkPortal>() });
			val.Options = (EntityQueryOptions)2;
			array[0] = val;
			EntityQuery val2 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)array);
			NativeArray<Entity> val3 = ((EntityQuery)(ref val2)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			Enumerator<Entity> enumerator = val3.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				ChunkPortal val4 = current.Read<ChunkPortal>();
				entityChunkPortals.Add(current, val4);
				val4.FromChunkPortalIndex = 0;
				current.Write<ChunkPortal>(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<ChunkPortalData> val5 = default(FixedList512Bytes<ChunkPortalData>);
			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<TerrainChunk>(val4.FromChunk);
					}
					log.LogError(val6);
					continue;
				}
				val3.Write<ChunkPortal>(val4);
				ChunkPortalData val7 = default(ChunkPortalData);
				val7.PortalEntity = val3;
				val7.PortalPosition = val3.Read<Translation>().Value;
				val7.PortalRotation = val3.Read<Rotation>().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<SpawnTag>), "OnUpdate")]
	internal static class RegisterSpawnedChunkObjectsSystem_ReactToSpawnPatch
	{
		private static Dictionary<TerrainChunk, (FixedList512Bytes<ChunkPortalData> initialList, List<(int, ChunkPortalData)> additions)> data = new Dictionary<TerrainChunk, (FixedList512Bytes<ChunkPortalData>, List<(int, ChunkPortalData)>)>();

		public static void Prefix(RegisterSpawnedChunkObjectsSystem<SpawnTag> __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<Entity> val = ((EntityQuery)(ref chunkPortalQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
			Enumerator<Entity> enumerator = val.GetEnumerator();
			FixedList512Bytes<ChunkPortalData> item = default(FixedList512Bytes<ChunkPortalData>);
			while (enumerator.MoveNext())
			{
				Entity current = enumerator.Current;
				ChunkPortal val2 = current.Read<ChunkPortal>();
				if (!data.TryGetValue(val2.FromChunk, out (FixedList512Bytes<ChunkPortalData>, List<(int, ChunkPortalData)>) value))
				{
					value = default((FixedList512Bytes<ChunkPortalData>, 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<Translation>().Value,
					PortalRotation = current.Read<Rotation>().Value,
					InPositionOffset = val2.InPositionOffset,
					ToChunk = val2.ToChunk,
					ToChunkPortalIndex = val2.ToChunkPortalIndex
				}));
				val2.FromChunkPortalIndex = 0;
				current.Write<ChunkPortal>(val2);
			}
			val.Dispose();
		}

		public static void Postfix(RegisterSpawnedChunkObjectsSystem<SpawnTag> __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<TerrainChunk, (FixedList512Bytes<ChunkPortalData>, List<(int, ChunkPortalData)>)> datum in data)
			{
				datum.Deconstruct(out var key, out var value);
				(FixedList512Bytes<ChunkPortalData>, List<(int, ChunkPortalData)>) tuple = value;
				TerrainChunk val = key;
				FixedList512Bytes<ChunkPortalData> item = tuple.Item1;
				List<(int, ChunkPortalData)> item2 = tuple.Item2;
				FixedList512Bytes<ChunkPortalData> 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<ChunkPortal>())
					{
						val2[num2] = val3;
						ChunkPortal componentData = val3.PortalEntity.Read<ChunkPortal>();
						componentData.FromChunkPortalIndex = num2;
						val3.PortalEntity.Write<ChunkPortal>(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._TeleportRequest