Decompiled source of NotezyLib v0.1.5

NoteBoxz.NotezyLib.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using DunGen;
using DunGen.Graph;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using NoteBoxz.NotezyLib.NetcodePatcher;
using NotezyLib.MultiDungeon;
using NotezyLib.Utils;
using Unity.AI.Navigation;
using Unity.Netcode;
using UnityEditor;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;

[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: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("LethalLevelLoader")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("NoteBoxz.NotezyLib")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.5.0")]
[assembly: AssemblyInformationalVersion("0.1.5+a0eedc02093e663d23c270bff638921b20c82763")]
[assembly: AssemblyProduct("NotezyLib")]
[assembly: AssemblyTitle("NoteBoxz.NotezyLib")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.5.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace NotezyLib
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("NoteBoxz.NotezyLib", "NotezyLib", "0.1.5")]
	public class NotezyLib : BaseUnityPlugin
	{
		public static NotezyLib Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		public static List<DungeonFlow> DungeonFlows => Resources.FindObjectsOfTypeAll<DungeonFlow>().ToList();

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			NetcodePatcher();
			Patch();
			Logger.LogInfo((object)"NoteBoxz.NotezyLib v0.1.5 has loaded!");
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("NoteBoxz.NotezyLib");
			}
			Logger.LogDebug((object)"Patching...");
			Type[] typesWithErrorHandling = GetTypesWithErrorHandling();
			Type[] array = typesWithErrorHandling;
			foreach (Type type in array)
			{
				if (type.Namespace == null || !type.Namespace.StartsWith("NotezyLib.Editor", StringComparison.Ordinal))
				{
					try
					{
						Harmony.CreateClassProcessor(type).Patch();
					}
					catch (Exception arg)
					{
						Logger.LogWarning((object)$"Failed to process patches for {type.FullName}: {arg}");
					}
				}
			}
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}

		private void NetcodePatcher()
		{
			Type[] typesWithErrorHandling = GetTypesWithErrorHandling();
			Type[] array = typesWithErrorHandling;
			foreach (Type type in array)
			{
				if (type.Namespace != null && type.Namespace.StartsWith("NotezyLib.Editor", StringComparison.Ordinal))
				{
					continue;
				}
				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);
					}
				}
			}
		}

		internal static Type[] GetTypesWithErrorHandling()
		{
			try
			{
				return Assembly.GetExecutingAssembly().GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				Logger.LogWarning((object)"ReflectionTypeLoadException caught while getting types. Some types will be skipped.");
				Exception[] loaderExceptions = ex.LoaderExceptions;
				foreach (Exception ex2 in loaderExceptions)
				{
					Logger.LogDebug((object)("Loader Exception: " + ex2.Message));
					if (ex2 is FileNotFoundException ex3)
					{
						Logger.LogDebug((object)("Could not load file: " + ex3.FileName));
					}
				}
				return ex.Types.Where((Type t) => t != null).ToArray();
			}
			catch (Exception arg)
			{
				Logger.LogError((object)$"Unexpected error while getting types: {arg}");
				return new Type[0];
			}
		}

		public static void LogMessage(object message)
		{
			Logger.LogMessage(message);
		}

		public static void LogDebug(object message)
		{
			Logger.LogDebug(message);
		}

		public static void LogWarning(object message)
		{
			Logger.LogWarning(message);
		}

		public static void LogError(object message)
		{
			Logger.LogError(message);
		}

		public static void LogFatal(object message)
		{
			Logger.LogFatal(message);
		}

		public static void LogInfo(object message)
		{
			Logger.LogInfo(message);
		}
	}
	public static class Extensions
	{
		public static bool AddIfNotAlreadyInList<T>(this List<T> list, T item)
		{
			if (!list.Contains(item))
			{
				list.Add(item);
				return true;
			}
			return false;
		}

		public static bool ContainsLowercase(this List<string> list, string item)
		{
			foreach (string item2 in list)
			{
				if (item2.ToLower() == item.ToLower())
				{
					return true;
				}
			}
			return false;
		}

		public static T[] AddToArray<T>(this T[] array, T obj)
		{
			if (array == null)
			{
				return new T[1] { obj };
			}
			T[] array2 = new T[array.Length + 1];
			for (int i = 0; i < array.Length; i++)
			{
				array2[i] = array[i];
			}
			array2[array.Length] = obj;
			return array2;
		}

		public static T[] RemoveFromArray<T>(this T[] array, T obj)
		{
			if (array == null || array.Length == 0)
			{
				return new T[0];
			}
			int indexFromArray = array.GetIndexFromArray(obj);
			if (indexFromArray == -1)
			{
				return array;
			}
			T[] array2 = new T[array.Length - 1];
			if (indexFromArray > 0)
			{
				Array.Copy(array, 0, array2, 0, indexFromArray);
			}
			if (indexFromArray < array.Length - 1)
			{
				Array.Copy(array, indexFromArray + 1, array2, indexFromArray, array.Length - indexFromArray - 1);
			}
			return array2;
		}

		public static int GetIndexFromArray<T>(this T[] array, T obj)
		{
			if (array == null || array.Length == 0)
			{
				return -1;
			}
			int num = 0;
			while (num < array.Length)
			{
				ref T reference = ref array[num];
				T val = default(T);
				if (val == null)
				{
					val = reference;
					reference = ref val;
					if (val == null)
					{
						goto IL_0060;
					}
				}
				if (!reference.Equals(obj))
				{
					goto IL_0060;
				}
				goto IL_0081;
				IL_0060:
				if (array[num] != null || obj != null)
				{
					num++;
					continue;
				}
				goto IL_0081;
				IL_0081:
				return num;
			}
			return -1;
		}

		public static bool TryGetComponentInParent<T>(this MonoBehaviour mono, out T component)
		{
			component = default(T);
			Transform transform = ((Component)mono).transform;
			if ((Object)(object)transform.parent == (Object)null)
			{
				return false;
			}
			component = ((Component)mono).GetComponentInParent<T>();
			return component != null;
		}

		public static bool TryGetComponentInChildren<T>(this MonoBehaviour mono, out T component)
		{
			component = default(T);
			Transform transform = ((Component)mono).transform;
			if (transform.childCount == 0)
			{
				return false;
			}
			component = ((Component)mono).GetComponentInChildren<T>();
			return component != null;
		}
	}
	[AddComponentMenu("NotezyLib/NavMeshLinkFixer")]
	public class NavMeshLinkFixer : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <DelayedFix>d__4 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public NavMeshLinkFixer <>4__this;

			private NavMeshHit <hitStart>5__1;

			private NavMeshHit <hitEnd>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DelayedFix>d__4(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				//IL_0093: Unknown result type (might be due to invalid IL or missing references)
				//IL_0098: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_0110: Unknown result type (might be due to invalid IL or missing references)
				//IL_0115: Unknown result type (might be due to invalid IL or missing references)
				//IL_0154: Unknown result type (might be due to invalid IL or missing references)
				//IL_0159: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if ((Object)(object)<>4__this.link == (Object)null)
					{
						<>4__this.link = ((Component)<>4__this).GetComponent<NavMeshLink>();
					}
					if (<>4__this.FixStart && NavMesh.SamplePosition(((Component)<>4__this.link).transform.TransformPoint(<>4__this.link.startPoint), ref <hitStart>5__1, 5f, -1))
					{
						<>4__this.link.startPoint = ((Component)<>4__this.link).transform.InverseTransformPoint(((NavMeshHit)(ref <hitStart>5__1)).position);
					}
					if (<>4__this.FixEnd && NavMesh.SamplePosition(((Component)<>4__this.link).transform.TransformPoint(<>4__this.link.endPoint), ref <hitEnd>5__2, 5f, -1))
					{
						<>4__this.link.endPoint = ((Component)<>4__this.link).transform.InverseTransformPoint(((NavMeshHit)(ref <hitEnd>5__2)).position);
					}
					<>4__this.link.UpdateLink();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[Header("If enabled, will attempt to fix the start and/or end point of the NavMeshLink to nearest valid NavMesh position on start")]
		public NavMeshLink link = null;

		public bool FixStart;

		public bool FixEnd;

		public void OnEnable()
		{
			((MonoBehaviour)this).StartCoroutine(DelayedFix());
		}

		[IteratorStateMachine(typeof(<DelayedFix>d__4))]
		private IEnumerator DelayedFix()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DelayedFix>d__4(0)
			{
				<>4__this = this
			};
		}
	}
	public struct NetworkIntWithRarity : INetworkSerializable
	{
		public int id;

		public int rarity;

		public NetworkIntWithRarity(int id, int rarity)
		{
			this.id = id;
			this.rarity = rarity;
		}

		public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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)
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref id, default(ForPrimitives));
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref rarity, default(ForPrimitives));
		}

		public IntWithRarity ToIntWithRarity()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			IntWithRarity val = new IntWithRarity();
			Extensions.Add(val, id, rarity);
			return val;
		}

		public static NetworkIntWithRarity FromIntWithRarity(IntWithRarity intWithRarity)
		{
			return new NetworkIntWithRarity(intWithRarity.id, intWithRarity.rarity);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "NoteBoxz.NotezyLib";

		public const string PLUGIN_NAME = "NotezyLib";

		public const string PLUGIN_VERSION = "0.1.5";
	}
}
namespace NotezyLib.Utils
{
	public static class GeneralUtils
	{
		public static T? FindClosestInstanceOfScript<T>(Vector3 position) where T : MonoBehaviour
		{
			//IL_0024: 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)
			T result = default(T);
			float num = float.MaxValue;
			T[] array = Object.FindObjectsOfType<T>();
			foreach (T val in array)
			{
				float num2 = Vector3.Distance(position, ((Component)(object)val).transform.position);
				if (num2 < num)
				{
					num = num2;
					result = val;
				}
			}
			return result;
		}

