Decompiled source of LGTuner v1.1.2

LGTuner.dll

Decompiled 2 months ago
using System;
using System.CodeDom.Compiler;
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 System.Text.Json;
using System.Text.Json.Serialization;
using AIGraph;
using AssetShards;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using CullingSystem;
using Expedition;
using FluffyUnderware.DevTools.Extensions;
using GTFO.API;
using GTFO.API.Utilities;
using GameData;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LGTuner.Configs;
using LGTuner.Manager;
using LGTuner.Utils;
using LGTuner.hirnugeos;
using LevelGeneration;
using LevelGeneration.Core;
using LogUtils;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
using XXHashing;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("LGTuner")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+git8f77ed4-dirty-master.8f77ed4ad58a391ea6fcf250c7111074c5e3cce3")]
[assembly: AssemblyProduct("LGTuner")]
[assembly: AssemblyTitle("LGTuner")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LGTuner
{
	public static class BuilderInfo
	{
		private static readonly List<Complex> _extraComplexResourceToLoad = new List<Complex>();

		public static IEnumerable<Complex> ExtraComplexResourceToLoad => _extraComplexResourceToLoad;

		public static ComplexResourceSetDataBlock ComplexResourceSet { get; private set; }

		public static int GridSize { get; private set; }

		public static int GridCenter { get; private set; }

		public static int GridZeroOffset { get; private set; }

		public static float AltitudeOffset { get; private set; }

		public static LayoutConfig MainLayer { get; private set; }

		public static LayoutConfig SecondaryLayer { get; private set; }

		public static LayoutConfig ThirdLayer { get; private set; }

		public static LayoutConfig[] DimensionLayer { get; private set; } = Array.Empty<LayoutConfig>();


		internal static void OnResourceSetSelected()
		{
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			ComplexResourceSet = Builder.ComplexResourceSetBlock;
			GridSize = ComplexResourceSet.LevelGenConfig.GridSize;
			GridCenter = GridSize / 2;
			GridZeroOffset = -GridCenter;
			AltitudeOffset = ComplexResourceSet.LevelGenConfig.AltitudeOffset;
			MainLayer = null;
			SecondaryLayer = null;
			ThirdLayer = null;
			DimensionLayer = new LayoutConfig[Enum.GetValues(typeof(eDimensionIndex)).Length];
			_extraComplexResourceToLoad.Clear();
			ExpeditionInTierData activeExpedition = RundownManager.ActiveExpedition;
			if (ConfigManager.TryGetConfig(activeExpedition.LevelLayoutData, out var config))
			{
				MainLayer = config;
			}
			if (activeExpedition.SecondaryLayerEnabled && ConfigManager.TryGetConfig(activeExpedition.SecondaryLayout, out var config2))
			{
				SecondaryLayer = config2;
			}
			if (activeExpedition.ThirdLayerEnabled && ConfigManager.TryGetConfig(activeExpedition.ThirdLayout, out var config3))
			{
				ThirdLayer = config3;
			}
			Enumerator<Dimension> enumerator = Builder.CurrentFloor.m_dimensions.GetEnumerator();
			while (enumerator.MoveNext())
			{
				Dimension current = enumerator.Current;
				if (!current.IsMainDimension && !current.DimensionData.IsStaticDimension)
				{
					LevelLayoutDataBlock block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock(current.DimensionData.LevelLayoutData);
					if (block != null && ConfigManager.TryGetConfig(((GameDataBlockBase<LevelLayoutDataBlock>)(object)block).persistentID, out var config4))
					{
						Logger.Info("loysimme dimension ja levellayoutin");
						config4.Reset(((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)current.Grid).m_sizeX);
						DimensionLayer[current.DimensionIndex] = config4;
					}
				}
			}
			MainLayer?.Reset(GridSize);
			SecondaryLayer?.Reset(GridSize);
			ThirdLayer?.Reset(GridSize);
			AddExtraShard(MainLayer);
			AddExtraShard(SecondaryLayer);
			AddExtraShard(ThirdLayer);
			Array.ForEach(DimensionLayer, delegate(LayoutConfig x)
			{
				AddExtraShard(x);
			});
		}

		private static void AddExtraShard(LayoutConfig layerConfig)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (layerConfig == null)
			{
				return;
			}
			Complex[] extraComplexResourceToLoad = layerConfig.ExtraComplexResourceToLoad;
			foreach (Complex item in extraComplexResourceToLoad)
			{
				if (!_extraComplexResourceToLoad.Contains(item))
				{
					_extraComplexResourceToLoad.Add(item);
				}
			}
		}

		public static bool TryGetConfig(LG_Zone zone, out LayoutConfig config)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected I4, but got Unknown
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			Dimension val = default(Dimension);
			if (!Dimension.GetDimension(zone.DimensionIndex, ref val))
			{
				Logger.Info("dimension getter failed");
				config = null;
				return false;
			}
			if (val.IsMainDimension)
			{
				LG_LayerType type = zone.Layer.m_type;
				switch ((int)type)
				{
				case 0:
					config = MainLayer;
					return MainLayer != null;
				case 1:
					config = SecondaryLayer;
					return SecondaryLayer != null;
				case 2:
					config = ThirdLayer;
					return ThirdLayer != null;
				}
			}
			else if (!val.DimensionData.IsStaticDimension)
			{
				Enumerator<Dimension> enumerator = Builder.CurrentFloor.m_dimensions.GetEnumerator();
				while (enumerator.MoveNext())
				{
					Dimension current = enumerator.Current;
					if (!current.IsMainDimension && !current.DimensionData.IsStaticDimension)
					{
						LevelLayoutDataBlock block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock(current.DimensionData.LevelLayoutData);
						if (block != null && ConfigManager.TryGetConfig(((GameDataBlockBase<LevelLayoutDataBlock>)(object)block).persistentID, out var config2))
						{
							Logger.Info("found a dimension + levellayout");
							config2.Reset(((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)current.Grid).m_sizeX);
							DimensionLayer[current.DimensionIndex] = config2;
						}
					}
				}
				config = DimensionLayer[zone.DimensionIndex];
				return config != null;
			}
			config = null;
			return false;
		}

		public static GameObject GetRandomPlug(uint seed, int plugHeight, SubComplex subcomplex, bool withGate)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			ComplexResourceSetDataBlock complexResourceSet = ComplexResourceSet;
			return (GameObject)(plugHeight switch
			{
				0 => complexResourceSet.GetRandomPrefab(seed, withGate ? complexResourceSet.m_straightPlugsWithGates : complexResourceSet.m_straightPlugsNoGates, subcomplex), 
				1 => complexResourceSet.GetRandomPrefab(seed, withGate ? complexResourceSet.m_singleDropPlugsWithGates : complexResourceSet.m_singleDropPlugsNoGates, subcomplex), 
				2 => complexResourceSet.GetRandomPrefab(seed, withGate ? complexResourceSet.m_doubleDropPlugsWithGates : complexResourceSet.m_doubleDropPlugsNoGates, subcomplex), 
				_ => null, 
			});
		}

		public static uint GetLayoutIdOfZone(LG_Zone zone)
		{
			//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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected I4, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			Dimension dimension = zone.Dimension;
			if (dimension.IsMainDimension)
			{
				LG_LayerType type = zone.Layer.m_type;
				ExpeditionInTierData activeExpedition = RundownManager.ActiveExpedition;
				return (int)type switch
				{
					0 => activeExpedition.LevelLayoutData, 
					1 => activeExpedition.SecondaryLayout, 
					2 => activeExpedition.ThirdLayout, 
					_ => throw new NotSupportedException($"LayerType: {type} is not supported!"), 
				};
			}
			return dimension.DimensionData.LevelLayoutData;
		}
	}
	[BepInPlugin("LGTuner", "LGTuner", "1.1.2")]
	[BepInProcess("GTFO.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class EntryPoint : BasePlugin
	{
		public static GameObject hirnuigo;

		public static GameObject hirnuhubgo;

		public static GameObject hirnudeadendgo;

		public static GameObject hirnuhubgengo;

		public static GameObject hirnuhubreactorgo;

		public static GameObject hirnuhubelevatorgo;

		public static GameObject hirnuiareatestgo;

		public static LG_PrefabSpawner hirnulamp;

		public static GameObject hirnulampfixture;

		public static GameObject hirnureactorterminal;

		public static GameObject hirnucargocage;

		public static Material hirnufloormaterial;

		public static Material hirnuwallmaterial;

		public Harmony HarmonyInstance { get; private set; }

		public override void Load()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			HarmonyInstance = new Harmony("LGTuner");
			HarmonyInstance.PatchAll();
			LG_Factory.OnFactoryBuildDone += Action.op_Implicit((Action)Hirnu_materials.OnFactoryBuildDone);
			ConfigManager.Init();
		}
	}
	public static class LGExtensions
	{
		public static bool IsSame(this LG_GridPosition position, LG_GridPosition other)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			if (position.x == other.x)
			{
				return position.z == other.z;
			}
			return false;
		}

		public static LG_GridPosition ToNormalGrid(this LG_Tile tile, int gridSize)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			return tile.m_shape.m_gridPosition.GetNormal(gridSize);
		}

		public static LG_GridPosition GetNormal(this LG_GridPosition position, int gridSize)
		{
			//IL_003a: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			LG_GridPosition result;
			if (gridSize < 0)
			{
				result = default(LG_GridPosition);
				result.x = position.x + BuilderInfo.GridZeroOffset;
				result.z = position.z + BuilderInfo.GridZeroOffset;
				return result;
			}
			int num = gridSize / 2;
			result = default(LG_GridPosition);
			result.x = position.x - num;
			result.z = position.z - num;
			return result;
		}

		public static Vector3 GetPositionNormal(this LG_Grid grid, int x, int z, int gridSize)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (gridSize < 0)
			{
				return ((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)grid).GetPosition(x - BuilderInfo.GridZeroOffset, z - BuilderInfo.GridZeroOffset);
			}
			int num = gridSize / 2;
			return ((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)grid).GetPosition(x + num, z + num);
		}

		public static int GetGridSize(this Dimension dimension)
		{
			return ((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)dimension.Grid).m_sizeX;
		}

		public static bool TryGetDimension(this LG_Floor floor, int dimensionIndex, out Dimension dimension)
		{
			if (Enum.IsDefined(typeof(eDimensionIndex), dimensionIndex))
			{
				return floor.GetDimension((eDimensionIndex)dimensionIndex, ref dimension);
			}
			dimension = null;
			return false;
		}

		public static bool TryGetDimension(this LG_Floor floor, eDimensionIndex dimensionIndex, out Dimension dimension)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			if (Enum.IsDefined(typeof(eDimensionIndex), dimensionIndex))
			{
				return floor.GetDimension(dimensionIndex, ref dimension);
			}
			dimension = null;
			return false;
		}
	}
	public static class RandomExtensions
	{
		public static uint NextUint(this Random random)
		{
			int num = random.Next(1073741824);
			uint num2 = (uint)random.Next(4);
			return (uint)(num << 2) | num2;
		}

		public static float NextFloat(this Random random)
		{
			return Mathf.Clamp01((float)random.NextDouble());
		}

		public static int ToSeed(this uint seed)
		{
			return (int)seed;
		}
	}
	internal static class Logger
	{
		private static readonly ManualLogSource _logger;

		static Logger()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			_logger = new ManualLogSource("LGTuner");
			Logger.Sources.Add((ILogSource)(object)_logger);
		}

		private static string Format(object msg)
		{
			return msg.ToString();
		}

		public static void Info(object data)
		{
			_logger.LogMessage((object)Format(data));
		}

		public static void Verbose(object data)
		{
		}

		public static void Debug(object data)
		{
			_logger.LogDebug((object)Format(data));
		}

		public static void Error(object data)
		{
			_logger.LogError((object)Format(data));
		}
	}
	public enum DirectionType
	{
		Unknown,
		Forward,
		Backward,
		Left,
		Right
	}
	public enum RotateType
	{
		None,
		Flip,
		MoveTo_Left,
		MoveTo_Right,
		Towards_Random,
		Towards_Forward,
		Towards_Backward,
		Towards_Left,
		Towards_Right
	}
	public struct LG_PlugInfo
	{
		public static readonly Quaternion NoRotation = Quaternion.AngleAxis(0f, Vector3.up);

		public static readonly Quaternion RightRotation = Quaternion.AngleAxis(90f, Vector3.up);

		public static readonly Quaternion BackwardRotation = Quaternion.AngleAxis(180f, Vector3.up);

		public static readonly Quaternion LeftRotation = Quaternion.AngleAxis(270f, Vector3.up);

		public static readonly Vector3 FrontPlugPosition = Vector3.forward * 32f;

		public static readonly Vector3 BackPlugPosition = Vector3.back * 32f;

		public static readonly Vector3 LeftPlugPosition = Vector3.left * 32f;

		public static readonly Vector3 RightPlugPosition = Vector3.right * 32f;

		public bool IsValid { get; private set; }

		public DirectionType StartDirection { get; private set; }

		public int Count { get; private set; }

		public bool HasFront { get; private set; }

		public bool HasBack { get; private set; }

		public bool HasLeft { get; private set; }

		public bool HasRight { get; private set; }

		public bool TryGetNewRotation(uint seed, RotateType rotate, out Quaternion rotation)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			DirectionType newDirection = GetNewDirection(seed, StartDirection, rotate);
			if (Count >= 4)
			{
				rotation = GetRotationOfDirection(newDirection);
				return true;
			}
			Logger.Info($"You are rotating {Count} side Geomorph, this could lead to level gen crash!");
			rotation = GetRotationOfDirection(newDirection);
			return true;
		}

		public bool HasPlug(DirectionType direction)
		{
			if (!IsValid)
			{
				return false;
			}
			if (Count >= 4)
			{
				return true;
			}
			return direction switch
			{
				DirectionType.Forward => HasFront, 
				DirectionType.Backward => HasBack, 
				DirectionType.Left => HasLeft, 
				DirectionType.Right => HasRight, 
				_ => false, 
			};
		}

		public static LG_PlugInfo BuildPlugInfo(GameObject geoObject, Quaternion rotation)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_007e: Expected I4, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)geoObject.GetComponent<LG_Geomorph>() == (Object)null)
			{
				return default(LG_PlugInfo);
			}
			Il2CppArrayBase<LG_Plug> componentsInChildren = geoObject.GetComponentsInChildren<LG_Plug>();
			if (componentsInChildren == null)
			{
				return default(LG_PlugInfo);
			}
			if (componentsInChildren.Length < 1)
			{
				return default(LG_PlugInfo);
			}
			LG_PlugInfo result = default(LG_PlugInfo);
			foreach (LG_Plug item in componentsInChildren)
			{
				LG_PlugDir dir = item.m_dir;
				switch (dir - 2)
				{
				case 0:
					result.HasBack = true;
					result.Count++;
					break;
				case 2:
					result.HasFront = true;
					result.Count++;
					break;
				case 3:
					result.HasLeft = true;
					result.Count++;
					break;
				case 1:
					result.HasRight = true;
					result.Count++;
					break;
				}
			}
			result.IsValid = result.Count > 0;
			float num = Mathf.Round(((Quaternion)(ref rotation)).eulerAngles.y);
			Logger.Verbose($"angle: {num}");
			num = Mathf.Repeat(num, 360f);
			result.StartDirection = Mathf.RoundToInt(num / 90f) switch
			{
				0 => DirectionType.Forward, 
				1 => DirectionType.Right, 
				2 => DirectionType.Backward, 
				3 => DirectionType.Left, 
				_ => DirectionType.Unknown, 
			};
			return result;
		}

		public static DirectionType GetNewDirection(uint seed, DirectionType direction, RotateType rotate)
		{
			if (direction == DirectionType.Unknown)
			{
				return DirectionType.Unknown;
			}
			if (rotate == RotateType.Towards_Random)
			{
				rotate = new Random(seed.ToSeed()).Next(4) switch
				{
					0 => RotateType.Towards_Forward, 
					1 => RotateType.Towards_Backward, 
					2 => RotateType.Towards_Left, 
					3 => RotateType.Towards_Right, 
					_ => throw new IndexOutOfRangeException("Towards_Random: nextIndex was out of range?!"), 
				};
			}
			return rotate switch
			{
				RotateType.None => direction, 
				RotateType.Flip => direction switch
				{
					DirectionType.Forward => DirectionType.Backward, 
					DirectionType.Backward => DirectionType.Forward, 
					DirectionType.Left => DirectionType.Right, 
					DirectionType.Right => DirectionType.Left, 
					_ => throw new ArgumentOutOfRangeException("direction"), 
				}, 
				RotateType.MoveTo_Left => direction switch
				{
					DirectionType.Forward => DirectionType.Left, 
					DirectionType.Backward => DirectionType.Right, 
					DirectionType.Left => DirectionType.Backward, 
					DirectionType.Right => DirectionType.Forward, 
					_ => throw new ArgumentOutOfRangeException("direction"), 
				}, 
				RotateType.MoveTo_Right => direction switch
				{
					DirectionType.Forward => DirectionType.Right, 
					DirectionType.Backward => DirectionType.Left, 
					DirectionType.Left => DirectionType.Forward, 
					DirectionType.Right => DirectionType.Backward, 
					_ => throw new ArgumentOutOfRangeException("direction"), 
				}, 
				RotateType.Towards_Forward => DirectionType.Forward, 
				RotateType.Towards_Backward => DirectionType.Backward, 
				RotateType.Towards_Left => DirectionType.Left, 
				RotateType.Towards_Right => DirectionType.Right, 
				_ => throw new ArgumentOutOfRangeException("direction"), 
			};
		}

		public static Quaternion GetRotationOfDirection(DirectionType direction)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0045: Unknown result type (might be due to invalid IL or missing references)
			return (Quaternion)(direction switch
			{
				DirectionType.Forward => NoRotation, 
				DirectionType.Backward => BackwardRotation, 
				DirectionType.Left => LeftRotation, 
				DirectionType.Right => RightRotation, 
				_ => throw new ArgumentOutOfRangeException("direction"), 
			});
		}
	}
	[GeneratedCode("VersionInfoGenerator", "2.0.0+git50a4b1a-master")]
	[CompilerGenerated]
	internal static class VersionInfo
	{
		public const string RootNamespace = "LGTuner";

		public const string Version = "1.0.0";

		public const string VersionPrerelease = null;

		public const string VersionMetadata = "git8f77ed4-dirty-master";

		public const string SemVer = "1.0.0+git8f77ed4-dirty-master";

		public const string GitRevShort = "8f77ed4-dirty";

		public const string GitRevLong = "8f77ed4ad58a391ea6fcf250c7111074c5e3cce3-dirty";

		public const string GitBranch = "master";

		public const string GitTag = null;

		public const bool GitIsDirty = true;
	}
}
namespace LGTuner.Utils
{
	internal static class JSON
	{
		private static readonly JsonSerializerOptions _setting;

