Decompiled source of ArachNOPE v1.1.0

BepInEx\plugins\ArachNOPE.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using ArachNOPE.Helpers;
using ArachNOPE.Patches;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.Gameplay.Systems;
using ProjectM.Hybrid;
using Stunlock.Core;
using Unity.Collections;
using Unity.Entities;
using Unity.Physics;
using Unity.Physics.Systems;
using Unity.Transforms;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ArachNOPE")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+b76ec3426aee2f2d266017f7d334f6d6dde9e22c")]
[assembly: AssemblyProduct("ArachNOPE")]
[assembly: AssemblyTitle("ArachNOPE")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 ArachNOPE
{
	[BepInPlugin("io.vrising.ArachNOPE", "ArachNOPE", "1.1.0")]
	internal class Plugin : BasePlugin
	{
		private Harmony _harmony;

		internal static Plugin Instance { get; private set; }

		internal static ManualLogSource Logger => ((BasePlugin)Instance).Log;

		public override void Load()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			Instance = this;
			_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(10, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("ArachNOPE");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.1.0");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded!");
			}
			log.LogInfo(val);
		}

		public override bool Unload()
		{
			_harmony.UnpatchSelf();
			SpiderHidePatch.Cleanup();
			SpiderBuffPatch.Cleanup();
			return true;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "io.vrising.ArachNOPE";

		public const string PLUGIN_NAME = "ArachNOPE";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}
namespace ArachNOPE.Patches
{
	[HarmonyPatch]
	internal static class SpiderBuffPatch
	{
		private static bool _initialized;

		private static int _applyFireCount;

		private static int _removeFireCount;

		private static readonly Dictionary<Entity, Entity> _buffToPlayer = new Dictionary<Entity, Entity>();

		private static void OnBuffApplyPrefix(CreateGameplayEventOnSpawnSystem __instance)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_00f2: 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_00fa: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: 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_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: 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_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Expected O, but got Unknown
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Expected O, but got Unknown
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Expected O, but got Unknown
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Expected O, but got Unknown
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Expected O, but got Unknown
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			_applyFireCount++;
			ManualLogSource logger = Plugin.Logger;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(72, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ArachNOPE][SysPatch] CreateGameplayEventOnSpawnSystem.OnUpdate fired (");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_applyFireCount);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
			}
			logger.LogInfo(val);
			try
			{
				if (((ComponentSystemBase)__instance).World == null || !((ComponentSystemBase)__instance).World.IsCreated)
				{
					Plugin.Logger.LogInfo((object)"[ArachNOPE][SysPatch] World null or not created");
					return;
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger2 = Plugin.Logger;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(45, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ArachNOPE][SysPatch] World check exception: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				logger2.LogError(val2);
				return;
			}
			if (!_initialized)
			{
				Plugin.Logger.LogInfo((object)"[ArachNOPE][SysPatch] Not initialized, attempting init...");
				if (!TryInitialize(((ComponentSystemBase)__instance).World))
				{
					Plugin.Logger.LogInfo((object)"[ArachNOPE][SysPatch] Init failed");
					return;
				}
				Plugin.Logger.LogInfo((object)"[ArachNOPE][SysPatch] Init succeeded");
			}
			EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager;
			EntityQuery val3 = default(EntityQuery);
			NativeArray<Entity> val4 = default(NativeArray<Entity>);
			try
			{
				val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[2]
				{
					ComponentType.ReadOnly<PrefabGUID>(),
					ComponentType.ReadOnly<Buff>()
				});
				val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
				ManualLogSource logger3 = Plugin.Logger;
				val = new BepInExInfoLogInterpolatedStringHandler(64, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ArachNOPE][SysPatch] Query found ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(val4.Length);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" entities with Buff+PrefabGUID");
				}
				logger3.LogInfo(val);
				Enumerator<Entity> enumerator = val4.GetEnumerator();
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					if (!((EntityManager)(ref entityManager)).HasComponent<PrefabGUID>(current))
					{
						continue;
					}
					PrefabGUID componentData = ((EntityManager)(ref entityManager)).GetComponentData<PrefabGUID>(current);
					int guidHash = ((PrefabGUID)(ref componentData)).GuidHash;
					ManualLogSource logger4 = Plugin.Logger;
					val = new BepInExInfoLogInterpolatedStringHandler(54, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ArachNOPE][SysPatch]   buff entity ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(current.Index);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(":");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(current.Version);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" PrefabGUID hash=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(guidHash);
					}
					logger4.LogInfo(val);
					if (!SpiderLookup.IsSpiderBuff(guidHash))
					{
						continue;
					}
					ManualLogSource logger5 = Plugin.Logger;
					val = new BepInExInfoLogInterpolatedStringHandler(50, 0, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ArachNOPE][SysPatch]   *** SPIDER BUFF MATCH! ***");
					}
					logger5.LogInfo(val);
					Entity target = ((EntityManager)(ref entityManager)).GetComponentData<Buff>(current).Target;
					bool flag2 = ((EntityManager)(ref entityManager)).Exists(target);
					bool flag3 = ((EntityManager)(ref entityManager)).HasComponent<PlayerCharacter>(target);
					ManualLogSource logger6 = Plugin.Logger;
					val = new BepInExInfoLogInterpolatedStringHandler(62, 4, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ArachNOPE][SysPatch]   Target=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(target.Index);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(":");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(target.Version);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Exists=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(flag2);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", HasPlayerCharacter=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(flag3);
					}
					logger6.LogInfo(val);
					if (!flag2 || !flag3)
					{
						continue;
					}
					if (_buffToPlayer.ContainsKey(current))
					{
						Plugin.Logger.LogInfo((object)"[ArachNOPE][SysPatch]   Already tracked, skipping");
						continue;
					}
					if (SpiderHidePatch._playerSpiders.ContainsKey(target))
					{
						Plugin.Logger.LogInfo((object)"[ArachNOPE][SysPatch]   Player already has furniture, skipping");
						continue;
					}
					_buffToPlayer[current] = target;
					Plugin.Logger.LogInfo((object)"[ArachNOPE][SysPatch]   Added to tracking");
					if (((EntityManager)(ref entityManager)).HasComponent<LocalTransform>(target))
					{
						LocalTransform componentData2 = ((EntityManager)(ref entityManager)).GetComponentData<LocalTransform>(target);
						componentData2.Scale = 0f;
						((EntityManager)(ref entityManager)).SetComponentData<LocalTransform>(target, componentData2);
						Plugin.Logger.LogInfo((object)"[ArachNOPE][SysPatch]   Set player scale to 0");
					}
					Entity furnitureEntity = Entity.Null;
					bool flag4 = TrySpawnFurniture(entityManager, target, out furnitureEntity);
					ManualLogSource logger7 = Plugin.Logger;
					val = new BepInExInfoLogInterpolatedStringHandler(52, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ArachNOPE][SysPatch]   Spawned furniture=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(flag4);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", entity=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(furnitureEntity.Index);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(":");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(furnitureEntity.Version);
					}
					logger7.LogInfo(val);
					if (flag4)
					{
						SpiderHidePatch._playerSpiders[target] = furnitureEntity;
					}
				}
			}
			finally
			{
				if (val4.IsCreated)
				{
					val4.Dispose();
				}
				try
				{
					((EntityQuery)(ref val3)).Dispose();
				}
				catch
				{
				}
			}
		}

		private static void HandleBuffRemoval(EntityManager em, Entity playerEntity)
		{
			//IL_0005: 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_004b: Expected O, but got Unknown
			//IL_0079: 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_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_001b: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			if (SpiderHidePatch._playerSpiders.TryGetValue(playerEntity, out var value))
			{
				try
				{
					if (((EntityManager)(ref em)).Exists(value))
					{
						SpiderHidePatch.TryUnparentEntity(em, playerEntity, value);
						((EntityManager)(ref em)).DestroyEntity(value);
					}
					Plugin.Logger.LogInfo((object)"[ArachNOPE][SysPatch] Destroyed furniture");
				}
				catch (Exception ex)
				{
					ManualLogSource logger = Plugin.Logger;
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(50, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ArachNOPE][SysPatch] Error destroying furniture: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					logger.LogError(val);
				}
				SpiderHidePatch._playerSpiders.Remove(playerEntity);
			}
			SpiderHidePatch.RestorePlayerVisual(playerEntity);
		}

		private static bool TryInitialize(World world)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			try
			{
				SpiderHidePatch._clientWorld = world;
				SpiderHidePatch._prefabCollectionSystem = world.GetExistingSystemManaged<PrefabCollectionSystem>();
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(52, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ArachNOPE][SysPatch] PrefabCollectionSystem found: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(SpiderHidePatch._prefabCollectionSystem != null);
				}
				logger.LogInfo(val);
				_initialized = true;
				return true;
			}
			catch (Exception ex)
			{
				ManualLogSource logger2 = Plugin.Logger;
				bool flag2 = default(bool);
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(34, 1, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ArachNOPE][SysPatch] Init error: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				logger2.LogError(val2);
				return false;
			}
		}

		private static bool TrySpawnFurniture(EntityManager em, Entity playerEntity, out Entity furnitureEntity)
		{
			//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_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0031: 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_003a: 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_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_00a1: 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_004e: 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_00b0: 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: Expected O, but got Unknown
			//IL_00ef: 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_00fa: 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_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_00e1: 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_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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_0113: 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)
			furnitureEntity = Entity.Null;
			PrefabCollectionSystem prefabCollectionSystem = SpiderHidePatch._prefabCollectionSystem;
			if (prefabCollectionSystem == null)
			{
				return false;
			}
			try
			{
				int furnitureGuidHashForBuff = SpiderLookup.GetFurnitureGuidHashForBuff(124832551);
				PrefabGUID val = default(PrefabGUID);
				((PrefabGUID)(ref val))..ctor(furnitureGuidHashForBuff);
				Entity val2 = Entity.Null;
				PrefabLookupMap prefabLookupMap = prefabCollectionSystem._PrefabLookupMap;
				if (!((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(val, ref val2) && !prefabCollectionSystem._PrefabGuidToEntityMap.TryGetValue(val, ref val2))
				{
					ManualLogSource logger = Plugin.Logger;
					bool flag = default(bool);
					BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(48, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[ArachNOPE][SysPatch] Prefab not found for hash ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(furnitureGuidHashForBuff);
					}
					logger.LogInfo(val3);
					return false;
				}
				furnitureEntity = ((EntityManager)(ref em)).Instantiate(val2);
				if (((EntityManager)(ref em)).HasComponent<PhysicsCollider>(furnitureEntity))
				{
					((EntityManager)(ref em)).RemoveComponent<PhysicsCollider>(furnitureEntity);
				}
				if (((EntityManager)(ref em)).HasComponent<Translation>(playerEntity) && ((EntityManager)(ref em)).HasComponent<Translation>(furnitureEntity))
				{
					Translation componentData = ((EntityManager)(ref em)).GetComponentData<Translation>(playerEntity);
					((EntityManager)(ref em)).SetComponentData<Translation>(furnitureEntity, componentData);
				}
				if (((EntityManager)(ref em)).HasComponent<Rotation>(playerEntity) && ((EntityManager)(ref em)).HasComponent<Rotation>(furnitureEntity))
				{
					Rotation componentData2 = ((EntityManager)(ref em)).GetComponentData<Rotation>(playerEntity);
					((EntityManager)(ref em)).SetComponentData<Rotation>(furnitureEntity, componentData2);
				}
				return true;
			}
			catch (Exception ex)
			{
				ManualLogSource logger2 = Plugin.Logger;
				bool flag2 = default(bool);
				BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(45, 1, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[ArachNOPE][SysPatch] Spawn furniture error: ");
					((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex.Message);
				}
				logger2.LogError(val4);
				furnitureEntity = Entity.Null;
				return false;
			}
		}

		internal static void Cleanup()
		{
			_buffToPlayer.Clear();
			_initialized = false;
		}
	}
	[HarmonyPatch]
	internal static class SpiderHidePatch
	{
		private struct TrackedSpider
		{
			public Entity SpiderEntity;

			public Entity FurnitureEntity;

			public bool FurnitureSpawned;
		}

		private static bool _emReady;

		internal static World _clientWorld;

		internal static PrefabCollectionSystem _prefabCollectionSystem;

		private static readonly Dictionary<int, TrackedSpider> _tracked = new Dictionary<int, TrackedSpider>();

		internal static readonly Dictionary<Entity, Entity> _playerSpiders = new Dictionary<Entity, Entity>();

		private static readonly Dictionary<Entity, bool> _playerBurrowed = new Dictionary<Entity, bool>();

		private static readonly HashSet<Entity> _seenPlayerBuffs = new HashSet<Entity>();

		private static readonly Dictionary<Entity, Entity> _buffToPlayer = new Dictionary<Entity, Entity>();

		private static HybridModelSystem _hybridModelSystem;

		private static readonly Dictionary<Entity, GameObject> _disabledPlayerModels = new Dictionary<Entity, GameObject>();

		private static readonly HashSet<Entity> _pendingHidePlayers = new HashSet<Entity>();

		private static int _framesSinceWorldChange;

		private static EntityQuery _buffQuery;

		private static bool _buffQueryCreated;

		private static int _buffScanCounter;

		private static EntityQuery _npcQuery;

		private static bool _npcQueryCreated;

		private static int _rehideCounter;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(ClientBootstrapSystem), "OnDestroy")]
		private static void OnClientDisconnect(ClientBootstrapSystem __instance)
		{
			ResetState();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(HybridEquipmentSystem), "OnUpdate")]
		private static void OnUpdatePostfix(HybridEquipmentSystem __instance)
		{
			//IL_00cb: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (((ComponentSystemBase)__instance).World == null || !((ComponentSystemBase)__instance).World.IsCreated)
				{
					if (_emReady)
					{
						ResetState();
					}
					return;
				}
			}
			catch
			{
				ResetState();
				return;
			}
			if (_emReady && ((ComponentSystemBase)__instance).World != _clientWorld)
			{
				ResetState();
				_framesSinceWorldChange = 0;
				return;
			}
			if (!_emReady)
			{
				_framesSinceWorldChange++;
				if (_framesSinceWorldChange < 3)
				{
					return;
				}
				try
				{
					_clientWorld = ((ComponentSystemBase)__instance).World;
					TryGetPrefabCollectionSystem();
					TryGetSystems();
					_emReady = true;
				}
				catch
				{
					ResetState();
					_framesSinceWorldChange = 0;
					return;
				}
			}
			_buffScanCounter++;
			if (_buffScanCounter >= 3)
			{
				_buffScanCounter = 0;
				try
				{
					SafetyScanBuffs(((ComponentSystemBase)__instance).EntityManager);
				}
				catch
				{
					ResetState();
				}
			}
			SyncPositions(((ComponentSystemBase)__instance).EntityManager);
			try
			{
				ScanSpiders(((ComponentSystemBase)__instance).EntityManager);
			}
			catch
			{
				ResetState();
			}
		}

		private static void SafetyScanBuffs(EntityManager em)
		{
			//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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: 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_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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: 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_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: 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_010e: 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_011c: 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_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: 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_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			if (!_buffQueryCreated)
			{
				_buffQuery = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[2]
				{
					ComponentType.ReadOnly<PrefabGUID>(),
					ComponentType.ReadOnly<Buff>()
				});
				_buffQueryCreated = true;
			}
			if (_clientWorld == null || !_clientWorld.IsCreated)
			{
				ResetState();
				return;
			}
			NativeArray<Entity> val = default(NativeArray<Entity>);
			try
			{
				val = ((EntityQuery)(ref _buffQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
				HashSet<Entity> hashSet = new HashSet<Entity>();
				Dictionary<Entity, bool> dictionary = new Dictionary<Entity, bool>();
				Enumerator<Entity> enumerator = val.GetEnumerator();
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					if (!((EntityManager)(ref em)).HasComponent<PrefabGUID>(current))
					{
						continue;
					}
					PrefabGUID componentData = ((EntityManager)(ref em)).GetComponentData<PrefabGUID>(current);
					int guidHash = ((PrefabGUID)(ref componentData)).GuidHash;
					if (!SpiderLookup.IsSpiderBuff(guidHash) && !SpiderLookup.IsBurrowBuff(guidHash))
					{
						continue;
					}
					Entity target = ((EntityManager)(ref em)).GetComponentData<Buff>(current).Target;
					if (!((EntityManager)(ref em)).Exists(target) || !((EntityManager)(ref em)).HasComponent<PlayerCharacter>(target))
					{
						continue;
					}
					if (SpiderLookup.IsBurrowBuff(guidHash))
					{
						dictionary[target] = true;
						continue;
					}
					hashSet.Add(current);
					if (_seenPlayerBuffs.Add(current) && !_playerSpiders.ContainsKey(target))
					{
						_buffToPlayer[current] = target;
						_pendingHidePlayers.Add(target);
						Entity furnitureEntity = Entity.Null;
						if (TrySpawnFurniture(em, target, guidHash, out furnitureEntity))
						{
							_playerSpiders[target] = furnitureEntity;
						}
					}
				}
				List<Entity> list = new List<Entity>();
				List<Entity> list2 = new List<Entity>();
				foreach (KeyValuePair<Entity, Entity> playerSpider in _playerSpiders)
				{
					if (dictionary.ContainsKey(playerSpider.Key))
					{
						list.Add(playerSpider.Key);
					}
				}
				foreach (Entity key in _playerBurrowed.Keys)
				{
					if (!dictionary.ContainsKey(key))
					{
						list2.Add(key);
					}
				}
				foreach (Entity item in list)
				{
					if (_playerSpiders.TryGetValue(item, out var value))
					{
						try
						{
							if (((EntityManager)(ref em)).Exists(value))
							{
								((EntityManager)(ref em)).DestroyEntity(value);
							}
						}
						catch
						{
						}
						_playerSpiders.Remove(item);
					}
					_playerBurrowed[item] = true;
				}
				foreach (Entity item2 in list2)
				{
					_playerBurrowed.Remove(item2);
					int guidHash2 = 124832551;
					Entity furnitureEntity2 = Entity.Null;
					if (TrySpawnFurniture(em, item2, guidHash2, out furnitureEntity2))
					{
						_playerSpiders[item2] = furnitureEntity2;
						_pendingHidePlayers.Add(item2);
					}
				}
				if (_buffToPlayer.Count <= 0)
				{
					return;
				}
				List<Entity> list3 = new List<Entity>();
				foreach (KeyValuePair<Entity, Entity> item3 in _buffToPlayer)
				{
					if (!hashSet.Contains(item3.Key))
					{
						list3.Add(item3.Key);
					}
				}
				foreach (Entity item4 in list3)
				{
					Entity val2 = _buffToPlayer[item4];
					_playerBurrowed.Remove(val2);
					if (_playerSpiders.TryGetValue(val2, out var value2))
					{
						try
						{
							if (((EntityManager)(ref em)).Exists(value2))
							{
								((EntityManager)(ref em)).DestroyEntity(value2);
							}
						}
						catch
						{
						}
						_playerSpiders.Remove(val2);
					}
					RestorePlayerVisual(val2);
					_buffToPlayer.Remove(item4);
					_seenPlayerBuffs.Remove(item4);
				}
			}
			catch
			{
			}
			finally
			{
				if (val.IsCreated)
				{
					val.Dispose();
				}
			}
		}

		private static void ScanSpiders(EntityManager em)
		{
			//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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_00b6: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: 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_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: 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_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			if (!_npcQueryCreated)
			{
				_npcQuery = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[3]
				{
					ComponentType.ReadOnly<PrefabGUID>(),
					ComponentType.ReadOnly<Health>(),
					ComponentType.ReadOnly<Team>()
				});
				_npcQueryCreated = true;
			}
			if (_clientWorld == null || !_clientWorld.IsCreated)
			{
				ResetState();
				return;
			}
			NativeArray<Entity> val = default(NativeArray<Entity>);
			try
			{
				val = ((EntityQuery)(ref _npcQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
				Enumerator<Entity> enumerator = val.GetEnumerator();
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					if (!((EntityManager)(ref em)).HasComponent<PrefabGUID>(current))
					{
						continue;
					}
					PrefabGUID componentData = ((EntityManager)(ref em)).GetComponentData<PrefabGUID>(current);
					int guidHash = ((PrefabGUID)(ref componentData)).GuidHash;
					if (!SpiderLookup.IsSpider(guidHash))
					{
						continue;
					}
					int index = current.Index;
					if (_tracked.TryGetValue(index, out var value))
					{
						if (value.SpiderEntity.Version == current.Version)
						{
							continue;
						}
						if (value.FurnitureSpawned && _clientWorld != null && _clientWorld.IsCreated)
						{
							EntityManager entityManager = _clientWorld.EntityManager;
							if (((EntityManager)(ref entityManager)).Exists(value.FurnitureEntity))
							{
								((EntityManager)(ref entityManager)).DestroyEntity(value.FurnitureEntity);
							}
						}
						_tracked.Remove(index);
					}
					if (((EntityManager)(ref em)).HasComponent<LocalTransform>(current))
					{
						LocalTransform componentData2 = ((EntityManager)(ref em)).GetComponentData<LocalTransform>(current);
						componentData2.Scale = 0f;
						((EntityManager)(ref em)).SetComponentData<LocalTransform>(current, componentData2);
					}
					Entity furnitureEntity = Entity.Null;
					bool furnitureSpawned = false;
					if (_prefabCollectionSystem != null)
					{
						furnitureSpawned = TrySpawnFurniture(em, current, guidHash, out furnitureEntity);
					}
					_tracked[index] = new TrackedSpider
					{
						SpiderEntity = current,
						FurnitureEntity = furnitureEntity,
						FurnitureSpawned = furnitureSpawned
					};
				}
				List<int> list = new List<int>();
				foreach (KeyValuePair<int, TrackedSpider> item in _tracked)
				{
					if (IsSpiderAlive(em, item.Value.SpiderEntity))
					{
						continue;
					}
					if (item.Value.FurnitureSpawned && _clientWorld != null && _clientWorld.IsCreated)
					{
						EntityManager entityManager2 = _clientWorld.EntityManager;
						if (((EntityManager)(ref entityManager2)).Exists(item.Value.FurnitureEntity))
						{
							((EntityManager)(ref entityManager2)).DestroyEntity(item.Value.FurnitureEntity);
						}
					}
					list.Add(item.Key);
				}
				foreach (int item2 in list)
				{
					_tracked.Remove(item2);
				}
			}
			finally
			{
				try
				{
					if (val.IsCreated)
					{
						val.Dispose();
					}
				}
				catch
				{
				}
			}
		}

		private static bool IsSpiderAlive(EntityManager em, Entity spider)
		{
			//IL_0002: 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_002d: 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_001b: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!((EntityManager)(ref em)).Exists(spider))
				{
					return false;
				}
				if (((EntityManager)(ref em)).HasComponent<Health>(spider) && ((EntityManager)(ref em)).GetComponentData<Health>(spider).IsDead)
				{
					return false;
				}
				if (((EntityManager)(ref em)).HasComponent<DestroyState>(spider) && (int)((EntityManager)(ref em)).GetComponentData<DestroyState>(spider).Value != 0)
				{
					return false;
				}
				return true;
			}
			catch
			{
				return false;
			}
		}

		private static bool HidePlayerVisual(EntityManager em, Entity playerEntity)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_00a3: 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)
			bool flag = default(bool);
			if (!((EntityManager)(ref em)).Exists(playerEntity))
			{
				ManualLogSource logger = Plugin.Logger;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(50, 0, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ArachNOPE] HidePlayerVisual: entity doesn't exist");
				}
				logger.LogWarning(val);
				return false;
			}
			if (_hybridModelSystem == null)
			{
				ManualLogSource logger2 = Plugin.Logger;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(55, 0, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ArachNOPE] HidePlayerVisual: HybridModelSystem is null");
				}
				logger2.LogError(val2);
				return false;
			}
			try
			{
				Dictionary<Entity, GameObject> entityToGameObjectMap = _hybridModelSystem.GetEntityToGameObjectMap();
				if (entityToGameObjectMap == null || entityToGameObjectMap.Count == 0)
				{
					ManualLogSource logger3 = Plugin.Logger;
					BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(78, 0, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[ArachNOPE] HidePlayerVisual: map empty (may not be populated yet), will retry");
					}
					logger3.LogInfo(val3);
					return false;
				}
				GameObject val4 = default(GameObject);
				if (!entityToGameObjectMap.TryGetValue(playerEntity, ref val4) || (Object)(object)val4 == (Object)null)
				{
					return false;
				}
				Il2CppArrayBase<Renderer> componentsInChildren = val4.GetComponentsInChildren<Renderer>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].enabled = false;
				}
				_disabledPlayerModels[playerEntity] = val4;
				return true;
			}
			catch (Exception ex)
			{
				ManualLogSource logger4 = Plugin.Logger;
				bool flag2 = default(bool);
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(36, 1, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ArachNOPE] HidePlayerVisual error: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				logger4.LogError(val2);
				return false;
			}
		}

		internal static void RestorePlayerVisual(Entity playerEntity)
		{
			//IL_0005: 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_006c: Expected O, but got Unknown
			//IL_001d: 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)
			if (!_disabledPlayerModels.TryGetValue(playerEntity, out var value) || (Object)(object)value == (Object)null)
			{
				_disabledPlayerModels.Remove(playerEntity);
				return;
			}
			try
			{
				Il2CppArrayBase<Renderer> componentsInChildren = value.GetComponentsInChildren<Renderer>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].enabled = true;
				}
				_disabledPlayerModels.Remove(playerEntity);
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(39, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ArachNOPE] RestorePlayerVisual error: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				logger.LogError(val);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(BuffSystem_Spawn_Client), "OnUpdate")]
		private static void OnBuffApply(BuffSystem_Spawn_Client __instance)
		{
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Expected O, but got Unknown
			//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_010a: 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_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_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_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_0117: 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_005e: 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_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_0076: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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_00b1: 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_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: 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_014c: 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_015a: 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_0167: 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_0174: 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_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			if (!_emReady)
			{
				return;
			}
			EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager;
			if (!_buffQueryCreated)
			{
				_buffQuery = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[2]
				{
					ComponentType.ReadOnly<PrefabGUID>(),
					ComponentType.ReadOnly<Buff>()
				});
				_buffQueryCreated = true;
			}
			NativeArray<Entity> val = default(NativeArray<Entity>);
			try
			{
				val = ((EntityQuery)(ref _buffQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
				Enumerator<Entity> enumerator = val.GetEnumerator();
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					if (!((EntityManager)(ref entityManager)).HasComponent<PrefabGUID>(current))
					{
						continue;
					}
					PrefabGUID componentData = ((EntityManager)(ref entityManager)).GetComponentData<PrefabGUID>(current);
					int guidHash = ((PrefabGUID)(ref componentData)).GuidHash;
					if (SpiderLookup.IsBurrowBuff(guidHash))
					{
						Entity target = ((EntityManager)(ref entityManager)).GetComponentData<Buff>(current).Target;
						if (!((EntityManager)(ref entityManager)).Exists(target) || !((EntityManager)(ref entityManager)).HasComponent<PlayerCharacter>(target) || _playerBurrowed.ContainsKey(target))
						{
							continue;
						}
						if (_playerSpiders.TryGetValue(target, out var value))
						{
							try
							{
								if (((EntityManager)(ref entityManager)).Exists(value))
								{
									((EntityManager)(ref entityManager)).DestroyEntity(value);
								}
							}
							catch
							{
							}
							_playerSpiders.Remove(target);
						}
						_playerBurrowed[target] = true;
					}
					else
					{
						if (!SpiderLookup.IsSpiderBuff(guidHash))
						{
							continue;
						}
						Entity target2 = ((EntityManager)(ref entityManager)).GetComponentData<Buff>(current).Target;
						if (!((EntityManager)(ref entityManager)).Exists(target2) || !((EntityManager)(ref entityManager)).HasComponent<PlayerCharacter>(target2) || !_seenPlayerBuffs.Add(current))
						{
							continue;
						}
						_buffToPlayer[current] = target2;
						if (_playerSpiders.ContainsKey(target2))
						{
							_pendingHidePlayers.Add(target2);
							continue;
						}
						_pendingHidePlayers.Add(target2);
						Entity furnitureEntity = Entity.Null;
						if (TrySpawnFurniture(entityManager, target2, guidHash, out furnitureEntity))
						{
							_playerSpiders[target2] = furnitureEntity;
						}
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(31, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[ArachNOPE] OnBuffApply error: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				logger.LogError(val2);
			}
			finally
			{
				if (val.IsCreated)
				{
					val.Dispose();
				}
			}
		}

		private static void SyncPositions(EntityManager em)
		{
			//IL_0077: 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_0063: 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_005b: 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_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			if (_pendingHidePlayers.Count == 0 && _tracked.Count == 0 && _playerSpiders.Count == 0)
			{
				return;
			}
			if (_pendingHidePlayers.Count > 0)
			{
				List<Entity> list = new List<Entity>();
				foreach (Entity pendingHidePlayer in _pendingHidePlayers)
				{
					try
					{
						if (!((EntityManager)(ref em)).Exists(pendingHidePlayer))
						{
							list.Add(pendingHidePlayer);
						}
						else if (HidePlayerVisual(em, pendingHidePlayer))
						{
							list.Add(pendingHidePlayer);
						}
					}
					catch
					{
						list.Add(pendingHidePlayer);
					}
				}
				foreach (Entity item in list)
				{
					_pendingHidePlayers.Remove(item);
				}
			}
			_rehideCounter++;
			if (_rehideCounter >= 5)
			{
				_rehideCounter = 0;
				foreach (KeyValuePair<Entity, GameObject> disabledPlayerModel in _disabledPlayerModels)
				{
					try
					{
						GameObject value = disabledPlayerModel.Value;
						if (!((Object)(object)value == (Object)null))
						{
							Il2CppArrayBase<Renderer> componentsInChildren = value.GetComponentsInChildren<Renderer>(true);
							for (int i = 0; i < componentsInChildren.Length; i++)
							{
								componentsInChildren[i].enabled = false;
							}
						}
					}
					catch
					{
					}
				}
			}
			foreach (KeyValuePair<int, TrackedSpider> item2 in _tracked)
			{
				TrackedSpider value2 = item2.Value;
				if (!value2.FurnitureSpawned)
				{
					continue;
				}
				try
				{
					if (((EntityManager)(ref em)).Exists(value2.SpiderEntity) && ((EntityManager)(ref em)).Exists(value2.FurnitureEntity))
					{
						if (((EntityManager)(ref em)).HasComponent<Translation>(value2.SpiderEntity) && ((EntityManager)(ref em)).HasComponent<Translation>(value2.FurnitureEntity))
						{
							Translation componentData = ((EntityManager)(ref em)).GetComponentData<Translation>(value2.SpiderEntity);
							((EntityManager)(ref em)).SetComponentData<Translation>(value2.FurnitureEntity, componentData);
						}
						if (((EntityManager)(ref em)).HasComponent<Rotation>(value2.SpiderEntity) && ((EntityManager)(ref em)).HasComponent<Rotation>(value2.FurnitureEntity))
						{
							Rotation componentData2 = ((EntityManager)(ref em)).GetComponentData<Rotation>(value2.SpiderEntity);
							((EntityManager)(ref em)).SetComponentData<Rotation>(value2.FurnitureEntity, componentData2);
						}
					}
				}
				catch
				{
					break;
				}
			}
			foreach (KeyValuePair<Entity, Entity> playerSpider in _playerSpiders)
			{
				try
				{
					Entity key = playerSpider.Key;
					Entity value3 = playerSpider.Value;
					if (((EntityManager)(ref em)).Exists(key) && ((EntityManager)(ref em)).Exists(value3))
					{
						if (((EntityManager)(ref em)).HasComponent<Translation>(key) && ((EntityManager)(ref em)).HasComponent<Translation>(value3))
						{
							Translation componentData3 = ((EntityManager)(ref em)).GetComponentData<Translation>(key);
							((EntityManager)(ref em)).SetComponentData<Translation>(value3, componentData3);
						}
						if (((EntityManager)(ref em)).HasComponent<Rotation>(key) && ((EntityManager)(ref em)).HasComponent<Rotation>(value3))
						{
							Rotation componentData4 = ((EntityManager)(ref em)).GetComponentData<Rotation>(key);
							((EntityManager)(ref em)).SetComponentData<Rotation>(value3, componentData4);
						}
					}
				}
				catch
				{
					break;
				}
			}
		}

		private static void TryGetPrefabCollectionSystem()
		{
			try
			{
				_prefabCollectionSystem = _clientWorld.GetExistingSystemManaged<PrefabCollectionSystem>();
			}
			catch
			{
				_prefabCollectionSystem = null;
			}
		}

		private static void TryGetSystems()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Expected O, but got Unknown
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			ManualLogSource logger = Plugin.Logger;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(49, 0, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ArachNOPE] TryGetSystems: scanning all worlds...");
			}
			logger.LogInfo(val);
			int num = -1;
			HybridModelSystem val2 = null;
			World val3 = null;
			Enumerator<World> enumerator = World.All.GetEnumerator();
			while (enumerator.MoveNext())
			{
				World current = enumerator.Current;
				if (current == null || !current.IsCreated)
				{
					continue;
				}
				try
				{
					HybridModelSystem existingSystemManaged = current.GetExistingSystemManaged<HybridModelSystem>();
					if (existingSystemManaged == null)
					{
						ManualLogSource logger2 = Plugin.Logger;
						val = new BepInExInfoLogInterpolatedStringHandler(44, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ArachNOPE]   World '");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(current.Name);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': no HybridModelSystem");
						}
						logger2.LogInfo(val);
						continue;
					}
					int num2 = 0;
					try
					{
						num2 = existingSystemManaged.GetEntityToGameObjectMap()?.Count ?? (-1);
					}
					catch
					{
					}
					int num3 = 0;
					try
					{
						num3 = existingSystemManaged._EntityToGameObject?.Count ?? (-1);
					}
					catch
					{
					}
					ManualLogSource logger3 = Plugin.Logger;
					val = new BepInExInfoLogInterpolatedStringHandler(88, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ArachNOPE]   World '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(current.Name);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': HybridModelSystem ");
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("GetEntityToGameObjectMap=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num2);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" _EntityToGameObject=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num3);
					}
					logger3.LogInfo(val);
					int num4 = ((num2 > num3) ? num2 : num3);
					if (num4 > num)
					{
						num = num4;
						val2 = existingSystemManaged;
						val3 = current;
					}
				}
				catch
				{
				}
			}
			if (val2 != null)
			{
				_hybridModelSystem = val2;
				_clientWorld = val3;
				ManualLogSource logger4 = Plugin.Logger;
				val = new BepInExInfoLogInterpolatedStringHandler(68, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[ArachNOPE]   => Using HybridModelSystem from world '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(val3.Name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' ");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("(map count: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
				}
				logger4.LogInfo(val);
			}
			else
			{
				ManualLogSource logger5 = Plugin.Logger;
				BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(53, 0, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[ArachNOPE] HybridModelSystem not found in any world!");
				}
				logger5.LogError(val4);
			}
		}

		private static void TryRemoveComponent<T>(EntityManager em, Entity e) where T : struct
		{
			//IL_0002: 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)
			if (((EntityManager)(ref em)).HasComponent<T>(e))
			{
				((EntityManager)(ref em)).RemoveComponent<T>(e);
			}
		}

		private static void TryParentToEntity(EntityManager em, Entity parent, Entity child)
		{
		}

		internal static void TryUnparentEntity(EntityManager em, Entity parent, Entity child)
		{
			//IL_0002: 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_000c: 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_0051: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (((EntityManager)(ref em)).HasBuffer<Child>(parent))
				{
					DynamicBuffer<Child> buffer = ((EntityManager)(ref em)).GetBuffer<Child>(parent, false);
					for (int i = 0; i < buffer.Length; i++)
					{
						if (buffer[i].Value == child)
						{
							buffer.RemoveAt(i);
							break;
						}
					}
				}
				if (((EntityManager)(ref em)).HasComponent<Parent>(child))
				{
					((EntityManager)(ref em)).RemoveComponent<Parent>(child);
				}
			}
			catch
			{
			}
		}

		private static bool TrySpawnFurniture(EntityManager em, Entity sourceEntity, int guidHash, out Entity furnitureEntity)
		{
			//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_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00bb: 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_00c7: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: 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_00eb: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: 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_0111: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: 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_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			furnitureEntity = Entity.Null;
			if (_prefabCollectionSystem == null)
			{
				return false;
			}
			try
			{
				int num = (SpiderLookup.IsSpider(guidHash) ? SpiderLookup.GetFurnitureGuidHash(guidHash) : SpiderLookup.GetFurnitureGuidHashForBuff(guidHash));
				PrefabGUID val = default(PrefabGUID);
				((PrefabGUID)(ref val))..ctor(num);
				Entity val2 = Entity.Null;
				PrefabLookupMap prefabLookupMap = _prefabCollectionSystem._PrefabLookupMap;
				if (!((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(val, ref val2) && !_prefabCollectionSystem._PrefabGuidToEntityMap.TryGetValue(val, ref val2))
				{
					return false;
				}
				furnitureEntity = ((EntityManager)(ref em)).Instantiate(val2);
				TryRemoveComponent<PhysicsCollider>(em, furnitureEntity);
				TryRemoveComponent<PhysicsWorldIndex>(em, furnitureEntity);
				TryRemoveComponent<StaticPhysicsWorldBodyIndex>(em, furnitureEntity);
				TryRemoveComponent<CollisionRadius>(em, furnitureEntity);
				TryRemoveComponent<MoveStopTrigger>(em, furnitureEntity);
				TryRemoveComponent<TileCollisionTag>(em, furnitureEntity);
				TryRemoveComponent<TilePathfindingTag>(em, furnitureEntity);
				TryRemoveComponent<TileLineOfSightTag>(em, furnitureEntity);
				TryRemoveComponent<TileModelSpatialData>(em, furnitureEntity);
				TryRemoveComponent<TilePosition>(em, furnitureEntity);
				TryRemoveComponent<TileBounds>(em, furnitureEntity);
				TryRemoveComponent<TileData>(em, furnitureEntity);
				TryRemoveComponent<TileModelRegistrationState>(em, furnitureEntity);
				if (((EntityManager)(ref em)).HasComponent<Translation>(sourceEntity) && ((EntityManager)(ref em)).HasComponent<Translation>(furnitureEntity))
				{
					Translation componentData = ((EntityManager)(ref em)).GetComponentData<Translation>(sourceEntity);
					((EntityManager)(ref em)).SetComponentData<Translation>(furnitureEntity, componentData);
				}
				if (((EntityManager)(ref em)).HasComponent<Rotation>(sourceEntity) && ((EntityManager)(ref em)).HasComponent<Rotation>(furnitureEntity))
				{
					Rotation componentData2 = ((EntityManager)(ref em)).GetComponentData<Rotation>(sourceEntity);
					((EntityManager)(ref em)).SetComponentData<Rotation>(furnitureEntity, componentData2);
				}
				return true;
			}
			catch
			{
				furnitureEntity = Entity.Null;
				return false;
			}
		}

		private static void ResetState()
		{
			_emReady = false;
			_prefabCollectionSystem = null;
			_clientWorld = null;
			_rehideCounter = 0;
			_buffScanCounter = 0;
			_framesSinceWorldChange = 0;
			_hybridModelSystem = null;
			if (_buffQueryCreated)
			{
				try
				{
					((EntityQuery)(ref _buffQuery)).Dispose();
				}
				catch
				{
				}
				_buffQueryCreated = false;
			}
			if (_npcQueryCreated)
			{
				try
				{
					((EntityQuery)(ref _npcQuery)).Dispose();
				}
				catch
				{
				}
				_npcQueryCreated = false;
			}
			_tracked.Clear();
			_playerSpiders.Clear();
			_playerBurrowed.Clear();
			_seenPlayerBuffs.Clear();
			_buffToPlayer.Clear();
			_pendingHidePlayers.Clear();
			foreach (KeyValuePair<Entity, GameObject> disabledPlayerModel in _disabledPlayerModels)
			{
				try
				{
					if ((Object)(object)disabledPlayerModel.Value != (Object)null)
					{
						Il2CppArrayBase<Renderer> componentsInChildren = disabledPlayerModel.Value.GetComponentsInChildren<Renderer>(true);
						for (int i = 0; i < componentsInChildren.Length; i++)
						{
							componentsInChildren[i].enabled = true;
						}
					}
				}
				catch
				{
				}
			}
			_disabledPlayerModels.Clear();
		}

		internal static void Cleanup()
		{
			//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_00c1: 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_004b: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<int, TrackedSpider> item in _tracked)
			{
				if (!item.Value.FurnitureSpawned)
				{
					continue;
				}
				try
				{
					if (_clientWorld != null && _clientWorld.IsCreated)
					{
						EntityManager entityManager = _clientWorld.EntityManager;
						if (((EntityManager)(ref entityManager)).Exists(item.Value.FurnitureEntity))
						{
							((EntityManager)(ref entityManager)).DestroyEntity(item.Value.FurnitureEntity);
						}
					}
				}
				catch
				{
				}
			}
			foreach (KeyValuePair<Entity, Entity> playerSpider in _playerSpiders)
			{
				try
				{
					if (_clientWorld != null && _clientWorld.IsCreated)
					{
						EntityManager entityManager2 = _clientWorld.EntityManager;
						if (((EntityManager)(ref entityManager2)).Exists(playerSpider.Value))
						{
							((EntityManager)(ref entityManager2)).DestroyEntity(playerSpider.Value);
						}
					}
				}
				catch
				{
				}
			}
			foreach (KeyValuePair<Entity, GameObject> disabledPlayerModel in _disabledPlayerModels)
			{
				try
				{
					if ((Object)(object)disabledPlayerModel.Value != (Object)null)
					{
						Il2CppArrayBase<Renderer> componentsInChildren = disabledPlayerModel.Value.GetComponentsInChildren<Renderer>(true);
						for (int i = 0; i < componentsInChildren.Length; i++)
						{
							componentsInChildren[i].enabled = true;
						}
					}
				}
				catch
				{
				}
			}
			_tracked.Clear();
			_playerSpiders.Clear();
			_playerBurrowed.Clear();
			_seenPlayerBuffs.Clear();
			_buffToPlayer.Clear();
			ResetState();
		}
	}
}
namespace ArachNOPE.Helpers
{
	internal static class SpiderLookup
	{
		private const int TM_Laboratory_Chair_Leather_01 = -813681645;