		public static bool DoesTypeUseMethod(Type type, string methodName)
		{
			if (type == null)
			{
				return false;
			}
			MethodInfo[] methods = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			MethodInfo[] array = methods;
			foreach (MethodInfo methodInfo in array)
			{
				try
				{
					MethodBody methodBody = methodInfo.GetMethodBody();
					if (methodBody == null)
					{
						continue;
					}
					byte[] iLAsByteArray = methodBody.GetILAsByteArray();
					if (iLAsByteArray == null)
					{
						continue;
					}
					for (int j = 0; j < iLAsByteArray.Length - 4; j++)
					{
						if (iLAsByteArray[j] != 40 && iLAsByteArray[j] != 111)
						{
							continue;
						}
						int metadataToken = BitConverter.ToInt32(iLAsByteArray, j + 1);
						try
						{
							MethodBase methodBase = methodInfo.Module.ResolveMethod(metadataToken);
							if (methodBase.Name == methodName)
							{
								return true;
							}
						}
						catch (Exception)
						{
						}
					}
				}
				catch (Exception)
				{
				}
			}
			return false;
		}

		public static bool IsServerRpcPrefixValid(NetworkBehaviour __instance)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Invalid comparison between Unknown and I4
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Invalid comparison between Unknown and I4
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			string name = new StackTrace().GetFrame(1).GetMethod().Name;
			NetworkManager networkManager = __instance.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				NotezyLib.LogDebug("IsServerRpcPrefixValid (No): NetworkManager is null or not listening when calling " + name);
				return false;
			}
			if ((int)__instance.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost) && __instance.OwnerClientId != networkManager.LocalClientId)
			{
				NotezyLib.LogDebug($"IsServerRpcPrefixValid (No): OwnerClientId {__instance.OwnerClientId} does not match LocalClientId {networkManager.LocalClientId} when calling {name}");
				return false;
			}
			if ((int)__instance.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				NotezyLib.LogDebug($"IsServerRpcPrefixValid (Yes): RpcExecStage is {__instance.__rpc_exec_stage}, IsServer: {networkManager.IsServer}, IsHost: {networkManager.IsHost} when calling {name}");
				return true;
			}
			NotezyLib.LogDebug($"IsServerRpcPrefixValid (No): RpcExecStage is {__instance.__rpc_exec_stage}, IsServer: {networkManager.IsServer}, IsHost: {networkManager.IsHost} when calling {name}");
			return false;
		}

		public static bool IsServerRpcNoOwnershipPrefixValid(NetworkBehaviour __instance)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Invalid comparison between Unknown and I4
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			string name = new StackTrace().GetFrame(1).GetMethod().Name;
			NetworkManager networkManager = __instance.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				NotezyLib.LogDebug("IsServerRpcNoOwnershipPrefixValid (No): NetworkManager is null or not listening when calling " + name);
				return false;
			}
			if ((int)__instance.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				NotezyLib.LogDebug($"IsServerRpcNoOwnershipPrefixValid (No): RpcExecStage is {__instance.__rpc_exec_stage}, IsServer: {networkManager.IsServer}, IsHost: {networkManager.IsHost} when calling {name}");
				return false;
			}
			NotezyLib.LogDebug($"IsServerRpcNoOwnershipPrefixValid (Yes): RpcExecStage is {__instance.__rpc_exec_stage}, IsServer: {networkManager.IsServer}, IsHost: {networkManager.IsHost} when calling {name}");
			return true;
		}

		public static bool IsClientRpcPrefixValid(NetworkBehaviour __instance)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Invalid comparison between Unknown and I4
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			string name = new StackTrace().GetFrame(1).GetMethod().Name;
			NetworkManager networkManager = __instance.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)__instance.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					NotezyLib.LogDebug($"IsClientRpcPrefixValid (Yes): RpcExecStage is {__instance.__rpc_exec_stage}, IsClient: {networkManager.IsClient}, IsHost: {networkManager.IsHost} {name}");
					return true;
				}
				NotezyLib.LogDebug($"IsClientRpcPrefixValid (No): RpcExecStage is {__instance.__rpc_exec_stage}, IsClient: {networkManager.IsClient}, IsHost: {networkManager.IsHost} {name}");
				return false;
			}
			NotezyLib.LogDebug("IsClientRpcPrefixValid (No): NetworkManager is null or not listening " + name);
			return false;
		}
	}
	public static class PlayerUtils
	{
		public static bool IsPlayerConnected(PlayerControllerB player)
		{
			PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[0];
			return (Object)(object)player == (Object)(object)val || ((Object)(object)player != (Object)(object)val && ((NetworkBehaviour)player).OwnerClientId != 0L && StartOfRound.Instance.ClientPlayerList.ContainsKey(((NetworkBehaviour)player).OwnerClientId));
		}

		public static List<PlayerControllerB> GetAllConnectedPlayers()
		{
			List<PlayerControllerB> list = new List<PlayerControllerB>();
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (IsPlayerConnected(val))
				{
					list.Add(val);
				}
			}
			return list;
		}

		public static PlayerControllerB? GetPlayerByClientId(ulong clientId)
		{
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (((NetworkBehaviour)val).OwnerClientId == clientId && IsPlayerConnected(val))
				{
					return val;
				}
			}
			return null;
		}

		public static void SetPlayerInside(PlayerControllerB player, bool Inside)
		{
			try
			{
				player.isInsideFactory = Inside;
				EntranceTeleport val = RoundManager.FindMainEntranceScript(!Inside);
				NotezyLib.LogInfo($"Set player {((NetworkBehaviour)player).OwnerClientId} inside state to {Inside}. Main EntranceTeleport {((val != null) ? ((Object)((Component)val).gameObject).name : null)}");
				if ((Object)(object)val == (Object)null || val.audioReverbPreset == -1)
				{
					NotezyLib.LogWarning("No valid EntranceTeleport found or no audio reverb preset set.");
				}
				else
				{
					Object.FindObjectOfType<AudioReverbPresets>().audioPresets[val.audioReverbPreset].ChangeAudioReverbForPlayer(player);
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("Error setting player inside state: " + ex.Message));
			}
		}
	}
}
namespace NotezyLib.MultiDungeon
{
	public class DungeonFlowShrinker
	{
		private static Dictionary<DungeonFlow, ShrinkedFlow> _shrinkedFlows = new Dictionary<DungeonFlow, ShrinkedFlow>();