		static JSON()
		{
			_setting = new JsonSerializerOptions
			{
				ReadCommentHandling = JsonCommentHandling.Skip,
				IncludeFields = false,
				PropertyNameCaseInsensitive = true,
				WriteIndented = true,
				IgnoreReadOnlyProperties = true
			};
			_setting.Converters.Add(new JsonStringEnumConverter());
			if (MTFOPartialDataUtil.IsLoaded && MTFOPartialDataUtil.Initialized)
			{
				_setting.Converters.Add(MTFOPartialDataUtil.PersistentIDConverter);
				Logger.Info("PartialData Support Found!");
			}
		}

		public static T Deserialize<T>(string json)
		{
			return JsonSerializer.Deserialize<T>(json, _setting);
		}

		public static object Deserialize(Type type, string json)
		{
			return JsonSerializer.Deserialize(json, type, _setting);
		}

		public static string Serialize(object value, Type type)
		{
			return JsonSerializer.Serialize(value, type, _setting);
		}
	}
	public static class MTFOPartialDataUtil
	{
		public const string PLUGIN_GUID = "MTFO.Extension.PartialBlocks";

		public static JsonConverter PersistentIDConverter { get; private set; }

		public static bool IsLoaded { get; private set; }

		public static bool Initialized { get; private set; }

		public static string PartialDataPath { get; private set; }

		public static string ConfigPath { get; private set; }

