Decompiled source of Konoha v0.2.0

plugins/Konoha/Konoha.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using EntityStates;
using HG.BlendableTypes;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using On.RoR2;
using R2API;
using RoR2;
using RoR2.CameraModes;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.Navigation;
using RoR2.Networking;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.LowLevel;
using UnityEngine.Networking;
using UnityEngine.PlayerLoop;
using UnityEngine.Rendering;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Konoha")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+bac9e64dbb68db287580177aaea9415797ee8a0e")]
[assembly: AssemblyProduct("Konoha")]
[assembly: AssemblyTitle("Konoha")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace KonohaMod
{
	public static class Recon
	{
		public sealed class MB
		{
			public readonly List<Vector3> v = new List<Vector3>();

			public readonly List<Vector2> uv = new List<Vector2>();

			public readonly List<int> t = new List<int>();

			public void Quad(Vector3 a, Vector3 b, Vector3 c, Vector3 d, Vector4 r, float su = 1f, float sv = 1f)
			{
				//IL_0012: 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)
				//IL_002a: 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_003d: 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_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: 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_0098: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
				int count = v.Count;
				v.Add(a);
				v.Add(b);
				v.Add(c);
				v.Add(d);
				float x = r.x;
				float num = r.x + (r.z - r.x) * su;
				float num2 = 1f - r.w;
				float num3 = 1f - r.w + (r.w - r.y) * sv;
				uv.Add(new Vector2(x, num2));
				uv.Add(new Vector2(num, num2));
				uv.Add(new Vector2(num, num3));
				uv.Add(new Vector2(x, num3));
				t.Add(count);
				t.Add(count + 3);
				t.Add(count + 2);
				t.Add(count);
				t.Add(count + 2);
				t.Add(count + 1);
			}

			public void QuadTiled(Vector3 a, Vector3 b, Vector3 c, Vector3 d, float tile)
			{
				//IL_0012: 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)
				//IL_002a: 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_003d: 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_0048: 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_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				int count = v.Count;
				v.Add(a);
				v.Add(b);
				v.Add(c);
				v.Add(d);
				float num = Vector3.Distance(a, b) / tile;
				float num2 = Vector3.Distance(a, d) / tile;
				float num3 = (a.x + a.z) / tile;
				uv.Add(new Vector2(num3, a.y / tile));
				uv.Add(new Vector2(num3 + num, a.y / tile));
				uv.Add(new Vector2(num3 + num, a.y / tile + num2));
				uv.Add(new Vector2(num3, a.y / tile + num2));
				t.Add(count);
				t.Add(count + 3);
				t.Add(count + 2);
				t.Add(count);
				t.Add(count + 2);
				t.Add(count + 1);
			}

			public void Tri(Vector3 a, Vector3 b, Vector3 c, Vector2 ua, Vector2 ub, Vector2 uc)
			{
				//IL_0012: 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)
				//IL_002a: 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_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				int count = v.Count;
				v.Add(a);
				v.Add(b);
				v.Add(c);
				uv.Add(ua);
				uv.Add(ub);
				uv.Add(uc);
				t.Add(count);
				t.Add(count + 2);
				t.Add(count + 1);
			}
		}

		public sealed class Cut
		{
			public string group;

			public string why;

			public float x0;

			public float z0;

			public float x1;

			public float z1;

			public float minSpan;

			public float maxY = 1E+09f;
		}

		public static readonly Vector2[] WallPoly = (Vector2[])(object)new Vector2[29]
		{
			new Vector2(-345f, 380f),
			new Vector2(-350f, 295f),
			new Vector2(-369f, 204f),
			new Vector2(-376f, 115f),
			new Vector2(-376f, 33f),
			new Vector2(-375f, -35f),
			new Vector2(-357f, -102f),
			new Vector2(-342f, -164f),
			new Vector2(-309f, -215f),
			new Vector2(-280f, -266f),
			new Vector2(-203f, -342f),
			new Vector2(-108f, -392f),
			new Vector2(-95f, -404f),
			new Vector2(-4f, -420f),
			new Vector2(40f, -427f),
			new Vector2(60f, -423f),
			new Vector2(131f, -396f),
			new Vector2(159f, -370f),
			new Vector2(216f, -331f),
			new Vector2(271f, -259f),
			new Vector2(289f, -243f),
			new Vector2(323f, -158f),
			new Vector2(335f, -101f),
			new Vector2(347f, -41f),
			new Vector2(346f, 23f),
			new Vector2(341f, 93f),
			new Vector2(328f, 171f),
			new Vector2(309f, 263f),
			new Vector2(295f, 380f)
		};

		public static readonly Vector3[] TrailNorth = (Vector3[])(object)new Vector3[8]
		{
			V(62f, -421f),
			V(64f, -470f),
			V(62f, -510f),
			V(108f, -546f),
			V(158f, -574f),
			V(200f, -578f),
			V(240f, -569f),
			V(272f, -550f)
		};

		public static readonly Vector3[] TrailSouth = (Vector3[])(object)new Vector3[7]
		{
			V(27.5f, -575f),
			V(40f, -552f),
			V(92f, -574f),
			V(142f, -602f),
			V(130f, -630f),
			V(128f, -665f),
			V(138f, -696f)
		};

		public static readonly Vector3[] TrainingFence = (Vector3[])(object)new Vector3[13]
		{
			V(270f, -552f),
			V(276f, -564f),
			V(282f, -594f),
			V(288f, -618f),
			V(294f, -642f),
			V(294f, -648f),
			V(282f, -654f),
			V(264f, -666f),
			V(240f, -672f),
			V(222f, -672f),
			V(204f, -678f),
			V(174f, -690f),
			V(138f, -696f)
		};

		private static Vector2[] southPoly;

		private static Shader hg;

		private static readonly Dictionary<string, Texture2D> texCache = new Dictionary<string, Texture2D>();

		private static readonly Dictionary<string, Material> matCache = new Dictionary<string, Material>();

		public static readonly Vector4 RectPlanks = new Vector4(0.525f, 0.005f, 0.73f, 0.19f);

		public static readonly Vector4 RectShutter = new Vector4(0.41f, 0.215f, 0.585f, 0.395f);

		public static readonly Vector4 RectTiles = new Vector4(0.76f, 0.13f, 0.99f, 0.42f);

		public static readonly Vector4 Full = new Vector4(0f, 0f, 1f, 1f);

		private static readonly Dictionary<Material, MB> builders = new Dictionary<Material, MB>();

		private static MB collide = new MB();

		private static Material mPlanks;

		private static Material mShutter;

		private static Material mTiles;

		private static Material mPlaster;

		private static Material mStone;

		private static Material mDarkWood;

		private static Material mCrest;

		private static Material mBanner;

		private static Material mGrass;

		private static Material mDirt;

		private static Material mIntelPlaster;

		private static Material mIntelStone;

		private static Material mPlaque;

		private static Material mPaving;

		private static Material mDirt2;

		private static Material mTree;

		private static Material mForest;

		private static Material mBush;

		public static readonly Vector3 UchihaMin = new Vector3(210f, 0f, 34f);

		public static readonly Vector3 UchihaMax = new Vector3(306f, 0f, 104f);

		public static readonly float UchihaStreetZ = 69f;

		public static readonly float UchihaSouthGateX = 262f;

		public static readonly List<Cut> CollisionCuts = new List<Cut>
		{
			new Cut
			{
				group = "sa00z",
				x0 = 160f,
				z0 = 25f,
				x1 = 250f,
				z1 = 112f,
				minSpan = 30f,
				why = "Storm invisible tall walls inside the north-east lot (Uchiha District)"
			},
			new Cut
			{
				group = "sa00z",
				x0 = 182f,
				z0 = 63.5f,
				x1 = 194f,
				z1 = 74.5f,
				minSpan = 0f,
				why = "retaining wall opening for the Uchiha stairs"
			},
			new Cut
			{
				group = "sa00z",
				x0 = 13f,
				z0 = -415f,
				x1 = 47f,
				z1 = -410f,
				minSpan = 0f,
				maxY = 26f,
				why = "one-sided closed-gate plane in the Main Gate opening"
			}
		};

		public static readonly List<Cut> RenderCuts = new List<Cut>
		{
			new Cut
			{
				group = "ki",
				x0 = 182f,
				z0 = 58f,
				x1 = 214f,
				z1 = 80f,
				why = "tree cards on the Uchiha stairs and gate road"
			},
			new Cut
			{
				group = "ki",
				x0 = 186f,
				z0 = 28f,
				x1 = 320f,
				z1 = 109f,
				why = "Storm tree cards inside the Uchiha lot"
			},
			new Cut
			{
				group = "ha",
				x0 = 200f,
				z0 = 28f,
				x1 = 320f,
				z1 = 109f,
				why = "Storm bush cards inside the Uchiha compound"
			},
			new Cut
			{
				group = "sa00zflo007",
				x0 = 185f,
				z0 = 63.5f,
				x1 = 192f,
				z1 = 74.5f,
				why = "retaining-wall rim at the stairs opening"
			},
			new Cut
			{
				group = "sa00zback00",
				x0 = 236f,
				z0 = 40f,
				x1 = 330f,
				z1 = 128f,
				why = "Storm backdrop canopy over the Uchiha back corner and the Naka Shrine"
			}
		};

		private static HashSet<long> boundaryCuts;

		public static int BoundaryCutCount;

		public static readonly List<Vector3> NavHints = new List<Vector3>();

		public static readonly List<Vector3> NavHintsExact = new List<Vector3>();

		public static readonly Vector3[] ForestLine = (Vector3[])(object)new Vector3[8]
		{
			new Vector3(-30f, 0f, -434f),
			new Vector3(-34f, 0f, -480f),
			new Vector3(-32f, 0f, -530f),
			new Vector3(-12f, 0f, -560f),
			new Vector3(10f, 0f, -571f),
			new Vector3(27.5f, 0f, -575f),
			new Vector3(52f, 0f, -581f),
			new Vector3(78f, 0f, -590f)
		};

		public static readonly Vector3 IntelGate = new Vector3(74f, 0f, -34f);

		public static readonly Vector3[] RoadPts = (Vector3[])(object)new Vector3[5]
		{
			new Vector3(27.5f, 0f, -428f),
			new Vector3(27.5f, 0f, -500f),
			new Vector3(52f, 0f, -532f),
			new Vector3(100f, 0f, -560f),
			new Vector3(150f, 0f, -588f)
		};

		public const string SkirtName = "TrainingSkirt_reconstructed";

		private static int World => LayerIndex.world.intVal;

		public static Vector3 UchihaGate => new Vector3(UchihaMin.x, 0f, UchihaStreetZ);

		public static Vector3 UchihaCenter => new Vector3(250f, 0f, UchihaStreetZ);

		private static Vector3 V(float x, float z)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(x, 0f, z);
		}

		private static Vector2[] SouthPoly()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (southPoly != null)
			{
				return southPoly;
			}
			List<Vector2> list = new List<Vector2>();
			list.Add(new Vector2(-30f, -420f));
			list.AddRange(((IEnumerable<Vector3>)TrailNorth).Select((Func<Vector3, Vector2>)((Vector3 p) => new Vector2(p.x, p.z))));
			list.AddRange(((IEnumerable<Vector3>)TrainingFence).Select((Func<Vector3, Vector2>)((Vector3 p) => new Vector2(p.x, p.z))));
			list.AddRange(TrailSouth.Reverse().Skip(1).Select((Func<Vector3, Vector2>)((Vector3 p) => new Vector2(p.x, p.z))));
			list.AddRange(ForestLine.Where((Vector3 p) => p.z >= -575f && p.x <= 27.5f).Reverse().Select((Func<Vector3, Vector2>)((Vector3 p) => new Vector2(p.x, p.z))));
			return southPoly = list.ToArray();
		}

		private static bool InPoly(Vector2[] poly, float x, float z)
		{
			bool flag = false;
			int num = 0;
			int num2 = poly.Length - 1;
			while (num < poly.Length)
			{
				if (poly[num].y > z != poly[num2].y > z && x < (poly[num2].x - poly[num].x) * (z - poly[num].y) / (poly[num2].y - poly[num].y) + poly[num].x)
				{
					flag = !flag;
				}
				num2 = num++;
			}
			return flag;
		}

		public static bool Playable(float x, float z)
		{
			if (!InPoly(WallPoly, x, z))
			{
				return InPoly(SouthPoly(), x, z);
			}
			return true;
		}

		public static bool InsideWall(float x, float z)
		{
			return InPoly(WallPoly, x, z);
		}

		private static float GroundLow(float x, float z, float fromY = 40f)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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)
			float num = float.MaxValue;
			RaycastHit[] array = Physics.RaycastAll(new Vector3(x, fromY, z), Vector3.down, fromY + 20f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val = array[i];
				if (((RaycastHit)(ref val)).normal.y > 0.5f)
				{
					num = Mathf.Min(num, ((RaycastHit)(ref val)).point.y);
				}
			}
			if (num != float.MaxValue)
			{
				return num;
			}
			return 0f;
		}

		private static int ForestEdge(Transform t, Vector3[] line, bool berm, string name, bool collide = true)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: 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)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0980: Unknown result type (might be due to invalid IL or missing references)
			//IL_0987: Expected O, but got Unknown
			//IL_09a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b9: Expected O, but got Unknown
			//IL_012d: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: 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_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: 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_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: 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_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0461: Unknown result type (might be due to invalid IL or missing references)
			//IL_0463: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_047f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0481: 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_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: 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_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: 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_048c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0548: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_054e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0553: Unknown result type (might be due to invalid IL or missing references)
			//IL_0558: Unknown result type (might be due to invalid IL or missing references)
			//IL_055c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0561: Unknown result type (might be due to invalid IL or missing references)
			//IL_0566: Unknown result type (might be due to invalid IL or missing references)
			//IL_0568: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0573: Unknown result type (might be due to invalid IL or missing references)
			//IL_0593: Unknown result type (might be due to invalid IL or missing references)
			//IL_061c: Unknown result type (might be due to invalid IL or missing references)
			//IL_061e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0622: Unknown result type (might be due to invalid IL or missing references)
			//IL_0627: 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_0630: Unknown result type (might be due to invalid IL or missing references)
			//IL_0635: Unknown result type (might be due to invalid IL or missing references)
			//IL_063a: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0647: Unknown result type (might be due to invalid IL or missing references)
			//IL_0667: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0703: 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_070a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0715: Unknown result type (might be due to invalid IL or missing references)
			//IL_0735: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_07be: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07da: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_081e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0820: Unknown result type (might be due to invalid IL or missing references)
			//IL_0825: Unknown result type (might be due to invalid IL or missing references)
			//IL_0829: Unknown result type (might be due to invalid IL or missing references)
			//IL_0893: 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_0899: Unknown result type (might be due to invalid IL or missing references)
			//IL_089e: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0900: Unknown result type (might be due to invalid IL or missing references)
			//IL_0904: Unknown result type (might be due to invalid IL or missing references)
			Random rnd = new Random(line.Length * 31 + (int)line[0].x);
			int num = 0;
			MB mB = new MB();
			float bermW = 10f;
			float bermH = (berm ? 2.5f : 0f);
			Vector3 val8 = default(Vector3);
			Vector3 val9 = default(Vector3);
			for (int i = 0; i < line.Length - 1; i++)
			{
				Vector3 val = line[i];
				Vector3 val2 = line[i + 1];
				Vector3 val3 = val2 - val;
				val3.y = 0f;
				float magnitude = ((Vector3)(ref val3)).magnitude;
				if (magnitude < 0.5f)
				{
					continue;
				}
				val3 /= magnitude;
				Vector3 val4 = Vector3.Cross(val3, Vector3.up);
				Vector3 val5 = (val + val2) / 2f;
				if (Playable((val5 + val4 * 12f).x, (val5 + val4 * 12f).z) && !Playable((val5 - val4 * 12f).x, (val5 - val4 * 12f).z))
				{
					val4 = -val4;
				}
				int num2 = Mathf.Max(1, Mathf.CeilToInt(magnitude / 4f));
				Quaternion val14;
				for (int j = 0; j < num2; j++)
				{
					Vector3 val6 = val + val3 * (magnitude * (float)j / (float)num2);
					Vector3 val7 = val + val3 * (magnitude * (float)(j + 1) / (float)num2);
					float num3 = GroundLow(val6.x, val6.z);
					float num4 = GroundLow(val7.x, val7.z);
					if (berm && !Water.Over(val6.x, val6.z) && !Water.Over(val7.x, val7.z))
					{
						((Vector3)(ref val8))..ctor(val6.x, num3 + 0.02f, val6.z);
						((Vector3)(ref val9))..ctor(val7.x, num4 + 0.02f, val7.z);
						Vector3 val10 = val8 + val4 * bermW + Vector3.up * bermH;
						Vector3 val11 = val9 + val4 * bermW + Vector3.up * bermH;
						int count = mB.v.Count;
						mB.v.Add(val8);
						mB.v.Add(val9);
						mB.v.Add(val11);
						mB.v.Add(val10);
						Vector3[] array = (Vector3[])(object)new Vector3[4] { val8, val9, val11, val10 };
						foreach (Vector3 val12 in array)
						{
							mB.uv.Add(new Vector2(val12.x / 9f, val12.z / 9f));
						}
						mB.t.Add(count);
						mB.t.Add(count + 1);
						mB.t.Add(count + 2);
						mB.t.Add(count);
						mB.t.Add(count + 2);
						mB.t.Add(count + 3);
					}
					if (collide)
					{
						Vector3 val13 = (val6 + val7) / 2f + val4 * 3f;
						string name2 = name + "Edge";
						Vector3 center = new Vector3(val13.x, (num3 + num4) / 2f + 7f, val13.z);
						Vector3 size = new Vector3(1.2f, 16f, magnitude / (float)num2 + 0.6f);
						val14 = Quaternion.LookRotation(val3);
						BoxCollider(t, name2, center, size, ((Quaternion)(ref val14)).eulerAngles.y);
					}
				}
				for (float num5 = 0f; num5 < magnitude; num5 += 3.6f * R(0.6f, 1.4f))
				{
					float num6 = R(0.5f, 2f);
					float num7 = R(0.7f, 1.3f);
					Vector3 val15 = val + val3 * num5 + val4 * num6;
					if (Dry(val15))
					{
						val15.y = BY(val15, num6) - 0.15f;
						TreeCard(B(mBush), val15, R(4f, 6f) * num7, R(2.6f, 3.6f) * num7, R(0f, 180f), 2);
						num++;
					}
				}
				for (float num8 = 1.8f; num8 < magnitude; num8 += 4.2f * R(0.6f, 1.4f))
				{
					float num9 = R(2.5f, 3.5f);
					float num10 = R(0.7f, 1.3f);
					Vector3 val16 = val + val3 * num8 + val4 * num9;
					if (Dry(val16))
					{
						val16.y = BY(val16, num9) - 0.15f;
						TreeCard(B(mBush), val16, R(4f, 6f) * num10, R(2.8f, 3.8f) * num10, R(0f, 180f), 2);
						num++;
					}
				}
				for (float num11 = 0f; num11 < magnitude; num11 += 5f * R(0.75f, 1.25f))
				{
					float num12 = R(3f, 5f);
					Vector3 val17 = val + val3 * num11 + val4 * num12;
					if (Dry(val17))
					{
						val17.y = BY(val17, num12) - 0.6f;
						TreeCard(B(mTree), val17, R(8f, 11f), R(10f, 14f), R(0f, 180f), 3);
						num++;
					}
				}
				for (float num13 = 2.5f; num13 < magnitude; num13 += 6f * R(0.75f, 1.25f))
				{
					float num14 = R(6f, 8f);
					Vector3 val18 = val + val3 * num13 + val4 * num14;
					if (Dry(val18))
					{
						val18.y = BY(val18, num14) - 0.8f;
						TreeCard(B(mTree), val18, R(9f, 12f), R(11f, 15f), R(0f, 180f), 3);
						num++;
					}
				}
				for (float num15 = 0f; num15 < magnitude; num15 += 8f * R(0.8f, 1.2f))
				{
					float num16 = R(9f, 12f);
					Vector3 val19 = val + val3 * num15 + val4 * num16;
					val19.y = BY(val19, num16) - 3.5f;
					MB m = B(mForest);
					Vector3 p = val19;
					float w = R(18f, 24f);
					float h = R(17f, 21f);
					val14 = Quaternion.LookRotation(val3);
					TreeCard(m, p, w, h, ((Quaternion)(ref val14)).eulerAngles.y + R(-15f, 15f), 2);
					num++;
				}
				for (float num17 = 0f; num17 < magnitude; num17 += 10f * R(0.8f, 1.2f))
				{
					float num18 = R(15f, 21f);
					Vector3 val20 = val + val3 * num17 + val4 * num18;
					val20.y = BY(val20, num18) - 3.5f;
					MB m2 = B(mForest);
					Vector3 p2 = val20;
					float w2 = R(20f, 26f);
					float h2 = R(19f, 23f);
					val14 = Quaternion.LookRotation(val3);
					TreeCard(m2, p2, w2, h2, ((Quaternion)(ref val14)).eulerAngles.y + R(-20f, 20f), 2);
					num++;
				}
			}
			if (berm && mB.v.Count > 0)
			{
				GameObject val21 = new GameObject(name + "Berm_reconstructed");
				val21.layer = World;
				val21.transform.SetParent(t, false);
				Mesh val22 = new Mesh
				{
					name = name + "_berm"
				};
				val22.SetVertices(mB.v);
				val22.SetUVs(0, mB.uv);
				val22.SetTriangles(mB.t, 0);
				val22.RecalculateNormals();
				val22.RecalculateBounds();
				if (val22.normals.Length != 0 && val22.normals[0].y < 0f)
				{
					for (int l = 0; l < mB.t.Count; l += 3)
					{
						int value = mB.t[l + 1];
						mB.t[l + 1] = mB.t[l + 2];
						mB.t[l + 2] = value;
					}
					val22.SetTriangles(mB.t, 0);
					val22.RecalculateNormals();
				}
				val21.AddComponent<MeshFilter>().sharedMesh = val22;
				((Renderer)val21.AddComponent<MeshRenderer>()).sharedMaterial = mGrass;
				val21.AddComponent<MeshCollider>().sharedMesh = val22;
				StageBuilder.Tris += mB.t.Count / 3;
				StageBuilder.Draws++;
			}
			return num;
			float BY(Vector3 q, float d)
			{
				//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)
				return GroundLow(q.x, q.z) + bermH * Mathf.Clamp01(d / bermW);
			}
			static bool Dry(Vector3 q)
			{
				//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)
				return !Water.Over(q.x, q.z);
			}
			float R(float a, float b)
			{
				return a + (float)rnd.NextDouble() * (b - a);
			}
		}

		private static int InvisibleWall(Transform t, Vector3[] line, float off, string name)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0022: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_005c: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			for (int i = 0; i < line.Length - 1; i++)
			{
				Vector3 val = line[i];
				Vector3 val2 = line[i + 1];
				Vector3 val3 = val2 - val;
				val3.y = 0f;
				float magnitude = ((Vector3)(ref val3)).magnitude;
				if (!(magnitude < 0.5f))
				{
					val3 /= magnitude;
					Vector3 val4 = Vector3.Cross(val3, Vector3.up);
					Vector3 val5 = (val + val2) / 2f;
					if (Playable((val5 + val4 * 6f).x, (val5 + val4 * 6f).z) && !Playable((val5 - val4 * 6f).x, (val5 - val4 * 6f).z))
					{
						val4 = -val4;
					}
					Vector3 val6 = val5 + val4 * off;
					float num2 = GroundLow(val6.x, val6.z);
					Vector3 center = new Vector3(val6.x, num2 + 8f, val6.z);
					Vector3 size = new Vector3(1f, 20f, magnitude + 1.2f);
					Quaternion val7 = Quaternion.LookRotation(val3);
					BoxCollider(t, name, center, size, ((Quaternion)(ref val7)).eulerAngles.y);
					num++;
				}
			}
			return num;
		}

		private static int WallRingForest(Transform t)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_0047: 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_0074: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: 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_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: 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_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			Random rnd = new Random(1103);
			int num = 0;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0f, -40f);
			Vector3 val4 = default(Vector3);
			Vector3 val5 = default(Vector3);
			for (int i = 0; i < WallPoly.Length - 1; i++)
			{
				Vector2 val2 = WallPoly[i];
				Vector2 val3 = WallPoly[i + 1];
				if (val2.y > 330f && val3.y > 330f)
				{
					continue;
				}
				((Vector3)(ref val4))..ctor(val2.x, 0f, val2.y);
				((Vector3)(ref val5))..ctor(val3.x, 0f, val3.y);
				Vector3 val6 = val5 - val4;
				float magnitude = ((Vector3)(ref val6)).magnitude;
				val6 /= magnitude;
				Vector3 val7 = Vector3.Cross(val6, Vector3.up);
				Vector3 val8 = (val4 + val5) / 2f;
				if (Vector3.Dot(val7, new Vector3(val8.x - val.x, 0f, val8.z - val.y)) < 0f)
				{
					val7 = -val7;
				}
				var array = new[]
				{
					new
					{
						d0 = 9f,
						d1 = 13f,
						step = 7f,
						forest = false
					},
					new
					{
						d0 = 16f,
						d1 = 22f,
						step = 9f,
						forest = true
					},
					new
					{
						d0 = 26f,
						d1 = 34f,
						step = 10f,
						forest = true
					},
					new
					{
						d0 = 38f,
						d1 = 48f,
						step = 12f,
						forest = true
					}
				};
				foreach (var anon in array)
				{
					for (float num2 = R(0f, anon.step); num2 < magnitude; num2 += anon.step * R(0.7f, 1.3f))
					{
						float num3 = R(anon.d0, anon.d1);
						Vector3 val9 = val4 + val6 * num2 + val7 * num3;
						if (!InPoly(SouthPoly(), val9.x, val9.z) && !Water.Over(val9.x, val9.z))
						{
							float num4 = GroundLow(val9.x, val9.z);
							val9.y = num4 - (anon.forest ? 3f : 0.6f);
							if (anon.forest)
							{
								MB m = B(mForest);
								Vector3 p = val9;
								float w = R(20f, 27f);
								float h = R(19f, 24f);
								Quaternion val10 = Quaternion.LookRotation(val6);
								TreeCard(m, p, w, h, ((Quaternion)(ref val10)).eulerAngles.y + R(-25f, 25f), 2);
							}
							else
							{
								TreeCard(B(mTree), val9, R(9f, 12f), R(11f, 15f), R(0f, 180f), 3);
							}
							num++;
						}
					}
				}
			}
			return num;
			float R(float a, float b)
			{
				return a + (float)rnd.NextDouble() * (b - a);
			}
		}

		private static int RockBack(Transform t)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Expected O, but got Unknown
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Expected O, but got Unknown
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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_0601: Unknown result type (might be due to invalid IL or missing references)
			//IL_062b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0592: Unknown result type (might be due to invalid IL or missing references)
			//IL_0597: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a8: 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)
			Random rnd = new Random(4242);
			List<Vector3> list = new List<Vector3>();
			RaycastHit val = default(RaycastHit);
			for (float num = -300f; num <= 380f; num += 8f)
			{
				float num2 = -1f;
				List<Vector3> list2 = new List<Vector3>();
				for (float num3 = 110f; num3 <= 240f; num3 += 1.5f)
				{
					if (Physics.Raycast(new Vector3(num, 400f, num3), Vector3.down, ref val, 500f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1))
					{
						list2.Add(((RaycastHit)(ref val)).point);
						num2 = Mathf.Max(num2, ((RaycastHit)(ref val)).point.y);
					}
				}
				if (num2 < 60f)
				{
					continue;
				}
				Vector3 item = Vector3.zero;
				foreach (Vector3 item2 in list2)
				{
					if (item2.y >= num2 - 10f)
					{
						item = item2;
					}
				}
				list.Add(item);
			}
			int num4 = 0;
			int num5 = 0;
			for (int i = 0; i < list.Count - 1; i++)
			{
				Vector3 val2 = list[i];
				Vector3 val3 = list[i + 1];
				Vector3 val4 = (val2 + val3) / 2f;
				Vector3 val5 = val3 - val2;
				val5.y = 0f;
				float magnitude = ((Vector3)(ref val5)).magnitude;
				Vector3 val6 = Vector3.Cross(((Vector3)(ref val5)).normalized, Vector3.up);
				if (val6.z < 0f)
				{
					val6 = -val6;
				}
				Vector3 center = new Vector3(val4.x, 120f, val4.z) + val6 * 2f;
				Vector3 size = new Vector3(1f, 320f, magnitude + 1.5f);
				Quaternion val7 = Quaternion.LookRotation(val5);
				BoxCollider(t, "RockBackWall", center, size, ((Quaternion)(ref val7)).eulerAngles.y);
				num4++;
				for (float num6 = 3f; num6 < magnitude; num6 += 11f * R(0.8f, 1.3f))
				{
					Vector3 p = Vector3.Lerp(val2, val3, num6 / magnitude) + val6 * R(14f, 22f);
					p.y = Mathf.Min(val2.y, val3.y) - 24f;
					TreeCard(B(mForest), p, R(18f, 24f), R(17f, 21f), R(-15f, 15f), 2);
					num5++;
				}
			}
			MB mB = new MB();
			float num7 = -6.5f;
			float num8 = 9f;
			for (float num9 = -1200f; num9 < 1300f; num9 += 250f)
			{
				for (float num10 = 600f; num10 < 1700f; num10 += 250f)
				{
					mB.QuadTiled(new Vector3(num9, num7, num10), new Vector3(num9 + 250f, num7, num10), new Vector3(num9 + 250f, num7, num10 + 250f), new Vector3(num9, num7, num10 + 250f), num8);
				}
			}
			for (int j = 0; j < mB.v.Count; j++)
			{
				mB.uv[j] = new Vector2(mB.v[j].x / num8, mB.v[j].z / num8);
			}
			GameObject val8 = new GameObject("RockBackGround_reconstructed");
			val8.layer = World;
			val8.transform.SetParent(t, false);
			Mesh val9 = new Mesh
			{
				name = "rock_back_ground"
			};
			val9.SetVertices(mB.v);
			val9.SetUVs(0, mB.uv);
			val9.SetTriangles(mB.t, 0);
			val9.RecalculateNormals();
			val9.RecalculateBounds();
			if (val9.normals.Length != 0 && val9.normals[0].y < 0f)
			{
				for (int k = 0; k < mB.t.Count; k += 3)
				{
					int value = mB.t[k + 1];
					mB.t[k + 1] = mB.t[k + 2];
					mB.t[k + 2] = value;
				}
				val9.SetTriangles(mB.t, 0);
				val9.RecalculateNormals();
			}
			val8.AddComponent<MeshFilter>().sharedMesh = val9;
			MeshRenderer obj = val8.AddComponent<MeshRenderer>();
			((Renderer)obj).sharedMaterial = mGrass;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
			RaycastHit val10 = default(RaycastHit);
			Vector3 val11 = default(Vector3);
			for (float num11 = 215f; num11 < 1600f; num11 += ((num11 < 600f) ? 20f : ((num11 < 1000f) ? 30f : 45f)) * R(0.85f, 1.15f))
			{
				float num12 = ((num11 < 600f) ? 18f : ((num11 < 1000f) ? 28f : 40f));
				float num13 = ((num11 < 600f) ? 1f : ((num11 < 1000f) ? 1.4f : 1.9f));
				for (float num14 = -1150f + R(0f, num12); num14 < 1250f; num14 += num12 * R(0.7f, 1.3f))
				{
					if (!(num11 < 330f) || !(num14 > -310f) || !(num14 < 390f) || !Physics.Raycast(new Vector3(num14, 400f, num11), Vector3.down, ref val10, 500f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1) || !(((RaycastHit)(ref val10)).point.y > 30f))
					{
						((Vector3)(ref val11))..ctor(num14, Ground(num14, num11, 40f) - 2.5f, num11 + R(-6f, 6f));
						if (val11.y < num7 - 3f)
						{
							val11.y = num7 - 2.5f;
						}
						TreeCard(B(mForest), val11, R(20f, 27f) * num13, R(19f, 24f) * num13, R(-25f, 25f), 2);
						num5++;
					}
				}
			}
			KonohaPlugin.Log("BOUNDARY rock back: rim points=" + list.Count + " (z " + ((list.Count > 0) ? (list.Min((Vector3 r) => r.z).ToString("0") + ".." + list.Max((Vector3 r) => r.z).ToString("0")) : "-") + ") wall segments=" + num4 + " tree cards=" + num5);
			return num5;
			float R(float a, float b)
			{
				return a + (float)rnd.NextDouble() * (b - a);
			}
		}

		private static int OuterForest(Transform t)
		{
			//IL_0030: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			Random rnd = new Random(9157);
			int num = 0;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0f, -150f);
			float num3;
			for (float num2 = -1350f; num2 < 215f; num2 += num3 * R(0.85f, 1.1f))
			{
				Mathf.Abs(num2 - val.y);
				num3 = 15f;
				float num4 = -1200f + R(0f, 15f);
				while (num4 < 1300f)
				{
					float num5 = Vector2.Distance(new Vector2(num4, num2), val);
					float num6 = ((num5 < 650f) ? 15f : ((num5 < 1000f) ? 22f : 32f));
					float num7 = num4 + R(-0.35f, 0.35f) * num6;
					float num8 = num2 + R(-0.35f, 0.35f) * num6;
					num4 += num6 * R(0.8f, 1.2f);
					num3 = num6;
					if (!NearPlay(num7, num8) && !Water.Over(num7, num8))
					{
						float num9 = ((num7 > -462f && num7 < 418f && num8 > -535f && num8 < 335f) ? GroundLow(num7, num8) : (-6.5f));
						float num10 = num6 / 15f;
						TreeCard(B(mForest), new Vector3(num7, num9 - 2.5f, num8), R(19f, 26f) * num10, R(18f, 23f) * Mathf.Lerp(1f, num10, 0.6f), R(0f, 180f), 2);
						num++;
					}
				}
			}
			KonohaPlugin.Log("BOUNDARY outer forest cards=" + num);
			return num;
			static bool NearPlay(float x, float z)
			{
				if (!Playable(x, z) && !Playable(x + 10f, z) && !Playable(x - 10f, z) && !Playable(x, z + 10f))
				{
					return Playable(x, z - 10f);
				}
				return true;
			}
			float R(float a, float b)
			{
				return a + (float)rnd.NextDouble() * (b - a);
			}
		}

		private static void Boundaries(Transform root)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = new GameObject("Boundaries_reconstructed").transform;
			transform.SetParent(root, false);
			try
			{
				RockBack(transform);
			}
			catch (Exception ex)
			{
				KonohaPlugin.Log("BOUNDARY rock back failed " + ex);
			}
			try
			{
				OuterForest(transform);
			}
			catch (Exception ex2)
			{
				KonohaPlugin.Log("BOUNDARY outer forest failed " + ex2);
			}
			int num = ForestEdge(transform, TrailNorth, berm: true, "TrailNorth");
			int num2 = ForestEdge(transform, TrailSouth, berm: true, "TrailSouth");
			int num3 = InvisibleWall(transform, TrainingFence, 1.2f, "TrainingFenceWall");
			int num4 = ForestEdge(transform, TrainingFence.Select((Vector3 p) => p).ToArray(), berm: false, "TrainingFenceTrees", collide: false);
			int num5 = WallRingForest(transform);
			Flush(transform, "Boundaries");
			KonohaPlugin.Log("BOUNDARY trail north trees=" + num + " south trees=" + num2 + " training fence wall segments=" + num3 + " fence trees=" + num4 + " wall-ring forest cards=" + num5 + " playable(27.5,-495)=" + Playable(27.5f, -495f) + " (72.7,-428.6)=" + Playable(72.7f, -428.6f) + " (-11.9,-421)=" + Playable(-11.9f, -421f) + " (209,-643)=" + Playable(209f, -643f) + " (120,-567)=" + Playable(120f, -567f) + " (0,-100)=" + Playable(0f, -100f));
		}

		public static int FlagOutside(NodeGraph g)
		{
			//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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)g))
			{
				return 0;
			}
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
			if (!(typeof(NodeGraph).GetField("nodes", bindingAttr).GetValue(g) is Array array))
			{
				return 0;
			}
			Type? elementType = array.GetType().GetElementType();
			FieldInfo field = elementType.GetField("flags", bindingAttr);
			FieldInfo field2 = elementType.GetField("position", bindingAttr);
			int num = 0;
			int num2 = 0;
			for (int i = 0; i < array.Length; i++)
			{
				object value = array.GetValue(i);
				Vector3 val = (Vector3)field2.GetValue(value);
				bool flag = false;
				float num3 = val.x - Districts.ArenaCenter.x;
				float num4 = val.z - Districts.ArenaCenter.z;
				if (num3 * num3 + num4 * num4 < 900f && val.y > 1.9f && val.y < 2.6f)
				{
					val.y -= 1.39f;
					field2.SetValue(value, val);
					flag = true;
					num2++;
				}
				if (!Playable(val.x, val.z))
				{
					NodeFlags val2 = (NodeFlags)field.GetValue(value);
					val2 = (NodeFlags)(val2 | 0x1C);
					val2 = (NodeFlags)(val2 & 0xFD);
					field.SetValue(value, val2);
					flag = true;
					num++;
				}
				if (flag)
				{
					array.SetValue(value, i);
				}
			}
			KonohaPlugin.Log("NAV outside the playable area (no interactables/monsters/teleporter): " + num + " of " + array.Length + " nodes; arena floor nodes lowered to the real floor: " + num2);
			return num;
		}

		public static Texture2D Tex(string file)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			if (texCache.TryGetValue(file, out var value) && Object.op_Implicit((Object)(object)value))
			{
				return value;
			}
			value = StageBuilder.FindTex(file);
			if (Object.op_Implicit((Object)(object)value))
			{
				texCache[file] = value;
				return value;
			}
			string text = Path.Combine(Path.Combine(KonohaPlugin.AssetDir, "Textures"), file);
			value = new Texture2D(2, 2, (TextureFormat)4, true)
			{
				name = "recon_" + file
			};
			if (File.Exists(text))
			{
				ImageConversion.LoadImage(value, File.ReadAllBytes(text), false);
				value.Compress(true);
				value.Apply(true, true);
			}
			else
			{
				KonohaPlugin.Log("RECON texture missing " + text);
			}
			((Texture)value).wrapMode = (TextureWrapMode)0;
			((Texture)value).filterMode = (FilterMode)2;
			((Texture)value).anisoLevel = 4;
			texCache[file] = value;
			return value;
		}

		public static Material Mat(string key, Texture2D t, Color tint, bool cutout = false)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			if (matCache.TryGetValue(key, out var value) && Object.op_Implicit((Object)(object)value))
			{
				return value;
			}
			if (!Object.op_Implicit((Object)(object)hg))
			{
				hg = StageBuilder.HG;
			}
			value = new Material(hg)
			{
				name = "recon_" + key
			};
			value.SetColor("_Color", tint);
			if (Object.op_Implicit((Object)(object)t))
			{
				value.SetTexture("_MainTex", (Texture)(object)t);
			}
			value.SetFloat("_Smoothness", 0f);
			value.SetFloat("_SpecularStrength", 0f);
			value.SetFloat("_Cull", 0f);
			if (cutout)
			{
				value.SetFloat("_EnableCutout", 1f);
				value.EnableKeyword("CUTOUT");
				value.SetFloat("_Cutoff", 0.5f);
			}
			matCache[key] = value;
			return value;
		}

		private static MB B(Material m)
		{
			if (!builders.TryGetValue(m, out var value))
			{
				value = (builders[m] = new MB());
			}
			return value;
		}

		private static void Flush(Transform parent, string name)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Expected O, but got Unknown
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Expected O, but got Unknown
			foreach (KeyValuePair<Material, MB> builder in builders)
			{
				if (builder.Value.v.Count != 0)
				{
					GameObject val = new GameObject(name + "_" + ((Object)builder.Key).name + "_reconstructed");
					val.layer = World;
					val.transform.SetParent(parent, false);
					Mesh val2 = new Mesh
					{
						name = ((Object)val).name
					};
					if (builder.Value.v.Count > 65000)
					{
						val2.indexFormat = (IndexFormat)1;
					}
					val2.SetVertices(builder.Value.v);
					val2.SetUVs(0, builder.Value.uv);
					val2.SetTriangles(builder.Value.t, 0);
					val2.RecalculateNormals();
					val2.RecalculateBounds();
					val.AddComponent<MeshFilter>().sharedMesh = val2;
					((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = builder.Key;
					StageBuilder.Tris += builder.Value.t.Count / 3;
					StageBuilder.Draws++;
				}
			}
			builders.Clear();
			if (collide.v.Count > 0)
			{
				GameObject val3 = new GameObject(name + "_collision_reconstructed");
				val3.layer = World;
				val3.transform.SetParent(parent, false);
				Mesh val4 = new Mesh
				{
					name = ((Object)val3).name
				};
				if (collide.v.Count > 65000)
				{
					val4.indexFormat = (IndexFormat)1;
				}
				val4.SetVertices(collide.v);
				val4.SetTriangles(collide.t, 0);
				val3.AddComponent<MeshCollider>().sharedMesh = val4;
			}
			collide = new MB();
		}

		private static void BoxCollider(Transform p, string name, Vector3 center, Vector3 size, float yaw)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name + "_reconstructed")
			{
				layer = World
			};
			val.transform.SetParent(p, false);
			val.transform.position = center;
			val.transform.rotation = Quaternion.Euler(0f, yaw, 0f);
			val.AddComponent<BoxCollider>().size = size;
		}

		public static float Ground(float x, float z, float fromY = 200f)
		{
			//IL_0003: 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_0019: 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)
			RaycastHit val = default(RaycastHit);
			if (!Physics.Raycast(new Vector3(x, fromY, z), Vector3.down, ref val, 400f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1))
			{
				return 0f;
			}
			return ((RaycastHit)(ref val)).point.y;
		}

		private static void WallAtlas(MB m, Vector3 a, Vector3 b, float y0, float y1, Vector4 r, float segLen, Vector3 push)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: 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_0020: 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_002b: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			float num = Vector3.Distance(a, b);
			int num2 = Mathf.Max(1, Mathf.RoundToInt(num / segLen));
			for (int i = 0; i < num2; i++)
			{
				Vector3 val = Vector3.Lerp(a, b, (float)i / (float)num2) + push;
				Vector3 val2 = Vector3.Lerp(a, b, (float)(i + 1) / (float)num2) + push;
				m.Quad(new Vector3(val.x, y0, val.z), new Vector3(val2.x, y0, val2.z), new Vector3(val2.x, y1, val2.z), new Vector3(val.x, y1, val.z), r);
			}
		}

		private static void WallTiled(MB m, Vector3 a, Vector3 b, float y0, float y1, float tile, Vector3 push)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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_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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			a += push;
			b += push;
			m.QuadTiled(new Vector3(a.x, y0, a.z), new Vector3(b.x, y0, b.z), new Vector3(b.x, y1, b.z), new Vector3(a.x, y1, a.z), tile);
		}

		private static void BoxTiled(MB m, Vector3 c, Vector3 size, float yaw, float tile, bool top = true)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			Quaternion q = Quaternion.Euler(0f, yaw, 0f);
			float num = size.x / 2f;
			float num2 = size.z / 2f;
			float y = c.y - size.y / 2f;
			float num3 = c.y + size.y / 2f;
			Vector3 val = P(0f - num, 0f - num2);
			Vector3 val2 = P(num, 0f - num2);
			Vector3 val3 = P(num, num2);
			Vector3 val4 = P(0f - num, num2);
			WallTiled(m, val, val2, y, num3, tile, Vector3.zero);
			WallTiled(m, val2, val3, y, num3, tile, Vector3.zero);
			WallTiled(m, val3, val4, y, num3, tile, Vector3.zero);
			WallTiled(m, val4, val, y, num3, tile, Vector3.zero);
			if (top)
			{
				m.QuadTiled(new Vector3(val4.x, num3, val4.z), new Vector3(val3.x, num3, val3.z), new Vector3(val2.x, num3, val2.z), new Vector3(val.x, num3, val.z), tile);
			}
			Vector3 P(float x, float z)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: 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_001d: Unknown result type (might be due to invalid IL or missing references)
				return c + q * new Vector3(x, 0f, z);
			}
		}

		private static void Gable(MB tiles, MB gableFace, Vector3 c, float yaw, float hx, float hz, float y, float o, float h, bool collideRoof, bool onWalls = false)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: 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_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: 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_03da: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_0464: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_046b: Unknown result type (might be due to invalid IL or missing references)
			//IL_047b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0480: Unknown result type (might be due to invalid IL or missing references)
			//IL_0482: Unknown result type (might be due to invalid IL or missing references)
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: 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_04bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_050a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0515: Unknown result type (might be due to invalid IL or missing references)
			//IL_0525: Unknown result type (might be due to invalid IL or missing references)
			//IL_0534: 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)
			Quaternion q = Quaternion.Euler(0f, yaw, 0f);
			float num = hx + o;
			float num2 = hz + o;
			float yy = (onWalls ? (y - h * o / Mathf.Max(hz, 0.05f)) : y);
			float yy2 = y + h;
			int num3 = Mathf.Max(1, Mathf.RoundToInt(2f * num / 3f));
			for (int i = 0; i < num3; i++)
			{
				float x = 0f - num + 2f * num * (float)i / (float)num3;
				float x2 = 0f - num + 2f * num * (float)(i + 1) / (float)num3;
				tiles.Quad(P(x, yy, 0f - num2), P(x2, yy, 0f - num2), P(x2, yy2, 0f), P(x, yy2, 0f), RectTiles);
				tiles.Quad(P(x2, yy, num2), P(x, yy, num2), P(x, yy2, 0f), P(x2, yy2, 0f), RectTiles);
			}
			if (onWalls)
			{
				float[] array = new float[2] { -1f, 1f };
				foreach (float num4 in array)
				{
					float x3 = num4 * hx;
					float num5 = ((num4 < 0f) ? (0f - hz) : hz);
					float z = 0f - num5;
					gableFace.Tri(P(x3, y - 0.02f, num5), P(x3, y - 0.02f, z), P(x3, yy2, 0f), new Vector2(0f, 0f), new Vector2(2f, 0f), new Vector2(1f, 1f));
				}
			}
			else
			{
				float num6 = hx + 0.02f;
				float yy3 = y + h * o / num2;
				float[] array = new float[2] { -1f, 1f };
				foreach (float num7 in array)
				{
					float num8 = ((num7 < 0f) ? (0f - hz) : hz);
					float z2 = 0f - num8;
					float x4 = num7 * num6;
					gableFace.Tri(P(x4, y, num8), P(x4, y, z2), P(x4, yy3, z2), new Vector2(0f, 0f), new Vector2(2f, 0f), new Vector2(2f, 0.15f));
					gableFace.Tri(P(x4, y, num8), P(x4, yy3, z2), P(x4, yy3, num8), new Vector2(0f, 0f), new Vector2(2f, 0.15f), new Vector2(0f, 0.15f));
					gableFace.Tri(P(x4, yy3, num8), P(x4, yy3, z2), P(x4, y + h, 0f), new Vector2(0f, 0.15f), new Vector2(2f, 0.15f), new Vector2(1f, 1f));
				}
			}
			for (int k = 0; k < num3; k++)
			{
				float x5 = 0f - num + 2f * num * (float)k / (float)num3;
				float x6 = 0f - num + 2f * num * (float)(k + 1) / (float)num3;
				Vector3 val = Vector3.down * 0.03f;
				tiles.Quad(P(x6, yy, 0f - num2) + val, P(x5, yy, 0f - num2) + val, P(x5, yy2, 0f) + val, P(x6, yy2, 0f) + val, RectTiles);
				tiles.Quad(P(x5, yy, num2) + val, P(x6, yy, num2) + val, P(x6, yy2, 0f) + val, P(x5, yy2, 0f) + val, RectTiles);
			}
			if (collideRoof)
			{
				collide.Quad(P(0f - num, yy, 0f - num2), P(num, yy, 0f - num2), P(num, yy2, 0f), P(0f - num, yy2, 0f), Full);
				collide.Quad(P(num, yy, num2), P(0f - num, yy, num2), P(0f - num, yy2, 0f), P(num, yy2, 0f), Full);
			}
			Vector3 P(float num9, float num11, float num10)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: 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_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: 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)
				return c + q * new Vector3(num9, 0f, num10) + Vector3.up * num11;
			}
		}

		private static void Mats()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: 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_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			Texture2D t = Tex("sa00zobj101_0.png");
			Texture2D t2 = Tex("sa00zobj103_0.png");
			mPlanks = Mat("planks", t, new Color(0.82f, 0.74f, 0.66f));
			mShutter = Mat("shutter", t, new Color(0.7f, 0.62f, 0.55f));
			mDarkWood = Mat("darkwood", t, new Color(0.42f, 0.33f, 0.27f));
			mTiles = Mat("uchiha_tiles", t2, new Color(0.46f, 0.48f, 0.56f));
			mPlaster = Mat("plaster", Tex("sa00zflo013_0.png"), new Color(1f, 0.98f, 0.94f));
			mStone = Mat("stone", Tex("sa00zflo009_0.png"), new Color(0.85f, 0.84f, 0.82f));
			mIntelPlaster = Mat("intel_plaster", Tex("sa00zflo004_0.png"), new Color(0.82f, 0.86f, 0.9f));
			mIntelStone = Mat("intel_stone", Tex("sa00zflo009_0.png"), new Color(0.62f, 0.64f, 0.68f));
			mGrass = Mat("skirt_grass", Tex("sd00aflo005_0.png"), new Color(0.66f, 0.74f, 0.6f));
			mDirt = Mat("road_dirt", Tex("sd00aflo008_0.png"), Color.white);
			mCrest = Mat("crest", Districts.CrestTex, Color.white, cutout: true);
			mBanner = Mat("banner", Districts.BannerTex, Color.white);
			mPlaque = Mat("plaque", Districts.PlaqueTex, Color.white);
			mPaving = Mat("paving", Tex("sa00zflo003_0.png"), new Color(0.7f, 0.78f, 0.86f));
			mDirt2 = Mat("lane_dirt", Tex("sd00aflo008_0.png"), new Color(0.92f, 0.86f, 0.78f));
			mTree = Mat("tree_single", Tex("ki008_0.png"), Color.white, cutout: true);
			mForest = Mat("tree_forest", Tex("ki006_0.png"), Color.white, cutout: true);
			mBush = Mat("tree_bush", Tex("ki009_0.png"), Color.white, cutout: true);
		}

		public static void Build(Transform root)
		{
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			hg = StageBuilder.HG;
			Mats();
			NavHints.Clear();
			NavHintsExact.Clear();
			try
			{
				GateTrailForest(root);
			}
			catch (Exception ex)
			{
				KonohaPlugin.Log("RECON gate forest failed " + ex);
			}
			try
			{
				Uchiha(root);
			}
			catch (Exception ex2)
			{
				KonohaPlugin.Log("RECON uchiha failed " + ex2);
			}
			try
			{
				Intelligence(root);
			}
			catch (Exception ex3)
			{
				KonohaPlugin.Log("RECON intelligence failed " + ex3);
			}
			try
			{
				TrainingLink(root);
			}
			catch (Exception ex4)
			{
				KonohaPlugin.Log("RECON training link failed " + ex4);
			}
			try
			{
				OuterGround(root);
			}
			catch (Exception ex5)
			{
				KonohaPlugin.Log("RECON outer ground failed " + ex5);
			}
			try
			{
				Boundaries(root);
			}
			catch (Exception ex6)
			{
				KonohaPlugin.Log("RECON boundaries failed " + ex6);
			}
			try
			{
				Doors.Build(root, Mat("door_wall", Tex("sa00zflo013_0.png"), new Color(0.56f, 0.5f, 0.44f)), Mat("door_floor", Tex("sa00zflo009_0.png"), new Color(0.55f, 0.5f, 0.45f)), Mat("door_ceiling", Tex("sa00zflo013_0.png"), new Color(0.42f, 0.38f, 0.34f)));
			}
			catch (Exception ex7)
			{
				KonohaPlugin.Log("DOORS rooms failed " + ex7);
			}
		}

		private static void OuterGround(Transform root)
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			MB mB = new MB();
			float y = -6.5f;
			float tile = 9f;
			int num = 8;
			float num2 = -760f;
			float num3 = 840f;
			float num4 = -900f;
			float num5 = 600f;
			for (int i = 0; i < num; i++)
			{
				for (int j = 0; j < num; j++)
				{
					float x = Mathf.Lerp(num2, num3, (float)i / (float)num);
					float x2 = Mathf.Lerp(num2, num3, (float)(i + 1) / (float)num);
					float z = Mathf.Lerp(num4, num5, (float)j / (float)num);
					float z2 = Mathf.Lerp(num4, num5, (float)(j + 1) / (float)num);
					Ground2D(mB, x, z, x2, z2, y, tile);
				}
			}
			GameObject val = new GameObject("OuterGround_reconstructed")
			{
				layer = World
			};
			val.transform.SetParent(root, false);
			Mesh val2 = new Mesh
			{
				name = "outer_ground"
			};
			val2.SetVertices(mB.v);
			val2.SetUVs(0, mB.uv);
			val2.SetTriangles(mB.t, 0);
			val2.RecalculateNormals();
			val2.RecalculateBounds();
			val.AddComponent<MeshFilter>().sharedMesh = val2;
			MeshRenderer obj = val.AddComponent<MeshRenderer>();
			((Renderer)obj).sharedMaterial = mGrass;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
			StageBuilder.Tris += mB.t.Count / 3;
			StageBuilder.Draws++;
		}

		public static bool RenderCut(string mat, Vector3 a, Vector3 b, Vector3 c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_0049: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = (a + b + c) / 3f;