		private const int TM_Strongblade_Chair03 = -315172854;

		private const int TM_Elris_Stool_02 = 188374087;

		private const int TM_Elris_Stool_01 = -1041511902;

		private const int TM_Castle_Module_Child_RoundTable_3x3_StrongbladeDLC02 = -70745613;

		private const int TM_BanditLeaderChair_01 = -154796222;

		private const int TM_Elris_Bags_01 = 167350142;

		private const int TM_Castle_Throne_01DLC02Variant = -625213071;

		private const int TM_Castle_Throne_01_StrongbladeDLC = 980816206;

		private const int TM_GloomRot_Laboratory_Chair_Body01 = 114706283;

		private const int TM_Castle_Module_Child_RoundTable_6x6_StrongbladeDLC03 = 1592427758;

		private const int TM_Castle_Module_Child_RoundTable_3x3_StrongbladeDLC03 = -784399817;

		private const int TM_Castle_ObjectDecor_ChessTable01 = 624218349;

		private const int TM_Castle_ObjectDecor_Chair_StrongbladeDLC01 = 930898512;

		private const int CHAR_Spider_Melee = 2136899683;

		private const int CHAR_Spider_Melee_Summon = 2119230788;

		private const int CHAR_Spider_Melee_GateBoss_Summon = -725251219;

