Decompiled source of CoordinateForEasterEggs v0.1.1

CoordinateForEasterEggs.dll

Decompiled 3 weeks 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 BepInEx;
using BepInEx.Logging;
using CoordinateForEasterEggs.NetcodePatcher;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.SceneManagement;
using testModLethalCompany.Patches;

[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 = "")]
[assembly: AssemblyCompany("CoordinateForEasterEggs")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("CoordinateForEasterEggs")]
[assembly: AssemblyTitle("CoordinateForEasterEggs")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: NetcodePatchedAssembly]
namespace testModLethalCompany
{
	internal class EggLine : MonoBehaviour
	{
		private LineRenderer lineRenderer;

		private GameObject eggPosObj;

		private GameObject highlightFloorObj;

		private Vector3 pos;

		private float aliveCount;

		private readonly float aliveTime = 12f;

		private readonly float lineLength = 15f;

		public bool isDisabled = false;

		public void InitAndSetPos(Vector3 eggPos, bool isExplode, in float floorHeight)
		{
			//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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			//IL_018d: 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_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: 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_028b: Expected O, but got Unknown
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: 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)
			pos = eggPos;
			aliveCount = 0f;
			if ((Object)(object)lineRenderer == (Object)null)
			{
				lineRenderer = new LineRenderer();
			}
			Shader val = Shader.Find("Sprites/Default");
			if ((Object)(object)val == (Object)null)
			{
				Plugin.mls.LogInfo((object)"Error: Shader 'Sprites/Default' not found!!");
				return;
			}
			Material material = new Material(val);
			float num = 0.017f;
			Color val2 = ((!isExplode) ? Color.cyan : Color.green);
			int positionCount = 2;
			GameObject val3 = new GameObject("EggLineObj");
			lineRenderer = val3.AddComponent<LineRenderer>();
			lineRenderer.positionCount = positionCount;
			lineRenderer.startWidth = num;
			lineRenderer.endWidth = num;
			((Renderer)lineRenderer).material = material;
			lineRenderer.startColor = val2;
			lineRenderer.endColor = val2;
			if ((Object)(object)eggPosObj == (Object)null)
			{
				eggPosObj = GameObject.CreatePrimitive((PrimitiveType)3);
			}
			Shader val4 = Shader.Find("Sprites/Default");
			if ((Object)(object)val4 == (Object)null)
			{
				Plugin.mls.LogInfo((object)"Error: Shader 'Sprites / Default'' not found!!");
				return;
			}
			Material val5 = new Material(val4);
			if (isExplode)
			{
				val5.color = new Color(0f, 1f, 0f, 0.25f);
			}
			else
			{
				val5.color = new Color(0f, 1f, 1f, 0.25f);
			}
			eggPosObj.transform.position = pos;
			eggPosObj.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
			eggPosObj.transform.localScale = new Vector3(0.17f, 0.17f, 0.17f);
			((Renderer)eggPosObj.GetComponent<MeshRenderer>()).material = val5;
			Collider component = eggPosObj.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			if ((Object)(object)highlightFloorObj == (Object)null)
			{
				highlightFloorObj = GameObject.CreatePrimitive((PrimitiveType)4);
			}
			Shader val6 = Shader.Find("Sprites/Default");
			if ((Object)(object)val4 == (Object)null)
			{
				Plugin.mls.LogInfo((object)"Error: Shader 'Sprites / Default'' not found!!");
				return;
			}
			Material val7 = new Material(val4);
			if (isExplode)
			{
				val7.color = new Color(0f, 1f, 0f, 0.75f);
			}
			else
			{
				val7.color = new Color(0f, 1f, 1f, 0.75f);
			}
			highlightFloorObj.transform.position = new Vector3(pos.x, floorHeight, pos.z);
			highlightFloorObj.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
			highlightFloorObj.transform.localScale = new Vector3(0.006f, 1f, 0.006f);
			((Renderer)highlightFloorObj.GetComponent<MeshRenderer>()).material = val7;
			Collider component2 = highlightFloorObj.GetComponent<Collider>();
			if ((Object)(object)component2 != (Object)null)
			{
				Object.Destroy((Object)(object)component2);
			}
			SetLine();
			SetCube();
		}

		public void UpdateEggLine(float floorHeightPosY)
		{
			//IL_0060: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			if (!isDisabled && !((Object)(object)highlightFloorObj == (Object)null) && !((Object)(object)eggPosObj == (Object)null) && !((Object)(object)lineRenderer == (Object)null))
			{
				highlightFloorObj.transform.position = new Vector3(pos.x, floorHeightPosY, pos.z);
				if (highlightFloorObj.transform.position.y > pos.y + lineLength || highlightFloorObj.transform.position.y < pos.y - lineLength)
				{
					highlightFloorObj.SetActive(false);
				}
				else
				{
					highlightFloorObj.SetActive(true);
				}
				if (aliveCount >= aliveTime)
				{
					DisableIndicator();
				}
				aliveCount += Time.deltaTime;
			}
		}