		static MTFOPartialDataUtil()
		{
			PersistentIDConverter = null;
			IsLoaded = false;
			Initialized = false;
			PartialDataPath = string.Empty;
			ConfigPath = string.Empty;
			if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("MTFO.Extension.PartialBlocks", out var value))
			{
				return;
			}
			try
			{
				Assembly obj = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? null;
				if ((object)obj == null)
				{
					throw new Exception("Assembly is Missing!");
				}
				Type[] types = obj.GetTypes();
				Type type = types.First((Type t) => t.Name == "PersistentIDConverter");
				if ((object)type == null)
				{
					throw new Exception("Unable to Find PersistentIDConverter Class");
				}
				Type obj2 = types.First((Type t) => t.Name == "PartialDataManager") ?? throw new Exception("Unable to Find PartialDataManager Class");
				PropertyInfo property = obj2.GetProperty("Initialized", BindingFlags.Static | BindingFlags.Public);
				PropertyInfo property2 = obj2.GetProperty("PartialDataPath", BindingFlags.Static | BindingFlags.Public);
				PropertyInfo? property3 = obj2.GetProperty("ConfigPath", BindingFlags.Static | BindingFlags.Public);
				if ((object)property == null)
				{
					throw new Exception("Unable to Find Property: Initialized");
				}
				if ((object)property2 == null)
				{
					throw new Exception("Unable to Find Property: PartialDataPath");
				}
				if ((object)property3 == null)
				{
					throw new Exception("Unable to Find Field: ConfigPath");
				}
				Initialized = (bool)property.GetValue(null);
				PartialDataPath = (string)property2.GetValue(null);
				ConfigPath = (string)property3.GetValue(null);
				PersistentIDConverter = (JsonConverter)Activator.CreateInstance(type);
				IsLoaded = true;
			}
			catch (Exception value2)
			{
				Logger.Error($"Exception thrown while reading data from MTFO_Extension_PartialData:\n{value2}");
			}
		}
	}
	public static class MTFOUtil
	{
		public const string PLUGIN_GUID = "com.dak.MTFO";

		public const BindingFlags PUBLIC_STATIC = BindingFlags.Static | BindingFlags.Public;

		public static string GameDataPath { get; private set; }

		public static string CustomPath { get; private set; }

		public static bool HasCustomContent { get; private set; }

		public static bool IsLoaded { get; private set; }

		static MTFOUtil()
		{
			GameDataPath = string.Empty;
			CustomPath = string.Empty;
			HasCustomContent = false;
			IsLoaded = false;
			if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("com.dak.MTFO", out var value))
			{
				return;
			}
			try
			{
				Assembly obj = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? null;
				if ((object)obj == null)
				{
					throw new Exception("Assembly is Missing!");
				}
				Type obj2 = obj.GetTypes().First((Type t) => t.Name == "ConfigManager") ?? throw new Exception("Unable to Find ConfigManager Class");
				FieldInfo field = obj2.GetField("GameDataPath", BindingFlags.Static | BindingFlags.Public);
				FieldInfo field2 = obj2.GetField("CustomPath", BindingFlags.Static | BindingFlags.Public);
				FieldInfo? field3 = obj2.GetField("HasCustomContent", BindingFlags.Static | BindingFlags.Public);
				if ((object)field == null)
				{
					throw new Exception("Unable to Find Field: GameDataPath");
				}
				if ((object)field2 == null)
				{
					throw new Exception("Unable to Find Field: CustomPath");
				}
				if ((object)field3 == null)
				{
					throw new Exception("Unable to Find Field: HasCustomContent");
				}
				GameDataPath = (string)field.GetValue(null);
				CustomPath = (string)field2.GetValue(null);
				HasCustomContent = (bool)field3.GetValue(null);
				IsLoaded = true;
			}
			catch (Exception value2)
			{
				Logger.Error($"Exception thrown while reading path from DataDumper (MTFO): \n{value2}");
			}
		}
	}
}
namespace LGTuner.Manager
{
	public static class ConfigManager
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static LiveEditEventHandler <0>__LiveEdit_FileChanged;
		}

		private static readonly List<LayoutConfig> _layouts = new List<LayoutConfig>();

		private static readonly Dictionary<uint, LayoutConfig> _lookup = new Dictionary<uint, LayoutConfig>();

		private static readonly Dictionary<string, LayoutConfig> _fileNameLookup = new Dictionary<string, LayoutConfig>();

		public static IEnumerable<LayoutConfig> Layouts => _layouts;

		public static void Init()
		{
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Expected O, but got Unknown
			if (!MTFOUtil.HasCustomContent)
			{
				return;
			}
			string text = Path.Combine(MTFOUtil.CustomPath, "LGTuner");
			FileInfo[] files = Directory.CreateDirectory(text).GetFiles();
			foreach (FileInfo fileInfo in files)
			{
				string extension = fileInfo.Extension;
				bool flag = extension.Equals(".json", StringComparison.InvariantCultureIgnoreCase);
				bool flag2 = extension.Equals(".jsonc", StringComparison.InvariantCultureIgnoreCase);
				if (flag || flag2)
				{
					LayoutConfig layoutConfig = JSON.Deserialize<LayoutConfig>(File.ReadAllText(fileInfo.FullName));
					if (_lookup.ContainsKey(layoutConfig.LevelLayoutID))
					{
						Logger.Error($"Duplicated ID found!: {fileInfo.Name}, {layoutConfig.LevelLayoutID}");
					}
					else
					{
						_layouts.Add(layoutConfig);
						_lookup.Add(layoutConfig.LevelLayoutID, layoutConfig);
						_fileNameLookup.Add(fileInfo.Name.ToLowerInvariant(), layoutConfig);
					}
				}
			}
			LiveEditListener obj = LiveEdit.CreateListener(text, "*.*", true);
			object obj2 = <>O.<0>__LiveEdit_FileChanged;
			if (obj2 == null)
			{
				LiveEditEventHandler val = LiveEdit_FileChanged;
				<>O.<0>__LiveEdit_FileChanged = val;
				obj2 = (object)val;
			}
			obj.FileChanged += (LiveEditEventHandler)obj2;
			obj.StartListen();
		}

		private static void LiveEdit_FileChanged(LiveEditEventArgs e)
		{
			string key = Path.GetFileName(e.FullPath).ToLowerInvariant();
			string extension = Path.GetExtension(e.FullPath);
			if (!extension.Equals(".json", StringComparison.InvariantCulture) && !extension.Equals(".jsonc", StringComparison.InvariantCulture))
			{
				return;
			}
			Logger.Error($"File Edited: '{key}' '{e.FullPath}'");
			try
			{
				LayoutConfig data = _fileNameLookup[key];
				uint oldID = data.LevelLayoutID;
				LiveEdit.TryReadFileContent(e.FullPath, (Action<string>)delegate(string json)
				{
					try
					{
						LayoutConfig layoutConfig = JSON.Deserialize<LayoutConfig>(json);
						layoutConfig.LevelLayoutID = oldID;
						_fileNameLookup.Remove(key);
						_lookup.Remove(oldID);
						_layouts.Remove(data);
						_layouts.Add(layoutConfig);
						_lookup.Add(oldID, layoutConfig);
						_fileNameLookup.Add(key, layoutConfig);
					}
					catch (Exception value2)
					{
						Logger.Error($"Error while reading LGTuner Config: {value2}");
					}
				});
			}
			catch (Exception value)
			{
				Logger.Error($"Error while reading LGTuner Config: {value}");
			}
		}

		private static void DumpLevel()
		{
		}

		private static void DumpLayerToConfig()
		{
		}

		public static bool TryGetConfig(uint layoutID, out LayoutConfig config)
		{
			return _lookup.TryGetValue(layoutID, out config);
		}
	}
}
namespace LGTuner.Inject
{
	[HarmonyPatch(typeof(LG_Floor), "CreateDimension")]
	internal static class Inject_CreateDimension
	{
		[HarmonyPrefix]
		private static bool Prefix(LG_Floor __instance, uint seed, eDimensionIndex dimensionIndex, bool arenaDimension, DimensionData dimensionData, Vector3 position, ref int __result, int gridSize = 10, float cellSize = 64f)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_010c: 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_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_052c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			SubComplex subComplex = Builder.LayerBuildDatas[0].m_zoneBuildDatas[0].SubComplex;
			if ((Object)(object)EntryPoint.hirnuhubelevatorgo != (Object)null)
			{
				EntryPoint.hirnuhubelevatorgo.SetActive(false);
			}
			if (dimensionData.IsStaticDimension)
			{
				return true;
			}
			LayoutConfig config = null;
			LevelLayoutDataBlock block = GameDataBlockBase<LevelLayoutDataBlock>.GetBlock(dimensionData.LevelLayoutData);
			ConfigManager.TryGetConfig(((GameDataBlockBase<LevelLayoutDataBlock>)(object)block).persistentID, out config);
			if (config == null)
			{
				return true;
			}
			if (config.TileOverrides.Length == 0)
			{
				return true;
			}
			gridSize = 10;
			cellSize = 64f;
			GameObject val = null;
			XXHashSequence val2 = default(XXHashSequence);
			((XXHashSequence)(ref val2))..ctor(seed, true);
			Vector3 val3 = position - new Vector3(cellSize, 0f, cellSize) * (float)gridSize * 0.5f;
			LG_TileShape val4 = __instance.CreateTileShape((LG_TileShapeType)1, cellSize, ref val3);
			LG_Grid val5 = CellGridBase<LG_Grid, LG_Tile, LG_Cell>.Create(cellSize, val3);
			((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)val5).SetupCells(gridSize, gridSize);
			((CellGridBase<LG_Grid, LG_Tile, LG_Cell>)(object)val5).InititalizeCells();
			int count = __instance.m_dimensions.Count;
			Dimension val6 = new Dimension(val5, dimensionIndex, count, dimensionData, position, arenaDimension);
			DebugLog.LogPrefix((Object)(object)__instance, $"Created Dimension (Index: {dimensionIndex}, gridSize: {gridSize}, cellSize: {cellSize}).");
			val = val6.ResourceData.GetCustomGeomorph(dimensionData.DimensionGeomorph);
			if (block != null && config.TileOverrides[0].X == 0 && config.TileOverrides[0].Z == 0 && !string.IsNullOrEmpty(config.TileOverrides[0].Geomorph))
			{
				bool flag = false;
				if (config.TileOverrides[0].Geomorph == "hirnugeos_elevator")
				{
					Hirnu_hub_elevator.OnFactoryBuildStart(subComplex, dimensionData.IsOutside);
					val = EntryPoint.hirnuhubelevatorgo;
					EntryPoint.hirnuhubelevatorgo.SetActive(false);
					flag = true;
					Logger.Info($" - dim {dimensionIndex} elevator overriden! {((Object)EntryPoint.hirnuhubelevatorgo).name}");
				}
				if (!flag)
				{
					Object loadedAsset = AssetAPI.GetLoadedAsset(config.TileOverrides[0].Geomorph);
					val = ((loadedAsset != null) ? ((Il2CppObjectBase)loadedAsset).Cast<GameObject>() : null);
					Logger.Info($" - dim {dimensionIndex} elevator overriden! {((Object)val).name}");
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				DebugLog.LogPrefixError((Object)(object)__instance, $"<b><color=red>NULL ERROR</color></b> Could not get the Dimension Geomorph prefab for dimension {dimensionIndex}, are you using a resource set in the DimensionDataBlock that contains the Dimension Geomorph prefab under the \"Custom Geomorphs_Objective_1x1\" header?");
				__result = count;
				return false;
			}
			LG_FloorTransition val7 = __instance.CreateFloorTransition(((XXHashSequence)(ref val2)).NextSubSeed(), val6, position, Quaternion.identity, val, val6.DimensionData.IsStaticDimension);
			if ((Object)(object)val7 == (Object)null)
			{
				DebugLog.LogPrefixError((Object)(object)__instance, $"<b><color=red>NULL ERROR</color></b> The LG_FloorTransition of dimension {dimensionIndex} was null! Does the dimension prefab have a LG_FloorTransition component on its root?");
				__result = count;
				return false;
			}
			LG_Dimension val8 = ((Component)val7).GetComponent<LG_Dimension>();
			if ((Object)(object)val8 == (Object)null)
			{
				val8 = ((Component)val7).gameObject.AddComponent<LG_Dimension>();
				DebugLog.LogPrefixError((Object)(object)__instance, $"<b><color=red>NULL ERROR</color></b> The dimension {dimensionIndex} had no {typeof(LG_Dimension).Name} component, so added one automatically!");
			}
			val6.DimensionLevel = val8;
			if (val7.m_spawnPoints != null && ((Il2CppArrayBase<Transform>)(object)val7.m_spawnPoints).Length != 0)
			{
				val8.AddSpawnPoints(val7.m_spawnPoints);
			}
			val4.m_gridPosition = new LG_GridPosition(gridSize / 2, gridSize / 2);
			val4.m_type = val7.m_shapeType;
			AIG_GeomorphNodeVolume component = ((Component)val7).GetComponent<AIG_GeomorphNodeVolume>();
			if ((Object)(object)component == (Object)null)
			{
				DebugLog.LogPrefixError((Object)(object)__instance, $"<b><color=red>NULL ERROR</color></b> The Dimension Geomorph for {dimensionIndex} did not have a {typeof(AIG_GeomorphNodeVolume).Name} component on it!");
				__result = count;
				return false;
			}
			((LG_Geomorph)val7).m_nodeVolume = (AIG_NodeVolume)(object)component;
			((AIG_NodeVolume)component).ConstructVoxelNodeVolume();
			((LG_Geomorph)val7).ScanChildrenAreas();
			val6.m_startTile = LG_Tile.Create(val5, val4);
			val6.m_startTile.m_geoRoot = (LG_Geomorph)(object)val7;
			val6.m_startTile.m_geoRoot.m_tile = val6.m_startTile;
			((Component)val7).transform.SetParent(((Component)val6.DimensionRootTemp).transform);
			((LG_Geomorph)val7).m_tile = val6.m_startTile;
			val6.m_startTransition = val7;
			val6.Tiles.Add(val6.m_startTile);
			__instance.m_dimensions.Add(val6);
			__instance.m_indexToDimensionMap[dimensionIndex] = val6;
			__result = count;
			return false;
		}
	}
	[HarmonyPatch(typeof(LG_SetupFloor), "Build")]
	internal static class Inject_SetupFloor
	{
		private static LayoutConfig _configContext;