		public static ShrinkedFlow ShrinkFlow(DungeonFlow flow, float flowDivision, float minimumMinFlowLength, float minimumMaxFlowLength)
		{
			if (_shrinkedFlows.TryGetValue(flow, out var value))
			{
				NotezyLib.LogInfo($"Flow '{((Object)flow).name}' is already shrunk. Current Length: ({flow.Length.Min}, {flow.Length.Max})");
				return value;
			}
			int min = flow.Length.Min;
			int max = flow.Length.Max;
			int num = Mathf.RoundToInt((float)flow.Length.Min / flowDivision);
			int num2 = Mathf.RoundToInt((float)flow.Length.Max / flowDivision);
			int num3 = (((float)flow.Length.Min < minimumMinFlowLength) ? flow.Length.Min : num);
			int num4 = (((float)flow.Length.Max < minimumMaxFlowLength) ? flow.Length.Max : num2);
			flow.Length.Min = num3;
			flow.Length.Max = num4;
			ShrinkedFlow shrinkedFlow = default(ShrinkedFlow);
			shrinkedFlow.Flow = flow;
			shrinkedFlow.PrevMinLength = min;
			shrinkedFlow.PrevMaxLength = max;
			shrinkedFlow.NewMinLength = num3;
			shrinkedFlow.NewMaxLength = num4;
			ShrinkedFlow shrinkedFlow2 = shrinkedFlow;
			_shrinkedFlows[flow] = shrinkedFlow2;
			NotezyLib.LogInfo($"Shrunk flow '{((Object)flow).name}' from  ({max}, {min}) to ({num4}, {num3})");
			return shrinkedFlow2;
		}

		public static bool RestoreFlow(DungeonFlow flow)
		{
			if (_shrinkedFlows.TryGetValue(flow, out var value))
			{
				flow.Length.Min = value.PrevMinLength;
				flow.Length.Max = value.PrevMaxLength;
				_shrinkedFlows.Remove(flow);
				return true;
			}
			return false;
		}

		public static bool IsFlowShrunk(DungeonFlow flow)
		{
			return _shrinkedFlows.ContainsKey(flow);
		}

		public static void ClearAllShrinkedFlows()
		{
			foreach (KeyValuePair<DungeonFlow, ShrinkedFlow> shrinkedFlow in _shrinkedFlows)
			{
				shrinkedFlow.Key.Length.Min = shrinkedFlow.Value.PrevMinLength;
				shrinkedFlow.Key.Length.Max = shrinkedFlow.Value.PrevMaxLength;
			}
			_shrinkedFlows.Clear();
		}
	}
	[Serializable]
	public struct ShrinkedFlow
	{
		public DungeonFlow Flow;

		public int PrevMinLength;

		public int PrevMaxLength;

		public int NewMinLength;