		private void SetLine()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_0066: 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)
			if (!((Object)(object)lineRenderer == (Object)null))
			{
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(0f, lineLength, 0f);
				Vector3 val2 = pos + val;
				Vector3 val3 = default(Vector3);
				((Vector3)(ref val3))..ctor(0f, 0f - lineLength, 0f);
				Vector3 val4 = pos + val3;
				lineRenderer.SetPosition(0, val2);
				lineRenderer.SetPosition(1, val4);
			}
		}

		private void SetCube()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)eggPosObj == (Object)null))
			{
				eggPosObj.transform.position = pos;
			}
		}

		private void DisableIndicator()
		{
			isDisabled = true;
			Object.Destroy((Object)(object)lineRenderer);
			Object.Destroy((Object)(object)eggPosObj);
			Object.Destroy((Object)(object)highlightFloorObj);
		}
	}
	public class EggLineSync : NetworkBehaviour
	{
		public static EggLineSync Instance;

		public void Awake()
		{
			Plugin.mls.LogInfo((object)"Awake is called.");
			if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
			{
				Object.Destroy((Object)(object)Instance);
			}
			Instance = this;
		}

		[ClientRpc]
		public void EggLinesClientRpc(Vector3 egglinePos, bool explode)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: 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_008a: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2657101790u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref egglinePos);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref explode, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2657101790u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					testModLethalCompany.Patches.CoordinateForEasterEggs.GenerateEggLine(egglinePos, explode);
				}
			}
		}

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			Plugin.mls.LogInfo((object)"NetworkPrefab Spawned.");
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(2657101790u, new RpcReceiveHandler(__rpc_handler_2657101790), "EggLinesClientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_2657101790(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 egglinePos = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref egglinePos);
				bool explode = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref explode, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((EggLineSync)(object)target).EggLinesClientRpc(egglinePos, explode);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "EggLineSync";
		}
	}
	public struct HorizontalIntPos
	{
		public int x;

		public int z;

		public void InitToZero()
		{
			x = 0;
			z = 0;
		}

		public bool Equals(HorizontalIntPos other)
		{
			return x == other.x && z == other.z;
		}

		public override bool Equals(object obj)
		{
			if (obj is HorizontalIntPos other)
			{
				return Equals(other);
			}
			return false;
		}

		public override int GetHashCode()
		{
			return HashCode.Combine(x, z);
		}

		public static bool operator ==(HorizontalIntPos a, HorizontalIntPos b)
		{
			return a.x == b.x && a.z == b.z;
		}

		public static bool operator !=(HorizontalIntPos a, HorizontalIntPos b)
		{
			return !(a == b);
		}
	}
	public class CheckSceneChange
	{
		[HarmonyPatch(typeof(GameNetworkManager))]
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void Init()
		{
			SceneManager.activeSceneChanged -= OnSceneChanged;
			SceneManager.activeSceneChanged += OnSceneChanged;
			Plugin.mls.LogInfo((object)"CheckSceneChange is initialized");
		}

		private static void OnSceneChanged(Scene oldScene, Scene newScene)
		{
			Plugin.mls.LogInfo((object)("Scene changed to: " + ((Scene)(ref newScene)).name));
			if (((Scene)(ref newScene)).name == "MainMenu")
			{
				testModLethalCompany.Patches.CoordinateForEasterEggs.ResetAll();
			}
		}
	}
	internal class CommandReader
	{
		[HarmonyPatch(typeof(HUDManager))]
		[HarmonyPatch("AddTextToChatOnServer")]
		[HarmonyPostfix]
		private static void GetCommandFromChat(string chatMessage, int playerId = -1)
		{
			if (!chatMessage.StartsWith("/"))
			{
				return;
			}
			string[] array = chatMessage.Trim().Split(' ');
			string text = array[0];
			string text2 = ((array.Length > 1) ? array[1] : null);
			string text3 = ((array.Length > 2) ? array[2] : null);
			string text4 = ((array.Length > 3) ? array[3] : null);
			string text5 = ((array.Length > 4) ? array[4] : null);
			string text6 = ((array.Length > 5) ? array[5] : null);
			if (text == null)
			{
				return;
			}
			switch (text.ToLower())
			{
			case "/range":
			case "/rang":
			case "/ran":
			{
				int result7;
				if (text2 == null || text3 != null)
				{
					string text9 = testModLethalCompany.Patches.CoordinateForEasterEggs.maxLineRadius.ToString();
					Plugin.mls.LogInfo((object)("Usage: /range <value(max: " + text9 + ")>\nDefault: 15"));
					HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Usage: range <value(max: " + text9 + ")>\nDefault: 15", false, false, "LC_Tip1");
				}
				else if (int.TryParse(text2, out result7))
				{
					if (result7 > testModLethalCompany.Patches.CoordinateForEasterEggs.maxLineRadius)
					{
						string text10 = testModLethalCompany.Patches.CoordinateForEasterEggs.maxLineRadius.ToString();
						Plugin.mls.LogInfo((object)("Range must be " + text10 + " or less!!\nDefault: 15"));
						HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Range must be " + text10 + " or less!!\nDefault: 15", false, false, "LC_Tip1");
						break;
					}
					if (result7 < testModLethalCompany.Patches.CoordinateForEasterEggs.minLineRadius)
					{
						string text10 = testModLethalCompany.Patches.CoordinateForEasterEggs.minLineRadius.ToString();
						Plugin.mls.LogInfo((object)("Range must be " + text10 + " or above!!\nDefault: 15"));
						HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Range must be " + text10 + " or above!!\nDefault: 15", false, false, "LC_Tip1");
						break;
					}
					Plugin.mls.LogInfo((object)("Range is set to " + result7 + ".\nDefault: 15"));
					HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Range is set to " + result7 + ".\nDefault: 15", false, false, "LC_Tip1");
					if (!testModLethalCompany.Patches.CoordinateForEasterEggs.isVirtualGenerationMode)
					{
						testModLethalCompany.Patches.CoordinateForEasterEggs.ResetLine();
						testModLethalCompany.Patches.CoordinateForEasterEggs.lineRadius = result7;
						testModLethalCompany.Patches.CoordinateForEasterEggs.isRangeChanged = true;
					}
					else
					{
						Plugin.mls.LogInfo((object)"The range cannot be changed while in Virtual generation mode.");
						HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "The range cannot be changed while in Virtual generation mode.", false, false, "LC_Tip1");
					}
				}
				else
				{
					Plugin.mls.LogInfo((object)"Usage: /range <value(max 50)>\nDefault: 15");
					HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Usage: range <value(max 50)>\nDefault: 15", false, false, "LC_Tip1");
				}
				break;
			}
			case "/virtual":
			case "/virtua":
			case "/virtu":
			case "/virt":
			case "/vir":
				if (text2 == null || text3 != null)
				{
					Plugin.mls.LogInfo((object)"Usage: /virtual <flag('true' or 'false')>");
					HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Usage: /virtual <flag('true' or 'false')>", false, false, "LC_Tip1");
				}
				else if (text2.ToLower() == "true" || text2.ToLower() == "tru")
				{
					if (testModLethalCompany.Patches.CoordinateForEasterEggs.isVirtualGenerationMode)
					{
						Plugin.mls.LogInfo((object)"Warning: Virtual Generation Mode is already on!!");
						HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Warning: Virtual Generation Mode is already on!!", false, false, "LC_Tip1");
						break;
					}
					testModLethalCompany.Patches.CoordinateForEasterEggs.isVirtualGenerationMode = true;
					testModLethalCompany.Patches.CoordinateForEasterEggs.virtualMapSeed = testModLethalCompany.Patches.CoordinateForEasterEggs.randomMapSeed;
					testModLethalCompany.Patches.CoordinateForEasterEggs.ResetLine();
					testModLethalCompany.Patches.CoordinateForEasterEggs.VirtualNewLevelGenerator(testModLethalCompany.Patches.CoordinateForEasterEggs.randomMapSeed, isDisplayTip: false);
					Plugin.mls.LogInfo((object)"Virtual Generation Mode was turned on!!");
					HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Virtual Generation Mode was turned on!!", false, false, "LC_Tip1");
				}
				else if (text2.ToLower() == "false" || text2.ToLower() == "fals" || text2.ToLower() == "fal")
				{
					if (!testModLethalCompany.Patches.CoordinateForEasterEggs.isVirtualGenerationMode)
					{
						Plugin.mls.LogInfo((object)"Warning: Virtual Generation Mode is already off!!");
						HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Warning: Virtual Generation Mode is already off!!", false, false, "LC_Tip1");
						break;
					}
					testModLethalCompany.Patches.CoordinateForEasterEggs.isVirtualGenerationMode = false;
					testModLethalCompany.Patches.CoordinateForEasterEggs.virtualMapSeed = -1;
					testModLethalCompany.Patches.CoordinateForEasterEggs.ResetLine();
					testModLethalCompany.Patches.CoordinateForEasterEggs.isForceToUpdateNext = true;
					Plugin.mls.LogInfo((object)"Virtual Generation Mode was turned off!!");
					HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Virtual Generation Mode was turned off!!", false, false, "LC_Tip1");
				}
				break;
			case "/seed":
			case "/see":
			{
				int result6;
				if (!testModLethalCompany.Patches.CoordinateForEasterEggs.isVirtualGenerationMode)
				{
					Plugin.mls.LogInfo((object)"Warning: This command is available only in Virtual generation mode.");
					HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Warning: This command is available only in Virtual generation mode.", false, false, "LC_Tip1");
				}
				else if (text2 == null || text3 != null)
				{
					Plugin.mls.LogInfo((object)"Usage: /seed <seed value>\n/seed random>");
					HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Usage: /seed <seed value>\nU/seed random>", false, false, "LC_Tip1");
				}
				else if (text2.ToLower() == "random" || text2.ToLower() == "rando" || text2.ToLower() == "rand" || text2.ToLower() == "ran")
				{
					testModLethalCompany.Patches.CoordinateForEasterEggs.VirtualNewLevelGeneratorWithConditions();
				}
				else if (int.TryParse(text2, out result6))
				{
					testModLethalCompany.Patches.CoordinateForEasterEggs.VirtualNewLevelGenerator(result6);
				}
				break;
			}
			case "/clear":
			case "/clea":
			case "/cle":
				if (!testModLethalCompany.Patches.CoordinateForEasterEggs.isVirtualGenerationMode)
				{
					Plugin.mls.LogInfo((object)"Warning: This command is available only in Virtual generation mode.");
					HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Warning: This command is available only in Virtual generation mode.", false, false, "LC_Tip1");
				}
				else if (text2 != null)
				{
					Plugin.mls.LogInfo((object)"Usage: /clear");
					HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Usage: /clear", false, false, "LC_Tip1");
				}
				else
				{
					testModLethalCompany.Patches.CoordinateForEasterEggs.SetVirtualTilesToFlase();
					Plugin.mls.LogInfo((object)"Cleared virtual tiles!!");
					HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Cleared virtual tiles!!", false, false, "LC_Tip1");
				}
				break;
			case "/conditions":
			case "/condition":
			case "/conditio":
			case "/conditi":
			case "/condit":
			case "/condi":
			case "/cond":
			case "/con":
				if (text2 == null)
				{
					Plugin.mls.LogInfo((object)"Usage: /condition 'word'.\nword: dungeon, scraps, info, clear");
					HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Usage: /condition 'word'.\nword: dungeon, scraps, info, clear", false, false, "LC_Tip1");
				}
				else if (text2.ToLower() == "clear" || text2.ToLower() == "clea" || text2.ToLower() == "cle")
				{
					if (text3 != null)
					{
						Plugin.mls.LogInfo((object)"Usage: /condition clear");
						HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Usage: /condition clear", false, false, "LC_Tip1");
						break;
					}
					testModLethalCompany.Patches.CoordinateForEasterEggs.isConditionedFactory = false;
					testModLethalCompany.Patches.CoordinateForEasterEggs.isConditionedMansion = false;
					testModLethalCompany.Patches.CoordinateForEasterEggs.isConditionedMineshaft = false;
					testModLethalCompany.Patches.CoordinateForEasterEggs.isConditionedAnyDungeon = false;
					testModLethalCompany.Patches.CoordinateForEasterEggs.conditionedMinScraps = -1;
					testModLethalCompany.Patches.CoordinateForEasterEggs.conditionedMaxScraps = -1;
					Plugin.mls.LogInfo((object)"Conditions were cleared.");
					HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Conditions were cleared.", false, false, "LC_Tip1");
				}
				else if (text2.ToLower() == "dungeon" || text2.ToLower() == "dungeo" || text2.ToLower() == "dunge" || text2.ToLower() == "dung" || text2.ToLower() == "dun")
				{
					if (text3 == null)
					{
						Plugin.mls.LogInfo((object)"Usage: /condition dungeon 'word'.\nword: factory, mansion, mineshaft");
						HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Usage: /condition dungeon 'word'.\nword: factory, mansion, mineshaft", false, false, "LC_Tip1");
					}
					else if (text3.ToLower() == "factory" || text3.ToLower() == "factor" || text3.ToLower() == "facto" || text3.ToLower() == "fact" || text3.ToLower() == "fac")
					{
						testModLethalCompany.Patches.CoordinateForEasterEggs.isConditionedFactory = true;
						testModLethalCompany.Patches.CoordinateForEasterEggs.isConditionedAnyDungeon = true;
						Plugin.mls.LogInfo((object)"Dungeon conditions set to Factory.");
						HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Dungeon conditions set to Factory.", false, false, "LC_Tip1");
					}
					else if (text3.ToLower() == "mansion" || text3.ToLower() == "mansio" || text3.ToLower() == "mansi" || text3.ToLower() == "mans" || text3.ToLower() == "man")
					{
						testModLethalCompany.Patches.CoordinateForEasterEggs.isConditionedMansion = true;
						testModLethalCompany.Patches.CoordinateForEasterEggs.isConditionedAnyDungeon = true;
						Plugin.mls.LogInfo((object)"Dungeon conditions set to Mansion.");
						HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Dungeon conditions set to Mansion.", false, false, "LC_Tip1");
					}
					else if (text3.ToLower() == "mineshaft" || text3.ToLower() == "mineshaf" || text3.ToLower() == "minesha" || text3.ToLower() == "minesh" || text3.ToLower() == "mines" || text3.ToLower() == "mine" || text3.ToLower() == "min")
					{
						testModLethalCompany.Patches.CoordinateForEasterEggs.isConditionedMineshaft = true;
						testModLethalCompany.Patches.CoordinateForEasterEggs.isConditionedAnyDungeon = true;
						Plugin.mls.LogInfo((object)"Dungeon conditions set to Mineshaft.");
						HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Dungeon conditions set to Mineshaft.", false, false, "LC_Tip1");
					}
					else
					{
						Plugin.mls.LogInfo((object)"Usage: /condition dungeon 'word'.\nword: factory, mansion, mineshaft");
						HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Usage: /condition dungeon 'word'.\nword: factory, mansion, mineshaft", false, false, "LC_Tip1");
					}
				}
				else if (text2.ToLower() == "scraps" || text2.ToLower() == "scrap" || text2.ToLower() == "scra" || text2.ToLower() == "scr")
				{
					if (text3 != null && int.TryParse(text3, out var result3))
					{
						if (text4 != null && text4 == "to")
						{
							if (text5 != null && int.TryParse(text5, out var result4))
							{
								if (text6 == null)
								{
									if (result3 < StartOfRound.Instance.currentLevel.minScrap)
									{
										result3 = StartOfRound.Instance.currentLevel.minScrap;
										Plugin.mls.LogInfo((object)"Warning: minScraps has been changed due to actual minScraps");
									}
									if (result4 > StartOfRound.Instance.currentLevel.maxScrap)
									{
										result4 = StartOfRound.Instance.currentLevel.maxScrap;
										Plugin.mls.LogInfo((object)"Warning: maxScraps has been changed due to actual maxScraps");
									}
									if (result3 > result4)
									{
										Plugin.mls.LogInfo((object)("Warning: Min scraps must be less than max scraps.\nThis moon can spawn scraps in the range of " + StartOfRound.Instance.currentLevel.minScrap + " to " + StartOfRound.Instance.currentLevel.maxScrap + "."));
										HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Warning: Min scraps must be less than max scraps.\nThis moon can spawn scraps in the range of " + StartOfRound.Instance.currentLevel.minScrap + " to " + StartOfRound.Instance.currentLevel.maxScrap + ".", false, false, "LC_Tip1");
									}
									else
									{
										testModLethalCompany.Patches.CoordinateForEasterEggs.conditionedMinScraps = result3;
										testModLethalCompany.Patches.CoordinateForEasterEggs.conditionedMaxScraps = result4;
										Plugin.mls.LogInfo((object)("Scrap conditions set to " + result3 + " to " + result4 + ".\nThis moon can spawn scraps in the range of " + StartOfRound.Instance.currentLevel.minScrap + " to " + StartOfRound.Instance.currentLevel.maxScrap + "."));
										HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Scrap conditions set to " + result3 + " to " + result4 + ".\nThis moon can spawn scraps in the range of " + StartOfRound.Instance.currentLevel.minScrap + " to " + StartOfRound.Instance.currentLevel.maxScrap + ".", false, false, "LC_Tip1");
									}
								}
								else
								{
									UsageConditionScraps();
								}
							}
							else
							{
								UsageConditionScraps();
							}
						}
						else if (text4 == null)
						{
							if (int.TryParse(text3, out var result5))
							{
								if (result5 < StartOfRound.Instance.currentLevel.minScrap)
								{
									result5 = StartOfRound.Instance.currentLevel.minScrap;
									Plugin.mls.LogInfo((object)"Warning: minScraps has been changed due to actual minScrap");
								}
								if (result5 > StartOfRound.Instance.currentLevel.maxScrap)
								{
									result5 = StartOfRound.Instance.currentLevel.maxScrap;
									Plugin.mls.LogInfo((object)"Warning: maxScraps has been changed due to actual maxScrap");
								}
								testModLethalCompany.Patches.CoordinateForEasterEggs.conditionedMinScraps = result5;
								testModLethalCompany.Patches.CoordinateForEasterEggs.conditionedMaxScraps = result5;
								Plugin.mls.LogInfo((object)("Scrap conditions set to " + result5 + " .\nThis moon can spawn scraps in the range of " + StartOfRound.Instance.currentLevel.minScrap + " to " + StartOfRound.Instance.currentLevel.maxScrap + "."));
								HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Scrap conditions set to " + result5 + ".\nThis moon can spawn scraps in the range of " + StartOfRound.Instance.currentLevel.minScrap + " to " + StartOfRound.Instance.currentLevel.maxScrap + ".", false, false, "LC_Tip1");
							}
							else
							{
								UsageConditionScraps();
							}
						}
						else
						{
							UsageConditionScraps();
						}
					}
					else
					{
						UsageConditionScraps();
					}
				}
				else if (text2.ToLower() == "info" || text2.ToLower() == "inf")
				{
					if (text2 != null)
					{
						if (text3 == null)
						{
							string text7 = "none";
							if (testModLethalCompany.Patches.CoordinateForEasterEggs.conditionedMinScraps != -1 && testModLethalCompany.Patches.CoordinateForEasterEggs.conditionedMaxScraps != -1)
							{
								if (testModLethalCompany.Patches.CoordinateForEasterEggs.conditionedMinScraps < testModLethalCompany.Patches.CoordinateForEasterEggs.conditionedMaxScraps)
								{
									text7 = testModLethalCompany.Patches.CoordinateForEasterEggs.conditionedMinScraps + " to " + testModLethalCompany.Patches.CoordinateForEasterEggs.conditionedMaxScraps;
								}
								if (testModLethalCompany.Patches.CoordinateForEasterEggs.conditionedMinScraps == testModLethalCompany.Patches.CoordinateForEasterEggs.conditionedMaxScraps)
								{
									text7 = testModLethalCompany.Patches.CoordinateForEasterEggs.conditionedMaxScraps.ToString();
								}
							}
							string text8 = "none";
							if (testModLethalCompany.Patches.CoordinateForEasterEggs.isConditionedFactory)
							{
								text8 = "Factory";
							}
							if (testModLethalCompany.Patches.CoordinateForEasterEggs.isConditionedMansion)
							{
								text8 = ((!(text8 == "none")) ? (text8 + ", Mansion") : "Mansion");
							}
							if (testModLethalCompany.Patches.CoordinateForEasterEggs.isConditionedMineshaft)
							{
								text8 = ((!(text8 == "none")) ? (text8 + ", Mineshaft") : "MineShaft");
							}
							Plugin.mls.LogInfo((object)("Conditions info:\nScraps: " + text7 + "\nDungeons: " + text8));
							HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Conditions info:\nScraps: " + text7 + "\nDungeons: " + text8, false, false, "LC_Tip1");
						}
						else
						{
							Plugin.mls.LogInfo((object)"Usage: /condition info");
							HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Usage: /condition info", false, false, "LC_Tip1");
						}
					}
					else
					{
						Plugin.mls.LogInfo((object)"Usage: /condition info");
						HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Usage: /condition info", false, false, "LC_Tip1");
					}
				}
				else
				{
					Plugin.mls.LogInfo((object)"Usage: /condition 'word'.\nword: dungeon, scraps, info, clear");
					HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Usage: /condition 'word'.\nword: dungeon, scraps, info, clear", false, false, "LC_Tip1");
				}
				break;
			case "/generations":
			case "/generation":
			case "/generatio":
			case "/generati":
			case "/generat":
			case "/genera":
			case "/gener":
			case "/gene":
			case "/gen":
				if (text2 != null)
				{
					if (int.TryParse(text2, out var result))
					{
						if (text3 == null)
						{
							if (!testModLethalCompany.Patches.CoordinateForEasterEggs.isGeneratingSeed)
							{
								if (result >= testModLethalCompany.Patches.CoordinateForEasterEggs.minNumberOfGenerations && result <= testModLethalCompany.Patches.CoordinateForEasterEggs.maxNumberOfGenerations)
								{
									testModLethalCompany.Patches.CoordinateForEasterEggs.generateAttempts = result;
									Plugin.mls.LogInfo((object)("The number of generations has been set to " + result + "."));
									HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "The number of generations has been set to " + result + ".", false, false, "LC_Tip1");
								}
								else
								{
									Plugin.mls.LogInfo((object)"Warning: The number of generations is up to 10000.");
									HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Warning: The number of generations is up to 10000.", false, false, "LC_Tip1");
								}
							}
							else
							{
								Plugin.mls.LogInfo((object)"Warning: The number of generations cannot be changed while it is being generated.");
								HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Warning: The number of generations cannot be changed while it is being generated.", false, false, "LC_Tip1");
							}
						}
						else
						{
							Plugin.mls.LogInfo((object)"Usage: /generation <value(number of generations)>");
							HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Usage: /generation <value(number of generations)>", false, false, "LC_Tip1");
						}
						break;
					}
					if (text2 == "start" || text2 == "star" || text2 == "sta")
					{
						if (text3 == null)
						{
							if (testModLethalCompany.Patches.CoordinateForEasterEggs.isVirtualGenerationMode)
							{
								if (!testModLethalCompany.Patches.CoordinateForEasterEggs.isGeneratingSeed)
								{
									testModLethalCompany.Patches.CoordinateForEasterEggs.StartGeneration();
									Plugin.mls.LogInfo((object)"Started generation.");
								}
								else
								{
									Plugin.mls.LogInfo((object)"Warning: It is already being started.");
								}
							}
							else
							{
								Plugin.mls.LogInfo((object)"Warning: This command is available only in Virtual generation mode.");
								HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Warning: This command is available only in Virtual generation mode.", false, false, "LC_Tip1");
							}
						}
						else
						{
							Plugin.mls.LogInfo((object)"Usage: /generation start");
							HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Usage: /generation start", false, false, "LC_Tip1");
						}
						break;
					}
					if (text2 == "stop" || text2 == "sto")
					{
						if (text3 == null)
						{
							if (testModLethalCompany.Patches.CoordinateForEasterEggs.isVirtualGenerationMode)
							{
								if (testModLethalCompany.Patches.CoordinateForEasterEggs.isGeneratingSeed)
								{
									testModLethalCompany.Patches.CoordinateForEasterEggs.StopGeneration();
									Plugin.mls.LogInfo((object)"Stopped generation.");
								}
								else
								{
									Plugin.mls.LogInfo((object)"Warning: Generation is not being started.");
									HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Warning: Generation is not being started.", false, false, "LC_Tip1");
								}
							}
							else
							{
								Plugin.mls.LogInfo((object)"Warning: This command is available only in Virtual generation mode.");
								HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Warning: This command is available only in Virtual generation mode.", false, false, "LC_Tip1");
							}
						}
						else
						{
							Plugin.mls.LogInfo((object)"Usage: /generation stop");
							HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Usage: /generation stop", false, false, "LC_Tip1");
						}
						break;
					}
					switch (text2)
					{
					default:
						if (!(text2 == "int"))
						{
							Plugin.mls.LogInfo((object)"Usage: /generations <value(number of generations)>");
							HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Usage: /generation <value(number of generations)>\n/generation start\n/generation stop\n/generation interval", false, false, "LC_Tip1");
							break;
						}
						goto case "interval";
					case "interval":
					case "interva":
					case "interv":
					case "inter":
					case "inte":
					{
						if (text3 != null && float.TryParse(text3, out var result2))
						{
							if (result2 == float.NaN || float.IsInfinity(result2))
							{
								Plugin.mls.LogInfo((object)"Warning: invalid value.");
								HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Warning: invalid value.", false, false, "LC_Tip1");
							}
							else if (text4 == null)
							{
								if (result2 < testModLethalCompany.Patches.CoordinateForEasterEggs.minGenerationTimeInterval || result2 > testModLethalCompany.Patches.CoordinateForEasterEggs.maxGenerationTimeInterval)
								{
									Plugin.mls.LogInfo((object)("Generation interval must be in the range of " + testModLethalCompany.Patches.CoordinateForEasterEggs.minGenerationTimeInterval + " to " + testModLethalCompany.Patches.CoordinateForEasterEggs.maxGenerationTimeInterval));
									HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Generation interval must be in the range of " + testModLethalCompany.Patches.CoordinateForEasterEggs.minGenerationTimeInterval + " to " + testModLethalCompany.Patches.CoordinateForEasterEggs.maxGenerationTimeInterval, false, false, "LC_Tip1");
									break;
								}
								if (testModLethalCompany.Patches.CoordinateForEasterEggs.isGeneratingSeed)
								{
									Plugin.mls.LogInfo((object)"Warning: The generation interval cannot be changed while it is being generated.");
									HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "The generation interval cannot be changed while it is being generated.", false, false, "LC_Tip1");
									break;
								}
								testModLethalCompany.Patches.CoordinateForEasterEggs.generationTimeInterval = result2;
								Plugin.mls.LogInfo((object)("Generation interval set to " + result2 + "."));
								if (result2 >= 0.45f)
								{
									Plugin.mls.LogInfo((object)("Generation interval set to " + result2 + "."));
									HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Generation interval set to " + result2 + ".", false, false, "LC_Tip1");
								}
								else
								{
									HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Generation interval set to " + result2 + ".\nWarning: Tiles far from the center may be ignored due to shorter generation interval!!", false, false, "LC_Tip1");
								}
							}
							else
							{
								Plugin.mls.LogInfo((object)"Usage: /generation interval <float value(intereval)>\nDefault: 0.5");
								HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Usage: /generation interval <float value(intereval)>\nDefault: 0.5", false, false, "LC_Tip1");
							}
						}
						else
						{
							Plugin.mls.LogInfo((object)"Usage: /generation interval <float value(intereval)>\nDefault: 0.5");
							HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Usage: /generation interval <float value(intereval)>\nDefault: 0.5", false, false, "LC_Tip1");
						}
						break;
					}
					}
				}
				else
				{
					Plugin.mls.LogInfo((object)"Usage: /generations <value(number of generations)>");
					HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Usage: /generation <value(number of generations)>\n/generation start\n/generation stop\n/generation interval", false, false, "LC_Tip1");
				}
				break;
			default:
				Plugin.mls.LogInfo((object)"Warning: Unknown Command.\nUsage: /range /virtual /seed /clear /condition /generation");
				HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Warning: Unknown Command.\nUsage: /range /virtual /seed /clear /condition /generation", false, false, "LC_Tip1");
				break;
			}
		}

		private static void UsageConditionScraps()
		{
			Plugin.mls.LogInfo((object)("Usage: /condition scraps <value(min)> to <value(max)>\n/condition scraps <value>\nThis moon can spawn scraps in the range of " + StartOfRound.Instance.currentLevel.minScrap + " to " + StartOfRound.Instance.currentLevel.maxScrap + "."));
			HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Usage: /condition scraps <value(min)> to <value(max)>\n/condition scraps <value>\nThis moon can spawn scraps in the range of " + StartOfRound.Instance.currentLevel.minScrap + " to " + StartOfRound.Instance.currentLevel.maxScrap + ".", false, false, "LC_Tip1");
		}
	}
	[BepInPlugin("kakeEdition.CFEE", "CoordinateForEasterEggs", "0.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string modGUID = "kakeEdition.CFEE";

		public const string modName = "CoordinateForEasterEggs";

		public const string modVersion = "0.1.0";

		private static Harmony _harmony = new Harmony("kakeEdition.CFEE");

		internal static ManualLogSource mls = Logger.CreateLogSource("kakeEdition.CFEE");

		private void Awake()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			mls.LogInfo((object)"CoordinateForEasterEggs0.1.0 is loaded.");
			testModLethalCompany.Patches.CoordinateForEasterEggs.networkPrefab = NetworkPrefabs.CreateNetworkPrefab("networkPrefab");
			testModLethalCompany.Patches.CoordinateForEasterEggs.networkPrefab.AddComponent<EggLineSync>();
			NetworkPrefabs.RegisterNetworkPrefab(testModLethalCompany.Patches.CoordinateForEasterEggs.networkPrefab);
			mls.LogInfo((object)"Network registered.");
			PatchAllStuff();
		}

		private static void PatchAllStuff()
		{
			_harmony.PatchAll(typeof(testModLethalCompany.Patches.CoordinateForEasterEggs));
			_harmony.PatchAll(typeof(CheckSceneChange));
			_harmony.PatchAll(typeof(CommandReader));
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "CoordinateForEasterEggs";

		public const string PLUGIN_NAME = "CoordinateForEasterEggs";

		public const string PLUGIN_VERSION = "0.1.0";
	}
}
namespace testModLethalCompany.Patches
{
	internal class CoordinateForEasterEggs : NetworkBehaviour
	{
		private static bool isLocalPlayerServer;