		[HarmonyPrefix]
		private static bool Prefix(LG_SetupFloor __instance, ref bool __result)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Expected O, but got Unknown
			LayoutConfig config = null;
			Debug.Log(Object.op_Implicit(Deb.LG("LG_SetupFloor.Build", 0f)));
			GameObject val = null;
			uint num = 0u;
			if (Builder.LayerBuildDatas[0].m_zoneBuildDatas != null && Builder.LayerBuildDatas[0].m_zoneBuildDatas.Count > 0)
			{
				_ = Builder.LayerBuildDatas[0].m_zoneBuildDatas[0].SubComplex;
				num = (uint)Builder.LayerBuildDatas[0].m_zoneBuildDatas[0].SubSeed;
			}
			XXHashSeed seed = __instance.m_rnd.Seed;
			XXHashSequence val2 = default(XXHashSequence);
			((XXHashSequence)(ref val2))..ctor(((XXHashSeed)(ref seed)).SubSeed(num), true);
			ConfigManager.TryGetConfig(RundownManager.ActiveExpedition.LevelLayoutData, out config);
			if (config == null)
			{
				return true;
			}
			LG_GridPosition val3 = default(LG_GridPosition);
			val3.x = 0;
			val3.z = 0;
			if (config.TileOverrides.Length == 0)
			{
				return true;
			}
			if (config.TileOverrides[0].X != 0 || config.TileOverrides[0].Z != 0)
			{
				return true;
			}
			if (!string.IsNullOrEmpty(config.TileOverrides[0].Geomorph))
			{
				bool flag = false;
				if (config.TileOverrides[0].Geomorph == "hirnugeos_elevator")
				{
					Hirnu_hub_elevator.OnFactoryBuildStart((SubComplex)4, IsOutside: false);
					val = EntryPoint.hirnuhubelevatorgo;
					flag = true;
					Logger.Info(" - elevator overriden! " + ((Object)EntryPoint.hirnuhubelevatorgo).name);
				}
				if (!flag)
				{
					Object loadedAsset = AssetAPI.GetLoadedAsset(config.TileOverrides[0].Geomorph);
					val = ((loadedAsset != null) ? ((Il2CppObjectBase)loadedAsset).Cast<GameObject>() : null);
					if ((Object)(object)val == (Object)null)
					{
						Logger.Info("LGTuner failed to override elevator!");
						return true;
					}
					Logger.Info(" - elevator overriden! " + ((Object)val).name);
				}
				LG_FloorTransition val4 = GOUtil.SpawnChildAndGetComp<LG_FloorTransition>(val, __instance.m_position, __instance.m_rotation);
				((LG_Geomorph)val4).m_geoPrefab = val;
				((LG_Geomorph)val4).SetupAreas(((XXHashSequence)(ref val2)).NextSubSeed());
				((LG_Geomorph)val4).SetPlaced();
				__instance.m_floor.Setup(((XXHashSequence)(ref val2)).NextSubSeed(), (LG_FloorType)0, Builder.ComplexResourceSetBlock.LevelGenConfig.TransitionDirection, val4);
				for (int i = 0; i < __instance.m_floor.m_dimensions.Count; i++)
				{
					__instance.m_floor.InjectJobs(__instance.m_floor.m_dimensions[i].DimensionIndex);
				}
				LG_Factory.InjectJob((LG_FactoryJob)new LG_BuildFloorJob(__instance.m_floor), (BatchName)7);
				__result = true;
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(LG_BuildPlugBaseJob), "SpawnPlug")]
	internal static class Inject_BuildPlug
	{
		private static void Prefix(LG_Plug plug, ref GameObject prefab)
		{
			//IL_0023: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Expected I4, but got Unknown
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			Logger.Info($"found plug for zone: {((LG_ZoneExpander)plug).m_linksFrom.m_zone.LocalIndex}{((Object)((LG_ZoneExpander)plug).m_linksFrom).name}->{((LG_ZoneExpander)plug).m_linksTo.m_zone.LocalIndex}{((Object)((LG_ZoneExpander)plug).m_linksTo).name}");
			if (!BuilderInfo.TryGetConfig(((LG_ZoneExpander)plug).m_linksFrom.m_zone, out var config))
			{
				return;
			}
			LG_GridPosition normal = ((LG_ZoneExpander)plug).m_linksFrom.m_geomorph.m_tile.m_shape.m_gridPosition.GetNormal(config.GridSize);
			if (!config.TryGetTileData(normal, out var overrideData))
			{
				return;
			}
			ZoneOverrideData zoneData = overrideData.ZoneData;
			if (zoneData != null && zoneData.OverridePlugs && TryGetPlugPrefab(overrideData.ZoneData.GetNextPlug(), out var prefab2))
			{
				Logger.Info(" - Prefab Replaced by Zone OverridePlugs! " + ((Object)prefab2).name);
				prefab = prefab2;
			}
			LG_PlugDir dir = plug.m_dir;
			GameObject prefab3;
			switch (dir - 2)
			{
			case 0:
				if (TryGetPlugPrefab(overrideData.BackwardPlug, out prefab3))
				{
					Logger.Info(" - Prefab Replaced by BackwardPlug setting! " + ((Object)prefab3).name);
					prefab = prefab3;
					return;
				}
				break;
			case 2:
				if (TryGetPlugPrefab(overrideData.ForwardPlug, out prefab3))
				{
					Logger.Info(" - Prefab Replaced by ForwardPlug setting! " + ((Object)prefab3).name);
					prefab = prefab3;
					return;
				}
				break;
			case 3:
				if (TryGetPlugPrefab(overrideData.LeftPlug, out prefab3))
				{
					Logger.Info(" - Prefab Replaced by LeftPlug setting! " + ((Object)prefab3).name);
					prefab = prefab3;
					return;
				}
				break;
			case 1:
				if (TryGetPlugPrefab(overrideData.RightPlug, out prefab3))
				{
					Logger.Info(" - Prefab Replaced by RightPlug setting! " + ((Object)prefab3).name);
					prefab = prefab3;
					return;
				}
				break;
			}
			if (overrideData.OverridePlugWithNoGateChance)
			{
				Random random = new Random(((LG_ZoneExpander)plug).m_linksFrom.AreaSeed.ToSeed());
				bool withGate = ((LG_ZoneExpander)plug).m_isZoneSource || (!(overrideData.PlugWithNoGateChance >= 1f) && (overrideData.PlugWithNoGateChance <= 0f || random.NextFloat() >= overrideData.PlugWithNoGateChance));
				int dropHeight = GetDropHeight(plug);
				GameObject randomPlug = BuilderInfo.GetRandomPlug(random.NextUint(), dropHeight, GetSubComplexOfPlug(plug), withGate);
				if ((Object)(object)randomPlug == (Object)null)
				{
					Logger.Error($"Plug was null! - Height: {dropHeight}");
				}
				else
				{
					prefab = randomPlug;
				}
			}
		}

		private static SubComplex GetSubComplexOfPlug(LG_Plug plug)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			SubComplex result = ((LG_ZoneExpander)plug).m_subComplex;
			if (((LG_ZoneExpander)plug).m_subComplex != ((LG_ZoneExpander)plug.m_pariedWith).m_subComplex)
			{
				result = (SubComplex)8;
			}
			return result;
		}

		private static bool TryGetPlugPrefab(string prefabPath, out GameObject prefab)
		{
			if (string.IsNullOrEmpty(prefabPath))
			{
				prefab = null;
				return false;
			}
			prefab = ((Il2CppObjectBase)AssetAPI.GetLoadedAsset(prefabPath)).Cast<GameObject>();
			return (Object)(object)prefab != (Object)null;
		}