		public int NewMaxLength;
	}
	[AddComponentMenu("NotezyLib/Multi-Dungeon Generator")]
	public class MultiDungeonGenerator : NetworkBehaviour
	{
		[CompilerGenerated]
		private sealed class <GenerateNextDungeon>d__27 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public MultiDungeonGenerator <>4__this;

			private RuntimeDungeon <dungeon>5__1;

			private int <seed>5__2;

			private int <flowTypeId>5__3;

			private DungeonFlow <dungeonFlow>5__4;

			private ShrinkedFlow <shrinkedFlow>5__5;

			private float <num2>5__6;

			private List<ShrinkedFlow>.Enumerator <>s__7;

			private ShrinkedFlow <flow>5__8;

			private bool <did>5__9;

			private List<GlobalPropSettings>.Enumerator <>s__10;

			private GlobalPropSettings <globalPropSettings>5__11;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <GenerateNextDungeon>d__27(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<dungeon>5__1 = null;
				<dungeonFlow>5__4 = null;
				<shrinkedFlow>5__5 = default(ShrinkedFlow);
				<>s__7 = default(List<ShrinkedFlow>.Enumerator);
				<flow>5__8 = default(ShrinkedFlow);
				<>s__10 = default(List<GlobalPropSettings>.Enumerator);
				<globalPropSettings>5__11 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0489: Unknown result type (might be due to invalid IL or missing references)
				//IL_048f: Invalid comparison between Unknown and I4
				//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_04fd: Expected O, but got Unknown
				//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_03bb: Expected O, but got Unknown
				//IL_0458: Unknown result type (might be due to invalid IL or missing references)
				//IL_0462: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (<>4__this.currentDungeonIndex >= <>4__this.ExtraDungeons.Count)
					{
						<>4__this.isGeneratingDungeons = false;
						<>4__this.GeneratedExtraDungeons = true;
						NotezyLib.LogMessage("All extra dungeons have been generated");
						NotezyLib.LogDebug(string.Format("Seeds: (mapSeed: {0}) {1}", StartOfRound.Instance.randomMapSeed, string.Join(", ", <>4__this.RandomSeeds)));
						NotezyLib.LogDebug("Shrinked Flows: " + string.Join(", ", <>4__this.ShrinkedFlows.Select((ShrinkedFlow f) => ((Object)f.Flow).name + $"({f.PrevMinLength}->{f.NewMinLength}, {f.PrevMaxLength}->{f.NewMaxLength})")));
						<>s__7 = <>4__this.ShrinkedFlows.GetEnumerator();
						try
						{
							while (<>s__7.MoveNext())
							{
								<flow>5__8 = <>s__7.Current;
								<did>5__9 = DungeonFlowShrinker.RestoreFlow(<flow>5__8.Flow);
								NotezyLib.LogDebug($"Restored flow '{((Object)<flow>5__8.Flow).name}' to original length: ({<flow>5__8.PrevMinLength}, {<flow>5__8.PrevMaxLength}) - Success: {<did>5__9}");
								<flow>5__8 = default(ShrinkedFlow);
							}
						}
						finally
						{
							((IDisposable)<>s__7).Dispose();
						}
						<>s__7 = default(List<ShrinkedFlow>.Enumerator);
						DungeonFlowShrinker.ClearAllShrinkedFlows();
						RoundManager.Instance.FinishGeneratingLevel();
						<>4__this.OnAllDungeonsGenerated.Invoke();
						return false;
					}
					<dungeon>5__1 = <>4__this.ExtraDungeons[<>4__this.currentDungeonIndex];
					<seed>5__2 = <>4__this.RandomSeeds[<>4__this.currentDungeonIndex];
					<flowTypeId>5__3 = <>4__this.FlowIds[<>4__this.currentDungeonIndex];
					((Component)<dungeon>5__1).gameObject.SetActive(true);
					<dungeonFlow>5__4 = RoundManager.Instance.dungeonFlowTypes[<flowTypeId>5__3].dungeonFlow;
					<dungeon>5__1.Generator.ShouldRandomizeSeed = false;
					<dungeon>5__1.Generator.Seed = <seed>5__2;
					<shrinkedFlow>5__5 = DungeonFlowShrinker.ShrinkFlow(<dungeonFlow>5__4, <>4__this.FlowDevision, <>4__this.MinimumMinFlowLength, <>4__this.MinimumMaxFlowLength);
					<dungeon>5__1.Generator.DungeonFlow = <shrinkedFlow>5__5.Flow;
					<num2>5__6 = RoundManager.Instance.currentLevel.factorySizeMultiplier / RoundManager.Instance.dungeonFlowTypes[<flowTypeId>5__3].MapTileSize * RoundManager.Instance.mapSizeMultiplier;
					<num2>5__6 = (float)((double)Mathf.Round(<num2>5__6 * 100f) / 100.0);
					<dungeon>5__1.Generator.LengthMultiplier = <num2>5__6;
					<>s__10 = <dungeon>5__1.Generator.DungeonFlow.GlobalProps.GetEnumerator();
					try
					{
						while (<>s__10.MoveNext())
						{
							<globalPropSettings>5__11 = <>s__10.Current;
							if (<globalPropSettings>5__11.ID == 1231)
							{
								<globalPropSettings>5__11.Count = new IntRange(0, 0);
								break;
							}
							<globalPropSettings>5__11 = null;
						}
					}
					finally
					{
						((IDisposable)<>s__10).Dispose();
					}
					<>s__10 = default(List<GlobalPropSettings>.Enumerator);
					<>4__this.ShrinkedFlows.AddIfNotAlreadyInList(<shrinkedFlow>5__5);
					<>4__this.OnSingularExtraDungeonGenerationStarted.Invoke(<dungeon>5__1);
					NotezyLib.LogInfo($"Starting dungeon generation {<>4__this.currentDungeonIndex} with seed {<seed>5__2} and dungeon {((Object)<dungeon>5__1).name}");
					<>2__current = (object)new WaitForEndOfFrame();
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<dungeon>5__1.Generate();
					if ((int)<dungeon>5__1.Generator.Status == 6)
					{
						NotezyLib.LogInfo($"Dungeon {<>4__this.currentDungeonIndex} generated instantly with seed {<seed>5__2}");
						<>4__this.OnDungeonGenerationComplete(<dungeon>5__1.Generator);
					}
					else
					{
						<dungeon>5__1.Generator.OnGenerationStatusChanged += new GenerationStatusDelegate(<>4__this.Generator_OnGenerationStatusChanged);
						NotezyLib.LogInfo($"Listening for completion of dungeon {<>4__this.currentDungeonIndex}");
					}
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static MultiDungeonGenerator? Instance;

		[Header("Settings")]
		[Tooltip("List of extra dungeons to generate. These should be pre-placed in the scene.")]
		public List<RuntimeDungeon> ExtraDungeons = new List<RuntimeDungeon>();

		[Tooltip("Divides the length of the dungeon flow to make shorter dungeons. Higher values make shorter dungeons, but can lead to generation failures if too high.")]
		public float FlowDevision = 1.5f;

		[Tooltip("Minimum allowed value for the Min length of a dungeon flow to be devided. This prevents extremely short flows that can cause generation failures.")]
		public int MinimumMinFlowLength = 5;

		[Tooltip("Minimum allowed value for the Max length of a dungeon flow be devided. This prevents extremely short flows that can cause generation failures.")]
		public int MinimumMaxFlowLength = 6;

		[Tooltip("If enabled, after the RoundManager.SetExitIDs method FindExitPoint will be called to ensure all entrances have exit points set properly.")]
		public bool SetExitPointsAfterGeneration = true;

		[Header("(Status)")]
		public bool GeneratedExtraDungeons = false;

		public int currentDungeonIndex = 0;

		public bool isGeneratingDungeons = false;

		public UnityEvent OnExtraDungeonGenerationStarted = new UnityEvent();

		public UnityEvent<RuntimeDungeon> OnSingularExtraDungeonGenerationStarted = new UnityEvent<RuntimeDungeon>();

		public UnityEvent<RuntimeDungeon> OnSingularExtraDungeonGenerated = new UnityEvent<RuntimeDungeon>();

		public UnityEvent OnAllDungeonsGenerated = new UnityEvent();

		public UnityEvent OnExitIDsSet = new UnityEvent();

		[Header("Set by game, do not modify")]
		public List<ShrinkedFlow> ShrinkedFlows = new List<ShrinkedFlow>();

		public List<IntWithRarity> LLLdungeonFlowTypes = new List<IntWithRarity>();

		public int[] RandomSeeds = new int[0];

		public int[] FlowIds = new int[0];

		[HideInInspector]
		public Dictionary<int, Dungeon> LinkedDungeons = new Dictionary<int, Dungeon>();

		[HideInInspector]
		public List<EntranceTeleport> SortedOutdoorEntrances = new List<EntranceTeleport>();

		[HideInInspector]
		public List<EntranceTeleport> SortedIndoorEntrances = new List<EntranceTeleport>();

		[Tooltip("Maximum number of buildings to attempt to generate. This is capped at the number of assigned dungeons.")]
		public int MaxBuildings => ExtraDungeons.Select((RuntimeDungeon d) => (Object)(object)d != (Object)null).ToList().Count;

		public void Awake()
		{
			Instance = this;
		}

		public void Start()
		{
			foreach (RuntimeDungeon extraDungeon in ExtraDungeons)
			{
				if ((Object)(object)extraDungeon != (Object)null)
				{
					((Component)extraDungeon).gameObject.SetActive(false);
				}
			}
		}

		[ClientRpc]
		public void SyncExDungeonDataClientRpc(NetworkIntWithRarity[] intWithRarities, int[] seeds, int[] flowIds)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: 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_0088: 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_01a2: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2641838724u, val, (RpcDelivery)0);
				bool flag = intWithRarities != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkIntWithRarity>(intWithRarities, default(ForNetworkSerializable));
				}
				bool flag2 = seeds != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
				if (flag2)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<int>(seeds, default(ForPrimitives));
				}
				bool flag3 = flowIds != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag3, default(ForPrimitives));
				if (flag3)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe<int>(flowIds, default(ForPrimitives));
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2641838724u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			base.__rpc_exec_stage = (__RpcExecStage)0;
			try
			{
				if (!((NetworkBehaviour)this).IsServer)
				{
					NotezyLib.LogMessage("Client received complete Extra Dungeon synchronization data");
				}
				else
				{
					NotezyLib.LogDebug("Clients received completeExtra Dungeon synchronization data");
				}
				foreach (NetworkIntWithRarity networkIntWithRarity in intWithRarities)
				{
					LLLdungeonFlowTypes.Add(networkIntWithRarity.ToIntWithRarity());
				}
				RandomSeeds = seeds;
				FlowIds = flowIds;
				for (int j = 0; j < MaxBuildings; j++)
				{
					if (!((NetworkBehaviour)this).IsServer)
					{
						NotezyLib.LogInfo($"Building {j}: Seed={seeds[j]}, FlowId={FlowIds[j]}");
					}
					else
					{
						NotezyLib.LogDebug($"(Client) Building {j}: Seed={seeds[j]}, FlowId={FlowIds[j]}");
					}
				}
			}
			catch (Exception arg)
			{
				NotezyLib.LogError($"Error in SyncExDungeonDataClientRpc: {arg}");
			}
		}

		public void GenerateExtraDugens()
		{
			if (ExtraDungeons.Count == 0 || isGeneratingDungeons)
			{
				NotezyLib.LogError("No extra dungeons assigned or already generating");
				return;
			}
			OnExtraDungeonGenerationStarted.Invoke();
			isGeneratingDungeons = true;
			currentDungeonIndex = 0;
			((MonoBehaviour)this).StartCoroutine(GenerateNextDungeon());
		}

		[IteratorStateMachine(typeof(<GenerateNextDungeon>d__27))]
		private IEnumerator GenerateNextDungeon()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GenerateNextDungeon>d__27(0)
			{
				<>4__this = this
			};
		}

		private void Generator_OnGenerationStatusChanged(DungeonGenerator generator, GenerationStatus status)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			if ((int)status == 6)
			{
				OnDungeonGenerationComplete(generator);
			}
			else if ((int)status == 7)
			{
				NotezyLib.LogError($"Dungeon generation failed for dungeon {currentDungeonIndex}");
				generator.OnGenerationStatusChanged -= new GenerationStatusDelegate(Generator_OnGenerationStatusChanged);
				currentDungeonIndex++;
				((MonoBehaviour)this).StartCoroutine(GenerateNextDungeon());
			}
		}

		private void OnDungeonGenerationComplete(DungeonGenerator generator)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			DungeonGenerator generator2 = generator;
			generator2.OnGenerationStatusChanged -= new GenerationStatusDelegate(Generator_OnGenerationStatusChanged);
			NotezyLib.LogInfo($"Dungeon {currentDungeonIndex} generation completed successfully");
			RuntimeDungeon val = ExtraDungeons.Find((RuntimeDungeon d) => d.Generator == generator2);
			if ((Object)(object)val != (Object)null)
			{
				OnSingularExtraDungeonGenerated.Invoke(val);
			}
			else
			{
				NotezyLib.LogWarning($"Could not find RuntimeDungeon for generated dungeon {currentDungeonIndex} to invoke OnExtraDungeonGenerated");
			}
			currentDungeonIndex++;
			((MonoBehaviour)this).StartCoroutine(GenerateNextDungeon());
		}

		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(2641838724u, new RpcReceiveHandler(__rpc_handler_2641838724), "SyncExDungeonDataClientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_2641838724(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0074: 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_0058: 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_00b9: 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_009d: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				NetworkIntWithRarity[] intWithRarities = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<NetworkIntWithRarity>(ref intWithRarities, default(ForNetworkSerializable));
				}
				bool flag2 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
				int[] seeds = null;
				if (flag2)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref seeds, default(ForPrimitives));
				}
				bool flag3 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag3, default(ForPrimitives));
				int[] flowIds = null;
				if (flag3)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref flowIds, default(ForPrimitives));
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((MultiDungeonGenerator)(object)target).SyncExDungeonDataClientRpc(intWithRarities, seeds, flowIds);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		protected internal override string __getTypeName()
		{
			return "MultiDungeonGenerator";
		}
	}
}
namespace NotezyLib.MultiDungeon.Patches
{
	[HarmonyPatch(typeof(DungeonLoader))]
	public class DungeonLoaderPatch
	{
		[HarmonyPatch("PrepareDungeon")]
		[HarmonyPrefix]
		public static bool PrepareDungeonPrefix()
		{
			try
			{
				if ((Object)(object)MultiDungeonGenerator.Instance == (Object)null)
				{
					return true;
				}
				if (MultiDungeonGenerator.Instance.isGeneratingDungeons)
				{
					NotezyLib.LogDebug("!!!SKIPPING DungeonLoader.PrepareDungeon DURING EXTRA DUNGEN GENERATION!!!");
					return false;
				}
				return true;
			}
			catch (Exception arg)
			{
				NotezyLib.LogError($"Error in DungeonLoader.Generate Prefix: {arg}");
				return true;
			}
		}