		private const int CHAR_Spider_Range = 2103131615;

		private const int CHAR_Spider_Range_Summon = 1974733695;

		private const int CHAR_Spider_Spiderling_VerminNest = 1767714956;

		private const int CHAR_Spiderling_Summon = -18289884;

		private const int CHAR_Spider_Spiderling = 1078424589;

		private const int CHAR_Spider_Baneling = -764515001;

		private const int CHAR_Spider_Baneling_Summon = -1004061470;

		private const int CHAR_Spider_Forest = -581295882;

		private const int CHAR_Spider_Forestling = 574276383;

		private const int CHAR_Spider_Broodmother = 342127250;

		private const int CHAR_Spider_Queen_VBlood = -548489519;

		private const int CHAR_Spider_Queen_VBlood_GateBoss_Major = -943858353;

		private const int CHAR_Unholy_UnstableArachnid = 834333879;

		private const int CHAR_Unholy_UnstableArachnid_Small = -1106602776;

		private static readonly HashSet<int> SpiderGuidHashes = new HashSet<int>
		{
			-764515001, -1004061470, 342127250, -581295882, 574276383, 2136899683, -725251219, 2119230788, -548489519, -943858353,
			2103131615, 1974733695, 1078424589, 1767714956, -18289884, 834333879, -1106602776
		};