		internal static int randomMapSeed = -1;

		private static readonly float chanceToExplode = 16f;

		private static HorizontalIntPos closestPos;

		private static HorizontalIntPos previousClosestPos;

		private static float previousPlayerFloorPosY;

		private static float lastUpdateTime;

		private static float playerFloorPosY;

		private static List<LineRenderer> linesX = new List<LineRenderer>();

		private static List<LineRenderer> linesZ = new List<LineRenderer>();

		private static List<List<GameObject>> tiles = new List<List<GameObject>>();

		private static List<List<GameObject>> virtualTiles = new List<List<GameObject>>();

		private static List<List<Vector3>> tilePos = new List<List<Vector3>>();

		private static List<EggLine> eggLines = new List<EggLine>();

		internal static int lineRadius = 15;

		private static int lineDiameter;

		internal static bool isRangeChanged = false;

		internal static bool isInitializedLines = false;

		internal static bool isInitializedVirtualTiles = false;

		internal static bool isInitializedTiles = false;

		private static readonly int accurateTileDis = 15;

		private static readonly int prioritizedTileDis1 = 25;

		private static readonly int prioritizedTileDis2 = 30;

		private static readonly int prioritizedTileDis3 = 35;

		private static readonly int prioritizedTileDis4 = 40;

		private static readonly int prioritizedTileDis5 = 44;