		[HarmonyPatch("PrepareDungeon")]
		[HarmonyPostfix]
		public static void PrepareDungeonostfix()
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			try
			{
				if ((Object)(object)MultiDungeonGenerator.Instance == (Object)null || MultiDungeonGenerator.Instance.isGeneratingDungeons)
				{
					return;
				}
				NotezyLib.LogMessage("!!!OVERIDING DUNGEN SIZE!!!");
				DungeonGenerator generator = Patches.RoundManager.dungeonGenerator.Generator;
				ShrinkedFlow item = DungeonFlowShrinker.ShrinkFlow(generator.DungeonFlow, MultiDungeonGenerator.Instance.FlowDevision, MultiDungeonGenerator.Instance.MinimumMinFlowLength, MultiDungeonGenerator.Instance.MinimumMaxFlowLength);
				generator.DungeonFlow = item.Flow;
				foreach (GlobalPropSettings globalProp in generator.DungeonFlow.GlobalProps)
				{
					if (globalProp.ID == 1231)
					{
						globalProp.Count = new IntRange(0, 0);
						break;
					}
				}
				MultiDungeonGenerator.Instance.ShrinkedFlows.Add(item);
			}
			catch (Exception arg)
			{
				NotezyLib.LogError($"Error in DungeonLoader.Generate Postfix: {arg}");
			}
		}
	}
	[HarmonyPatch(typeof(LethalLevelLoaderNetworkManager))]
	public class LethalLevelLoaderNetworkManagerPatch
	{
		[HarmonyPatch("GetRandomExtendedDungeonFlowServerRpc")]
		[HarmonyPrefix]
		public static void GetRandomExtendedDungeonFlowServerRpcPrefix(LethalLevelLoaderNetworkManager __instance)
		{
			try
			{
				if (!GeneralUtils.IsServerRpcPrefixValid((NetworkBehaviour)(object)__instance) || (Object)(object)MultiDungeonGenerator.Instance == (Object)null)
				{
					return;
				}
				NotezyLib.LogMessage("Getting random extended dungeon flows for Extra buildings...");
				List<ExtendedDungeonFlowWithRarity> validExtendedDungeonFlows = DungeonManager.GetValidExtendedDungeonFlows(LevelManager.CurrentExtendedLevel, false);
				List<NetworkIntWithRarity> list = new List<NetworkIntWithRarity>();
				Dictionary<string, int> dictionary = new Dictionary<string, int>();
				int num = 0;
				foreach (DungeonFlow dungeonFlow in Extensions.GetDungeonFlows(Patches.RoundManager))
				{
					dictionary.Add(((Object)dungeonFlow).name, num);
					num++;
				}
				if (validExtendedDungeonFlows.Count == 0)
				{
					NotezyLib.LogError("No ExtendedDungeonFlow's found - using default flow");
					NetworkIntWithRarity item = new NetworkIntWithRarity(dictionary[((Object)PatchedContent.ExtendedDungeonFlows[0].DungeonFlow).name], 300);
					list.Add(item);
				}
				else
				{
					List<DungeonFlow> dungeonFlows = Extensions.GetDungeonFlows(Patches.RoundManager);
					foreach (ExtendedDungeonFlowWithRarity item3 in validExtendedDungeonFlows)
					{
						string name = ((Object)item3.extendedDungeonFlow.DungeonFlow).name;
						if (dictionary.ContainsKey(name))
						{
							NetworkIntWithRarity item2 = new NetworkIntWithRarity(dictionary[name], item3.rarity);
							list.Add(item2);
						}
					}
				}
				int[] array = new int[MultiDungeonGenerator.Instance.MaxBuildings];
				int[] array2 = new int[MultiDungeonGenerator.Instance.MaxBuildings];
				for (int i = 0; i < MultiDungeonGenerator.Instance.MaxBuildings; i++)
				{
					int num2 = (array[i] = Random.Range(1, 100000000));
					int randomWeightedIndex = RoundManager.Instance.GetRandomWeightedIndex(list.Select((NetworkIntWithRarity f) => f.rarity).ToArray(), new Random(num2));
					array2[i] = list[randomWeightedIndex].id;
					NotezyLib.LogInfo($"Building {i}: Seed={num2}, FlowId={array2[i]}");
				}
				MultiDungeonGenerator.Instance.SyncExDungeonDataClientRpc(list.ToArray(), array, array2);
			}
			catch (Exception arg)
			{
				NotezyLib.LogError($"Error in GetRandomExtendedDungeonFlowServerRpcPrefix: {arg}");
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	public class RoundManagerPatch
	{
		[HarmonyPatch("FinishGeneratingLevel")]
		[HarmonyPrefix]
		public static bool FinishGeneratingLevelPrefix(RoundManager __instance)
		{
			if ((Object)(object)MultiDungeonGenerator.Instance == (Object)null)
			{
				return true;
			}
			if (MultiDungeonGenerator.Instance.GeneratedExtraDungeons)
			{
				return true;
			}
			NotezyLib.LogMessage("!!!OVERTAKING RoundManager.FinishGeneratingLevel!!!");
			MultiDungeonGenerator.Instance.GenerateExtraDugens();
			return false;
		}

		[HarmonyPatch("SetExitIDs")]
		[HarmonyPriority(800)]
		[HarmonyPostfix]
		private static void SetBuildings(Vector3 mainEntrancePosition)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)MultiDungeonGenerator.Instance == (Object)null)
			{
				return;
			}
			List<Dungeon> list = Object.FindObjectsOfType<Dungeon>().ToList();
			MultiDungeonGenerator.Instance.LinkedDungeons = new Dictionary<int, Dungeon>();
			EntranceTeleport[] source = Object.FindObjectsOfType<EntranceTeleport>();
			List<EntranceTeleport> source2 = source.Where((EntranceTeleport e) => !e.isEntranceToBuilding).ToList();
			List<EntranceTeleport> list2 = source2.OrderBy((EntranceTeleport e) => Vector3.Distance(((Component)e).transform.position, mainEntrancePosition)).ToList();
			for (int i = 0; i < list2.Count; i++)
			{
				list2[i].entranceId = i;
				Dungeon val = null;
				float num = float.MaxValue;
				foreach (Dungeon item in list)
				{
					float num2 = Vector3.Distance(((Component)list2[i]).transform.position, ((Component)item).transform.position);
					if (num2 < num)
					{
						num = num2;
						val = item;
					}
				}
				if ((Object)(object)val != (Object)null)
				{
					MultiDungeonGenerator.Instance.LinkedDungeons[list2[i].entranceId] = val;
					list.Remove(val);
				}
				else
				{
					NotezyLib.LogWarning($"Could not find a dungeon for indoor entrance at position {((Component)list2[i]).transform.position}");
				}
				NotezyLib.LogInfo($"Setting ExitID {list2[i].entranceId} for entrance at position {((Component)list2[i]).transform.position}");
			}
			MultiDungeonGenerator.Instance.SortedIndoorEntrances = list2;
			List<EntranceTeleport> source3 = source.Where((EntranceTeleport e) => e.isEntranceToBuilding).ToList();
			List<EntranceTeleport> list3 = source3.OrderBy((EntranceTeleport e) => Vector3.Distance(((Component)e).transform.position, mainEntrancePosition)).ToList();
			for (int j = 0; j < list3.Count; j++)
			{
				list3[j].entranceId = j;
				NotezyLib.LogInfo($"Setting ExitID {list3[j].entranceId}({((Object)((Component)list3[j]).gameObject).name}) for outdoor entrance at position {((Component)list3[j]).transform.position}");
			}
			MultiDungeonGenerator.Instance.SortedOutdoorEntrances = list3;
			if (MultiDungeonGenerator.Instance.SetExitPointsAfterGeneration)
			{
				foreach (EntranceTeleport item2 in list2)
				{
					try
					{
						item2.FindExitPoint();
					}
					catch (Exception ex)
					{
						NotezyLib.LogError($"Error finding exit point for indoor entrance ID {item2.entranceId} at position {((Component)item2).transform.position}: {ex.Message}");
					}
				}
				foreach (EntranceTeleport item3 in list3)
				{
					try
					{
						item3.FindExitPoint();
					}
					catch (Exception ex2)
					{
						NotezyLib.LogError($"Error finding exit point for outdoor entrance ID {item3.entranceId} at position {((Component)item3).transform.position}: {ex2.Message}");
					}
				}
			}
			MultiDungeonGenerator.Instance.OnExitIDsSet.Invoke();
		}
	}
}
namespace NotezyLib.Editor
{
	public class MultiDungeonSetUp : EditorWindow
	{
		public RuntimeDungeon? DungeonToCopyFrom;