		private static readonly Dictionary<int, int> SpiderToFurniture = new Dictionary<int, int>
		{
			{ 2136899683, -813681645 },
			{ 2119230788, -813681645 },
			{ -725251219, -813681645 },
			{ 2103131615, -315172854 },
			{ 1974733695, -315172854 },
			{ 1078424589, 624218349 },
			{ 1767714956, 188374087 },
			{ -18289884, -1041511902 },
			{ -764515001, -70745613 },
			{ -1004061470, -70745613 },
			{ -581295882, -154796222 },
			{ 574276383, 167350142 },
			{ -548489519, -625213071 },
			{ -943858353, 980816206 },
			{ 342127250, 114706283 },
			{ 834333879, 1592427758 },
			{ -1106602776, -784399817 }
		};

		internal const int AB_Shapeshift_Spider_Buff = 124832551;

		internal const int AB_Shapeshift_Spider_Burrow_Buff = -1665328650;

		private static readonly HashSet<int> SpiderBuffHashes = new HashSet<int> { 124832551 };

		private static readonly HashSet<int> BurrowBuffHashes = new HashSet<int> { -1665328650 };

		private static readonly Dictionary<int, int> BuffToFurniture = new Dictionary<int, int> { { 124832551, 930898512 } };

		public static bool IsSpider(int guidHash)
		{
			return SpiderGuidHashes.Contains(guidHash);
		}

		public static bool IsSpiderBuff(int buffGuidHash)
		{
			return SpiderBuffHashes.Contains(buffGuidHash);
		}

		public static bool IsBurrowBuff(int buffGuidHash)
		{
			return BurrowBuffHashes.Contains(buffGuidHash);
		}

		public static int GetFurnitureGuidHash(int spiderGuidHash)
		{
			if (!SpiderToFurniture.TryGetValue(spiderGuidHash, out var value))
			{
				return 624218349;
			}
			return value;
		}

		public static int GetFurnitureGuidHashForBuff(int buffGuidHash)
		{
			if (!BuffToFurniture.TryGetValue(buffGuidHash, out var value))
			{
				return 624218349;
			}
			return value;
		}
	}
}