		private static readonly int prioritizedTileDis6 = 48;

		private static readonly int prioritizedTileDis7 = 50;

		internal static readonly int maxLineRadius = 50;

		internal static readonly int minLineRadius = 1;

		private static bool[] isProcessed = new bool[8];

		internal static bool isVirtualGenerationMode = false;

		internal static bool isForceToUpdateNext = false;

		internal static int virtualMapSeed = -1;

		internal static int virtualBaseScraps = -1;

		internal static int virtualDungeonType = -1;

		internal static int generateAttempts = 10;

		internal static bool isGeneratingSeed = false;

		internal static float generationTime = 0f;

		internal static float generationTimeInterval = 0.5f;

		internal static readonly float minGenerationTimeInterval = 0.2f;

		internal static readonly float maxGenerationTimeInterval = 10f;

		internal static readonly int minNumberOfGenerations = 1;

		internal static readonly int maxNumberOfGenerations = 10000;

		internal static int previousTimeInterval = 0;

		internal static bool isConditionedFactory = false;

		internal static bool isConditionedMansion = false;

		internal static bool isConditionedMineshaft = false;

		internal static bool isConditionedAnyDungeon = false;

		internal static int conditionedMinScraps = -1;

		internal static int conditionedMaxScraps = -1;

		internal static GameObject networkPrefab;