		private static int GetDropHeight(LG_Plug plug)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			return Mathf.RoundToInt(Mathf.Abs(((Component)plug).transform.position.y - ((Component)plug.m_pariedWith).transform.position.y) / BuilderInfo.AltitudeOffset);
		}
	}
	[HarmonyPatch(typeof(LG_BuildPlugJob), "Build")]
	internal class Inject_BuildPlugJob
	{
		[HarmonyWrapSafe]
		private static bool Prefix(LG_BuildPlugJob __instance)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Invalid comparison between Unknown and I4
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected I4, but got Unknown
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = null;
			LG_Plug plug = __instance.m_plug;
			Logger.Info($"buildplugjob plug in complex {((LG_ZoneExpander)plug).m_subComplex} plug status {((LG_ZoneExpander)plug).ExpanderStatus} plug direction {plug.m_dir} ..");
			if ((int)((LG_ZoneExpander)plug).ExpanderStatus == 1)
			{
				return true;
			}
			if (((LG_ZoneExpander)plug).m_isZoneSource)
			{
				return true;
			}
			if (!BuilderInfo.TryGetConfig(((LG_ZoneExpander)plug).m_linksFrom.m_zone, out var config))
			{
				return true;
			}
			LG_GridPosition normal = ((LG_ZoneExpander)plug).m_linksFrom.m_geomorph.m_tile.m_shape.m_gridPosition.GetNormal(config.GridSize);
			if (!config.TryGetTileData(normal, out var overrideData))
			{
				return true;
			}
			LG_PlugDir dir = plug.m_dir;
			GameObject prefab;
			switch (dir - 2)
			{
			case 0:
				if (TryGetPlugPrefab(overrideData.BackwardPlug, out prefab))
				{
					Logger.Info(" - Prefab Replaced by BackwardPlug setting! " + ((Object)prefab).name);
					val = prefab;
				}
				break;
			case 2:
				if (TryGetPlugPrefab(overrideData.ForwardPlug, out prefab))
				{
					Logger.Info(" - Prefab Replaced by ForwardPlug setting! " + ((Object)prefab).name);
					val = prefab;
				}
				break;
			case 3:
				if (TryGetPlugPrefab(overrideData.LeftPlug, out prefab))
				{
					Logger.Info(" - Prefab Replaced by LeftPlug setting! " + ((Object)prefab).name);
					val = prefab;
				}
				break;
			case 1:
				if (TryGetPlugPrefab(overrideData.RightPlug, out prefab))
				{
					Logger.Info(" - Prefab Replaced by RightPlug setting! " + ((Object)prefab).name);
					val = prefab;
				}
				break;
			}
			if ((Object)(object)val != (Object)null)
			{
				Logger.Info($"we shall replace a cap going {plug.m_dir}");
				Vector3 position = ((Component)plug).transform.position;
				Quaternion rotation = ((Component)plug).transform.rotation;
				GameObject val2 = Object.Instantiate<GameObject>(val, position, rotation);
				val2.transform.SetParent(((Component)plug).transform, true);
				LG_Factory.FindAndBuildSelectorsAndSpawners(val2, RandomExtensions.NextSubSeed(__instance.m_rnd.Random), false);
				__instance.ProcessDivider(plug, val2, false, RandomExtensions.NextSubSeed(__instance.m_rnd.Random));
				((LG_ZoneExpander)plug).m_wasProcessed = true;
			}
			return true;
		}

		private static bool TryGetPlugPrefab(string prefabPath, out GameObject prefab)
		{
			if (string.IsNullOrEmpty(prefabPath))
			{
				prefab = null;
				return false;
			}
			prefab = ((Il2CppObjectBase)AssetAPI.GetLoadedAsset(prefabPath)).Cast<GameObject>();
			return (Object)(object)prefab != (Object)null;
		}
	}
	[HarmonyPatch(typeof(LG_LevelBuilder), "PlaceRoot")]
	internal static class Inject_BuildGeomorph
	{
		private static LayoutConfig _configContext;

		private static RotateType _nextRotateType;

		[HarmonyPostfix]
		[HarmonyWrapSafe]
		[HarmonyPatch("BuildFloor")]
		private static void Post_BuildFloor()
		{
			BuilderInfo.OnResourceSetSelected();
		}

		[HarmonyPrefix]
		[HarmonyWrapSafe]
		[HarmonyPatch("PlaceRoot")]
		private static void Pre_PlaceRoot(LG_Tile tile, ref GameObject tilePrefab, ref bool forceAlignToVector, ref Vector3 alignVector, LG_Zone zone)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: 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_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			_configContext = null;
			_nextRotateType = RotateType.None;
			forceAlignToVector = alignVector != Vector3.zero;
			int gridSize = zone.Dimension.GetGridSize();
			LG_GridPosition val = tile.ToNormalGrid(gridSize);
			Logger.Info($"tile info: {val.x} {val.z} {((Object)tilePrefab).name} for {zone.LocalIndex} : {zone.DimensionIndex}");
			if (!BuilderInfo.TryGetConfig(zone, out _configContext))
			{
				return;
			}
			if (!_configContext.TryGetTileData(val, out var overrideData))
			{
				overrideData = _configContext.PopulateTileOverrideForZone(zone, val);
				if (overrideData == null)
				{
					return;
				}
			}
			if (!string.IsNullOrEmpty(overrideData.Geomorph))
			{
				if (overrideData.X == 0 && overrideData.Z == 0)
				{
					return;
				}
				bool flag = false;
				if (overrideData.Geomorph == "hirnugeos_i")
				{
					Hirnu_materials.OnFactoryBuildStart();
					Hirnu_i.OnFactoryBuildStart(zone.m_settings.m_zoneData.SubComplex, zone);
					tilePrefab = EntryPoint.hirnuigo;
					Logger.Info(" - tile overriden! " + ((Object)EntryPoint.hirnuigo).name);
					flag = true;
				}
				if (overrideData.Geomorph == "hirnugeos_hub")
				{
					Hirnu_materials.OnFactoryBuildStart();
					Hirnu_hub.OnFactoryBuildStart(zone.m_settings.m_zoneData.SubComplex, zone);
					tilePrefab = EntryPoint.hirnuhubgo;
					Logger.Info(" - tile overriden! " + ((Object)EntryPoint.hirnuhubgo).name);
					flag = true;
				}
				if (overrideData.Geomorph == "hirnugeos_deadend")
				{
					Hirnu_materials.OnFactoryBuildStart();
					Hirnu_deadend.OnFactoryBuildStart(zone.m_settings.m_zoneData.SubComplex, zone);
					tilePrefab = EntryPoint.hirnudeadendgo;
					Logger.Info(" - tile overriden! " + ((Object)EntryPoint.hirnudeadendgo).name);
					flag = true;
				}
				if (overrideData.Geomorph == "hirnugeos_hub_gencluster")
				{
					Hirnu_materials.OnFactoryBuildStart();
					Hirnu_hub_gencluster.OnFactoryBuildStart(zone.m_settings.m_zoneData.SubComplex, zone);
					tilePrefab = EntryPoint.hirnuhubgengo;
					Logger.Info(" - tile overriden! " + ((Object)EntryPoint.hirnuhubgengo).name);
					flag = true;
				}
				if (overrideData.Geomorph == "hirnugeos_hub_reactor")
				{
					Hirnu_materials.OnFactoryBuildStart();
					Hirnu_hub_reactor.OnFactoryBuildStart(zone.m_settings.m_zoneData.SubComplex, zone);
					tilePrefab = EntryPoint.hirnuhubreactorgo;
					Logger.Info(" - tile overriden! " + ((Object)EntryPoint.hirnuhubreactorgo).name);
					flag = true;
				}
				if (overrideData.Geomorph == "hirnugeos_i_areatest")
				{
					Hirnu_materials.OnFactoryBuildStart();
					Hirnu_i_areatest.OnFactoryBuildStart(zone.m_settings.m_zoneData.SubComplex, zone);
					tilePrefab = EntryPoint.hirnuiareatestgo;
					Logger.Info(" - tile overriden! " + ((Object)EntryPoint.hirnuiareatestgo).name);
					flag = true;
				}
				if (!flag)
				{
					Object loadedAsset = AssetAPI.GetLoadedAsset(overrideData.Geomorph);
					GameObject val2 = ((loadedAsset != null) ? ((Il2CppObjectBase)loadedAsset).Cast<GameObject>() : null);
					if ((Object)(object)val2 != (Object)null)
					{
						Logger.Info(" - tile overriden! " + ((Object)val2).name);
						tilePrefab = val2;
					}
				}
			}
			if (overrideData.Rotation != 0)
			{
				_nextRotateType = overrideData.Rotation;
			}
		}

		[HarmonyPostfix]
		[HarmonyWrapSafe]
		[HarmonyPatch("GetTilePosition")]
		private static void Post_GetTilePosition(LG_Tile tile, LG_Floor floor, int dimensionIndex, ref Vector3 __result)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			if (_configContext != null && floor.TryGetDimension(dimensionIndex, out var dimension))
			{
				int gridSize = _configContext.GridSize;
				LG_GridPosition val = tile.ToNormalGrid(gridSize);
				if (_configContext.TryGetTileData(val, out var overrideData) && overrideData.OverrideAltitude)
				{
					Vector3 positionNormal = dimension.Grid.GetPositionNormal(val.x, val.z, gridSize);
					positionNormal += new Vector3(0f, (float)overrideData.Altitude * BuilderInfo.AltitudeOffset, 0f);
					__result = positionNormal;
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyWrapSafe]
		[HarmonyPatch("PlaceRoot")]
		private static void Post_PlaceRoot(LG_Tile tile, LG_Zone zone, LG_Geomorph __result)
		{
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			Hirnu_i.OnFactoryBuildDone();
			Hirnu_hub.OnFactoryBuildDone();
			Hirnu_deadend.OnFactoryBuildDone();
			Hirnu_hub_gencluster.OnFactoryBuildDone();
			Hirnu_hub_reactor.OnFactoryBuildDone();
			Hirnu_hub_elevator.OnFactoryBuildDone();
			Hirnu_i_areatest.OnFactoryBuildDone();
			if (_configContext == null)
			{
				return;
			}
			if (_nextRotateType != 0)
			{
				GameObject gameObject = ((Component)__result).gameObject;
				LG_PlugInfo lG_PlugInfo = LG_PlugInfo.BuildPlugInfo(gameObject, gameObject.transform.rotation);
				Logger.Info($" - TRYING ROTATION! PLUG COUNT: {lG_PlugInfo.Count}");
				if (lG_PlugInfo.TryGetNewRotation(zone.m_subSeed, _nextRotateType, out var rotation))
				{
					Logger.Info(" - Done!");
					gameObject.transform.rotation = rotation;
				}
				__result.SetPlaced();
			}
			int gridSize = _configContext.GridSize;
			LG_GridPosition normalGridPosition = tile.ToNormalGrid(gridSize);
			if (!_configContext.TryGetTileData(normalGridPosition, out var overrideData) || !overrideData.OverrideAreaSeeds)
			{
				return;
			}
			if (overrideData.AreaSeeds.Length == ((Il2CppArrayBase<LG_Area>)(object)__result.m_areas).Length)
			{
				int length = ((Il2CppArrayBase<LG_Area>)(object)__result.m_areas).Length;
				for (int i = 0; i < length; i++)
				{
					uint num = overrideData.AreaSeeds[i];
					if (num != 0)
					{
						((Il2CppArrayBase<LG_Area>)(object)__result.m_areas)[i].AreaSeed = num;
						Logger.Info($" - new area seed: {((Il2CppArrayBase<LG_Area>)(object)__result.m_areas)[i].m_navInfo}, {num}");
					}
				}
			}
			else
			{
				Logger.Error($" - Area count and AreaSeeds item count mismatched! (CFG: {overrideData.AreaSeeds.Length} != AREA: {((Il2CppArrayBase<LG_Area>)(object)__result.m_areas).Length}) Area seed will not be applied!");
			}
		}
	}
	[HarmonyPatch(typeof(LG_LoadComplexDataSetResourcesJob), "Build")]
	internal static class Inject_LoadComplexShard
	{
		private static int _waitingShared;

		private static void Prefix(LG_LoadComplexDataSetResourcesJob __instance)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected I4, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.m_loadingStarted)
			{
				return;
			}
			foreach (Complex item in BuilderInfo.ExtraComplexResourceToLoad)
			{
				AssetBundleName val = (AssetBundleName)((int)item switch
				{
					0 => 2, 
					1 => 4, 
					2 => 3, 
					_ => 0, 
				});
				if ((int)val != 0)
				{
					AssetShardManager.LoadAllShardsForBundleAsync(val, Action.op_Implicit((Action)Loaded), 1, (LoadSceneMode)1);
					_waitingShared++;
				}
			}
		}

		private static void Loaded()
		{
			_waitingShared--;
		}

		[HarmonyWrapSafe]
		private static void Postfix(LG_LoadComplexDataSetResourcesJob __instance, ref bool __result)
		{
			if (_waitingShared >= 1)
			{
				__result = false;
			}
		}
	}
}
namespace LGTuner.hirnugeos
{
	public class Hirnu_materials : MonoBehaviour
	{
		public static void OnFactoryBuildDone()
		{
			//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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Invalid comparison between Unknown and I4
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Invalid comparison between Unknown and I4
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Invalid comparison between Unknown and I4
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Invalid comparison between Unknown and I4
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Invalid comparison between Unknown and I4
			EntryPoint.hirnufloormaterial = null;
			EntryPoint.hirnuwallmaterial = null;
			List<GameObject> list = new List<GameObject>();
			list.Clear();
			SubComplex subComplex = Builder.LayerBuildDatas[0].m_zoneBuildDatas[0].SubComplex;
			Debug.Log(Object.op_Implicit($"hirnugeos - building materials for {subComplex}"));
			if ((int)subComplex == 0 || (int)subComplex == 1)
			{
				GameObject obj = ((Il2CppObjectBase)AssetAPI.GetLoadedAsset("Assets/AssetPrefabs/Complex/Mining/Geomorphs/geo_32x32_elevator_shaft_dig_site_03.prefab")).Cast<GameObject>();
				Debug.Log(Object.op_Implicit("hirnugeos - materials digsite going"));
				foreach (LG_PrefabSpawner componentsInChild in obj.GetComponentsInChildren<LG_PrefabSpawner>(true))
				{
					if ((Object)(object)EntryPoint.hirnufloormaterial != (Object)null && (Object)(object)EntryPoint.hirnuwallmaterial != (Object)null)
					{
						Debug.Log(Object.op_Implicit("hirnugeos - materials breaking"));
					}
					if ((Object)(object)EntryPoint.hirnufloormaterial != (Object)null && (Object)(object)EntryPoint.hirnuwallmaterial != (Object)null)
					{
						break;
					}
					if (!((Object)componentsInChild.m_prefab).name.Contains("BuildingPart_StorageGround_Gravel_2x2_a"))
					{
						continue;
					}
					foreach (MeshRenderer componentsInChild2 in componentsInChild.m_prefab.GetComponentsInChildren<MeshRenderer>())
					{
						if (((Object)((Component)componentsInChild2).gameObject).name.Contains("g_BuildingPart"))
						{
							EntryPoint.hirnufloormaterial = Object.Instantiate<Material>(((Renderer)componentsInChild2).material);
							EntryPoint.hirnuwallmaterial = Object.Instantiate<Material>(((Renderer)componentsInChild2).material);
						}
					}
				}
			}
			Debug.Log(Object.op_Implicit("hirnugeos - materials digsite done"));
			if ((int)subComplex == 4 || (int)subComplex == 3)
			{
				foreach (LG_PrefabSpawner componentsInChild3 in ((Il2CppObjectBase)AssetAPI.GetLoadedAsset("Assets/AssetPrefabs/Complex/Tech/Geomorphs/geo_64x64_Lab_dead_end_HSU.prefab")).Cast<GameObject>().GetComponentsInChildren<LG_PrefabSpawner>(true))
				{
					if ((Object)(object)EntryPoint.hirnufloormaterial != (Object)null)
					{
						break;
					}
					if (!((Object)componentsInChild3.m_prefab).name.Contains("BuildingPart_Lab_Floor_4x4_a"))
					{
						continue;
					}
					foreach (MeshRenderer componentsInChild4 in componentsInChild3.m_prefab.GetComponentsInChildren<MeshRenderer>())
					{
						if (((Object)((Component)componentsInChild4).gameObject).name.Contains("g_BuildingPart"))
						{
							EntryPoint.hirnufloormaterial = Object.Instantiate<Material>(((Renderer)componentsInChild4).material);
						}
					}
				}
				foreach (LG_PrefabSpawner componentsInChild5 in ((Il2CppObjectBase)AssetAPI.GetLoadedAsset("Assets/AssetPrefabs/Complex/Tech/Geomorphs/geo_64x64_tech_node_transition_07_LF.prefab")).Cast<GameObject>().GetComponentsInChildren<LG_PrefabSpawner>(true))
				{
					if ((Object)(object)EntryPoint.hirnufloormaterial != (Object)null && (Object)(object)EntryPoint.hirnuwallmaterial != (Object)null)
					{
						Debug.Log(Object.op_Implicit("hirnugeos - materials breaking"));
					}
					if ((Object)(object)EntryPoint.hirnufloormaterial != (Object)null && (Object)(object)EntryPoint.hirnuwallmaterial != (Object)null)
					{
						break;
					}
					if (!((Object)componentsInChild5.m_prefab).name.Contains("BuildingPart_DataCenter_6x6_Roof_c"))
					{
						continue;
					}
					foreach (MeshRenderer componentsInChild6 in componentsInChild5.m_prefab.GetComponentsInChildren<MeshRenderer>())
					{
						if (((Object)((Component)componentsInChild6).gameObject).name.Contains("g_BuildingPart"))
						{
							EntryPoint.hirnuwallmaterial = Object.Instantiate<Material>(((Renderer)componentsInChild6).material);
						}
					}
				}
			}
			if ((int)subComplex == 6 || (int)subComplex == 11)
			{
				foreach (LG_PrefabSpawner componentsInChild7 in ((Il2CppObjectBase)AssetAPI.GetLoadedAsset("Assets/AssetPrefabs/Complex/Service/Geomorphs/Maintenance/geo_64x64_service_floodways_hub_AW_01.prefab")).Cast<GameObject>().GetComponentsInChildren<LG_PrefabSpawner>(true))
				{
					if ((Object)(object)EntryPoint.hirnufloormaterial != (Object)null && (Object)(object)EntryPoint.hirnuwallmaterial != (Object)null)
					{
						Debug.Log(Object.op_Implicit("hirnugeos - materials breaking"));
					}
					if ((Object)(object)EntryPoint.hirnufloormaterial != (Object)null && (Object)(object)EntryPoint.hirnuwallmaterial != (Object)null)
					{
						break;
					}
					if (!((Object)componentsInChild7.m_prefab).name.Contains("edgeup"))
					{
						continue;
					}
					foreach (MeshRenderer componentsInChild8 in componentsInChild7.m_prefab.GetComponentsInChildren<MeshRenderer>())
					{
						if (((Object)((Component)componentsInChild8).gameObject).name.Contains("g_Service"))
						{
							EntryPoint.hirnufloormaterial = Object.Instantiate<Material>(((Renderer)componentsInChild8).material);
							EntryPoint.hirnuwallmaterial = Object.Instantiate<Material>(((Renderer)componentsInChild8).material);
						}
					}
				}
			}
			Debug.Log(Object.op_Implicit($"hirnugeos - materials done {(Object)(object)EntryPoint.hirnufloormaterial == (Object)null} {(Object)(object)EntryPoint.hirnuwallmaterial == (Object)null}"));
			foreach (GameObject item in list)
			{
				item.SetActive(false);
			}
			foreach (LG_Geomorph item2 in Object.FindObjectsOfType<LG_Geomorph>())
			{
				foreach (MeshRenderer componentsInChild9 in ((Component)item2).GetComponentsInChildren<MeshRenderer>())
				{
					if (((Object)((Component)componentsInChild9).gameObject).name.Contains("hirnu_floor"))
					{
						((Renderer)componentsInChild9).SetMaterial(EntryPoint.hirnufloormaterial);
					}
					if (((Object)((Component)componentsInChild9).gameObject).name.Contains("hirnu_wall"))
					{
						((Renderer)componentsInChild9).SetMaterial(EntryPoint.hirnuwallmaterial);
					}
				}
			}
		}