		public GameObject? MainEntranceToCopyFrom;

		public bool MoveDungeonInsteadOfRoot = false;

		public bool ReuseExistingMultiDungeon = false;

		public int DungeonCount = 0;

		public float Spacing = 500f;

		public float BaseYPosition = -218f;

		[MenuItem("Tools/NotezyLib/Set Up Multi-Dungeon")]
		public static void ShowWindow()
		{
			EditorWindow.GetWindow<MultiDungeonSetUp>("Set Up Multi-Dungeon");
		}

		private void OnGUI()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			GUILayout.Label("Multi-Dungeon Setup", EditorStyles.boldLabel, Array.Empty<GUILayoutOption>());
			EditorGUILayout.HelpBox("This tool helps set up multiple dungeons in the current scene. It creates a parent GameObject named 'Multi-Dungeon' then creates and arranges the specified number of dungeons around the origin based on the chosen spacing. Each dungeon is instantiated from the selected RuntimeDungeon object, it does not need to be a prefab.", (MessageType)1);
			EditorGUILayout.HelpBox("NotezyLib currently doesn't support Fire Exits, so each EntranceTeleport must lead to a dungeon.", (MessageType)2);
			float labelWidth = EditorGUIUtility.labelWidth;
			EditorGUIUtility.labelWidth = 300f;
			DungeonToCopyFrom = (RuntimeDungeon)EditorGUILayout.ObjectField("Dungeon to Copy From", (Object)(object)DungeonToCopyFrom, typeof(RuntimeDungeon), true, Array.Empty<GUILayoutOption>());
			MainEntranceToCopyFrom = (GameObject)EditorGUILayout.ObjectField("Main Entrance to Copy From", (Object)(object)MainEntranceToCopyFrom, typeof(GameObject), true, Array.Empty<GUILayoutOption>());
			DungeonCount = EditorGUILayout.IntField("Number of Extra Dungeons", DungeonCount, Array.Empty<GUILayoutOption>());
			Spacing = EditorGUILayout.FloatField("Spacing Between Dungeons", Spacing, Array.Empty<GUILayoutOption>());
			BaseYPosition = EditorGUILayout.FloatField("Base Y Position", BaseYPosition, Array.Empty<GUILayoutOption>());
			MoveDungeonInsteadOfRoot = EditorGUILayout.Toggle("Move Dungeon Instead of Root", MoveDungeonInsteadOfRoot, Array.Empty<GUILayoutOption>());
			ReuseExistingMultiDungeon = EditorGUILayout.Toggle("Reuse Existing Multi-Dungeon Gen", ReuseExistingMultiDungeon, Array.Empty<GUILayoutOption>());
			EditorGUIUtility.labelWidth = labelWidth;
			if (GUILayout.Button("Set Up Multi-Dungeon in Current Scene", Array.Empty<GUILayoutOption>()))
			{
				SetUpMultiDungeonInCurrentScene();
			}
		}