		private static void InitializeLines()
		{
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Expected O, but got Unknown
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Expected O, but got Unknown
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Expected O, but got Unknown
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Expected O, but got Unknown
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Expected O, but got Unknown
			//IL_01e3: 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)
			if (linesX == null)
			{
				linesX = new List<LineRenderer>();
			}
			if (linesZ == null)
			{
				linesZ = new List<LineRenderer>();
			}
			if (tiles == null)
			{
				tiles = new List<List<GameObject>>();
			}
			if (virtualTiles == null)
			{
				virtualTiles = new List<List<GameObject>>();
			}
			if (tilePos == null)
			{
				tilePos = new List<List<Vector3>>();
			}
			if (eggLines == null)
			{
				eggLines = new List<EggLine>();
			}
			ResetIsProcessed();
			lineDiameter = lineRadius * 2;
			Shader val = Shader.Find("Sprites/Default");
			if ((Object)(object)val == (Object)null)
			{
				Plugin.mls.LogInfo((object)"Error: Shader 'Sprites/Default' not found.");
				return;
			}
			Material material = new Material(val);
			float num = 0.017f;
			Color white = Color.white;
			int positionCount = 2;
			for (int i = 0; i < lineDiameter + 1; i++)
			{
				LineRenderer val2 = new LineRenderer();
				GameObject val3 = new GameObject("LineObjZ" + i);
				val2 = new LineRenderer();
				val2 = val3.AddComponent<LineRenderer>();
				val2.positionCount = positionCount;
				val2.startWidth = num;
				val2.endWidth = num;
				((Renderer)val2).material = material;
				val2.startColor = white;
				val2.endColor = white;
				linesZ.Add(val2);
			}
			for (int j = 0; j < lineDiameter + 1; j++)
			{
				LineRenderer val4 = new LineRenderer();
				GameObject val5 = new GameObject("LineObjX" + j);
				val4 = new LineRenderer();
				val4 = val5.AddComponent<LineRenderer>();
				val4.positionCount = positionCount;
				val4.startWidth = num;
				val4.endWidth = num;
				((Renderer)val4).material = material;
				val4.startColor = white;
				val4.endColor = white;
				linesX.Add(val4);
			}
			isInitializedLines = true;
			Plugin.mls.LogInfo((object)"Initialized lines.");
		}