		public static void OnFactoryBuildStart()
		{
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)EntryPoint.hirnulamp == (Object)null))
			{
				return;
			}
			foreach (LG_PrefabSpawner componentsInChild in ((Il2CppObjectBase)AssetAPI.GetLoadedAsset("Assets/AssetPrefabs/Complex/Tech/Geomorphs/geo_32x32_elevator_shaft_lab_03.prefab")).Cast<GameObject>().GetComponentsInChildren<LG_PrefabSpawner>())
			{
				if (((Object)componentsInChild.m_prefab).name == "prop_generic_light_regular_wall_fluorescent_02")
				{
					EntryPoint.hirnulamp = Object.Instantiate<LG_PrefabSpawner>(componentsInChild);
					EntryPoint.hirnulampfixture = Object.Instantiate<GameObject>(EntryPoint.hirnulamp.m_prefab);
				}
				if ((Object)(object)EntryPoint.hirnulamp != (Object)null)
				{
					break;
				}
			}
			EntryPoint.hirnulamp.m_prefab = EntryPoint.hirnulampfixture;
			((Component)EntryPoint.hirnulamp).transform.position = new Vector3(0f, -50f, 0f);
			EntryPoint.hirnulampfixture.transform.position = new Vector3(0f, -50f, 0f);
		}
	}
	public class Hirnu_hub_elevator : MonoBehaviour
	{
		public static LG_PrefabSpawner hirnulamp;

		public static GameObject hirnulampfixture;

		public static void OnFactoryBuildDone()
		{
			if ((Object)(object)EntryPoint.hirnuhubelevatorgo != (Object)null)
			{
				EntryPoint.hirnuhubelevatorgo.SetActive(false);
			}
		}

		public static void OnFactoryBuildStart(SubComplex subcomplex, bool IsOutside)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: 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_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: 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)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_049a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04da: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_051a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0539: Unknown result type (might be due to invalid IL or missing references)
			//IL_059d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0618: Unknown result type (might be due to invalid IL or missing references)
			//IL_062c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0631: Unknown result type (might be due to invalid IL or missing references)
			//IL_0642: Unknown result type (might be due to invalid IL or missing references)
			//IL_0657: Unknown result type (might be due to invalid IL or missing references)
			//IL_066a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0675: Unknown result type (might be due to invalid IL or missing references)
			//IL_067a: Unknown result type (might be due to invalid IL or missing references)
			//IL_068b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f3: 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_0712: Unknown result type (might be due to invalid IL or missing references)
			//IL_0727: Unknown result type (might be due to invalid IL or missing references)
			//IL_073a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0745: Unknown result type (might be due to invalid IL or missing references)
			//IL_074a: Unknown result type (might be due to invalid IL or missing references)
			//IL_075b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0770: Unknown result type (might be due to invalid IL or missing references)
			//IL_077a: Unknown result type (might be due to invalid IL or missing references)
			//IL_078f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0801: Unknown result type (might be due to invalid IL or missing references)
			//IL_0808: Expected O, but got Unknown
			//IL_0830: Unknown result type (might be due to invalid IL or missing references)
			//IL_084b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0852: Expected O, but got Unknown
			//IL_0869: Unknown result type (might be due to invalid IL or missing references)
			//IL_086e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0880: Unknown result type (might be due to invalid IL or missing references)
			//IL_0895: Unknown result type (might be due to invalid IL or missing references)
			//IL_0abb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ada: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b3c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b5c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b7c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b86: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b8d: Expected O, but got Unknown
			//IL_0b8d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b94: Expected O, but got Unknown
			//IL_0b94: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b9b: Expected O, but got Unknown
			//IL_0b9b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ba2: Expected O, but got Unknown
			//IL_0bdc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bfc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c4f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c6e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c89: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cb3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cc5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cda: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ce4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cf9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d4b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d6b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a11: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a30: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0946: Unknown result type (might be due to invalid IL or missing references)
			//IL_0965: Unknown result type (might be due to invalid IL or missing references)
			//IL_0983: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dbe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ddd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0df8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e1d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e22: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e34: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e49: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e53: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e68: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eda: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f2d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f4c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f67: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f8c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f91: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fa3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fb8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fc2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fd7: Unknown result type (might be due to invalid IL or missing references)
			//IL_1029: Unknown result type (might be due to invalid IL or missing references)
			//IL_1049: Unknown result type (might be due to invalid IL or missing references)
			//IL_109c: Unknown result type (might be due to invalid IL or missing references)
			//IL_10bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_10d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_10fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_1100: Unknown result type (might be due to invalid IL or missing references)
			//IL_1112: Unknown result type (might be due to invalid IL or missing references)
			//IL_1127: Unknown result type (might be due to invalid IL or missing references)
			//IL_1131: Unknown result type (might be due to invalid IL or missing references)
			//IL_1146: Unknown result type (might be due to invalid IL or missing references)
			//IL_1163: Unknown result type (might be due to invalid IL or missing references)
			//IL_116a: Expected O, but got Unknown
			//IL_1193: Unknown result type (might be due to invalid IL or missing references)
			//IL_119d: Unknown result type (might be due to invalid IL or missing references)
			//IL_11a4: Expected O, but got Unknown
			//IL_11cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_11ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_11f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_11fe: Expected O, but got Unknown
			//IL_1227: Unknown result type (might be due to invalid IL or missing references)
			//IL_1247: Unknown result type (might be due to invalid IL or missing references)
			//IL_1251: Unknown result type (might be due to invalid IL or missing references)
			//IL_1258: Expected O, but got Unknown
			//IL_1281: Unknown result type (might be due to invalid IL or missing references)
			//IL_12a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_12fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_1319: Unknown result type (might be due to invalid IL or missing references)
			//IL_1333: Unknown result type (might be due to invalid IL or missing references)
			//IL_13aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_13c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_13e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_145a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1479: Unknown result type (might be due to invalid IL or missing references)
			//IL_1493: Unknown result type (might be due to invalid IL or missing references)
			//IL_1570: Unknown result type (might be due to invalid IL or missing references)
			//IL_1577: Expected O, but got Unknown
			//IL_159f: Unknown result type (might be due to invalid IL or missing references)
			//IL_15be: Unknown result type (might be due to invalid IL or missing references)
			//IL_15dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_15f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_1614: Unknown result type (might be due to invalid IL or missing references)
			//IL_150a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1529: Unknown result type (might be due to invalid IL or missing references)
			//IL_1543: Unknown result type (might be due to invalid IL or missing references)
			//IL_1671: Unknown result type (might be due to invalid IL or missing references)
			//IL_1678: Expected O, but got Unknown
			//IL_1694: Unknown result type (might be due to invalid IL or missing references)
			//IL_16b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_16e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_170b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1736: Unknown result type (might be due to invalid IL or missing references)
			//IL_173b: Unknown result type (might be due to invalid IL or missing references)
			//IL_174d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1762: Unknown result type (might be due to invalid IL or missing references)
			//IL_176c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1781: Unknown result type (might be due to invalid IL or missing references)
			subcomplex = Builder.LayerBuildDatas[0].m_zoneBuildDatas[0].SubComplex;
			Hirnu_materials.OnFactoryBuildStart();
			EntryPoint.hirnuhubelevatorgo = new GameObject();
			Debug.Log(Object.op_Implicit($"LGTuner - hirnugeos - building hub-elevator-tile, subcomplex {subcomplex}"));
			EntryPoint.hirnuhubelevatorgo.SetActive(true);
			((Object)EntryPoint.hirnuhubelevatorgo).hideFlags = (HideFlags)61;
			EntryPoint.hirnuhubelevatorgo.layer = LayerManager.LAYER_DEFAULT;
			((Object)EntryPoint.hirnuhubelevatorgo).name = "hirnu_tile_hub_elevator";
			LG_FloorTransition val = EntryPoint.hirnuhubelevatorgo.AddComponent<LG_FloorTransition>();
			val.m_shapeType = (LG_TileShapeType)1;
			val.m_transitionType = (LG_FloorTransitionType)2;
			ElevatorShaftLanding val2 = EntryPoint.hirnuhubelevatorgo.AddComponent<ElevatorShaftLanding>();
			EntryPoint.hirnuhubelevatorgo.AddComponent<AIG_VoxelNodeVolume>();
			GameObject val3 = new GameObject("Area A");
			val3.transform.parent = EntryPoint.hirnuhubelevatorgo.transform;
			((Object)val3).name = "hirnu_tile_hub_elevator_a";
			GameObject val4 = new GameObject("AreaAIGraphSource");
			val4.transform.parent = val3.transform;
			Transform transform = val4.transform;
			transform.localPosition += new Vector3(-5f, 2f, 0f);
			LG_AreaAIGraphSource val5 = val4.AddComponent<LG_AreaAIGraphSource>();
			val5.m_position = new Vector3(0f, 2f, 0f);
			LG_Area val6 = val3.AddComponent<LG_Area>();
			val6.m_size = (LG_AreaSize)2;
			val6.m_geomorph = (LG_Geomorph)(object)val;
			((LG_Geomorph)val).m_areas = Il2CppReferenceArray<LG_Area>.op_Implicit((LG_Area[])(object)new LG_Area[1] { val6 });
			GameObject val7 = ComponentExt.AddChildGameObject((Component)(object)val3.transform, "ExpeditionExitScanAlign");
			val7.transform.localPosition = new Vector3(0.32f, 0.4f, 15.27f);
			foreach (Transform componentsInChild in ((Il2CppObjectBase)AssetAPI.GetLoadedAsset("Assets/AssetPrefabs/Complex/Tech/Geomorphs/geo_32x32_elevator_shaft_lab_03.prefab")).Cast<GameObject>().GetComponentsInChildren<Transform>())
			{
				if (((Object)componentsInChild).name == "ElevatorCargoAlign")
				{
					EntryPoint.hirnucargocage = Object.Instantiate<GameObject>(((Component)componentsInChild).gameObject);
				}
			}
			GameObject val8 = Object.Instantiate<GameObject>(EntryPoint.hirnucargocage);
			val8.transform.parent = val3.transform;
			val8.transform.position = new Vector3(0f, 0f, 0f);
			val8.transform.localPosition = new Vector3(0f, 0f, 14f);
			val2.m_cargoCageAlign = val8.transform;
			val2.m_securityScanAlign = val7.transform;
			GameObject val9 = ComponentExt.AddChildGameObject((Component)(object)val3.transform, "spawn");
			val9.transform.localPosition = new Vector3(-3.136f, 1.338f, 13.661f);
			GameObject val10 = ComponentExt.AddChildGameObject((Component)(object)val3.transform, "spawn (2)");
			val10.transform.localPosition = new Vector3(-1.542f, 1.135f, 13.099f);
			GameObject val11 = ComponentExt.AddChildGameObject((Component)(object)val3.transform, "spawn (3)");
			val11.transform.localPosition = new Vector3(1.284f, 1.135f, 13.099f);
			GameObject val12 = ComponentExt.AddChildGameObject((Component)(object)val3.transform, "spawn (4)");
			val12.transform.localPosition = new Vector3(2.89f, 1.405f, 12.08f);
			val.m_spawnPoints = new Il2CppReferenceArray<Transform>((Transform[])(object)new Transform[4] { val9.transform, val10.transform, val11.transform, val12.transform });
			GameObject val13 = new GameObject("Gate");
			val13.transform.parent = val3.transform;
			val13.transform.localPosition = new Vector3(0f, 0f, 32f);
			val13.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
			GameObject obj = ComponentExt.AddChildGameObject((Component)(object)val13.transform, "plug");
			GameObject val14 = ComponentExt.AddChildGameObject((Component)(object)obj.transform, "crossing");
			ComponentExt.AddChildGameObject((Component)(object)obj.transform, "behind");
			GameObject val15 = ComponentExt.AddChildGameObject((Component)(object)val14.transform, "FreeNode 1");
			GameObject val16 = ComponentExt.AddChildGameObject((Component)(object)val14.transform, "FreeNode 2");
			GameObject val17 = ComponentExt.AddChildGameObject((Component)(object)val14.transform, "FreeNode 3");
			GameObject val18 = ComponentExt.AddChildGameObject((Component)(object)val14.transform, "FreeNode 4");
			GameObject val19 = ComponentExt.AddChildGameObject((Component)(object)val14.transform, "FreeNode 5");
			GameObject obj2 = ComponentExt.AddChildGameObject((Component)(object)val14.transform, "FreeNode 6");
			val15.transform.localPosition = new Vector3(-1.528f, 1.16f, 32f);
			val16.transform.localPosition = new Vector3(-0.905f, 0.168f, 32f);
			val17.transform.localPosition = new Vector3(-0.185f, 0.168f, 32f);
			val18.transform.localPosition = new Vector3(0.487f, 0.168f, 32f);
			val19.transform.localPosition = new Vector3(1.242f, 0.168f, 32f);
			obj2.transform.localPosition = new Vector3(1.974f, 0.168f, 32f);
			AIG_FreeNode val20 = val15.AddComponent<AIG_FreeNode>();
			AIG_FreeNode val21 = val16.AddComponent<AIG_FreeNode>();
			AIG_FreeNode val22 = val17.AddComponent<AIG_FreeNode>();
			AIG_FreeNode val23 = val18.AddComponent<AIG_FreeNode>();
			AIG_FreeNode val24 = val19.AddComponent<AIG_FreeNode>();
			AIG_FreeNode val25 = obj2.AddComponent<AIG_FreeNode>();
			GameObject obj3 = ComponentExt.AddChildGameObject((Component)(object)val14.transform, "PortalHelper");
			obj3.transform.localPosition = new Vector3(0f, 0f, 32f);
			obj3.transform.localScale = new Vector3(16f, 8f, 1f);
			obj3.AddComponent<C_PortalHelper>();
			LG_PlugCustom val26 = val13.AddComponent<LG_PlugCustom>();
			val13.AddComponent<AIG_PlugSocket>();
			AIG_DoorInsert val27 = val13.AddComponent<AIG_DoorInsert>();
			Il2CppReferenceArray<AIG_FreeNode> nodes = new Il2CppReferenceArray<AIG_FreeNode>((AIG_FreeNode[])(object)new AIG_FreeNode[6] { val20, val21, val22, val23, val24, val25 });
			val27.m_nodes = nodes;
			((LG_ZoneExpander)val26).m_subComplex = subcomplex;
			((LG_ZoneExpander)val26).m_linksFrom = val6;
			GameObject val28 = new GameObject("Gate X");
			val28.transform.parent = val3.transform;
			val28.transform.localPosition = new Vector3(0f, 0f, 32f);
			LG_Plug val29 = val28.AddComponent<LG_Plug>();
			((LG_ZoneExpander)val29).m_subComplex = subcomplex;
			GameObject val30 = new GameObject("Gate 2");
			val30.transform.parent = val3.transform;
			val30.transform.localPosition = new Vector3(-32f, 0f, 0f);
			val30.transform.localEulerAngles = new Vector3(0f, 270.0002f, 0f);
			LG_Plug val31 = val30.AddComponent<LG_Plug>();
			((LG_ZoneExpander)val31).m_subComplex = subcomplex;
			GameObject val32 = new GameObject("Gate 3");
			val32.transform.parent = val3.transform;
			val32.transform.localPosition = new Vector3(32f, 0f, 0f);
			val32.transform.localEulerAngles = new Vector3(0f, 89.9999f, 0f);
			LG_Plug val33 = val32.AddComponent<LG_Plug>();
			((LG_ZoneExpander)val33).m_subComplex = subcomplex;
			GameObject val34 = new GameObject("Gate 4");
			val34.transform.parent = val3.transform;
			val34.transform.localPosition = new Vector3(0f, 0f, -32f);
			val34.transform.localEulerAngles = new Vector3(0f, 180f, 0f);
			LG_Plug val35 = val34.AddComponent<LG_Plug>();
			((LG_Geomorph)val).m_plugs = new List<LG_Plug>();
			((LG_Geomorph)val).m_plugs.Add((LG_Plug)(object)val26);
			((LG_Geomorph)val).m_plugs.Add(val31);
			((LG_Geomorph)val).m_plugs.Add(val33);
			((LG_Geomorph)val).m_plugs.Add(val35);
			((LG_Geomorph)val).m_plugs.Add(val29);
			val6.m_groupSource = val5;
			val6.m_geomorph = (LG_Geomorph)(object)val;
			GameObject val36 = new GameObject("EnvProps");
			val36.transform.parent = val3.transform;
			val36.transform.localPosition = new Vector3(0f, 0f, 0f);
			MarkerGroupDataBlock block = GameDataBlockBase<MarkerGroupDataBlock>.GetBlock("Tech_DataCenter");
			GameObject val37 = new GameObject("Markers");
			val37.transform.parent = val3.transform;
			GameObject val38 = new GameObject("Fallback 1");
			val38.transform.parent = val37.transform;
			val38.transform.localPosition = new Vector3(0f, 0f, 22f);
			val38.AddComponent<TechDataCenterMarkerProducer>().m_markerDataBlockID = 63u;
			for (int i = -31; i < 32; i += 2)
			{
				for (int j = -31; j < 32; j += 2)
				{
					if ((i >= -24 || j <= -8 || j >= 8) && (i <= 24 || j <= -8 || j >= 8) && (j >= -24 || i <= -8 || i >= 8) && (j <= 24 || i <= -8 || i >= 8))
					{
						GameObject obj4 = GameObject.CreatePrimitive((PrimitiveType)5);
						((Object)obj4.gameObject).name = "hirnu_floor";
						obj4.transform.parent = val36.transform;
						obj4.transform.localPosition = new Vector3((float)i, -0.05f, (float)j);
						obj4.transform.localEulerAngles = new Vector3(90f, 0f, 0f);
						obj4.transform.localScale = new Vector3(2f, 2f, 2f);
					}
				}
			}
			for (int k = -31; k < 32; k += 2)
			{
				for (int l = -31; l < 32; l += 2)
				{
					if (k <= -16 || k >= 16 || l <= -16 || l >= 16)
					{
						GameObject obj5 = GameObject.CreatePrimitive((PrimitiveType)5);
						((Object)obj5.gameObject).name = "hirnu_wall";
						obj5.transform.parent = val36.transform;
						obj5.transform.localPosition = new Vector3((float)k, 8f, (float)l);
						obj5.transform.localEulerAngles = new Vector3(270f, 0f, 0f);
						obj5.transform.localScale = new Vector3(2f, 2f, 2f);
					}
				}
			}
			GameObject obj6 = GameObject.CreatePrimitive((PrimitiveType)5);
			GameObject val39 = GameObject.CreatePrimitive((PrimitiveType)5);
			((Object)obj6.gameObject).name = "hirnu_wall";
			obj6.transform.parent = val14.transform;
			obj6.transform.localPosition = new Vector3(-8f, 4f, 32f);
			obj6.transform.localScale = new Vector3(1f, 8f, 1f);
			obj6.transform.localEulerAngles = new Vector3(0f, 270f, 0f);
			((Object)val39.gameObject).name = "hirnu_wall";
			val39.transform.parent = val14.transform;
			val39.transform.localPosition = new Vector3(8f, 4f, 32f);
			val39.transform.localScale = new Vector3(1f, 8f, 1f);
			val39.transform.localEulerAngles = new Vector3(0f, 90f, 0f);
			GameObject val40 = new GameObject();
			GameObject val41 = new GameObject();
			GameObject val42 = new GameObject();
			GameObject val43 = new GameObject();
			((Object)val40.gameObject).name = "hirnu_wall_sw1";
			val40.transform.SetParent(val36.transform);
			val40.transform.localPosition = new Vector3(-20f, 4f, -20f);
			val40.transform.localEulerAngles = new Vector3(0f, 225f, 0f);
			for (float num = -14.97f; num < 17f; num += 3.394f)
			{
				GameObject obj7 = GameObject.CreatePrimitive((PrimitiveType)5);
				((Object)obj7.transform).name = "hirnu_wall";
				obj7.transform.parent = val40.transform;
				obj7.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
				obj7.transform.localScale = new Vector3(3.394f, 8.2f, 3.394f);
				obj7.transform.localPosition = new Vector3(num, 0f, 0f);
			}
			GameObject val44 = new GameObject("Sign 1");
			val44.transform.parent = val37.transform;
			val44.transform.localPosition = new Vector3(-20f, 5f, -20f);
			val44.transform.localEulerAngles = new Vector3(0f, 45f, 0f);
			TechDataCenterMarkerProducer obj8 = val44.AddComponent<TechDataCenterMarkerProducer>();
			obj8.m_markerDataBlockID = 9u;
			((LG_MarkerProducer)obj8).m_allowFunction = true;
			((Object)val41).name = "hirnu_wall_nw1";
			val41.transform.SetParent(val36.transform);
			val41.transform.localPosition = new Vector3(-20f, 4f, 20f);
			val41.transform.localEulerAngles = new Vector3(0f, 315f, 0f);
			for (float num2 = -14.97f; num2 < 17f; num2 += 3.394f)
			{
				GameObject obj9 = GameObject.CreatePrimitive((PrimitiveType)5);
				((Object)obj9.gameObject).name = "hirnu_wall";
				obj9.transform.parent = val41.transform;
				obj9.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
				obj9.transform.localScale = new Vector3(3.394f, 8.2f, 3.394f);
				obj9.transform.localPosition = new Vector3(num2, 0f, 0f);
			}
			GameObject val45 = new GameObject("Sign 2");
			val45.transform.parent = val37.transform;
			val45.transform.localPosition = new Vector3(-20f, 5f, 20f);
			val45.transform.localEulerAngles = new Vector3(0f, 135f, 0f);
			TechDataCenterMarkerProducer obj10 = val45.AddComponent<TechDataCenterMarkerProducer>();
			obj10.m_markerDataBlockID = 9u;
			((LG_MarkerProducer)obj10).m_allowFunction = true;
			((Object)val42).name = "hirnu_wall_ne1";
			val42.transform.SetParent(val36.transform);
			val42.transform.localPosition = new Vector3(20f, 4f, 20f);
			val42.transform.localEulerAngles = new Vector3(0f, 45f, 0f);
			for (float num3 = -14.97f; num3 < 17f; num3 += 3.394f)
			{
				GameObject obj11 = GameObject.CreatePrimitive((PrimitiveType)5);
				((Object)obj11.gameObject).name = "hirnu_wall";
				obj11.transform.parent = val42.transform;
				obj11.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
				obj11.transform.localScale = new Vector3(3.394f, 8.2f, 3.394f);
				obj11.transform.localPosition = new Vector3(num3, 0f, 0f);
			}
			GameObject val46 = new GameObject("Sign 3");
			val46.transform.parent = val37.transform;
			val46.transform.localPosition = new Vector3(20f, 5f, 20f);
			val46.transform.localEulerAngles = new Vector3(0f, 225f, 0f);
			TechDataCenterMarkerProducer obj12 = val46.AddComponent<TechDataCenterMarkerProducer>();
			obj12.m_markerDataBlockID = 9u;
			((LG_MarkerProducer)obj12).m_allowFunction = true;
			((Object)val43).name = "hirnu_wall_se1";
			val43.transform.SetParent(val36.t