		public void SetUpMultiDungeonInCurrentScene()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Expected O, but got Unknown
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Expected O, but got Unknown
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: 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_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			MultiDungeonGenerator multiDungeonGenerator = null;
			bool flag = true;
			if (ReuseExistingMultiDungeon)
			{
				MultiDungeonGenerator multiDungeonGenerator2 = Object.FindObjectOfType<MultiDungeonGenerator>();
				if ((Object)(object)multiDungeonGenerator2 != (Object)null)
				{
					multiDungeonGenerator = multiDungeonGenerator2;
				}
				else
				{
					flag = true;
				}
			}
			if (flag)
			{
				GameObject val = new GameObject("Multi-Dungeon");
				multiDungeonGenerator = val.AddComponent<MultiDungeonGenerator>();
				val.AddComponent<NetworkObject>();
			}
			for (int i = 0; i < DungeonCount; i++)
			{
				if ((Object)(object)DungeonToCopyFrom == (Object)null)
				{
					Debug.LogError((object)"Dungeon to copy from is not assigned.");
					break;
				}
				GameObject val2 = new GameObject($"Dungeon_{i + 1}");
				Vector3 val3 = CalculateDungeonPosition(i, DungeonCount, Spacing, BaseYPosition);
				val2.transform.position = val3;
				RuntimeDungeon val4 = null;
				if ((Object)(object)DungeonToCopyFrom != (Object)null)
				{
					val4 = Object.Instantiate<RuntimeDungeon>(DungeonToCopyFrom, val2.transform);
					((Object)((Component)val4).gameObject).name.Replace("(Clone)", "");
					((Component)val4).transform.localPosition = Vector3.zero;
				}
				else
				{
					GameObject val5 = new GameObject("Generator");
					val5.transform.SetParent(val2.transform);
					val4 = val5.AddComponent<RuntimeDungeon>();
				}
				if ((Object)(object)MainEntranceToCopyFrom != (Object)null)
				{
					GameObject val6 = Object.Instantiate<GameObject>(MainEntranceToCopyFrom);
					val6.transform.position = MainEntranceToCopyFrom.transform.position + (float)(i + 1) * MainEntranceToCopyFrom.transform.right * 5f;
					((Object)((Component)val4).gameObject).name.Replace("(Clone)", "");
					((Object)val6).name = ((Object)val6).name + $"_Dungeon_{i + 1}_Entrance";
				}
				GameObject val7 = new GameObject("Root");
				val7.transform.SetParent(val2.transform);
				val4.Root = val7;
				if (!MoveDungeonInsteadOfRoot)
				{
					val7.transform.localPosition = val3;
					val2.transform.localPosition = Vector3.zero;
				}
				else
				{
					val7.transform.localPosition = Vector3.zero;
					val2.transform.localPosition = val3;
				}
				val2.transform.SetParent(((Component)multiDungeonGenerator).transform, true);
				multiDungeonGenerator.ExtraDungeons.Add(val4);
			}
		}

		private Vector3 CalculateDungeonPosition(int index, int totalDungeons, float spacing, float baseY)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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)
			if (totalDungeons == 1)
			{
				return new Vector3(spacing * 0.5f, baseY, 0f);
			}
			if (totalDungeons <= 8)
			{
				return CalculateHollowSquarePosition(index, totalDungeons, spacing, baseY);
			}
			int num = 8;
			int num2 = index / num;
			int index2 = index % num;
			return (num2 != 0) ? CalculateFilledGridPosition(index2, spacing, baseY - (float)num2 * spacing) : CalculateHollowSquarePosition(index2, num, spacing, baseY);
		}

		private Vector3 CalculateHollowSquarePosition(int index, int totalDungeons, float spacing, float baseY)
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.CeilToInt((float)totalDungeons / 4f);
			int num2 = index / num;
			int num3 = index % num;
			float num4 = 0f;
			float num5 = 0f;
			switch (num2)
			{
			case 0:
				num4 = ((float)num3 - (float)num * 0.5f + 0.5f) * spacing;
				num5 = spacing;
				break;
			case 1:
				num4 = spacing;
				num5 = (0f - ((float)num3 - (float)num * 0.5f + 0.5f)) * spacing;
				break;
			case 2:
				num4 = (0f - ((float)num3 - (float)num * 0.5f + 0.5f)) * spacing;
				num5 = 0f - spacing;
				break;
			case 3:
				num4 = 0f - spacing;
				num5 = ((float)num3 - (float)num * 0.5f + 0.5f) * spacing;
				break;
			}
			return new Vector3(num4, baseY, num5);
		}

		private Vector3 CalculateFilledGridPosition(int index, float spacing, float y)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			int num = 3;
			int num2 = index / num;
			int num3 = index % num;
			float num4 = (float)(num3 - 1) * spacing;
			float num5 = (float)(num2 - 1) * spacing;
			return new Vector3(num4, y, num5);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace NoteBoxz.NotezyLib.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}