Decompiled source of LycansNewMaps v0.13.0

plugins/LycansNewMaps/LycansNewMaps.dll

Decompiled 7 hours ago
using System;
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.Cryptography;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using Fusion;
using Fusion.Sockets;
using HarmonyLib;
using HarmonyLib.Tools;
using Helpers.Collections;
using LycansNewMaps.SpecialArchitecture;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using TMPro;
using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Tables;
using UnityEngine.Scripting;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LycansNewMaps")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+b2d2937312b0b8f2dddc9ee5eff8eb0bbed370ad")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("LycansNewMaps")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LycansNewMaps
{
	public class DoorCustom : MonoBehaviour
	{
		private void Start()
		{
			//IL_0053: 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_0073: 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_00b7: 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_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Expected O, but got Unknown
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: 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_01af: Expected O, but got Unknown
			//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_01f3: Expected O, but got Unknown
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: 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_0232: Expected O, but got Unknown
			try
			{
				if ((Object)(object)GameManager.Instance == (Object)null)
				{
					return;
				}
				float? num = null;
				IEnumerable<GameObject> enumerable = from o in Object.FindObjectsOfType<GameObject>()
					where ((Object)o).name == "Doors"
					select o;
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(((Component)this).transform.position.x, ((Component)this).transform.position.y, ((Component)this).transform.position.z);
				Transform parent = null;
				foreach (GameObject item in enumerable)
				{
					for (int i = 0; i < item.transform.childCount; i++)
					{
						Transform child = item.transform.GetChild(i);
						float num2 = Vector3.Distance(val, ((Component)child).transform.position);
						if (!num.HasValue || num2 < num.Value)
						{
							num = num2;
							parent = child;
						}
					}
				}
				Animator component = ((Component)this).GetComponent<Animator>();
				if (component.runtimeAnimatorController.animationClips[1].events.Length == 0)
				{
					component.runtimeAnimatorController.animationClips[1].AddEvent(new AnimationEvent
					{
						functionName = "PlayOpenSoundCustom"
					});
					component.runtimeAnimatorController.animationClips[1].AddEvent(new AnimationEvent
					{
						time = component.runtimeAnimatorController.animationClips[1].length,
						functionName = "AnimationEndedCustom"
					});
				}
				if (component.runtimeAnimatorController.animationClips[3].events.Length == 0)
				{
					component.runtimeAnimatorController.animationClips[3].AddEvent(new AnimationEvent
					{
						functionName = "PlayCloseSoundCustom"
					});
					component.runtimeAnimatorController.animationClips[3].AddEvent(new AnimationEvent
					{
						time = component.runtimeAnimatorController.animationClips[3].length,
						functionName = "AnimationEndedCustom"
					});
				}
				((Component)this).gameObject.transform.parent = parent;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("DoorCustom start error: " + ex));
			}
		}

		private void PlayOpenSoundCustom()
		{
			((Component)this).GetComponent<Door>().PlayOpenSound();
		}

		private void PlayCloseSoundCustom()
		{
			((Component)this).GetComponent<Door>().PlayCloseSound();
		}

		private void AnimationEndedCustom()
		{
			((Component)this).GetComponent<Door>().AnimationEnded();
		}
	}
	public class DoorSpawnComponent : MonoBehaviour
	{
		public string DoorPrefabName;
	}
	public static class DungeonMap
	{
		public const string DungeonMapName = "dungeonmap";

		public static Color TorchColorDaytime = new Color(1f, 0.9f, 0.8f, 1f);

		public static Color TorchColorMostlyDay = new Color(1f, 0.75f, 0.6f, 1f);

		public static Color TorchColorMostlyNight = new Color(1f, 0.6f, 0.4f, 1f);

		public static Color TorchColorNight = new Color(1f, 0.5f, 0.3f, 1f);

		public static float TorchIntensityDaytime = 1f;

		public static float TorchIntensityMostlyDay = 0.8f;

		public static float TorchIntensityMostlyNight = 0.65f;

		public static float TorchIntensityNight = 0.5f;

		public static Color CurrentTorchColor = TorchColorDaytime;

		public static List<Light> Lights = new List<Light>();
	}
	[HarmonyPatch(typeof(GameState), "Spawned")]
	internal class DungeonGameStateNoMusicPatch
	{
		private static void Postfix(GameState __instance)
		{
			try
			{
				StateMachine<EGameState> value = Traverse.Create((object)__instance).Field<StateMachine<EGameState>>("StateMachine").Value;
				StateHooks<EGameState> obj = value[(EGameState)1];
				obj.onEnter = (Action<EGameState>)Delegate.Combine(obj.onEnter, (Action<EGameState>)delegate
				{
					if (((SimulationBehaviour)__instance).Runner.IsPlayer && GameManager.Instance.MapID == MapManager.FindMapIdByName("dungeonmap"))
					{
						AudioManager.StopMusic();
					}
				});
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("DungeonMapChangedPatch error: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(LightingManager), "UpdateLighting")]
	public class UpdateTorchLightsPatch
	{
		private static void Postfix(LightingManager __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//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_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_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)
			//IL_0185: 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_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)
			//IL_01a6: 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_010b: 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_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_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((int)GameManager.LocalGameState != 2 || GameManager.Instance.MapID != MapManager.FindMapIdByName("dungeonmap"))
				{
					return;
				}
				float value = Traverse.Create((object)__instance).Field<float>("_localTimeOfDay").Value;
				Color val = DungeonMap.TorchColorDaytime;
				float intensity = DungeonMap.TorchIntensityDaytime;
				if (value >= 6f && value <= 15f)
				{
					val = DungeonMap.TorchColorDaytime;
					intensity = DungeonMap.TorchIntensityDaytime;
				}
				else if (value > 15f && value <= 17f)
				{
					val = DungeonMap.TorchColorMostlyDay;
					intensity = DungeonMap.TorchIntensityMostlyDay;
				}
				else if (value > 17f && value <= 18f)
				{
					val = DungeonMap.TorchColorMostlyNight;
					intensity = DungeonMap.TorchIntensityMostlyNight;
				}
				else if (value > 18f || value <= 3f)
				{
					val = DungeonMap.TorchColorNight;
					intensity = DungeonMap.TorchIntensityNight;
				}
				else if (value > 3f && value <= 5f)
				{
					val = DungeonMap.TorchColorMostlyNight;
					intensity = DungeonMap.TorchIntensityMostlyNight;
				}
				else if (value > 5f && value <= 6f)
				{
					val = DungeonMap.TorchColorMostlyDay;
					intensity = DungeonMap.TorchIntensityMostlyDay;
				}
				if (!(DungeonMap.CurrentTorchColor != val))
				{
					return;
				}
				DungeonMap.CurrentTorchColor = val;
				foreach (Light light in DungeonMap.Lights)
				{
					light.color = val;
					light.intensity = intensity;
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("UpdateTorchLightsPatch error: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(LightingManager), "OnTimeChanged")]
	internal class DungeonMapNoMusicPatch
	{
		private static bool Prefix(Changed<LightingManager> changed)
		{
			try
			{
				if (GameManager.Instance.MapID == MapManager.FindMapIdByName("dungeonmap"))
				{
					Traverse.Create((object)changed.Behaviour).Method("UpdateAmbient", Array.Empty<object>()).GetValue();
					return false;
				}
				return true;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("DungeonMapNoMusicPatch error: " + ex));
				return true;
			}
		}
	}
	public static class GlobalManager
	{
		public static string PlayerMapCustomRegistryName => "LycansNewMaps.PlayerMapCustomRegistry";

		public static string PlayerMapCustomName => "LycansNewMaps.PlayerMapCustom";

		public static string GetPrefabName(string baseName)
		{
			return baseName;
		}
	}
	[HarmonyPatch(typeof(GameManager), "Spawned")]
	internal class GlobalManagerGameManagerSpawnedPatch
	{
		private static void Postfix(GameManager __instance)
		{
			//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_0047: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (((SimulationBehaviour)__instance).Runner.SessionInfo.IsOpen && ((SimulationBehaviour)__instance).Runner.IsServer)
				{
					NetworkPrefabId networkObject = NetworkObjectService.Instance.GetNetworkObject(GlobalManager.GetPrefabName(GlobalManager.PlayerMapCustomRegistryName));
					((SimulationBehaviour)__instance).Runner.Spawn(networkObject, (Vector3?)null, (Quaternion?)null, (PlayerRef?)null, (OnBeforeSpawned)null, (NetworkObjectPredictionKey?)null, true, (NetworkObject)null);
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("Error: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(NetworkRunner), "Awake")]
	internal class GlobalManagerNetworkRunnerAwakeCreatePrefabsPatch
	{
		private static void Prefix(NetworkRunner __instance)
		{
			try
			{
				Plugin.CreatePrefabs();
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("NetworkRunner Awake error: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(NetworkRunner), "OnDestroy")]
	internal class GlobalManagerNetworkRunnerOnDestroyUnloadPrefabsPatch
	{
		private static void Prefix(NetworkRunner __instance)
		{
			try
			{
				NetworkObjectService.Instance.Clear();
				NetworkProjectConfig.UnloadGlobal();
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("GlobalManagerNetworkRunnerOnDestroyUnloadPrefabsPatch Awake error: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(CharacterMovementHandler), "FixedUpdateNetwork")]
	internal class ChangeGravityPatch
	{
		private static void Postfix(CharacterMovementHandler __instance)
		{
			try
			{
				if ((Object)(object)((Component)__instance).gameObject.GetComponent<GravityComponent>() == (Object)null)
				{
					Traverse.Create((object)__instance).Field<NetworkCharacterControllerPrototypeCustom>("_networkCharacterControllerPrototypeCustom").Value.gravity = -40f;
					if (((SimulationBehaviour)__instance).HasStateAuthority)
					{
						((Component)__instance).gameObject.AddComponent<GravityComponent>();
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("ChangeGravityPatch error: " + ex));
			}
		}
	}
	public class GravityComponent : MonoBehaviour
	{
		private CharacterMovementHandler _characterMovementHandler;

		private NetworkCharacterControllerPrototypeCustom _networkCharacterControllerPrototypeCustom;

		private PlayerController _playerController;

		private float? _initialY = null;

		private void Awake()
		{
			_characterMovementHandler = ((Component)this).GetComponent<CharacterMovementHandler>();
			_networkCharacterControllerPrototypeCustom = Traverse.Create((object)_characterMovementHandler).Field<NetworkCharacterControllerPrototypeCustom>("_networkCharacterControllerPrototypeCustom").Value;
			_playerController = ((Component)this).GetComponent<PlayerController>();
		}

		private void Update()
		{
			//IL_0032: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Invalid comparison between Unknown and I4
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			bool isGrounded = _networkCharacterControllerPrototypeCustom.IsGrounded;
			if (!isGrounded && !_initialY.HasValue)
			{
				_initialY = ((Component)_playerController).transform.position.y;
			}
			if (!isGrounded || !_initialY.HasValue)
			{
				return;
			}
			float num = _initialY.Value - ((Component)_playerController).transform.position.y;
			if ((int)GameManager.LocalGameState == 2 && num > 3f)
			{
				float num2 = (float)GameManager.Instance.MaxHunger * (num * 0.05f);
				PlayerController value = Traverse.Create((object)_characterMovementHandler).Field<PlayerController>("_playerController").Value;
				value.Hunger = Math.Max(value.Hunger - num2, 0f);
				if (value.Hunger <= 0f)
				{
					value.Rpc_Kill(PlayerRef.None);
				}
			}
			_initialY = null;
		}
	}
	public class LadderCustom : MonoBehaviour
	{
		private void Start()
		{
			//IL_0053: 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_0073: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)GameManager.Instance == (Object)null)
				{
					return;
				}
				float? num = null;
				IEnumerable<GameObject> enumerable = from o in Object.FindObjectsOfType<GameObject>()
					where ((Object)o).name == "Ladders"
					select o;
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(((Component)this).transform.position.x, ((Component)this).transform.position.y, ((Component)this).transform.position.z);
				Transform parent = null;
				foreach (GameObject item in enumerable)
				{
					for (int i = 0; i < item.transform.childCount; i++)
					{
						Transform child = item.transform.GetChild(i);
						float num2 = Vector3.Distance(val, ((Component)child).transform.position);
						if (!num.HasValue || num2 < num.Value)
						{
							num = num2;
							parent = child;
						}
					}
				}
				((Component)this).gameObject.transform.parent = parent;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("LadderCustom start error: " + ex));
			}
		}
	}
	public class LadderSpawnComponent : MonoBehaviour
	{
		public string LadderPrefabName;
	}
	public class LootSpawnComponent : MonoBehaviour
	{
		public string LootPrefabName;
	}
	public static class MapManager
	{
		public static Dictionary<int, CustomMap> NewMapsByIdInfo = new Dictionary<int, CustomMap>();

		public static Dictionary<int, GameObject> NewMapsById = new Dictionary<int, GameObject>();

		public static void UpdateMapByPlayersAmount()
		{
			try
			{
				if (GameManager.Instance.MapID <= 2)
				{
					return;
				}
				int num = PlayerRegistry.CountWhere((Predicate<PlayerController>)((PlayerController o) => !NetworkBool.op_Implicit(o.IsDead)));
				GameObject[] source = Resources.FindObjectsOfTypeAll<GameObject>();
				foreach (GameObject item in source.Where((GameObject o) => ((Object)o).name.ToLower().Contains("minimumplayers")))
				{
					int num2 = int.Parse(((Object)item).name.ToLower().Replace("minimumplayers", ""));
					item.SetActive(num >= num2);
				}
				foreach (GameObject item2 in source.Where((GameObject o) => ((Object)o).name.ToLower().Contains("maximumplayers")))
				{
					int num3 = int.Parse(((Object)item2).name.ToLower().Replace("maximumplayers", ""));
					item2.SetActive(num <= num3);
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("UpdateMapByPlayersAmount error: " + ex));
			}
		}

		public static int? FindMapIdByName(string mapName)
		{
			if (NewMapsByIdInfo.Any((KeyValuePair<int, CustomMap> o) => o.Value.MapName == mapName))
			{
				return NewMapsByIdInfo.First((KeyValuePair<int, CustomMap> o) => o.Value.MapName == mapName).Key;
			}
			return null;
		}
	}
	public class CustomMap
	{
		public GameObject MapPrefab;

		public string MapName;
	}
	[HarmonyPatch(typeof(GameState), "Spawned")]
	internal class GameStateSpawnedPostfix
	{
		private static void Postfix(GameState __instance)
		{
			try
			{
				StateMachine<EGameState> value = Traverse.Create((object)__instance).Field<StateMachine<EGameState>>("StateMachine").Value;
				StateHooks<EGameState> obj = value[(EGameState)2];
				obj.onEnter = (Action<EGameState>)Delegate.Combine(obj.onEnter, (Action<EGameState>)delegate(EGameState state)
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					//IL_0003: Invalid comparison between Unknown and I4
					if ((int)state == 1)
					{
						MapManager.UpdateMapByPlayersAmount();
					}
				});
				StateHooks<EGameState> obj2 = value[(EGameState)3];
				obj2.onEnter = (Action<EGameState>)Delegate.Combine(obj2.onEnter, (Action<EGameState>)delegate(EGameState state)
				{
					//IL_0006: 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_0014: Invalid comparison between Unknown and I4
					if (!NetworkBool.op_Implicit(GameManager.LightingManager.IsNight) || (int)state == 4)
					{
						MapManager.UpdateMapByPlayersAmount();
					}
				});
				StateHooks<EGameState> obj3 = value[(EGameState)2];
				obj3.onEnter = (Action<EGameState>)Delegate.Combine(obj3.onEnter, (Action<EGameState>)delegate(EGameState state)
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					//IL_0003: Invalid comparison between Unknown and I4
					if ((int)state == 4)
					{
						MapManager.UpdateMapByPlayersAmount();
					}
				});
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("GameManagerStartGamePatch error: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(GameManager), "StartGame")]
	internal class GameManagerStartGamePatch
	{
		private static void Prefix(GameManager __instance)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			try
			{
				if (((SimulationBehaviour)__instance).Runner.IsServer && (int)GameManager.State.Current == 1)
				{
					MapManager.UpdateMapByPlayersAmount();
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("GameManagerStartGamePatch error: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(GameManager), "EndVote")]
	internal class GameManagerEndVotePatch
	{
		private static void Postfix(GameManager __instance)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!NetworkBool.op_Implicit(__instance.IsFinished))
				{
					MapManager.UpdateMapByPlayersAmount();
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("GameManagerEndVotePatch error: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(GameManager), "Awake")]
	internal class GameManagerAwakePatch
	{
		private static void Prefix(GameManager __instance)
		{
			//IL_012e: 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)
			try
			{
				foreach (KeyValuePair<int, GameObject> item2 in MapManager.NewMapsById)
				{
					Object.Destroy((Object)(object)item2.Value);
				}
				MapManager.NewMapsById.Clear();
				int num = 3000;
				int num2 = 3;
				foreach (KeyValuePair<int, AssetBundle> item3 in Plugin.AssetBundlesByMapId)
				{
					string[] allAssetNames = item3.Value.GetAllAssetNames();
					string text = allAssetNames.FirstOrDefault((string o) => o.Contains("map.prefab"));
					if (!MapManager.NewMapsByIdInfo.ContainsKey(item3.Key))
					{
						GameObject val = item3.Value.LoadAsset<GameObject>(text);
						val.SetActive(false);
						MapManager.NewMapsByIdInfo[item3.Key] = new CustomMap
						{
							MapPrefab = val,
							MapName = ((Object)item3.Value).name
						};
					}
					GameObject val2 = Object.Instantiate<GameObject>(MapManager.NewMapsByIdInfo[item3.Key].MapPrefab, new Vector3(0f, 0f, (float)num), Quaternion.identity, GameObject.Find("World").transform);
					val2.SetActive(true);
					MapManager.NewMapsById[num2] = val2;
					GameObject[] source = Object.FindObjectsOfType<GameObject>(true);
					List<GameObject> list = source.Where((GameObject obj) => ((Object)obj).name.ToLower() == "teleporter").ToList();
					foreach (GameObject item4 in list)
					{
						item4.gameObject.RemoveAllChildren();
						Teleporter val3 = item4.gameObject.AddComponent<Teleporter>();
						Traverse.Create((object)val3).Field<int>("mapID").Value = num2;
					}
					List<GameObject> list2 = source.Where((GameObject obj) => ((Object)obj).name == "ItemSpawn").ToList();
					foreach (GameObject item5 in list2)
					{
						item5.gameObject.RemoveAllChildren();
						ItemSpawner val4 = item5.gameObject.AddComponent<ItemSpawner>();
						Traverse.Create((object)val4).Field<int>("mapID").Value = num2;
					}
					List<Transform> list3 = Traverse.Create((object)__instance).Field<Transform[]>("mapSpawns").Value.ToList();
					Transform item = MapManager.NewMapsById[num2].transform.Find("MapSpawn");
					list3.Add(item);
					Traverse.Create((object)__instance).Field<Transform[]>("mapSpawns").Value = list3.ToArray();
					num += 3000;
					num2++;
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("GameManagerAwakePatch error: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(GameManager), "GetAndLockRandomItemSpawn")]
	internal class GameManagerGetAndLockRandomItemSpawnPatch
	{
		private static bool Prefix(GameManager __instance, ref ItemSpawner __result)
		{
			try
			{
				Dictionary<ItemSpawner, bool> value = Traverse.Create((object)__instance).Field<Dictionary<ItemSpawner, bool>>("_spawnedItems").Value;
				List<ItemSpawner> list = value.Where(delegate(KeyValuePair<ItemSpawner, bool> sp)
				{
					KeyValuePair<ItemSpawner, bool> keyValuePair = sp;
					int result;
					if (((Component)keyValuePair.Key).gameObject.activeSelf)
					{
						keyValuePair = sp;
						if (!keyValuePair.Value)
						{
							keyValuePair = sp;
							result = ((keyValuePair.Key.MapID == __instance.MapID) ? 1 : 0);
							goto IL_003e;
						}
					}
					result = 0;
					goto IL_003e;
					IL_003e:
					return (byte)result != 0;
				}).ToDictionary((KeyValuePair<ItemSpawner, bool> sp) => sp.Key, (KeyValuePair<ItemSpawner, bool> sp) => sp.Value).Keys.ToList();
				if (list.Any())
				{
					ItemSpawner val = CollectionsUtil.Grab<ItemSpawner>(list, 1).First();
					value[val] = true;
					__result = val;
					return false;
				}
				__result = null;
				return false;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("GameManagerGetAndLockRandomItemSpawnPatch error: " + ex));
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(GameManager), "MapChanged")]
	internal class MapChangedPatch
	{
		private static void Postfix(Changed<GameManager> changed)
		{
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_042d: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_077a: Unknown result type (might be due to invalid IL or missing references)
			//IL_078b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				GameManager behaviour = changed.Behaviour;
				if (((SimulationBehaviour)behaviour).Runner.IsServer)
				{
					List<Loot> list = (from o in Object.FindObjectsOfType<Loot>(true)
						where o.GetMapID() >= 3
						select o).ToList();
					for (int num = list.Count - 1; num >= 0; num--)
					{
						((SimulationBehaviour)behaviour).Runner.Despawn(((Component)list[num]).GetComponent<NetworkObject>(), false);
					}
					List<DoorCustom> list2 = Object.FindObjectsOfType<DoorCustom>(false).ToList();
					for (int num2 = list2.Count - 1; num2 >= 0; num2--)
					{
						((SimulationBehaviour)behaviour).Runner.Despawn(((Component)list2[num2]).GetComponent<NetworkObject>(), false);
					}
					List<LadderCustom> list3 = Object.FindObjectsOfType<LadderCustom>(false).ToList();
					for (int num3 = list3.Count - 1; num3 >= 0; num3--)
					{
						((SimulationBehaviour)behaviour).Runner.Despawn(((Component)list3[num3]).GetComponent<NetworkObject>(), false);
					}
				}
				if (behaviour.MapID > 2)
				{
					GameObject[] source = Object.FindObjectsOfType<GameObject>(true);
					GameObject val = MapManager.NewMapsById[behaviour.MapID];
					List<GameObject> list4 = source.Where((GameObject obj) => ((Object)obj).name == "FoodSpawn").ToList();
					foreach (GameObject item in list4)
					{
						if (!item.gameObject.activeSelf)
						{
							continue;
						}
						LootSpawnComponent component = item.GetComponent<LootSpawnComponent>();
						string text;
						if ((Object)(object)component != (Object)null)
						{
							text = component.LootPrefabName;
						}
						else
						{
							Transform child = item.transform.GetChild(0);
							if ((Object)(object)child == (Object)null)
							{
								Plugin.Logger.LogError((object)("Missing food name for: " + ((Object)item).name));
							}
							text = ((Object)((Component)child).gameObject).name;
							component = item.AddComponent<LootSpawnComponent>();
							component.LootPrefabName = text;
						}
						item.gameObject.RemoveAllChildren();
						if (((SimulationBehaviour)behaviour).Runner.IsServer)
						{
							NetworkPrefabId networkObject = NetworkObjectService.Instance.GetNetworkObject(GlobalManager.GetPrefabName(text));
							NetworkObject val2 = ((SimulationBehaviour)behaviour).Runner.Spawn(networkObject, (Vector3?)item.transform.position, (Quaternion?)item.transform.rotation, (PlayerRef?)null, (OnBeforeSpawned)null, (NetworkObjectPredictionKey?)null, true, (NetworkObject)null);
							((Component)val2).transform.parent = item.transform.parent;
							Loot component2 = ((Component)val2).GetComponent<Loot>();
							Traverse.Create((object)component2).Field<int>("map").Value = behaviour.MapID;
						}
					}
					List<GameObject> list5 = source.Where((GameObject obj) => ((Object)obj).name.Contains("DoorSpawn:")).ToList();
					foreach (GameObject item2 in list5)
					{
						if (!item2.gameObject.activeSelf)
						{
							continue;
						}
						DoorSpawnComponent component3 = item2.GetComponent<DoorSpawnComponent>();
						string text2;
						if ((Object)(object)component3 != (Object)null)
						{
							text2 = component3.DoorPrefabName;
						}
						else
						{
							Transform child2 = item2.transform.GetChild(0);
							if ((Object)(object)child2 == (Object)null)
							{
								Plugin.Logger.LogError((object)("Missing door name for: " + ((Object)item2).name));
							}
							text2 = ((Object)((Component)child2).gameObject).name;
							component3 = item2.AddComponent<DoorSpawnComponent>();
							component3.DoorPrefabName = text2;
						}
						item2.gameObject.RemoveAllChildren();
						if (((SimulationBehaviour)behaviour).Runner.IsServer)
						{
							NetworkPrefabId networkObject2 = NetworkObjectService.Instance.GetNetworkObject(GlobalManager.GetPrefabName(text2));
							NetworkObject val3 = ((SimulationBehaviour)behaviour).Runner.Spawn(networkObject2, (Vector3?)item2.transform.position, (Quaternion?)item2.transform.rotation, (PlayerRef?)null, (OnBeforeSpawned)null, (NetworkObjectPredictionKey?)null, true, (NetworkObject)null);
							((Component)val3).transform.parent = item2.transform.parent;
						}
					}
					List<GameObject> list6 = source.Where((GameObject obj) => ((Object)obj).name.Contains("LadderSpawn:")).ToList();
					foreach (GameObject item3 in list6)
					{
						if (!item3.gameObject.activeSelf)
						{
							continue;
						}
						LadderSpawnComponent component4 = item3.GetComponent<LadderSpawnComponent>();
						string text3;
						if ((Object)(object)component4 != (Object)null)
						{
							text3 = component4.LadderPrefabName;
						}
						else
						{
							Transform child3 = item3.transform.GetChild(0);
							if ((Object)(object)child3 == (Object)null)
							{
								Plugin.Logger.LogError((object)("Missing ladder name for: " + ((Object)item3).name));
							}
							text3 = ((Object)((Component)child3).gameObject).name;
							component4 = item3.AddComponent<LadderSpawnComponent>();
							component4.LadderPrefabName = text3;
						}
						item3.gameObject.RemoveAllChildren();
						if (((SimulationBehaviour)behaviour).Runner.IsServer)
						{
							NetworkPrefabId networkObject3 = NetworkObjectService.Instance.GetNetworkObject(GlobalManager.GetPrefabName(text3));
							NetworkObject val4 = ((SimulationBehaviour)behaviour).Runner.Spawn(networkObject3, (Vector3?)item3.transform.position, (Quaternion?)item3.transform.rotation, (PlayerRef?)null, (OnBeforeSpawned)null, (NetworkObjectPredictionKey?)null, true, (NetworkObject)null);
							((Component)val4).transform.parent = item3.transform.parent;
						}
					}
					RoomNameComponent.RoomKeyByIndex.Clear();
					List<GameObject> source2 = source.Where((GameObject obj) => ((Object)obj).name.Contains("RoomKey")).ToList();
					foreach (GameObject item4 in source2.OrderBy((GameObject o) => ((Object)o).name))
					{
						RoomNameComponent roomNameComponent = item4.gameObject.AddComponent<RoomNameComponent>();
						roomNameComponent.Init(((Object)item4).name.Replace("RoomKey:", ""));
						if (!((SimulationBehaviour)behaviour).Runner.IsServer)
						{
							Object.Destroy((Object)(object)((Component)roomNameComponent).GetComponent<Collider>());
						}
					}
					Transform val5 = val.transform.Find("SpecialArchitecture");
					if ((Object)(object)val5 != (Object)null)
					{
						Transform val6 = val5.Find("MovingFloors");
						if ((Object)(object)val6 != (Object)null)
						{
							int childCount = val6.childCount;
							for (int i = 0; i < childCount; i++)
							{
								Transform child4 = val6.GetChild(i);
								MovingPlatform movingPlatform = ((Component)child4).gameObject.AddComponent<MovingPlatform>();
								movingPlatform.Init(child4.position, child4.Find("Destination").position);
								((Component)child4).gameObject.RemoveAllChildren();
							}
						}
					}
				}
				((Behaviour)Traverse.Create((object)GameManager.LightingManager).Field<Light>("directionalLight").Value).enabled = behaviour.MapID <= 2;
				foreach (PlayerMapCustom allPlayer in PlayerMapCustomRegistry.AllPlayers)
				{
					allPlayer.Reset();
				}
				DungeonMap.Lights.Clear();
				Light[] source3 = Resources.FindObjectsOfTypeAll<Light>();
				DungeonMap.Lights.AddRange(source3.Where((Light o) => ((Object)((Component)o).gameObject).name == "RoomCenterLight"));
				if (behaviour.MapID == MapManager.FindMapIdByName("dungeonmap"))
				{
					AudioManager.StopMusic();
					foreach (Light light in DungeonMap.Lights)
					{
						((Component)light).gameObject.SetActive(true);
						light.color = DungeonMap.TorchColorDaytime;
						light.intensity = DungeonMap.TorchIntensityDaytime;
					}
					{
						foreach (PlayerMapCustom allPlayer2 in PlayerMapCustomRegistry.AllPlayers)
						{
							allPlayer2.CurrentRoomIndex = RoomNameComponent.RoomKeyByIndex.First((KeyValuePair<int, string> o) => o.Value == "ROOM_CENTRAL").Key;
						}
						return;
					}
				}
				AudioManager.PlayMusic("DAY", 1f);
				foreach (Light light2 in DungeonMap.Lights)
				{
					((Component)light2).gameObject.SetActive(false);
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("MapChangedPatch error: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(GameSettingsUI), "Start")]
	internal class GameConfigAddNewMapPatch
	{
		private static void Postfix(GameSettingsUI __instance)
		{
			try
			{
				for (int i = 0; i < Plugin.AssetBundlesByMapId.Count; i++)
				{
					Traverse.Create((object)__instance).Field<TMP_Dropdown>("mapDropdown").Value.AddOptions(new List<string> { (i + 3).ToString() });
				}
				Traverse.Create((object)__instance).Method("FillMapDropdown", Array.Empty<object>()).GetValue();
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("GameConfigAddNewMapPatch error: " + ex));
			}
		}
	}
	internal class NetworkObjectService
	{
		private static NetworkObjectService? _instance;

		private Dictionary<string, NetworkPrefabId> _prefabs;

		public static NetworkObjectService Instance
		{
			get
			{
				if (_instance == null)
				{
					_instance = new NetworkObjectService();
				}
				return _instance;
			}
		}

		private NetworkObjectService()
		{
			_prefabs = new Dictionary<string, NetworkPrefabId>();
		}

		public void RegisterNetworkObject(GameObject prefab, string uniqueKey)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			if (_prefabs.ContainsKey(uniqueKey))
			{
				throw new InvalidOperationException("Key '" + uniqueKey + "' already exists");
			}
			NetworkObject component = prefab.GetComponent<NetworkObject>();
			if ((Object)(object)component == (Object)null)
			{
				throw new MissingComponentException("Prefab is missing 'NetworkObject' component!");
			}
			component.NetworkedBehaviours = prefab.GetComponents<NetworkBehaviour>();
			component.NetworkGuid = new NetworkObjectGuid(uniqueKey.ToGuid().ToString());
			NetworkPrefabSourceUnityStatic val = ScriptableObject.CreateInstance<NetworkPrefabSourceUnityStatic>();
			val.PrefabReference = ((Component)component).gameObject;
			NetworkPrefabId value = default(NetworkPrefabId);
			if (!NetworkProjectConfig.Global.PrefabTable.TryAdd(component.NetworkGuid, (INetworkPrefabSource)(object)val, ref value))
			{
				throw new ApplicationException("Could not add prefab to registered prefabs, was it already present?");
			}
			_prefabs.Add(uniqueKey, value);
		}

		public NetworkPrefabId GetNetworkObject(string uniqueKey)
		{
			//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_002d: Unknown result type (might be due to invalid IL or missing references)
			if (_prefabs.TryGetValue(uniqueKey, out var value))
			{
				return value;
			}
			throw new KeyNotFoundException("No prefab registered with '" + uniqueKey + "' as identifier!");
		}

		public void Clear()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<string, NetworkPrefabId> prefab in _prefabs)
			{
				NetworkProjectConfig.Global.PrefabTable.Unload(prefab.Value);
			}
			_prefabs.Clear();
		}
	}
	internal static class StringExtensions
	{
		public static Guid ToGuid(this string value)
		{
			return new Guid(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(value)));
		}
	}
	[NetworkBehaviourWeaved(10)]
	public class PlayerMapCustom : NetworkBehaviour
	{
		[Networked]
		[NetworkedWeaved(0, 1)]
		public unsafe PlayerRef Ref
		{
			get
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing PlayerMapCustom.Ref. Networked properties can only be accessed when Spawned() has been called.");
				}
				return (PlayerRef)(*base.Ptr);
			}
			private set
			{
				//IL_0021: 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)
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing PlayerMapCustom.Ref. Networked properties can only be accessed when Spawned() has been called.");
				}
				Unsafe.Write(base.Ptr, value);
			}
		}

		[Networked]
		[NetworkedWeaved(1, 1)]
		public unsafe byte Index
		{
			get
			{
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing PlayerMapCustom.Index. Networked properties can only be accessed when Spawned() has been called.");
				}
				return *(byte*)(base.Ptr + 1);
			}
			private set
			{
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing PlayerMapCustom.Index. Networked properties can only be accessed when Spawned() has been called.");
				}
				*(byte*)(base.Ptr + 1) = value;
			}
		}

		[Networked(OnChanged = "CurrentRoomIndexChanged")]
		[NetworkedWeaved(2, 1)]
		public unsafe int CurrentRoomIndex
		{
			get
			{
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing PlayerMapCustom.CurrentRoomIndex. Networked properties can only be accessed when Spawned() has been called.");
				}
				return base.Ptr[2];
			}
			set
			{
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing PlayerMapCustom.CurrentRoomIndex. Networked properties can only be accessed when Spawned() has been called.");
				}
				base.Ptr[2] = value;
			}
		}

		public void Server_Init(PlayerRef pRef, byte index)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			Ref = pRef;
			Index = index;
			if (GameManager.Instance.MapID == MapManager.FindMapIdByName("dungeonmap") && RoomNameComponent.RoomKeyByIndex.Any((KeyValuePair<int, string> o) => o.Value == "ROOM_CENTRAL"))
			{
				CurrentRoomIndex = RoomNameComponent.RoomKeyByIndex.First((KeyValuePair<int, string> o) => o.Value == "ROOM_CENTRAL").Key;
			}
		}

		public void Reset()
		{
			CurrentRoomIndex = 0;
		}

		[Preserve]
		public static void CurrentRoomIndexChanged(Changed<PlayerMapCustom> changed)
		{
			//IL_0022: 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)
			try
			{
				PlayerMapCustom behaviour = changed.Behaviour;
				if ((Object)(object)PlayerController.Local.LocalCameraHandler.PovPlayer != (Object)null && behaviour.Ref == PlayerController.Local.LocalCameraHandler.PovPlayer.Ref)
				{
					behaviour.RefreshCurrentRoomUI();
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("CurrentRoomIndexChanged error: " + ex));
			}
		}

		public void RefreshCurrentRoomUI()
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PlayerController player = PlayerRegistry.GetPlayer(Ref);
				if (CurrentRoomIndex != 0)
				{
					UICurrentRoom.Instance.Show(active: true, RoomNameComponent.RoomKeyByIndex[CurrentRoomIndex]);
				}
				else
				{
					UICurrentRoom.Instance.Show(active: false, null);
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("RefreshCurrentRoomUI error: " + ex));
			}
		}
	}
	[StructLayout(LayoutKind.Sequential, Size = 1)]
	internal struct PlayerMapCustomReaderWriter : IElementReaderWriter<PlayerRef>
	{
		public static IElementReaderWriter<PlayerRef> Instance;

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public unsafe PlayerRef Read(byte* data, int index)
		{
			//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)
			return (PlayerRef)data[index * 4];
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public unsafe ref PlayerRef ReadRef(byte* data, int index)
		{
			return ref *(PlayerRef*)(data + index * 4);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public unsafe void Write(byte* data, int index, PlayerRef val)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Unsafe.Write(data + index * 4, val);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public int GetElementWordCount()
		{
			return 1;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public static IElementReaderWriter<PlayerRef> GetInstance()
		{
			if (Instance == null)
			{
				Instance = default(PlayerMapCustomReaderWriter);
			}
			return Instance;
		}
	}
	[NetworkBehaviourWeaved(88)]
	public class PlayerMapCustomRegistry : NetworkBehaviour, INetworkRunnerCallbacks, IElementReaderWriter<PlayerMapCustom>
	{
		[DefaultForProperty("PlayersMapCustom", 0, 88)]
		private SerializableDictionary<PlayerRef, PlayerMapCustom> _PlayersMapCustom;

		public static PlayerMapCustomRegistry Instance { get; private set; }

		[Networked]
		[Capacity(15)]
		[NetworkedWeaved(0, 88)]
		private unsafe NetworkDictionary<PlayerRef, PlayerMapCustom> PlayersMapCustom
		{
			get
			{
				//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_0031: Unknown result type (might be due to invalid IL or missing references)
				if (base.Ptr == null)
				{
					throw new InvalidOperationException("Error when accessing PlayerMapCustomManager.PlayersMapCustom. Networked properties can only be accessed when Spawned() has been called.");
				}
				return new NetworkDictionary<PlayerRef, PlayerMapCustom>(base.Ptr, 17, PlayerMapCustomReaderWriter.GetInstance(), (IElementReaderWriter<PlayerMapCustom>)this);
			}
		}

		public static List<PlayerMapCustom> AllPlayers => ((IEnumerable<KeyValuePair<PlayerRef, PlayerMapCustom>>)(object)Instance.PlayersMapCustom).Select((KeyValuePair<PlayerRef, PlayerMapCustom> o) => o.Value).ToList();

		public override void Spawned()
		{
			((NetworkBehaviour)this).Spawned();
			Instance = this;
			((SimulationBehaviour)this).Runner.AddCallbacks((INetworkRunnerCallbacks[])(object)new INetworkRunnerCallbacks[1] { this });
		}

		public override void Despawned(NetworkRunner runner, bool hasState)
		{
			((NetworkBehaviour)this).Despawned(runner, hasState);
			Instance = null;
			runner.RemoveCallbacks((INetworkRunnerCallbacks[])(object)new INetworkRunnerCallbacks[1] { this });
		}

		private bool GetAvailable(out byte index)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			if (PlayersMapCustom.Count == 0)
			{
				index = 0;
				return true;
			}
			if (PlayersMapCustom.Count == 15)
			{
				index = 0;
				return false;
			}
			byte[] array = ((IEnumerable<KeyValuePair<PlayerRef, PlayerMapCustom>>)(object)PlayersMapCustom).OrderBy(delegate(KeyValuePair<PlayerRef, PlayerMapCustom> kvp)
			{
				KeyValuePair<PlayerRef, PlayerMapCustom> keyValuePair2 = kvp;
				return keyValuePair2.Value.Index;
			}).Select(delegate(KeyValuePair<PlayerRef, PlayerMapCustom> kvp)
			{
				KeyValuePair<PlayerRef, PlayerMapCustom> keyValuePair = kvp;
				return keyValuePair.Value.Index;
			}).ToArray();
			for (int i = 0; i < array.Length - 1; i++)
			{
				if (array[i + 1] > array[i] + 1)
				{
					index = (byte)(array[i] + 1);
					return true;
				}
			}
			index = (byte)(array[^1] + 1);
			return true;
		}

		public static void Server_Add(NetworkRunner runner, PlayerRef pRef, PlayerMapCustom pObj)
		{
			//IL_0037: 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_001f: 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)
			if (Instance.GetAvailable(out var index))
			{
				Instance.PlayersMapCustom.Add(pRef, pObj);
				pObj.Server_Init(pRef, index);
			}
			else
			{
				Debug.LogWarning((object)$"Unable to register player {pRef}", (Object)(object)pObj);
			}
		}

		public static void Server_Remove(NetworkRunner runner, PlayerRef pRef)
		{
			//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)
			if (!Instance.PlayersMapCustom.Remove(pRef))
			{
				Debug.LogWarning((object)"Could not remove player from registry");
			}
		}

		public static bool HasPlayer(PlayerRef pRef)
		{
			//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)
			return Instance.PlayersMapCustom.ContainsKey(pRef);
		}

		public static PlayerMapCustom GetPlayer(int index)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return ((IEnumerable<KeyValuePair<PlayerRef, PlayerMapCustom>>)(object)Instance.PlayersMapCustom).First((KeyValuePair<PlayerRef, PlayerMapCustom> o) => o.Value.Index == index).Value;
		}

		public static PlayerMapCustom GetPlayer(PlayerRef pRef)
		{
			//IL_0001: 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)
			if (HasPlayer(pRef))
			{
				return Instance.PlayersMapCustom.Get(pRef);
			}
			return null;
		}

		public static IEnumerable<PlayerMapCustom> Where(Predicate<PlayerMapCustom> match)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return ((IEnumerable<KeyValuePair<PlayerRef, PlayerMapCustom>>)(object)Instance.PlayersMapCustom).Where(delegate(KeyValuePair<PlayerRef, PlayerMapCustom> kvp)
			{
				Predicate<PlayerMapCustom> predicate = match;
				KeyValuePair<PlayerRef, PlayerMapCustom> keyValuePair2 = kvp;
				return predicate(keyValuePair2.Value);
			}).Select(delegate(KeyValuePair<PlayerRef, PlayerMapCustom> kvp)
			{
				KeyValuePair<PlayerRef, PlayerMapCustom> keyValuePair = kvp;
				return keyValuePair.Value;
			});
		}

		public static void ForEach(Action<PlayerMapCustom> action)
		{
			//IL_0007: 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_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)
			Enumerator<PlayerRef, PlayerMapCustom> enumerator = Instance.PlayersMapCustom.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					action(enumerator.Current.Value);
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
		}

		public static void ForEachWhere(Predicate<PlayerMapCustom> match, Action<PlayerMapCustom> action)
		{
			//IL_0007: 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_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)
			Enumerator<PlayerRef, PlayerMapCustom> enumerator = Instance.PlayersMapCustom.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					KeyValuePair<PlayerRef, PlayerMapCustom> current = enumerator.Current;
					if (match(current.Value))
					{
						action(current.Value);
					}
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
		}

		public static int CountWhere(Predicate<PlayerMapCustom> match)
		{
			//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_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)
			int num = 0;
			Enumerator<PlayerRef, PlayerMapCustom> enumerator = Instance.PlayersMapCustom.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					if (match(enumerator.Current.Value))
					{
						num++;
					}
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			return num;
		}

		public static bool Any(Predicate<PlayerMapCustom> match)
		{
			//IL_0007: 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_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)
			Enumerator<PlayerRef, PlayerMapCustom> enumerator = Instance.PlayersMapCustom.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					if (match(enumerator.Current.Value))
					{
						return true;
					}
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			return false;
		}

		void INetworkRunnerCallbacks.OnPlayerLeft(NetworkRunner runner, PlayerRef player)
		{
		}

		void INetworkRunnerCallbacks.OnPlayerJoined(NetworkRunner runner, PlayerRef player)
		{
		}

		void INetworkRunnerCallbacks.OnInput(NetworkRunner runner, NetworkInput input)
		{
		}

		void INetworkRunnerCallbacks.OnInputMissing(NetworkRunner runner, PlayerRef player, NetworkInput input)
		{
		}

		void INetworkRunnerCallbacks.OnShutdown(NetworkRunner runner, ShutdownReason shutdownReason)
		{
		}

		void INetworkRunnerCallbacks.OnConnectedToServer(NetworkRunner runner)
		{
		}

		void INetworkRunnerCallbacks.OnDisconnectedFromServer(NetworkRunner runner)
		{
		}

		void INetworkRunnerCallbacks.OnConnectRequest(NetworkRunner runner, ConnectRequest request, byte[] token)
		{
		}

		void INetworkRunnerCallbacks.OnConnectFailed(NetworkRunner runner, NetAddress remoteAddress, NetConnectFailedReason reason)
		{
		}

		void INetworkRunnerCallbacks.OnUserSimulationMessage(NetworkRunner runner, SimulationMessagePtr message)
		{
		}

		void INetworkRunnerCallbacks.OnSessionListUpdated(NetworkRunner runner, List<SessionInfo> sessionList)
		{
		}

		void INetworkRunnerCallbacks.OnCustomAuthenticationResponse(NetworkRunner runner, Dictionary<string, object> data)
		{
		}

		void INetworkRunnerCallbacks.OnReliableDataReceived(NetworkRunner runner, PlayerRef player, ArraySegment<byte> data)
		{
		}

		void INetworkRunnerCallbacks.OnSceneLoadDone(NetworkRunner runner)
		{
		}

		void INetworkRunnerCallbacks.OnSceneLoadStart(NetworkRunner runner)
		{
		}

		void INetworkRunnerCallbacks.OnHostMigration(NetworkRunner runner, HostMigrationToken hostMigrationToken)
		{
		}

		unsafe PlayerMapCustom IElementReaderWriter<PlayerMapCustom>.Read(byte* data, int index)
		{
			NetworkBehaviour val = null;
			ReadWriteUtilsForWeaver.VerifyRawNetworkUnwrap<PlayerMapCustom>(NetworkBehaviour.NetworkDeserialize(((SimulationBehaviour)this).Runner, data + index * 8, ref val), 8);
			return (PlayerMapCustom)(object)val;
		}

		public unsafe ref PlayerMapCustom ReadRef(byte* data, int index)
		{
			throw new NotSupportedException("Only supported for trivially copyable types. PlayerMapCustom is not trivially copyable.");
		}

		unsafe void IElementReaderWriter<PlayerMapCustom>.Write(byte* data, int index, PlayerMapCustom val)
		{
			ReadWriteUtilsForWeaver.VerifyRawNetworkWrap<PlayerMapCustom>(NetworkBehaviour.NetworkSerialize(((SimulationBehaviour)this).Runner, (NetworkBehaviour)(object)val, data + index * 8), 8);
		}

		public int GetElementWordCount()
		{
			return 2;
		}

		public override void CopyBackingFieldsToState(bool A_1)
		{
			//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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			int num = _PlayersMapCustom?.Count ?? 0;
			if (num == 0)
			{
				return;
			}
			if (num > PlayersMapCustom.Capacity)
			{
				Log.Error((object)$"Source dictionary is too long for {((Object)this).name} with capacity of {PlayersMapCustom.Capacity}: {num}. Ignoring extra elements.");
				num = PlayersMapCustom.Capacity;
			}
			PlayersMapCustom.Clear();
			foreach (KeyValuePair<PlayerRef, PlayerMapCustom> item in _PlayersMapCustom)
			{
				if (--num < 0)
				{
					break;
				}
				PlayersMapCustom.Add(item.Key, item.Value);
			}
		}

		public override void CopyStateToBackingFields()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (_PlayersMapCustom == null)
			{
				_PlayersMapCustom = new SerializableDictionary<PlayerRef, PlayerMapCustom>();
			}
			else
			{
				_PlayersMapCustom.Clear();
			}
			Enumerator<PlayerRef, PlayerMapCustom> enumerator = PlayersMapCustom.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					KeyValuePair<PlayerRef, PlayerMapCustom> current = enumerator.Current;
					_PlayersMapCustom.Add(current.Key, current.Value);
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
		}
	}
	[HarmonyPatch(typeof(PlayerController), "Spawned")]
	internal class AddPlayerAddCustomPlayerPatch
	{
		private static void Postfix(PlayerController __instance)
		{
			//IL_002b: 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_0075: 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_0096: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				CharacterController component = ((Component)__instance).GetComponent<CharacterController>();
				component.center = new Vector3(0f, 0.8f, 0f);
				component.height = 1.5f;
				if (((SimulationBehaviour)__instance).HasStateAuthority)
				{
					NetworkPrefabId networkObject = NetworkObjectService.Instance.GetNetworkObject(GlobalManager.GetPrefabName(GlobalManager.PlayerMapCustomName));
					NetworkObject val = ((SimulationBehaviour)__instance).Runner.Spawn(networkObject, (Vector3?)new Vector3(((Component)__instance).transform.position.x, ((Component)__instance).transform.position.y, ((Component)__instance).transform.position.z), (Quaternion?)null, (PlayerRef?)((SimulationBehaviour)__instance).Object.InputAuthority, (OnBeforeSpawned)delegate(NetworkRunner _, NetworkObject no)
					{
						((Component)no).transform.parent = ((Component)__instance).transform;
					}, (NetworkObjectPredictionKey?)null, true, (NetworkObject)null);
					((Component)val).transform.parent = ((Component)__instance).transform;
					PlayerMapCustomRegistry.Server_Add(((SimulationBehaviour)__instance).Runner, ((SimulationBehaviour)__instance).Object.InputAuthority, ((Component)val).GetComponent<PlayerMapCustom>());
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("AddPlayerAddCustomPlayerPatch error: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(GameManager), "Rpc_DeletePlayer")]
	internal class DeletePlayerDeleteCustomPlayerPatch
	{
		private static void Postfix(NetworkRunner runner, PlayerRef playerRef)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Invalid comparison between Unknown and I4
			//IL_002a: 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)
			if ((NetworkBehaviourUtils.InvokeRpc || (int)runner.Stage != 4) && runner.IsServer)
			{
				PlayerMapCustom player = PlayerMapCustomRegistry.GetPlayer(playerRef);
				if ((Object)(object)player != (Object)null)
				{
					PlayerMapCustomRegistry.Server_Remove(runner, playerRef);
					runner.Despawn(((SimulationBehaviour)player).Object, false);
				}
			}
		}
	}
	[BepInPlugin("LycansNewMaps", "Lycans New Maps", "0.13")]
	public class Plugin : BaseUnityPlugin
	{
		public static NetworkObject NetworkObject;

		internal static ManualLogSource Logger;

		public static string Location;

		public static AssetBundle CoreBundle;

		public static Dictionary<int, AssetBundle> AssetBundlesByMapId;

		public const string CoreBundleName = "lycansnewmaps";

		private void Awake()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			try
			{
				Logger = ((BaseUnityPlugin)this).Logger;
				Logger.LogInfo((object)"Plugin LycansNewMaps is loaded!");
				TranslationManager.Instance.Initialize();
				Harmony val = new Harmony("lycans.nalesnewmaps");
				HarmonyFileLog.Enabled = true;
				val.PatchAll();
				Logger.LogInfo((object)"Harmony patched!");
				Location = ((BaseUnityPlugin)this).Info.Location;
				try
				{
					AssetBundlesByMapId = new Dictionary<int, AssetBundle>();
					string path = Path.GetDirectoryName(Location) + "/resources/";
					List<string> source = Directory.EnumerateFiles(path).ToList();
					int num = 3;
					foreach (string item in source.Where((string o) => !o.Contains(".json")))
					{
						string text = item.Split('/').Last();
						if (text == "lycansnewmaps")
						{
							CoreBundle = AssetBundle.LoadFromFile(item);
							continue;
						}
						AssetBundlesByMapId[num] = AssetBundle.LoadFromFile(item);
						Logger.LogInfo((object)("Bundle " + text + " loaded"));
						num++;
					}
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("Error loading bundle: " + ex));
				}
			}
			catch (Exception ex2)
			{
				Logger.LogError((object)("Error initializing plugin: " + ex2));
			}
		}

		public static void CreatePrefabs()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Logger.LogInfo((object)"CreatePrefabs...");
				GameObject val = new GameObject("PlayerMapCustomRegistry");
				val.AddComponent<NetworkObject>();
				val.AddComponent<PlayerMapCustomRegistry>();
				val.SetActive(false);
				NetworkObjectService.Instance.RegisterNetworkObject(val, GlobalManager.PlayerMapCustomRegistryName);
				GameObject val2 = new GameObject("PlayerMapCustom");
				val2.AddComponent<NetworkObject>();
				val2.AddComponent<NetworkTransform>();
				val2.AddComponent<PlayerMapCustom>();
				val2.SetActive(false);
				NetworkObjectService.Instance.RegisterNetworkObject(val2, GlobalManager.PlayerMapCustomName);
				foreach (KeyValuePair<int, AssetBundle> item in AssetBundlesByMapId)
				{
					foreach (string item2 in from o in item.Value.GetAllAssetNames()
						where o.Contains("food_") && o.Contains(".prefab")
						select o)
					{
						GameObject val3 = item.Value.LoadAsset<GameObject>(item2);
						GameObject val4 = Object.Instantiate<GameObject>(val3);
						val4.AddComponent<NetworkObject>();
						val4.AddComponent<NetworkTransform>();
						Loot val5 = val4.AddComponent<Loot>();
						Traverse.Create((object)val5).Field<NetworkBool>("_Available").Value = NetworkBool.op_Implicit(false);
						int value = 0;
						if (item2.Contains("rarity0"))
						{
							value = 0;
						}
						else if (item2.Contains("rarity1"))
						{
							value = 1;
						}
						else if (item2.Contains("rarity2"))
						{
							value = 2;
						}
						else if (item2.Contains("rarity3"))
						{
							value = 3;
						}
						Traverse.Create((object)val5).Field<int>("rarity").Value = value;
						if (item2.Contains("notfood"))
						{
							Traverse.Create((object)val5).Field<bool>("notFood").Value = true;
						}
						val4.SetActive(false);
						NetworkObjectService.Instance.RegisterNetworkObject(val4.gameObject, ((Object)val3).name);
						Logger.LogInfo((object)("Added loot: " + ((Object)val3).name));
					}
					foreach (string item3 in from o in item.Value.GetAllAssetNames()
						where o.Contains("door_") && o.Contains(".prefab")
						select o)
					{
						GameObject val6 = item.Value.LoadAsset<GameObject>(item3);
						GameObject val7 = Object.Instantiate<GameObject>(val6);
						Door val8 = val7.AddComponent<Door>();
						Traverse.Create((object)val8).Field<GameObject>("locks").Value = ((Component)val7.transform.Find("Lock")).gameObject;
						val7.AddComponent<DoorCustom>();
						val7.SetActive(false);
						NetworkObjectService.Instance.RegisterNetworkObject(val7.gameObject, ((Object)val6).name);
						Logger.LogInfo((object)("Added door: " + ((Object)val6).name));
					}
					foreach (string item4 in from o in item.Value.GetAllAssetNames()
						where o.Contains("ladder_") && o.Contains(".prefab")
						select o)
					{
						GameObject val9 = item.Value.LoadAsset<GameObject>(item4);
						GameObject val10 = Object.Instantiate<GameObject>(val9);
						Ladder val11 = val10.AddComponent<Ladder>();
						Transform val12 = val10.transform.Find("LadderStartTrigger");
						((Component)val12).gameObject.AddComponent<LadderStartTrigger>();
						Transform val13 = val10.transform.Find("LadderEndTrigger");
						LadderEndTrigger val14 = ((Component)val13).gameObject.AddComponent<LadderEndTrigger>();
						Transform value2 = val10.transform.Find("LadderUpClimbingPoint");
						Traverse.Create((object)val14).Field<Transform>("upClimbingPoint").Value = value2;
						Transform value3 = val10.transform.Find("LadderStartPoint");
						Traverse.Create((object)val11).Field<Transform>("startClimbingPoint").Value = value3;
						Transform value4 = val10.transform.Find("LadderEndPoint");
						Traverse.Create((object)val11).Field<Transform>("fallingPoint").Value = value4;
						Traverse.Create((object)val11).Field<NetworkBool>("_CanClimb").Value = NetworkBool.op_Implicit(true);
						val10.AddComponent<LadderCustom>();
						val10.SetActive(false);
						NetworkObjectService.Instance.RegisterNetworkObject(val10.gameObject, ((Object)val9).name);
						Logger.LogInfo((object)("Added ladder: " + ((Object)val9).name));
					}
				}
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Error starting plugin: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(GameUI), "Awake")]
	public class GameUIAwakePatch
	{
		private static void Postfix(GameUI __instance)
		{
			//IL_0077: 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_00a3: 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_00d0: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				TextMeshProUGUI value = Traverse.Create((object)__instance).Field<TextMeshProUGUI>("mmVersionText").Value;
				((TMP_Text)value).text = ((TMP_Text)value).text + Environment.NewLine + "New Maps 0.13";
				GameObject val = Plugin.CoreBundle.LoadAsset<GameObject>("CurrentRoom");
				GameObject val2 = Object.Instantiate<GameObject>(val, ((Component)__instance).transform.Find("Canvas").Find("Fixed"));
				RectTransform component = val2.GetComponent<RectTransform>();
				component.pivot = new Vector2(0f, 1f);
				component.anchorMin = new Vector2(0f, 1f);
				component.anchorMax = new Vector2(0f, 1f);
				val2.transform.position = new Vector3(val2.transform.position.x + 128f, val2.transform.position.y, val2.transform.position.z);
				val2.transform.SetAsLastSibling();
				UICurrentRoom instance = val2.AddComponent<UICurrentRoom>();
				UICurrentRoom.Instance = instance;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("GameUI Awake postfix error: " + ex));
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "LycansNewMaps";

		public const string PLUGIN_NAME = "Lycans New Maps";

		public const string PLUGIN_VERSION = "0.13";
	}
	public class RoomNameComponent : MonoBehaviour
	{
		public static Dictionary<int, string> RoomKeyByIndex = new Dictionary<int, string>();

		private int _index;

		private string _roomKey;

		public void Init(string roomKey)
		{
			try
			{
				_roomKey = roomKey;
				_index = RoomKeyByIndex.Count + 1;
				RoomKeyByIndex[_index] = roomKey;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("RoomNameComponent init error: " + ex));
			}
		}

		private void OnTriggerEnter(Collider other)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((int)GameManager.LocalGameState == 2)
				{
					PlayerController component = ((Component)other).GetComponent<PlayerController>();
					if ((Object)(object)component != (Object)null)
					{
						PlayerMapCustom player = PlayerMapCustomRegistry.GetPlayer(component.Ref);
						player.CurrentRoomIndex = _index;
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("OnTriggerEnter error: " + ex));
			}
		}

		private void OnTriggerExit(Collider other)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PlayerController component = ((Component)other).GetComponent<PlayerController>();
				if ((Object)(object)component != (Object)null)
				{
					PlayerMapCustom player = PlayerMapCustomRegistry.GetPlayer(component.Ref);
					if (player.CurrentRoomIndex == _index)
					{
						player.CurrentRoomIndex = 0;
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("OnTriggerEnter error: " + ex));
			}
		}
	}
	public class UICurrentRoom : MonoBehaviour
	{
		public static UICurrentRoom Instance;

		private static Color ColorBackground = Color.white;

		private static Color ColorText = Color.black;

		private Image ImageBorder;

		private Image ImageBackground;

		private TextMeshProUGUI TextRoomName;

		private bool Active = false;

		private void Awake()
		{
			//IL_0059: 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)
			try
			{
				ImageBorder = ((Component)((Component)this).transform.Find("Border")).GetComponent<Image>();
				ImageBackground = ((Component)((Component)this).transform.Find("Background")).GetComponent<Image>();
				TextRoomName = ((Component)((Component)this).transform.Find("Text")).GetComponent<TextMeshProUGUI>();
				((Graphic)ImageBackground).color = ColorBackground;
				((Graphic)TextRoomName).color = ColorText;
				Show(active: false, null);
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("UICurrentRoom awake error: " + ex));
			}
		}

		public void Show(bool active, string roomKey)
		{
			try
			{
				((Component)ImageBorder).gameObject.SetActive(active);
				((Component)ImageBackground).gameObject.SetActive(active);
				((Component)TextRoomName).gameObject.SetActive(active);
				if (active)
				{
					((TMP_Text)TextRoomName).text = TranslationManager.Instance.GetTranslation(roomKey);
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("Show error: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(LocalCameraHandler), "SwitchPov")]
	internal class SwitchPovPatch
	{
		private static void Postfix(LocalCameraHandler __instance, PlayerController spectatedPlayer)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)__instance.PovPlayer != (Object)null && (int)GameManager.LocalGameState == 2)
				{
					PlayerMapCustom player = PlayerMapCustomRegistry.GetPlayer(spectatedPlayer.Ref);
					player.RefreshCurrentRoomUI();
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("SwitchPovPatch error: " + ex));
			}
		}
	}
	[HarmonyPatch(typeof(LocalCameraHandler), "Start")]
	internal class CameraStartPatch
	{
		private static void Postfix(LocalCameraHandler __instance)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)__instance.PovPlayer != (Object)null)
				{
					PlayerMapCustom player = PlayerMapCustomRegistry.GetPlayer(__instance.PovPlayer.Ref);
					player.RefreshCurrentRoomUI();
				}
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("CameraStartPatch error: " + ex));
			}
		}
	}
	public class TranslationManager
	{
		private Dictionary<string, string> _translationsForCurrentLanguage = new Dictionary<string, string>();

		private Dictionary<string, Dictionary<string, string>> _allTranslationsByLanguage = null;

		private static TranslationManager _instance;

		public static TranslationManager Instance
		{
			get
			{
				if (_instance == null)
				{
					_instance = new TranslationManager();
				}
				return _instance;
			}
		}

		public TranslationManager()
		{
			LoadTranslationsFromFile();
			LoadTranslationsForLanguage(GetLanguageCode());
			LocalizationSettings.SelectedLocaleChanged += SelectedLocaleChanged;
		}

		public void Initialize()
		{
		}

		private void SelectedLocaleChanged(Locale locale)
		{
			LoadTranslationsForLanguage(GetLanguageCode());
		}

		private string GetLanguageCode()
		{
			return (PlayerPrefs.GetInt("SETTINGS_LANGUAGE") == 0) ? "en" : "fr";
		}

		private void LoadTranslationsFromFile()
		{
			string name = "LycansNewMaps.resources.translations.json";
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			try
			{
				using Stream stream = executingAssembly.GetManifestResourceStream(name);
				if (stream != null)
				{
					using (StreamReader streamReader = new StreamReader(stream))
					{
						_allTranslationsByLanguage = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>(streamReader.ReadToEnd());
						return;
					}
				}
				Plugin.Logger.LogError((object)"Translations resource not found");
			}
			catch (Exception ex)
			{
				Log.Info((object)ex.Message);
			}
		}

		public string GetTranslation(string key)
		{
			string value;
			return _translationsForCurrentLanguage.TryGetValue(key, out value) ? value : key;
		}

		private void LoadTranslationsForLanguage(string languageCode)
		{
			_translationsForCurrentLanguage = _allTranslationsByLanguage[languageCode];
			PopulateStringDatabase();
		}

		private void PopulateStringDatabase()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			StringTable table = ((LocalizedDatabase<StringTable, StringTableEntry>)(object)LocalizationSettings.StringDatabase).GetTable(TableReference.op_Implicit("UI Text"), (Locale)null);
			foreach (KeyValuePair<string, string> item in _translationsForCurrentLanguage)
			{
				((DetailedLocalizationTable<StringTableEntry>)(object)table).AddEntry(item.Key, item.Value);
			}
		}
	}
	public static class ComponentExtensions
	{
		public static T GetCopyOf<T>(this T comp, T other) where T : Component
		{
			Type type = ((object)comp).GetType();
			Type type2 = ((object)other).GetType();
			if (type != type2)
			{
				Plugin.Logger.LogError((object)$"The type \"{type.AssemblyQualifiedName}\" of \"{comp}\" does not match the type \"{type2.AssemblyQualifiedName}\" of \"{other}\"!");
				return default(T);
			}
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
			PropertyInfo[] properties = type.GetProperties(bindingAttr);
			PropertyInfo[] array = properties;
			foreach (PropertyInfo propertyInfo in array)
			{
				if (propertyInfo.CanWrite)
				{
					propertyInfo.SetValue(comp, propertyInfo.GetValue(other, null), null);
				}
			}
			FieldInfo[] fields = type.GetFields(bindingAttr);
			FieldInfo[] array2 = fields;
			foreach (FieldInfo fieldInfo in array2)
			{
				fieldInfo.SetValue(comp, fieldInfo.GetValue(other));
			}
			return comp;
		}

		public static void ListComponentsAndChildren(this GameObject gameObject)
		{
			//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)
			ManualLogSource logger = Plugin.Logger;
			string name = ((Object)gameObject).name;
			Vector3 position = gameObject.transform.position;
			logger.LogInfo((object)(name + ", position: " + ((object)(Vector3)(ref position)).ToString()));
			Component[] components = gameObject.GetComponents<Component>();
			foreach (Component val in components)
			{
				Plugin.Logger.LogInfo((object)(((Object)gameObject).name + " Component: " + (object)val));
			}
			for (int j = 0; j < gameObject.transform.childCount; j++)
			{
				Transform child = gameObject.transform.GetChild(j);
				Plugin.Logger.LogInfo((object)(((Object)gameObject).name + " Child: " + ((object)child)?.ToString() + " / " + ((Object)((Component)child).gameObject).name));
				Component[] components2 = ((Component)child).gameObject.GetComponents<Component>();
				foreach (Component val2 in components2)
				{
					Plugin.Logger.LogInfo((object)(((Object)gameObject).name + " Child component: " + ((object)val2).ToString()));
				}
				int num = 0;
				for (; j < child.childCount; j++)
				{
					Transform child2 = child.GetChild(j);
					Plugin.Logger.LogInfo((object)(((object)child)?.ToString() + " Child: " + ((object)child2)?.ToString() + " / " + ((Object)((Component)child2).gameObject).name));
					Component[] components3 = ((Component)child2).gameObject.GetComponents<Component>();
					foreach (Component val3 in components3)
					{
						Plugin.Logger.LogInfo((object)("Child Child component: " + ((object)val3).ToString()));
					}
				}
			}
		}

		public static void RemoveAllChildren(this GameObject gameObject)
		{
			int childCount = gameObject.transform.childCount;
			for (int num = childCount - 1; num >= 0; num--)
			{
				Object.Destroy((Object)(object)((Component)gameObject.transform.GetChild(num)).gameObject);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LycansNewMaps";

		public const string PLUGIN_NAME = "My first plugin";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace LycansNewMaps.SpecialArchitecture
{
	public class MovingPlatform : MonoBehaviour
	{
		private enum PlatformState
		{
			Origin,
			OriginToDestination,
			Destination,
			DestinationToOrigin
		}

		private float _speed = 8f;

		private float _intervalBetweenMovements = 5f;

		private float _timeSinceLastMovement = 0f;

		private Vector3 _origin;

		private Vector3 _destination;

		private PlatformState _currentState = PlatformState.Origin;

		private List<PlayerController> _attachedPlayers = new List<PlayerController>();

		public void Init(Vector3 origin, Vector3 destination)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: 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_000a: Unknown result type (might be due to invalid IL or missing references)
			_origin = origin;
			_destination = destination;
		}

		private void Update()
		{
			//IL_0007: 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_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_0085: 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_009c: 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_00b2: 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_00bf: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: 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_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: 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_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)this).transform.position;
			Vector3 val = Vector3.zero;
			switch (_currentState)
			{
			case PlatformState.Origin:
			case PlatformState.Destination:
				_timeSinceLastMovement += Time.deltaTime;
				if (_timeSinceLastMovement >= _intervalBetweenMovements)
				{
					_currentState = ((_currentState == PlatformState.Origin) ? PlatformState.OriginToDestination : PlatformState.DestinationToOrigin);
				}
				break;
			case PlatformState.OriginToDestination:
				((Component)this).transform.position = Vector3.MoveTowards(((Component)this).transform.position, _destination, _speed * Time.deltaTime);
				val = ((Component)this).transform.position - position;
				if (Vector3.Distance(((Component)this).transform.position, _destination) < 0.001f)
				{
					_currentState = PlatformState.Destination;
					_timeSinceLastMovement = 0f;
				}
				break;
			case PlatformState.DestinationToOrigin:
				((Component)this).transform.position = Vector3.MoveTowards(((Component)this).transform.position, _origin, _speed * Time.deltaTime);
				val = ((Component)this).transform.position - position;
				if (Vector3.Distance(((Component)this).transform.position, _origin) < 0.001f)
				{
					_currentState = PlatformState.Origin;
					_timeSinceLastMovement = 0f;
				}
				break;
			}
			if (!(val != Vector3.zero))
			{
				return;
			}
			foreach (PlayerController attachedPlayer in _attachedPlayers)
			{
				ManualLogSource logger = Plugin.Logger;
				Vector3 val2 = val;
				logger.LogInfo((object)("Move player: " + ((object)(Vector3)(ref val2)).ToString()));
				Traverse.Create((object)attachedPlayer.CharacterMovementHandler).Field<NetworkCharacterControllerPrototypeCustom>("_networkCharacterControllerPrototypeCustom").Value.Controller.Move(val);
				Transform transform = ((Component)attachedPlayer).transform;
				transform.position += val;
			}
		}

		private void OnTriggerEnter(Collider other)
		{
			PlayerController component = ((Component)other).GetComponent<PlayerController>();
			if ((Object)(object)component != (Object)null && !_attachedPlayers.Contains(component))
			{
				Plugin.Logger.LogInfo((object)"Attach player!");
				_attachedPlayers.Add(component);
			}
		}

		private void OnTriggerExit(Collider other)
		{
			PlayerController component = ((Component)other).GetComponent<PlayerController>();
			if ((Object)(object)component != (Object)null)
			{
				Plugin.Logger.LogInfo((object)"Detach player!");
				_attachedPlayers.Remove(component);
			}
		}
	}
}