		private static void InitializeTiles()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_0152: Unknown result type (might be due to invalid IL or missing references)
			Shader val = Shader.Find("Sprites/Default");
			if ((Object)(object)val == (Object)null)
			{
				Plugin.mls.LogInfo((object)"Error: Shader 'Sprites / Default'' not found.");
				return;
			}
			Material val2 = new Material(val);
			val2.color = new Color(1f, 0f, 0f, 0.2f);
			Vector3 item = default(Vector3);
			for (int i = 0; i < lineDiameter; i++)
			{
				List<GameObject> list = new List<GameObject>();
				List<Vector3> list2 = new List<Vector3>();
				for (int j = 0; j < lineDiameter; j++)
				{
					GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)5);
					val3.transform.position = new Vector3(0f, 0f, 0f);
					val3.transform.rotation = Quaternion.Euler(90f, 0f, 0f);
					val3.transform.localScale = new Vector3(1f, 1f, 1f);
					((Renderer)val3.GetComponent<MeshRenderer>()).material = val2;
					Collider component = val3.GetComponent<Collider>();
					if ((Object)(object)component != (Object)null)
					{
						Object.Destroy((Object)(object)component);
					}
					list.Add(val3);
					((Vector3)(ref item))..ctor((float)(-lineDiameter / 2) + 0.5f + (float)j, 0f, 0f + ((float)(-lineDiameter / 2) + 0.5f) + (float)i);
					list2.Add(item);
				}
				tiles.Add(list);
				tilePos.Add(list2);
			}
			isInitializedTiles = true;
			Plugin.mls.LogInfo((object)"Initialized tiles.");
		}

		private static void InitializeVirtualTiles()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_0152: Unknown result type (might be due to invalid IL or missing references)
			Shader val = Shader.Find("Sprites/Default");
			if ((Object)(object)val == (Object)null)
			{
				Plugin.mls.LogInfo((object)"Error: Shader 'Sprites / Default'' not found.");
				return;
			}
			Material val2 = new Material(val);
			val2.color = new Color(1f, 0f, 1f, 0.2f);
			Vector3 item = default(Vector3);
			for (int i = 0; i < lineDiameter; i++)
			{
				List<GameObject> list = new List<GameObject>();
				List<Vector3> list2 = new List<Vector3>();
				for (int j = 0; j < lineDiameter; j++)
				{
					GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)5);
					val3.transform.position = new Vector3(0f, 0f, 0f);
					val3.transform.rotation = Quaternion.Euler(90f, 0f, 0f);
					val3.transform.localScale = new Vector3(1f, 1f, 1f);
					((Renderer)val3.GetComponent<MeshRenderer>()).material = val2;
					Collider component = val3.GetComponent<Collider>();
					if ((Object)(object)component != (Object)null)
					{
						Object.Destroy((Object)(object)component);
					}
					list.Add(val3);
					((Vector3)(ref item))..ctor((float)(-lineDiameter / 2) + 0.5f + (float)j, 0f, 0f + ((float)(-lineDiameter / 2) + 0.5f) + (float)i);
					list2.Add(item);
				}
				virtualTiles.Add(list);
				tilePos.Add(list2);
			}
			SetVirtualTilesToFlase();
			isInitializedVirtualTiles = true;
			Plugin.mls.LogInfo((object)"Initialized virtualTiles.");
		}

		[HarmonyPatch(typeof(StartOfRound))]
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void InitializeOnServer()
		{
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(networkPrefab);
				val.GetComponent<NetworkObject>().Spawn(true);
				Plugin.mls.LogInfo((object)"InitializedOnServer is called.");
			}
		}

		private static void ResetIsProcessed()
		{
			if (isProcessed == null)
			{
				isProcessed = new bool[8];
			}
			for (int i = 0; i < isProcessed.Length; i++)
			{
				isProcessed[i] = false;
			}
		}

		[HarmonyPatch(typeof(RoundManager))]
		[HarmonyPatch("__rpc_handler_2729232387")]
		[HarmonyPostfix]
		private static void SetRandomMapSeed(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			randomMapSeed = StartOfRound.Instance.randomMapSeed;
			Plugin.mls.LogInfo((object)("Current mapseed is " + randomMapSeed));
			VirtualNewLevelGenerator(randomMapSeed);
		}

		internal static void VirtualNewLevelGenerator(int mapSeed, bool isDisplayTip = true)
		{
			Random random = new Random(mapSeed + 5);
			float num = 1f;
			int num2 = (int)((float)random.Next(StartOfRound.Instance.currentLevel.minScrap, StartOfRound.Instance.currentLevel.maxScrap) * num);
			Random random2 = new Random(mapSeed);
			int num3 = 1;
			int num4 = -1;
			if (StartOfRound.Instance.currentLevel.dungeonFlowTypes.Length != 0)
			{
				List<int> list = new List<int>();
				for (int i = 0; i < StartOfRound.Instance.currentLevel.dungeonFlowTypes.Length; i++)
				{
					list.Add(StartOfRound.Instance.currentLevel.dungeonFlowTypes[i].rarity);
				}
				int randomWeightedIndex = RoundManager.Instance.GetRandomWeightedIndex(list.ToArray(), random2);
				num4 = RoundManager.Instance.currentLevel.dungeonFlowTypes[randomWeightedIndex].id;
				num3 = num4;
			}
			string text = ((num3 == 0 || num3 == 2 || num3 == 3) ? new string("Factory") : (num3 switch
			{
				1 => new string("Mansion"), 
				4 => new string("MineShaft"), 
				_ => new string("Unknown"), 
			}));
			if (isVirtualGenerationMode)
			{
				virtualMapSeed = mapSeed;
				virtualDungeonType = num3;
				virtualBaseScraps = num2;
			}
			isForceToUpdateNext = true;
			if (isDisplayTip && !isVirtualGenerationMode)
			{
				Plugin.mls.LogInfo((object)("Current mapseed is " + randomMapSeed + "\n" + num2 + " base scraps and Dungeon is " + text));
				HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Current mapseed is " + randomMapSeed + "\n" + num2 + " base scraps and Dungeon is " + text, false, false, "LC_Tip1");
			}
			if (isDisplayTip && isVirtualGenerationMode)
			{
				Plugin.mls.LogInfo((object)("Virtual mapseed is " + virtualMapSeed + "\n" + num2 + " base scraps and Dungeon is " + text));
				HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Virtual mapseed is " + virtualMapSeed + "\n" + num2 + " base scraps and Dungeon is " + text, false, false, "LC_Tip1");
			}
		}

		internal static void StartGeneration()
		{
			isGeneratingSeed = true;
			generationTime = 0f;
			previousTimeInterval = 0;
		}

		internal static void StopGeneration()
		{
			isGeneratingSeed = false;
			generationTime = 0f;
			previousTimeInterval = 0;
		}

		private static void UpdateGeneration()
		{
			if (isGeneratingSeed && isVirtualGenerationMode)
			{
				if (generationTimeInterval != 0f)
				{
					int num = (int)(generationTime / generationTimeInterval);
					if (num != previousTimeInterval)
					{
						VirtualNewLevelGeneratorWithConditions();
					}
					previousTimeInterval = num;
				}
				generationTime += Time.deltaTime;
				if (previousTimeInterval >= generateAttempts)
				{
					StopGeneration();
				}
			}
			else
			{
				StopGeneration();
			}
		}

		internal static void VirtualNewLevelGeneratorWithConditions(int maxTimes = 100, bool isDisplayTip = true)
		{
			if (!isVirtualGenerationMode)
			{
				Plugin.mls.LogInfo((object)"Warning: This command is available only in Virtual generation mode.");
				HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Warning: This command is available only in Virtual generation mode.", false, false, "LC_Tip1");
				return;
			}
			bool flag = false;
			int num = 0;
			for (int i = 0; i < maxTimes; i++)
			{
				int num2 = Random.Range(1, 100000000);
				Random random = new Random(num2 + 5);
				float num3 = 1f;
				int num4 = (int)((float)random.Next(StartOfRound.Instance.currentLevel.minScrap, StartOfRound.Instance.currentLevel.maxScrap) * num3);
				if ((conditionedMinScraps != -1 || conditionedMaxScraps != -1) && (conditionedMinScraps > num4 || conditionedMaxScraps < num4))
				{
					continue;
				}
				Random random2 = new Random(num2);
				int num5 = 1;
				int num6 = -1;
				if (StartOfRound.Instance.currentLevel.dungeonFlowTypes.Length != 0)
				{
					List<int> list = new List<int>();
					for (int j = 0; j < StartOfRound.Instance.currentLevel.dungeonFlowTypes.Length; j++)
					{
						list.Add(StartOfRound.Instance.currentLevel.dungeonFlowTypes[j].rarity);
					}
					int randomWeightedIndex = RoundManager.Instance.GetRandomWeightedIndex(list.ToArray(), random2);
					num6 = RoundManager.Instance.currentLevel.dungeonFlowTypes[randomWeightedIndex].id;
					num5 = num6;
				}
				string text;
				if (num5 == 0 || num5 == 2 || num5 == 3)
				{
					if (!isConditionedFactory && isConditionedAnyDungeon)
					{
						continue;
					}
					text = new string("Factory");
				}
				else
				{
					switch (num5)
					{
					case 1:
						if (!isConditionedMansion && isConditionedAnyDungeon)
						{
							continue;
						}
						text = new string("Mansion");
						break;
					case 4:
						if (!isConditionedMineshaft && isConditionedAnyDungeon)
						{
							continue;
						}
						text = new string("MineShaft");
						break;
					default:
						text = new string("Unknown");
						continue;
					}
				}
				virtualMapSeed = num2;
				virtualDungeonType = num5;
				virtualBaseScraps = num4;
				num = i + 1;
				flag = true;
				if (isDisplayTip)
				{
					int num7 = previousTimeInterval + 1;
					HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Virtual mapseed is " + virtualMapSeed + "\n" + virtualBaseScraps + " base scraps and Dungeon is " + text + ": " + num7 + "/" + generateAttempts, false, false, "LC_Tip1");
				}
				break;
			}
			if (flag)
			{
				int num8 = previousTimeInterval + 1;
				Plugin.mls.LogInfo((object)("Successflly generated a valid mapseed after " + num + " attempts. " + num8 + "/" + generateAttempts));
				isForceToUpdateNext = true;
			}
			else
			{
				int num9 = previousTimeInterval + 1;
				Plugin.mls.LogInfo((object)("Failed to generate a mapseed that meets the conditions after " + maxTimes + " attempts. " + num9 + "/" + generateAttempts));
				HUDManager.Instance.DisplayTip("CoordinateForEasterEggs", "Failed to generate a mapseed that meets the conditions after " + maxTimes + " attempts. " + num9 + "/" + generateAttempts, false, false, "LC_Tip1");
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB))]
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void PlayerControllerUpdateExtension(PlayerControllerB __instance)
		{
			//IL_00fa: 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_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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)
			if ((Object)(object)__instance == (Object)null)
			{
				Plugin.mls.LogInfo((object)"Error: PlayerControllerB __instance is null.");
			}
			else
			{
				if ((Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController || !__instance.isPlayerControlled)
				{
					return;
				}
				if (!isInitializedLines)
				{
					InitializeLines();
					if (!isInitializedTiles && !isVirtualGenerationMode)
					{
						InitializeTiles();
					}
					else if (!isInitializedVirtualTiles && isVirtualGenerationMode)
					{
						InitializeVirtualTiles();
						closestPos.x = (int)Math.Round(((Component)__instance).transform.position.x);
						closestPos.z = (int)Math.Round(((Component)__instance).transform.position.z);
					}
					if (!isInitializedLines)
					{
						return;
					}
				}
				_ = ((Component)__instance).transform.position;
				if (false)
				{
					Plugin.mls.LogInfo((object)"Error: transform.position is null.");
					return;
				}
				playerFloorPosY = ((Component)__instance).transform.position.y;
				if (!isVirtualGenerationMode)
				{
					closestPos.x = (int)Math.Round(((Component)__instance).transform.position.x);
					closestPos.z = (int)Math.Round(((Component)__instance).transform.position.z);
				}
				UpdateGeneration();
				UpdateLine();
				if (!isVirtualGenerationMode)
				{
					UpdateTilePosition();
				}
				else if (isVirtualGenerationMode)
				{
					UpdateTilePositionOnVirtualGenerationMode();
				}
				UpdateEggLines();
				previousClosestPos = closestPos;
				previousPlayerFloorPosY = playerFloorPosY;
				isLocalPlayerServer = ((NetworkBehaviour)__instance).IsServer;
				lastUpdateTime += Time.deltaTime;
				if (isRangeChanged)
				{
					isRangeChanged = false;
				}
				if (isForceToUpdateNext)
				{
					isForceToUpdateNext = false;
				}
			}
		}

		private static void UpdateLine()
		{
			//IL_0143: 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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: 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_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			if (linesZ == null || linesX == null)
			{
				Plugin.mls.LogInfo((object)"Skipped UpdateLine due to some of variables are null.");
				return;
			}
			_ = previousClosestPos;
			if (false)
			{
				previousClosestPos.InitToZero();
			}
			if (previousClosestPos == closestPos && playerFloorPosY == previousPlayerFloorPosY && !isRangeChanged && !isForceToUpdateNext)
			{
				return;
			}
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor((float)closestPos.x - (float)(lineDiameter / 2), playerFloorPosY + 0.102f, (float)closestPos.z);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor((float)closestPos.x + (float)(lineDiameter / 2), playerFloorPosY + 0.102f, (float)closestPos.z);
			for (int i = 0; i < linesZ.Count; i++)
			{
				if ((Object)(object)linesZ[i] == (Object)null)
				{
					continue;
				}
				int num = 0;
				if (i != 0)
				{
					if (i % 2 == 0)
					{
						num = i / 2;
						num = -num;
					}
					else
					{
						num = (i + 1) / 2;
					}
				}
				Vector3 val3 = val;
				val3.z += num;
				Vector3 val4 = val2;
				val4.z += num;
				linesZ[i].SetPosition(0, val3);
				linesZ[i].SetPosition(1, val4);
			}
			Vector3 val5 = default(Vector3);
			((Vector3)(ref val5))..ctor((float)closestPos.x, playerFloorPosY + 0.102f, (float)closestPos.z - (float)(lineDiameter / 2));
			Vector3 val6 = default(Vector3);
			((Vector3)(ref val6))..ctor((float)closestPos.x, playerFloorPosY + 0.102f, (float)closestPos.z + (float)(lineDiameter / 2));
			for (int j = 0; j < linesX.Count; j++)
			{
				if ((Object)(object)linesX[j] == (Object)null)
				{
					continue;
				}
				int num2 = 0;
				if (j != 0)
				{
					if (j % 2 == 0)
					{
						num2 = j / 2;
						num2 = -num2;
					}
					else
					{
						num2 = (j + 1) / 2;
					}
				}
				Vector3 val7 = val5;
				val7.x += num2;
				Vector3 val8 = val6;
				val8.x += num2;
				linesX[j].SetPosition(0, val7);
				linesX[j].SetPosition(1, val8);
			}
		}

		private static void UpdateTilePosition()
		{
			//IL_06fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0730: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_061b: Unknown result type (might be due to invalid IL or missing references)
			if (tilePos == null || tiles == null)
			{
				Plugin.mls.LogInfo((object)"Skipped UpdateTilePosition due to some of variables are null.");
			}
			else if (randomMapSeed != -1)
			{
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor((float)closestPos.x, 0f, (float)closestPos.z);
				if (previousClosestPos != closestPos || isRangeChanged || isForceToUpdateNext)
				{
					Vector3 val2 = default(Vector3);
					for (int i = 0; i < lineDiameter; i++)
					{
						int num = 0;
						while (num < lineDiameter)
						{
							if (!((Object)(object)tiles[i][num] == (Object)null))
							{
								((Vector3)(ref val2))..ctor((float)(-lineDiameter / 2) + 0.5f + (float)num, playerFloorPosY + 0.1f, 0f + ((float)(-lineDiameter / 2) + 0.5f) + (float)i);
								tilePos[i][num] = val + val2;
								tiles[i][num].transform.position = tilePos[i][num];
								if (i >= lineRadius - accurateTileDis && i <= lineRadius + accurateTileDis && num >= lineRadius - accurateTileDis && num <= lineRadius + accurateTileDis)
								{
									GameObject obj = tiles[i][num];
									Vector3 position = tiles[i][num].transform.position;
									obj.SetActive(CalculateExplodeEgg(in position));
								}
								num++;
								continue;
							}
							goto IL_00bb;
						}
						continue;
						IL_00bb:
						Plugin.mls.LogInfo((object)"Error: Tile is null.");
						break;
					}
					lastUpdateTime = 0f;
					ResetIsProcessed();
					isProcessed[0] = true;
				}
				else if (lastUpdateTime > 0.4f && isProcessed[7])
				{
					if (previousClosestPos == closestPos && playerFloorPosY == previousPlayerFloorPosY)
					{
						return;
					}
					Vector3 val3 = default(Vector3);
					for (int j = 0; j < lineDiameter; j++)
					{
						for (int k = 0; k < lineDiameter; k++)
						{
							((Vector3)(ref val3))..ctor((float)(-lineDiameter / 2) + 0.5f + (float)k, playerFloorPosY + 0.1f, 0f + ((float)(-lineDiameter / 2) + 0.5f) + (float)j);
							tilePos[j][k] = val + val3;
							tiles[j][k].transform.position = tilePos[j][k];
						}
					}
				}
				else if (lastUpdateTime > 0.35f && !isProcessed[7] && isProcessed[6])
				{
					ProcessTileUpdate(playerFloorPosY, prioritizedTileDis6, prioritizedTileDis7);
					isProcessed[7] = true;
				}
				else if (lastUpdateTime > 0.3f && !isProcessed[6] && isProcessed[5])
				{
					ProcessTileUpdate(playerFloorPosY, prioritizedTileDis5, prioritizedTileDis6);
					isProcessed[6] = true;
				}
				else if (lastUpdateTime > 0.25f && !isProcessed[5] && isProcessed[4])
				{
					ProcessTileUpdate(playerFloorPosY, prioritizedTileDis4, prioritizedTileDis5);
					isProcessed[5] = true;
				}
				else if (lastUpdateTime > 0.2f && !isProcessed[4] && isProcessed[3])
				{
					ProcessTileUpdate(playerFloorPosY, prioritizedTileDis3, prioritizedTileDis4);
					isProcessed[4] = true;
				}
				else if (lastUpdateTime > 0.15f && !isProcessed[3] && isProcessed[2])
				{
					ProcessTileUpdate(playerFloorPosY, prioritizedTileDis2, prioritizedTileDis3);
					isProcessed[3] = true;
				}
				else if (lastUpdateTime > 0.1f && !isProcessed[2] && isProcessed[1])
				{
					ProcessTileUpdate(playerFloorPosY, prioritizedTileDis1, prioritizedTileDis2);
					isProcessed[2] = true;
				}
				else if (lastUpdateTime > 0.05f && !isProcessed[1] && isProcessed[0])
				{
					ProcessTileUpdate(playerFloorPosY, accurateTileDis, prioritizedTileDis1);
					isProcessed[1] = true;
				}
				else
				{
					if (previousClosestPos == closestPos && playerFloorPosY == previousPlayerFloorPosY)
					{
						return;
					}
					Vector3 val4 = default(Vector3);
					for (int l = 0; l < lineDiameter; l++)
					{
						for (int m = 0; m < lineDiameter; m++)
						{
							((Vector3)(ref val4))..ctor((float)(-lineDiameter / 2) + 0.5f + (float)m, playerFloorPosY + 0.1f, 0f + ((float)(-lineDiameter / 2) + 0.5f) + (float)l);
							tilePos[l][m] = val + val4;
							tiles[l][m].transform.position = tilePos[l][m];
						}
					}
				}
			}
			else
			{
				if (!(previousClosestPos != closestPos))
				{
					return;
				}
				Vector3 val5 = default(Vector3);
				((Vector3)(ref val5))..ctor((float)closestPos.x, 0f, (float)closestPos.z);
				Vector3 val6 = default(Vector3);
				for (int n = 0; n < lineDiameter; n++)
				{
					for (int num2 = 0; num2 < lineDiameter; num2++)
					{
						((Vector3)(ref val6))..ctor((float)(-lineDiameter / 2) + 0.5f + (float)num2, playerFloorPosY + 0.1f, 0f + ((float)(-lineDiameter / 2) + 0.5f) + (float)n);
						tilePos[n][num2] = val5 + val6;
						tiles[n][num2].transform.position = tilePos[n][num2];
						tiles[n][num2].SetActive(false);
					}
				}
			}
		}

		private static void UpdateTilePositionOnVirtualGenerationMode()
		{
			//IL_0704: Unknown result type (might be due to invalid IL or missing references)
			//IL_0706: Unknown result type (might be due to invalid IL or missing references)
			//IL_0708: Unknown result type (might be due to invalid IL or missing references)
			//IL_0739: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: 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_02f0: 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_05f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0624: Unknown result type (might be due to invalid IL or missing references)
			if (tilePos == null || virtualTiles == null)
			{
				Plugin.mls.LogInfo((object)"Skipped UpdateTilePosition due to some of variables are null.");
			}
			else if (virtualMapSeed != -1)
			{
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor((float)closestPos.x, 0f, (float)closestPos.z);
				if (previousClosestPos != closestPos || isRangeChanged || isForceToUpdateNext)
				{
					Vector3 val2 = default(Vector3);
					for (int i = 0; i < lineDiameter; i++)
					{
						int num = 0;
						while (num < lineDiameter)
						{
							if (!((Object)(object)virtualTiles[i][num] == (Object)null))
							{
								((Vector3)(ref val2))..ctor((float)(-lineDiameter / 2) + 0.5f + (float)num, playerFloorPosY + 0.1f, 0f + ((float)(-lineDiameter / 2) + 0.5f) + (float)i);
								tilePos[i][num] = val + val2;
								virtualTiles[i][num].transform.position = tilePos[i][num];
								if (i >= lineRadius - accurateTileDis && i <= lineRadius + accurateTileDis && num >= lineRadius - accurateTileDis && num <= lineRadius + accurateTileDis)
								{
									Vector3 position = virtualTiles[i][num].transform.position;
									if (CalculateVirtualExplodeEgg(in position))
									{
										virtualTiles[i][num].SetActive(true);
									}
								}
								num++;
								continue;
							}
							goto IL_00bb;
						}
						continue;
						IL_00bb:
						Plugin.mls.LogInfo((object)"Error: virtualTile is null.");
						break;
					}
					lastUpdateTime = 0f;
					ResetIsProcessed();
					isProcessed[0] = true;
				}
				else if (lastUpdateTime > 0.4f && isProcessed[7])
				{
					if (previousClosestPos == closestPos && playerFloorPosY == previousPlayerFloorPosY)
					{
						return;
					}
					Vector3 val3 = default(Vector3);
					for (int j = 0; j < lineDiameter; j++)
					{
						for (int k = 0; k < lineDiameter; k++)
						{
							((Vector3)(ref val3))..ctor((float)(-lineDiameter / 2) + 0.5f + (float)k, playerFloorPosY + 0.1f, 0f + ((float)(-lineDiameter / 2) + 0.5f) + (float)j);
							tilePos[j][k] = val + val3;
							virtualTiles[j][k].transform.position = tilePos[j][k];
						}
					}
				}
				else if (lastUpdateTime > 0.35f && !isProcessed[7] && isProcessed[6])
				{
					ProcessVirtualTileUpdate(playerFloorPosY, prioritizedTileDis6, prioritizedTileDis7);
					isProcessed[7] = true;
				}
				else if (lastUpdateTime > 0.3f && !isProcessed[6] && isProcessed[5])
				{
					ProcessVirtualTileUpdate(playerFloorPosY, prioritizedTileDis5, prioritizedTileDis6);
					isProcessed[6] = true;
				}
				else if (lastUpdateTime > 0.25f && !isProcessed[5] && isProcessed[4])
				{
					ProcessVirtualTileUpdate(playerFloorPosY, prioritizedTileDis4, prioritizedTileDis5);
					isProcessed[5] = true;
				}
				else if (lastUpdateTime > 0.2f && !isProcessed[4] && isProcessed[3])
				{
					ProcessVirtualTileUpdate(playerFloorPosY, prioritizedTileDis3, prioritizedTileDis4);
					isProcessed[4] = true;
				}
				else if (lastUpdateTime > 0.15f && !isProcessed[3] && isProcessed[2])
				{
					ProcessVirtualTileUpdate(playerFloorPosY, prioritizedTileDis2, prioritizedTileDis3);
					isProcessed[3] = true;
				}
				else if (lastUpdateTime > 0.1f && !isProcessed[2] && isProcessed[1])
				{
					ProcessVirtualTileUpdate(playerFloorPosY, prioritizedTileDis1, prioritizedTileDis2);
					isProcessed[2] = true;
				}
				else if (lastUpdateTime > 0.05f && !isProcessed[1] && isProcessed[0])
				{
					ProcessVirtualTileUpdate(playerFloorPosY, accurateTileDis, prioritizedTileDis1);
					isProcessed[1] = true;
				}
				else
				{
					if (previousClosestPos == closestPos && playerFloorPosY == previousPlayerFloorPosY)
					{
						return;
					}
					Vector3 val4 = default(Vector3);
					for (int l = 0; l < lineDiameter; l++)
					{
						for (int m = 0; m < lineDiameter; m++)
						{
							((Vector3)(ref val4))..ctor((float)(-lineDiameter / 2) + 0.5f + (float)m, playerFloorPosY + 0.1f, 0f + ((float)(-lineDiameter / 2) + 0.5f) + (float)l);
							tilePos[l][m] = val + val4;
							virtualTiles[l][m].transform.position = tilePos[l][m];
						}
					}
				}
			}
			else
			{
				if (!(previousClosestPos != closestPos))
				{
					return;
				}
				Vector3 val5 = default(Vector3);
				((Vector3)(ref val5))..ctor((float)closestPos.x, 0f, (float)closestPos.z);
				Vector3 val6 = default(Vector3);
				for (int n = 0; n < lineDiameter; n++)
				{
					for (int num2 = 0; num2 < lineDiameter; num2++)
					{
						((Vector3)(ref val6))..ctor((float)(-lineDiameter / 2) + 0.5f + (float)num2, playerFloorPosY + 0.1f, 0f + ((float)(-lineDiameter / 2) + 0.5f) + (float)n);
						tilePos[n][num2] = val5 + val6;
						virtualTiles[n][num2].transform.position = tilePos[n][num2];
						virtualTiles[n][num2].SetActive(false);
					}
				}
			}
		}

		internal static void SetVirtualTilesToFlase()
		{
			for (int i = 0; i < lineDiameter; i++)
			{
				for (int j = 0; j < lineDiameter; j++)
				{
					if ((Object)(object)virtualTiles[i][j] == (Object)null)
					{
						Plugin.mls.LogInfo((object)"Error: virtualTile is null.");
						return;
					}
					virtualTiles[i][j].SetActive(false);
				}
			}
		}

		private static void UpdateEggLines()
		{
			for (int i = 0; i < eggLines.Count; i++)
			{
				if ((Object)(object)eggLines[i] != (Object)null && !eggLines[i].isDisabled)
				{
					eggLines[i].UpdateEggLine(playerFloorPosY + 0.101f);
					if (eggLines[i].isDisabled)
					{
						Object.Destroy((Object)(object)((Component)eggLines[i]).gameObject);
						Object.Destroy((Object)(object)eggLines[i]);
					}
				}
			}
		}

		private static void ProcessTileUpdate(float playerPosY, int MinSize, int MaxSize)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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)
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor((float)closestPos.x, 0f, (float)closestPos.z);
			Vector3 val2 = default(Vector3);
			for (int i = 0; i < lineDiameter; i++)
			{
				for (int j = 0; j < lineDiameter; j++)
				{
					((Vector3)(ref val2))..ctor((float)(-lineDiameter / 2) + 0.5f + (float)j, playerPosY + 0.1f, 0f + ((float)(-lineDiameter / 2) + 0.5f) + (float)i);
					tilePos[i][j] = val + val2;
					tiles[i][j].transform.position = tilePos[i][j];
					if ((i < lineRadius - MinSize || i > lineRadius + MinSize || j < lineRadius - MinSize || j > lineRadius + MinSize) && i >= lineRadius - MaxSize && i <= lineRadius + MaxSize && j >= lineRadius - MaxSize && j <= lineRadius + MaxSize)
					{
						GameObject obj = tiles[i][j];
						Vector3 position = tiles[i][j].transform.position;
						obj.SetActive(CalculateExplodeEgg(in position));
					}
				}
			}
		}

		private static void ProcessVirtualTileUpdate(float playerPosY, int MinSize, int MaxSize)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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)
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor((float)closestPos.x, 0f, (float)closestPos.z);
			Vector3 val2 = default(Vector3);
			for (int i = 0; i < lineDiameter; i++)
			{
				for (int j = 0; j < lineDiameter; j++)
				{
					((Vector3)(ref val2))..ctor((float)(-lineDiameter / 2) + 0.5f + (float)j, playerPosY + 0.1f, 0f + ((float)(-lineDiameter / 2) + 0.5f) + (float)i);
					tilePos[i][j] = val + val2;
					virtualTiles[i][j].transform.position = tilePos[i][j];
					if ((i < lineRadius - MinSize || i > lineRadius + MinSize || j < lineRadius - MinSize || j > lineRadius + MinSize) && i >= lineRadius - MaxSize && i <= lineRadius + MaxSize && j >= lineRadius - MaxSize && j <= lineRadius + MaxSize)
					{
						Vector3 position = virtualTiles[i][j].transform.position;
						if (CalculateVirtualExplodeEgg(in position))
						{
							virtualTiles[i][j].SetActive(true);
						}
					}
				}
			}
		}

		private static bool CalculateExplodeEgg(in Vector3 position)
		{
			return (float)new Random(randomMapSeed + 10 + (int)position.x + (int)position.z).Next(0, 100) <= chanceToExplode;
		}

		private static bool CalculateVirtualExplodeEgg(in Vector3 position)
		{
			return (float)new Random(virtualMapSeed + 10 + (int)position.x + (int)position.z).Next(0, 100) <= chanceToExplode;
		}

		[HarmonyPatch(typeof(StunGrenadeItem))]
		[HarmonyPatch("__rpc_handler_1175066890")]
		[HarmonyPostfix]
		private static void SetExplodeOnThrowClinetRPCExtension(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			if (isLocalPlayerServer)
			{
				StunGrenadeItem val = (StunGrenadeItem)(object)((target is StunGrenadeItem) ? target : null);
				if ((Object)(object)val == (Object)null)
				{
					Plugin.mls.LogInfo((object)"Error: NetworkBehaviour stunGrenadeTarget is null.");
				}
				else if ((Object)(object)EggLineSync.Instance == (Object)null)
				{
					Plugin.mls.LogInfo((object)"Error: EggLineSync is null.");
				}
				else if (isLocalPlayerServer)
				{
					EggLineSync.Instance.EggLinesClientRpc(((Component)val).transform.position, val.explodeOnThrow);
				}
			}
		}

		public static void GenerateEggLine(Vector3 egglinePos, bool explode)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if (explode)
			{
				HUDManager instance = HUDManager.Instance;
				Vector3 val = egglinePos;
				instance.DisplayTip("CoordinateForEasterEggs", "The easter egg will explode!!\nPicked it up from:\n" + ((object)(Vector3)(ref val)).ToString(), false, false, "LC_Tip1");
				ManualLogSource mls = Plugin.mls;
				val = egglinePos;
				mls.LogInfo((object)("The easter egg will explode!!\nPicked it up from:\n" + ((object)(Vector3)(ref val)).ToString()));
			}
			GameObject val2 = new GameObject("EggLine");
			EggLine eggLine = val2.AddComponent<EggLine>();
			eggLine.InitAndSetPos(egglinePos, explode, in playerFloorPosY);
			for (int i = 0; i < eggLines.Count; i++)
			{
				if ((Object)(object)eggLines[i] == (Object)null)
				{
					eggLines[i] = eggLine;
					Plugin.mls.LogInfo((object)("New EggLine is added at index " + i + ". Length is " + (eggLines.Count - 1)));
					return;
				}
			}
			eggLines.Add(eggLine);
			Plugin.mls.LogInfo((object)("New EggLine is added at index " + (eggLines.Count - 1) + " as new index"));
		}

		public static void ResetAll()
		{
			ResetLine();
			eggLines = null;
			randomMapSeed = -1;
			closestPos.InitToZero();
			isRangeChanged = false;
			previousClosestPos.InitToZero();
			previousPlayerFloorPosY = 0f;
			lastUpdateTime = 0f;
			playerFloorPosY = 0f;
			isProcessed = null;
			isLocalPlayerServer = false;
			virtualMapSeed = -1;
			virtualBaseScraps = -1;
			virtualDungeonType = -1;
			isGeneratingSeed = false;
			previousTimeInterval = 0;
			isVirtualGenerationMode = false;
			isConditionedFactory = false;
			isConditionedMansion = false;
			isConditionedMineshaft = false;
			isConditionedAnyDungeon = false;
			conditionedMinScraps = -1;
			conditionedMaxScraps = -1;
			isForceToUpdateNext = false;
			Plugin.mls.LogInfo((object)"ResetAll is called");
		}

		public static void ResetLine()
		{
			for (int i = 0; i < linesX.Count; i++)
			{
				if ((Object)(object)linesX[i] != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)linesX[i]).gameObject);
				}
			}
			linesX.Clear();
			for (int j = 0; j < linesZ.Count; j++)
			{
				if ((Object)(object)linesZ[j] != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)linesZ[j]).gameObject);
				}
			}
			linesZ.Clear();
			for (int k = 0; k < tiles.Count; k++)
			{
				for (int l = 0; l < tiles[k].Count; l++)
				{
					if ((Object)(object)tiles[k][l] != (Object)null)
					{
						Object.Destroy((Object)(object)tiles[k][l].gameObject);
					}
				}
			}
			tiles.Clear();
			for (int m = 0; m < virtualTiles.Count; m++)
			{
				for (int n = 0; n < virtualTiles[m].Count; n++)
				{
					if ((Object)(object)virtualTiles[m][n] != (Object)null)
					{
						Object.Destroy((Object)(object)virtualTiles[m][n].gameObject);
					}
				}
			}
			virtualTiles.Clear();
			tilePos.Clear();
			isInitializedLines = false;
			isInitializedTiles = false;
			isInitializedVirtualTiles = false;
			lineDiameter = 0;
			Plugin.mls.LogInfo((object)"ResetLine is called");
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			((NetworkBehaviour)this).__initializeRpcs();
		}

		protected internal override string __getTypeName()
		{
			return "CoordinateForEasterEggs";
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace CoordinateForEasterEggs.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}