Decompiled source of Packers MapGenerator v1.1.0

Packer.MapGenerator.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using Atlas.MappingComponents;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using FistVR;
using H3MP;
using H3MP.Networking;
using H3MP.Scripts;
using MapGenerator;
using Microsoft.CodeAnalysis;
using Packer;
using SupplyRaid;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("Packer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Map generator script!")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7b37453cea202a2b166e7bc75c2f8310f8b7b227")]
[assembly: AssemblyProduct("Packer.MapGenerator")]
[assembly: AssemblyTitle("Map Generator")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace SupplyRaid
{
	public class SupplyRaidGame : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <SetupSupplyPoints>d__3 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public SupplyRaidGame <>4__this;

			private Section[] <sections>5__1;

			private bool <hub>5__2;

			private int <supplyPointCount>5__3;

			private int <i>5__4;

			private int <i>5__5;

			private SR_SupplyPoint <point>5__6;

			private int <i>5__7;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<sections>5__1 = null;
				<point>5__6 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0214: 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_0305: Unknown result type (might be due to invalid IL or missing references)
				//IL_032e: Unknown result type (might be due to invalid IL or missing references)
				//IL_028e: Unknown result type (might be due to invalid IL or missing references)
				//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					Debug.Log((object)("Map Generator: Generating Supply Raid Points " + MG_Manager.sections.Length));
					Random.InitState(MG_Manager.profile.seed);
					<sections>5__1 = MG_Manager.sections;
					<hub>5__2 = MG_Manager.profile.hub;
					<supplyPointCount>5__3 = <sections>5__1.Length;
					if (<hub>5__2)
					{
						<supplyPointCount>5__3++;
					}
					if (<>4__this.supplyPoints != null)
					{
						<i>5__4 = 0;
						while (<i>5__4 < <>4__this.supplyPoints.Length)
						{
							Object.Destroy((Object)(object)((Component)<>4__this.supplyPoints[<i>5__4]).gameObject);
							<i>5__4++;
						}
					}
					<>4__this.supplyPoints = (SR_SupplyPoint[])(object)new SR_SupplyPoint[<supplyPointCount>5__3];
					<i>5__5 = 0;
					while (<i>5__5 < <supplyPointCount>5__3)
					{
						<point>5__6 = Object.Instantiate<GameObject>(<>4__this.supplyPointPrefab).GetComponent<SR_SupplyPoint>();
						((Component)<point>5__6).gameObject.SetActive(true);
						<>4__this.supplyPoints[<i>5__5] = <point>5__6;
						<>4__this.manager.supplyPoints.Add(<point>5__6);
						<point>5__6 = null;
						<i>5__5++;
					}
					<i>5__7 = 0;
					goto IL_0362;
				case 1:
					<>1__state = -1;
					<i>5__7++;
					goto IL_0362;
				case 2:
					{
						<>1__state = -1;
						return false;
					}
					IL_0362:
					if (<i>5__7 < <supplyPointCount>5__3)
					{
						Random.InitState(MG_Manager.profile.seed + <i>5__7);
						if ((<i>5__7 == 0) & <hub>5__2)
						{
							<>4__this.SetupSupplyPoint(<>4__this.supplyPoints[<i>5__7], new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), ((Component)MG_Manager.instance.hubStructure).GetComponent<MG_Structure>());
						}
						else if (<hub>5__2)
						{
							<>4__this.SetupSupplyPoint(<>4__this.supplyPoints[<i>5__7], new Vector2(<sections>5__1[<i>5__7 - 1].minX, <sections>5__1[<i>5__7 - 1].minZ), new Vector2(<sections>5__1[<i>5__7 - 1].maxX, <sections>5__1[<i>5__7 - 1].maxZ), null);
						}
						else
						{
							<>4__this.SetupSupplyPoint(<>4__this.supplyPoints[<i>5__7], new Vector2(<sections>5__1[<i>5__7].minX, <sections>5__1[<i>5__7].minZ), new Vector2(<sections>5__1[<i>5__7].maxX, <sections>5__1[<i>5__7].maxZ), null);
						}
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					if ((Object)(object)<>4__this.manager != (Object)null)
					{
						<>4__this.manager.forceStaticPlayerSupplyPoint = MG_Manager.profile.staticSRPoint;
						Debug.Log((object)"Map Generator: Supply Raid Supply Point Static");
					}
					<>2__current = null;
					<>1__state = 2;
					return true;
				}
			}

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

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

		public SR_Manager manager;

		public SR_SupplyPoint[] supplyPoints;

		public GameObject supplyPointPrefab;

		public IEnumerator SetupSupplyPoints()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SetupSupplyPoints>d__3(0)
			{
				<>4__this = this
			};
		}

		private void AddLoot()
		{
		}

		private MG_Structure SupplyPointCast(Transform marker, Vector3 start)
		{
			//IL_0003: 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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_0037: 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_0056: 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_009c: 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)
			Ray val = default(Ray);
			((Ray)(ref val)).direction = Vector3.down;
			Ray val2 = val;
			Vector3 origin = default(Vector3);
			((Vector3)(ref origin))..ctor(start.x, MG_Manager.instance.raycastHeight, start.z);
			((Ray)(ref val2)).origin = origin;
			RaycastHit val3 = default(RaycastHit);
			if (Physics.Raycast(val2, ref val3, MG_Manager.instance.raycastHeight + 1f, LayerMask.op_Implicit(MG_Manager.instance.enviromentMask)))
			{
				marker.position = ((RaycastHit)(ref val3)).point;
				MG_Structure component = ((Component)((RaycastHit)(ref val3)).collider).GetComponent<MG_Structure>();
				if (Object.op_Implicit((Object)(object)component))
				{
					return component;
				}
				NavMeshHit val4 = default(NavMeshHit);
				if (NavMesh.SamplePosition(marker.position, ref val4, 10f, -1))
				{
					marker.position = ((NavMeshHit)(ref val4)).position;
				}
			}
			else
			{
				Debug.LogError((object)("Map Generator: Could not find surface to place object on - " + ((Object)marker).name));
			}
			return null;
		}

		private void PointCast(Transform marker, Vector3 start)
		{
			//IL_0003: 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_0016: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_0066: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			Ray val = default(Ray);
			((Ray)(ref val)).direction = Vector3.down;
			Ray val2 = val;
			Vector3 origin = default(Vector3);
			((Vector3)(ref origin))..ctor(start.x, start.y, start.z);
			Vector3 position = marker.position;
			marker.position = Vector3.zero;
			((Ray)(ref val2)).origin = origin;
			RaycastHit val3 = default(RaycastHit);
			if (Physics.Raycast(val2, ref val3, MG_Manager.instance.raycastHeight + 1f, LayerMask.op_Implicit(MG_Manager.instance.enviromentMask)))
			{
				marker.position = ((RaycastHit)(ref val3)).point;
			}
			else
			{
				marker.position = position;
			}
		}

		private bool HasCollisionInMarker(Transform marker)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			if (Physics.CheckBox(marker.position + Vector3.up, Vector3.one * 0.5f, marker.rotation, LayerMask.op_Implicit(MG_Manager.instance.enviromentMask)))
			{
				return true;
			}
			return false;
		}

		private Vector3 GetRandomXZVector(float range)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(Random.Range(0f - range, range), 0f, Random.Range(0f - range, range));
		}

		private void SetupSupplyPoint(SR_SupplyPoint sr, Vector2 min, Vector2 max, MG_Structure hubStructure)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: 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_0141: 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_0171: 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_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: 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_01d9: 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_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0478: Unknown result type (might be due to invalid IL or missing references)
			//IL_047d: 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_0451: Unknown result type (might be due to invalid IL or missing references)
			//IL_045d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0542: Unknown result type (might be due to invalid IL or missing references)
			//IL_0547: Unknown result type (might be due to invalid IL or missing references)
			//IL_0549: Unknown result type (might be due to invalid IL or missing references)
			//IL_051b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0527: Unknown result type (might be due to invalid IL or missing references)
			GenerationProfile profile = MG_Manager.profile;
			float num = profile.mapSize * 2;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(num * min.x - (float)profile.mapSize, 0f, num * min.y - (float)profile.mapSize);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(num * max.x - (float)profile.mapSize, 0f, num * max.y - (float)profile.mapSize);
			MG_Structure mG_Structure = hubStructure;
			if (!Object.op_Implicit((Object)(object)mG_Structure))
			{
				mG_Structure = SupplyPointCast(sr.captureZone, new Vector3(Random.Range(val.x, val2.x), 0f, Random.Range(val.z, val2.z)));
				sr.buyMenu.parent.position = sr.captureZone.position + Vector3.up * 0.1f;
			}
			Vector3 position = sr.captureZone.position;
			if (!Object.op_Implicit((Object)(object)mG_Structure))
			{
				mG_Structure = SupplyPointCast(sr.buyMenu, position + sr.buyMenu.localPosition);
				if (!Object.op_Implicit((Object)(object)mG_Structure))
				{
					mG_Structure = SupplyPointCast(sr.recycler, position + sr.recycler.localPosition);
				}
				if (!Object.op_Implicit((Object)(object)mG_Structure))
				{
					mG_Structure = SupplyPointCast(sr.ammoStation, position + sr.ammoStation.localPosition);
				}
				if (!Object.op_Implicit((Object)(object)mG_Structure))
				{
					mG_Structure = SupplyPointCast(sr.duplicator, position + sr.duplicator.localPosition);
				}
				if (!Object.op_Implicit((Object)(object)mG_Structure))
				{
					mG_Structure = SupplyPointCast(sr.attachmentStation, position + sr.attachmentStation.localPosition);
				}
			}
			if (Object.op_Implicit((Object)(object)hubStructure))
			{
				mG_Structure = hubStructure;
			}
			if (Object.op_Implicit((Object)(object)mG_Structure) && Object.op_Implicit((Object)(object)mG_Structure.captureZone))
			{
				sr.captureZone.SetPositionAndRotation(mG_Structure.captureZone.position, mG_Structure.captureZone.rotation);
			}
			if (Object.op_Implicit((Object)(object)mG_Structure) && Object.op_Implicit((Object)(object)mG_Structure.playerSpawn))
			{
				sr.respawn.position = mG_Structure.playerSpawn.position;
				sr.respawn.rotation = mG_Structure.playerSpawn.rotation;
			}
			else
			{
				SupplyPointCast(sr.respawn, sr.captureZone.position + GetRandomXZVector(2f));
			}
			if (Object.op_Implicit((Object)(object)mG_Structure) && Object.op_Implicit((Object)(object)mG_Structure.squadPoint))
			{
				sr.squadPoint.position = mG_Structure.squadPoint.position;
				sr.squadPoint.rotation = mG_Structure.squadPoint.rotation;
			}
			else
			{
				SupplyPointCast(sr.squadPoint, sr.captureZone.position + GetRandomXZVector(2f));
			}
			Vector3 up = Vector3.up;
			up.y = sr.buyMenu.parent.position.y + 5f;
			if (Object.op_Implicit((Object)(object)mG_Structure) && Object.op_Implicit((Object)(object)mG_Structure.buyMenu))
			{
				sr.buyMenu.SetPositionAndRotation(mG_Structure.buyMenu.position, mG_Structure.buyMenu.rotation);
			}
			else
			{
				PointCast(sr.buyMenu, sr.buyMenu.position + up);
			}
			if (Object.op_Implicit((Object)(object)mG_Structure) && Object.op_Implicit((Object)(object)mG_Structure.recyclerMenu))
			{
				sr.recycler.SetPositionAndRotation(mG_Structure.recyclerMenu.position, mG_Structure.recyclerMenu.rotation);
			}
			else
			{
				PointCast(sr.recycler, sr.recycler.position + up);
			}
			if (Object.op_Implicit((Object)(object)mG_Structure) && Object.op_Implicit((Object)(object)mG_Structure.ammoMenu))
			{
				sr.ammoStation.SetPositionAndRotation(mG_Structure.ammoMenu.position, mG_Structure.ammoMenu.rotation);
			}
			else
			{
				PointCast(sr.ammoStation, sr.ammoStation.position + up);
			}
			if (Object.op_Implicit((Object)(object)mG_Structure) && Object.op_Implicit((Object)(object)mG_Structure.magazineMenu))
			{
				sr.duplicator.SetPositionAndRotation(mG_Structure.magazineMenu.position, mG_Structure.magazineMenu.rotation);
			}
			else
			{
				PointCast(sr.duplicator, sr.duplicator.position + up);
			}
			if (Object.op_Implicit((Object)(object)mG_Structure) && Object.op_Implicit((Object)(object)mG_Structure.attachmentMenu))
			{
				sr.attachmentStation.SetPositionAndRotation(mG_Structure.attachmentMenu.position, mG_Structure.attachmentMenu.rotation);
			}
			else
			{
				PointCast(sr.attachmentStation, sr.attachmentStation.position + up);
			}
			SetupList(sr, sr.sosigSpawns, StructureMarkerEnum.SosigSpawn, 50f);
			SetupList(sr, sr.guardPoints.ToArray(), StructureMarkerEnum.GuardPoint, 20f);
			SetupList(sr, sr.sniperPoints.ToArray(), StructureMarkerEnum.SniperPoint, 45f);
			for (int i = 0; i < sr.patrolPaths.Length; i++)
			{
				SetupList(sr, sr.patrolPaths[i].patrolPoints.ToArray(), StructureMarkerEnum.PatrolPath, 40f);
			}
		}

		private void SetupList(SR_SupplyPoint sr, Transform[] srList, StructureMarkerEnum type, float randomRange)
		{
			//IL_001a: 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_00db: 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_00f5: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
			Transform[] array = (Transform[])(object)new Transform[0];
			for (int i = 0; i < srList.Length; i++)
			{
				MG_Structure mG_Structure = SupplyPointCast(srList[i], sr.captureZone.position + GetRandomXZVector(randomRange));
				if (Object.op_Implicit((Object)(object)mG_Structure))
				{
					switch (type)
					{
					case StructureMarkerEnum.GuardPoint:
						array = mG_Structure.guardPoints;
						break;
					case StructureMarkerEnum.SniperPoint:
						array = mG_Structure.sniperPoints;
						break;
					case StructureMarkerEnum.PatrolPath:
						array = mG_Structure.patrolPaths;
						break;
					case StructureMarkerEnum.SosigSpawn:
						array = mG_Structure.sosigSpawns;
						break;
					case StructureMarkerEnum.Encryptions:
						array = mG_Structure.encryptions;
						break;
					}
				}
				if (array != null && array.Length != 0)
				{
					Transform val = array[Random.Range(0, array.Length)];
					srList[i].position = val.position;
					srList[i].rotation = val.rotation;
				}
				else
				{
					srList[i].rotation = Quaternion.Euler(Vector3.up * (float)Random.Range(-180, 180));
				}
			}
		}
	}
}
namespace MapGenerator
{
	public class Generation_Core : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <GenerateInteriorProps>d__1 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public Generation_Core <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					return false;
				}
			}

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

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

		[CompilerGenerated]
		private sealed class <GenerateProps>d__0 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public Generation_Core <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					return false;
				}
			}

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

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

		public virtual IEnumerator GenerateProps()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GenerateProps>d__0(0)
			{
				<>4__this = this
			};
		}

		public virtual IEnumerator GenerateInteriorProps()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GenerateInteriorProps>d__1(0)
			{
				<>4__this = this
			};
		}
	}
	public class Generation_Generic : Generation_Core
	{
		[CompilerGenerated]
		private sealed class <GenerateInteriorProps>d__11 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public Generation_Generic <>4__this;

			private int <x>5__1;

			private int <y>5__2;

			private Transform <zone>5__3;

			private int <xRange>5__4;

			private int <zRange>5__5;

			private int <u>5__6;

			private int <count>5__7;

			private int <v>5__8;

			private Vector3 <spawnPosition>5__9;

			private NavMeshHit <hit>5__10;

			private float <chance>5__11;

			private int <index>5__12;

			private GameObject <obj>5__13;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<zone>5__3 = null;
				<obj>5__13 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0180: Unknown result type (might be due to invalid IL or missing references)
				//IL_0185: Unknown result type (might be due to invalid IL or missing references)
				//IL_018c: 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_01a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b4: 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_0111: 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)
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
					goto IL_02e2;
				}
				<>1__state = -1;
				Random.InitState(MG_Manager.profile.seed + 5);
				if (MG_Manager.profile.interiorPropDensity <= 0f)
				{
					return false;
				}
				<x>5__1 = 0;
				goto IL_03b1;
				IL_033a:
				if (<u>5__6 < <xRange>5__4)
				{
					<v>5__8 = -<zRange>5__5;
					goto IL_0310;
				}
				<zone>5__3 = null;
				<y>5__2++;
				goto IL_036b;
				IL_02e2:
				<obj>5__13 = null;
				goto IL_02eb;
				IL_0310:
				if (<v>5__8 < <zRange>5__5)
				{
					<spawnPosition>5__9 = <>4__this.mg.generatedStructures[<x>5__1].interiorProps[<y>5__2].position;
					<spawnPosition>5__9 += new Vector3((float)<u>5__6, 0f, (float)<v>5__8);
					if (NavMesh.SamplePosition(<spawnPosition>5__9, ref <hit>5__10, 0.5f, -1))
					{
						<chance>5__11 = Random.Range(0f, 1f);
						if (<chance>5__11 <= MG_Manager.profile.interiorPropDensity)
						{
							<index>5__12 = Random.Range(0, <>4__this.mg.interiorProps.Count);
							<obj>5__13 = Object.Instantiate<GameObject>(<>4__this.mg.interiorProps[<index>5__12], ((NavMeshHit)(ref <hit>5__10)).position, Quaternion.Euler(0f, (float)Random.Range(-180, 180), 0f), ((Component)<>4__this.mg.generatedStructures[<x>5__1]).transform);
							<>4__this.mg.generatedObjects.Add(<obj>5__13);
							if (<count>5__7 > 3)
							{
								<count>5__7 = 0;
								<>2__current = null;
								<>1__state = 1;
								return true;
							}
							goto IL_02e2;
						}
					}
					goto IL_02eb;
				}
				<u>5__6++;
				goto IL_033a;
				IL_039f:
				<x>5__1++;
				goto IL_03b1;
				IL_036b:
				if (<y>5__2 < <>4__this.mg.generatedStructures[<x>5__1].interiorProps.Length)
				{
					<zone>5__3 = <>4__this.mg.generatedStructures[<x>5__1].interiorProps[<y>5__2];
					<xRange>5__4 = Mathf.RoundToInt(<zone>5__3.localScale.x / 2f);
					<zRange>5__5 = Mathf.RoundToInt(<zone>5__3.localScale.z / 2f);
					<u>5__6 = -<xRange>5__4;
					<count>5__7 = 0;
					goto IL_033a;
				}
				goto IL_039f;
				IL_02eb:
				<v>5__8++;
				<count>5__7++;
				goto IL_0310;
				IL_03b1:
				if (<x>5__1 < <>4__this.mg.generatedStructures.Count)
				{
					if ((Object)(object)<>4__this.mg.generatedStructures[<x>5__1] == (Object)null || <>4__this.mg.generatedStructures[<x>5__1].interiorProps.Length == 0)
					{
						goto IL_039f;
					}
					<y>5__2 = 0;
					goto IL_036b;
				}
				return false;
			}

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

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

		[CompilerGenerated]
		private sealed class <GenerateProps>d__2 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public Generation_Generic <>4__this;

			private List<GameObject>.Enumerator <>s__1;

			private GameObject <item>5__2;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>s__1 = default(List<GameObject>.Enumerator);
				<item>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_023f: Unknown result type (might be due to invalid IL or missing references)
				//IL_024e: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					Random.InitState(MG_Manager.profile.seed);
					<>4__this.GenerateTerrainObjects();
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.GenerateGrassData();
					<>2__current = null;
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					Random.InitState(MG_Manager.profile.seed + 1);
					if (MG_Manager.profile.hub)
					{
						<>4__this.SetupHub();
						<>2__current = null;
						<>1__state = 3;
						return true;
					}
					goto IL_0105;
				case 3:
					<>1__state = -1;
					Random.InitState(MG_Manager.profile.seed + 2);
					goto IL_0105;
				case 4:
					<>1__state = -1;
					Random.InitState(MG_Manager.profile.seed + 3);
					<>4__this.GenerateStructures();
					<>2__current = null;
					<>1__state = 5;
					return true;
				case 5:
					<>1__state = -1;
					Random.InitState(MG_Manager.profile.seed + 4);
					<>4__this.GenerateEnviroment();
					<>2__current = null;
					<>1__state = 6;
					return true;
				case 6:
					<>1__state = -1;
					Random.InitState(MG_Manager.profile.seed + 6);
					<>4__this.GenerateExteriorProps();
					<>2__current = null;
					<>1__state = 7;
					return true;
				case 7:
					{
						<>1__state = -1;
						Random.InitState(MG_Manager.profile.seed + 7);
						if (MG_Manager.profile.allScale != 1f)
						{
							<>s__1 = <>4__this.mg.generatedObjects.GetEnumerator();
							try
							{
								while (<>s__1.MoveNext())
								{
									<item>5__2 = <>s__1.Current;
									Transform transform = <item>5__2.transform;
									transform.localScale *= MG_Manager.profile.allScale;
									<item>5__2 = null;
								}
							}
							finally
							{
								((IDisposable)<>s__1).Dispose();
							}
							<>s__1 = default(List<GameObject>.Enumerator);
						}
						return false;
					}
					IL_0105:
					if (MG_Manager.profile.oneOfAKind)
					{
						<>4__this.GenerateOneOfAKind();
					}
					<>2__current = null;
					<>1__state = 4;
					return true;
				}
			}

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

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

		private MG_Manager mg;

		private void Start()
		{
			mg = MG_Manager.instance;
		}

		public override IEnumerator GenerateProps()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GenerateProps>d__2(0)
			{
				<>4__this = this
			};
		}

		private void SetupHub()
		{
			//IL_0003: 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_0013: 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_001f: 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_0045: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val = default(RaycastHit);
			Ray val2 = default(Ray);
			((Ray)(ref val2)).direction = Vector3.down;
			Ray val3 = val2;
			Vector3 origin = default(Vector3);
			((Vector3)(ref origin))..ctor(0f, mg.raycastHeight, 0f);
			((Ray)(ref val3)).origin = origin;
			if (Physics.Raycast(val3, ref val, mg.raycastHeight + 5f, LayerMask.op_Implicit(mg.enviromentMask)))
			{
				mg.hubStructure.position = ((RaycastHit)(ref val)).point;
			}
		}

		private void GenerateGrassData()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"Gen Grass");
			if (MG_Manager.profile.grassDensity <= 0f)
			{
				return;
			}
			RaycastHit val = default(RaycastHit);
			Ray val2 = default(Ray);
			((Ray)(ref val2)).direction = Vector3.down;
			Ray val3 = val2;
			List<Matrix4x4> list = new List<Matrix4x4>();
			int num = 0;
			int num2 = MG_Manager.profile.mapSize - MG_Manager.instance.generationBuffer;
			for (int i = -num2; i < num2; i++)
			{
				for (int j = -num2; j < num2; j++)
				{
					float num3 = Random.Range(0f, 1f);
					if (num3 > MG_Manager.profile.grassDensity)
					{
						continue;
					}
					((Ray)(ref val3)).origin = new Vector3((float)i + Random.Range(-0.5f, 0.5f), mg.raycastHeight, (float)j + Random.Range(-0.5f, 0.5f));
					if (Physics.Raycast(val3, ref val, mg.raycastHeight + 5f, LayerMask.op_Implicit(mg.enviromentMask)))
					{
						list.Add(Matrix4x4.TRS(((RaycastHit)(ref val)).point, Quaternion.LookRotation((((RaycastHit)(ref val)).normal != Vector3.zero) ? ((RaycastHit)(ref val)).normal : Vector3.up), Vector3.one * Random.Range(0.75f, 1.25f)));
						num++;
						if (num == 1000)
						{
							MG_Manager.instance.generatedGrass.Add(new MG_Manager.GrassChunk
							{
								matrix = list.ToArray()
							});
							list.Clear();
							num = 0;
						}
					}
				}
			}
			if (num != 0)
			{
				Debug.Log((object)num);
				MG_Manager.instance.generatedGrass.Add(new MG_Manager.GrassChunk
				{
					matrix = list.ToArray()
				});
				list.Clear();
				num = 0;
			}
		}

		private void GenerateTerrainObjects()
		{
			//IL_0022: 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_0032: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			if (mg.terrain.Count <= 0)
			{
				return;
			}
			RaycastHit val = default(RaycastHit);
			Ray val2 = default(Ray);
			((Ray)(ref val2)).direction = Vector3.down;
			Ray val3 = val2;
			for (int i = 0; i < MG_Manager.profile.terrainProps; i++)
			{
				((Ray)(ref val3)).origin = mg.GetRandomMapPosition();
				if (Physics.Raycast(val3, ref val, mg.raycastHeight + 5f, LayerMask.op_Implicit(mg.enviromentMask)))
				{
					GameObject item = Object.Instantiate<GameObject>(mg.terrain[Random.Range(0, mg.terrain.Count)], ((RaycastHit)(ref val)).point, Quaternion.Euler(Vector3.up * (float)Random.Range(-180, 180)), mg.parentTerrain);
					mg.generatedObjects.Add(item);
				}
			}
		}

		private void GenerateStructures()
		{
			//IL_0036: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: 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_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: 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_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: 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_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: 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_01c0: 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_01cf: 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)
			if (mg.structures.Count <= 0)
			{
				return;
			}
			GenerationProfile profile = MG_Manager.profile;
			List<Vector3> list = new List<Vector3>();
			List<Vector3> list2 = new List<Vector3>();
			RaycastHit val = default(RaycastHit);
			Ray val2 = default(Ray);
			((Ray)(ref val2)).direction = Vector3.down;
			Ray val3 = val2;
			int num = 0;
			for (int i = 0; i < MG_Manager.profile.structureCount; i++)
			{
				if (profile.structureCityGrid)
				{
					((Ray)(ref val3)).origin = mg.GetRandomMapPositionGrid(profile.structureSpacing);
				}
				else
				{
					((Ray)(ref val3)).origin = mg.GetRandomMapPosition();
				}
				if (Physics.Raycast(val3, ref val, mg.raycastHeight + 5f, LayerMask.op_Implicit(mg.enviromentMask)) && !list.Contains(((RaycastHit)(ref val)).point))
				{
					if ((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponent<MG_Structure>() == (Object)null)
					{
						list.Add(((RaycastHit)(ref val)).point);
						num++;
					}
					else
					{
						i--;
					}
				}
			}
			Debug.Log((object)("Map Generator: " + num + " structures generated"));
			for (int j = 0; j < list.Count; j++)
			{
				Vector3 val4 = (Vector3)((!profile.structureCityGrid) ? (Vector3.up * (float)Random.Range(-180, 180)) : (Random.Range(0, 4) switch
				{
					1 => Vector3.up * 90f, 
					2 => Vector3.up * 180f, 
					3 => Vector3.up * 270f, 
					_ => Vector3.zero, 
				}));
				GameObject val5 = Object.Instantiate<GameObject>(mg.structures[Random.Range(0, mg.structures.Count)], list[j], Quaternion.Euler(val4), mg.parentStructures);
				mg.generatedObjects.Add(val5);
				MG_Structure component = val5.GetComponent<MG_Structure>();
				if ((Object)(object)component != (Object)null)
				{
					mg.generatedStructures.Add(component);
				}
			}
		}

		private void GenerateEnviroment()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0045: 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_0062: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: 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_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			if (mg.enviromental.Count <= 0)
			{
				return;
			}
			List<Vector3> list = new List<Vector3>();
			RaycastHit val = default(RaycastHit);
			Ray val2 = default(Ray);
			((Ray)(ref val2)).direction = Vector3.down;
			Ray val3 = val2;
			for (int i = 0; i < MG_Manager.profile.enviromentProps; i++)
			{
				((Ray)(ref val3)).origin = mg.GetRandomMapPosition();
				if (Physics.Raycast(val3, ref val, mg.raycastHeight + 5f, LayerMask.op_Implicit(mg.enviromentMask)))
				{
					if (((Object)((RaycastHit)(ref val)).collider).name == "Terrain")
					{
						list.Add(((RaycastHit)(ref val)).point);
					}
					else
					{
						i--;
					}
				}
			}
			for (int j = 0; j < list.Count; j++)
			{
				GameObject val4 = Object.Instantiate<GameObject>(mg.enviromental[Random.Range(0, mg.enviromental.Count)], list[j], Quaternion.Euler(Vector3.up * (float)Random.Range(-180, 180)), mg.parentEnviroment);
				float num = Random.Range(MG_Manager.profile.enviromentScaleMin, MG_Manager.profile.enviromentScaleMax);
				val4.transform.localScale = new Vector3(num, num, num);
				mg.generatedObjects.Add(val4);
			}
		}

		private void GenerateOneOfAKind()
		{
			//IL_001f: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_004f: 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_00a7: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			if (mg.oneOfAKind.Count != 0)
			{
				RaycastHit val = default(RaycastHit);
				Ray val2 = default(Ray);
				((Ray)(ref val2)).direction = Vector3.down;
				((Ray)(ref val2)).origin = mg.GetRandomMapPosition();
				Ray val3 = val2;
				if (Physics.Raycast(val3, ref val, mg.raycastHeight + 5f, LayerMask.op_Implicit(mg.enviromentMask)))
				{
					GameObject item = Object.Instantiate<GameObject>(mg.oneOfAKind[Random.Range(0, mg.oneOfAKind.Count)], ((RaycastHit)(ref val)).point, Quaternion.Euler(Vector3.up * (float)Random.Range(-180, 180)), mg.parentStructures);
					mg.generatedObjects.Add(item);
				}
			}
		}

		private void GenerateExteriorProps()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0067: 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_00b3: 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_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			if (mg.exteriorProps.Count <= 0)
			{
				return;
			}
			List<Vector3> list = new List<Vector3>();
			List<Vector3> list2 = new List<Vector3>();
			RaycastHit val = default(RaycastHit);
			Ray val2 = default(Ray);
			((Ray)(ref val2)).direction = Vector3.down;
			Ray val3 = val2;
			for (int i = 0; i < MG_Manager.profile.exteriorProps; i++)
			{
				((Ray)(ref val3)).origin = mg.GetRandomMapPosition();
				if (Physics.Raycast(val3, ref val, mg.raycastHeight + 5f, LayerMask.op_Implicit(mg.enviromentMask)))
				{
					if ((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponent<MG_Structure>() == (Object)null)
					{
						list.Add(((RaycastHit)(ref val)).point);
					}
					else
					{
						i--;
					}
				}
			}
			for (int j = 0; j < list.Count; j++)
			{
				GameObject item = Object.Instantiate<GameObject>(mg.exteriorProps[Random.Range(0, mg.exteriorProps.Count)], list[j], Quaternion.Euler(Vector3.up * (float)Random.Range(-180, 180)), mg.parentExteriorProps);
				mg.generatedObjects.Add(item);
			}
		}

		public Vector3 GetHitNormal(RaycastHit hit)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_0084: 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_008d: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: 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_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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			Collider collider = ((RaycastHit)(ref hit)).collider;
			MeshCollider val = (MeshCollider)(object)((collider is MeshCollider) ? collider : null);
			if ((Object)(object)val == (Object)null || (Object)(object)val.sharedMesh == (Object)null)
			{
				return Vector3.up;
			}
			Mesh sharedMesh = val.sharedMesh;
			Vector3[] normals = sharedMesh.normals;
			int[] triangles = sharedMesh.triangles;
			Vector3 val2 = normals[triangles[((RaycastHit)(ref hit)).triangleIndex * 3]];
			Vector3 val3 = normals[triangles[((RaycastHit)(ref hit)).triangleIndex * 3 + 1]];
			Vector3 val4 = normals[triangles[((RaycastHit)(ref hit)).triangleIndex * 3 + 2]];
			Vector3 barycentricCoordinate = ((RaycastHit)(ref hit)).barycentricCoordinate;
			Vector3 val5 = val2 * barycentricCoordinate.x + val3 * barycentricCoordinate.y + val4 * barycentricCoordinate.z;
			val5 = ((Vector3)(ref val5)).normalized;
			Transform transform = ((Component)((RaycastHit)(ref hit)).collider).transform;
			val5 = transform.TransformDirection(val5);
			return val5;
		}

		public override IEnumerator GenerateInteriorProps()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GenerateInteriorProps>d__11(0)
			{
				<>4__this = this
			};
		}
	}
	public class MapGen_Networking : MonoBehaviour
	{
		public static MapGen_Networking instance;

		public bool isClient = false;

		private int sync_ID = -1;

		private int requestSync_ID = -1;

		private void Awake()
		{
			instance = this;
		}

		private void StartNetworking()
		{
			if (Networking.ServerRunning())
			{
				if (Networking.IsHost() || Client.isFullyConnected)
				{
					SetupPacketTypes();
				}
				MG_Menu.SetClientEnable(!Networking.IsHost());
				MG_Menu.SetClientDisable(Networking.IsHost());
				if (Networking.IsClient())
				{
					MG_Manager.instance.isClient = true;
					MG_Menu.instance.canGenerate = false;
					MG_Menu.instance.UpdateUI();
				}
			}
			else
			{
				MG_Menu.SetClientEnable(set: false);
			}
		}

		private void Start()
		{
			if (MapGeneratorPlugin.H3MP)
			{
				Debug.Log((object)"Map Generator: H3MP ENABLED");
				StartNetworking();
			}
		}

		private void SetupPacketTypes()
		{
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Expected O, but got Unknown
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Expected O, but got Unknown
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			if (Networking.IsHost())
			{
				if (Mod.registeredCustomPacketIDs.ContainsKey("MapGen_Sync"))
				{
					sync_ID = Mod.registeredCustomPacketIDs["MapGen_Sync"];
				}
				else
				{
					sync_ID = Server.RegisterCustomPacketType("MapGen_Sync", 0);
				}
				Mod.customPacketHandlers[sync_ID] = new CustomPacketHandler(Sync_Handler);
				if (Mod.registeredCustomPacketIDs.ContainsKey("MapGen_RequestSync"))
				{
					requestSync_ID = Mod.registeredCustomPacketIDs["MapGen_RequestSync"];
				}
				else
				{
					requestSync_ID = Server.RegisterCustomPacketType("MapGen_RequestSync", 0);
				}
				Mod.customPacketHandlers[requestSync_ID] = new CustomPacketHandler(RequestSync_Handler);
				return;
			}
			if (Mod.registeredCustomPacketIDs.ContainsKey("MapGen_Sync"))
			{
				sync_ID = Mod.registeredCustomPacketIDs["MapGen_Sync"];
				Mod.customPacketHandlers[sync_ID] = new CustomPacketHandler(Sync_Handler);
			}
			else
			{
				ClientSend.RegisterCustomPacketType("MapGen_Sync");
				Mod.CustomPacketHandlerReceived += new CustomPacketHandlerReceivedDelegate(Sync_Received);
			}
			if (Mod.registeredCustomPacketIDs.ContainsKey("MapGen_RequestSync"))
			{
				requestSync_ID = Mod.registeredCustomPacketIDs["MapGen_RequestSync"];
				Mod.customPacketHandlers[requestSync_ID] = new CustomPacketHandler(RequestSync_Handler);
			}
			else
			{
				ClientSend.RegisterCustomPacketType("MapGen_RequestSync");
				Mod.CustomPacketHandlerReceived += new CustomPacketHandlerReceivedDelegate(RequestSync_Received);
			}
		}

		public void Sync_Send()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			if (Networking.ServerRunning() && !Networking.IsClient())
			{
				Packet val = new Packet(sync_ID);
				val.Write(MG_Manager.profile.seed);
				val.Write(MG_Manager.profile.mapSize);
				val.Write(MG_Manager.profile.allScale);
				val.Write(MG_Manager.profile.generationSystem);
				val.Write(MG_Manager.profile.loadedThemes.Count);
				for (int i = 0; i < MG_Manager.profile.loadedThemes.Count; i++)
				{
					val.Write(MG_Manager.profile.loadedThemes[i]);
				}
				val.Write(MG_Manager.profile.selectedLandscape);
				val.Write(MG_Manager.profile.terrainProps);
				val.Write(MG_Manager.profile.enviromentScaleMin);
				val.Write(MG_Manager.profile.enviromentScaleMax);
				val.Write(MG_Manager.profile.enviromentProps);
				val.Write(MG_Manager.profile.interiorPropDensity);
				val.Write(MG_Manager.profile.exteriorProps);
				val.Write(MG_Manager.profile.structureCount);
				val.Write(MG_Manager.profile.hub);
				val.Write(MG_Manager.profile.oneOfAKind);
				val.Write(MG_Manager.profile.structureCityGrid);
				val.Write(MG_Manager.profile.structureSpacing);
				val.Write(MG_Manager.profile.structureSmooth);
				val.Write(MG_Manager.profile.sections);
				val.Write(MG_Manager.profile.extractionEdge);
				val.Write(MG_Manager.profile.staticSRPoint);
				val.Write(MG_Manager.profile.srLootSpawns);
				val.Write(MG_Manager.profile.grassDensity);
				val.Write(MG_Manager.instance.mapGenerated);
				ServerSend.SendTCPDataToAll(val, true);
			}
		}

		private void Sync_Handler(int clientID, Packet packet)
		{
			MG_Manager.profile.loadedThemes.Clear();
			MG_Manager.profile.seed = packet.ReadInt(true);
			MG_Manager.profile.mapSize = packet.ReadInt(true);
			MG_Manager.profile.allScale = packet.ReadFloat(true);
			MG_Manager.profile.generationSystem = packet.ReadInt(true);
			int num = packet.ReadInt(true);
			for (int i = 0; i < num; i++)
			{
				MG_Manager.profile.loadedThemes.Add(packet.ReadString(true));
			}
			MG_Manager.profile.selectedLandscape = packet.ReadString(true);
			MG_Manager.profile.terrainProps = packet.ReadInt(true);
			MG_Manager.profile.enviromentScaleMin = packet.ReadFloat(true);
			MG_Manager.profile.enviromentScaleMax = packet.ReadFloat(true);
			MG_Manager.profile.enviromentProps = packet.ReadInt(true);
			MG_Manager.profile.interiorPropDensity = packet.ReadFloat(true);
			MG_Manager.profile.exteriorProps = packet.ReadInt(true);
			MG_Manager.profile.structureCount = packet.ReadInt(true);
			MG_Manager.profile.hub = packet.ReadBool(true);
			MG_Manager.profile.oneOfAKind = packet.ReadBool(true);
			MG_Manager.profile.structureCityGrid = packet.ReadBool(true);
			MG_Manager.profile.structureSpacing = packet.ReadInt(true);
			MG_Manager.profile.structureSmooth = packet.ReadBool(true);
			MG_Manager.profile.sections = packet.ReadInt(true);
			MG_Manager.profile.extractionEdge = packet.ReadBool(true);
			MG_Manager.profile.staticSRPoint = packet.ReadBool(true);
			MG_Manager.profile.srLootSpawns = packet.ReadInt(true);
			MG_Manager.profile.grassDensity = packet.ReadFloat(true);
			MG_Menu.instance.canGenerate = packet.ReadBool(true);
			MG_Menu.instance.UpdateUI();
		}

		public void RequestSync_Send()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if (Networking.ServerRunning() && !Networking.IsHost())
			{
				Packet val = new Packet(requestSync_ID);
				ClientSend.SendTCPData(val, true);
			}
		}

		private void RequestSync_Handler(int clientID, Packet packet)
		{
			Sync_Send();
		}

		private void Sync_Received(string handlerID, int index)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			if (handlerID == "MapGen_Sync")
			{
				sync_ID = index;
				Mod.customPacketHandlers[index] = new CustomPacketHandler(Sync_Handler);
				Mod.CustomPacketHandlerReceived -= new CustomPacketHandlerReceivedDelegate(Sync_Received);
			}
		}

		private void RequestSync_Received(string handlerID, int index)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			if (handlerID == "MapGen_RequestSync")
			{
				requestSync_ID = index;
				Mod.customPacketHandlers[index] = new CustomPacketHandler(RequestSync_Handler);
				Mod.CustomPacketHandlerReceived -= new CustomPacketHandlerReceivedDelegate(RequestSync_Received);
				RequestSync_Send();
			}
		}
	}
	public class MG_Button : MonoBehaviour
	{
		public int index = -1;

		public int value = -1;

		public string sentence;

		public float amount = 0f;

		public bool isOn = false;

		public Toggle toggle;

		public Image image;

		public Color color;

		public Button button;

		public InputField inputField;

		public Text text;

		[HideInInspector]
		public MG_ModLoader.ModData modData;

		public void SetToggleButton(bool status)
		{
			isOn = status;
			((Component)image).gameObject.SetActive(status);
		}

		public void ToggleButton()
		{
			isOn = !isOn;
			((Component)image).gameObject.SetActive(isOn);
		}

		public void UpdateTheme()
		{
			if (!MG_Manager.instance.isClient)
			{
				MG_Menu.instance.ToggleTheme(index, isOn);
				MG_Menu.instance.UpdateUI();
			}
		}

		public void SelectLandscape()
		{
			MG_Menu.instance.SelectLandscape(text.text);
		}

		public void SelectProfile()
		{
			MG_Menu.instance.SetProfile(sentence);
		}
	}
	public class Vector2Int
	{
		public int x;

		public int y;

		public Vector2Int(int x, int y)
		{
			x = this.x;
			y = this.y;
		}
	}
	public class Vector3Int
	{
		public int x;

		public int y;

		public int z;

		public Vector3Int(int x, int y, int z)
		{
			x = this.x;
			y = this.y;
			z = this.z;
		}
	}
	public class MG_Manager : MonoBehaviour
	{
		public class GrassChunk
		{
			public Matrix4x4[] matrix;
		}

		public delegate void OnGeneratorReady();

		public delegate void OnGenerate();

		public delegate void OnPostTerrainGenerate();

		public delegate void OnPostPropGenerate();

		public delegate void OnGamemodePostGenerate();

		public delegate void OnPostGenerate();

		public delegate void OnPreFinalNavBake();

		[CompilerGenerated]
		private sealed class <GenerateMap>d__82 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public MG_Manager <>4__this;

			private int <i>5__1;

			private int <i>5__2;

			private int <i>5__3;

			private GameObject <hubPrefab>5__4;

			private GameObject <newHub>5__5;

			private int <i>5__6;

			private int <x>5__7;

			private int <i>5__8;

			private int <i>5__9;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<hubPrefab>5__4 = null;
				<newHub>5__5 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_06d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0410: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (Object.op_Implicit((Object)(object)<>4__this.generationIcon))
					{
						((Component)<>4__this.generationIcon.transform.parent).gameObject.SetActive(true);
					}
					if (MG_Manager.OnGenerateEvent != null)
					{
						MG_Manager.OnGenerateEvent();
					}
					MG_Menu.instance.generateButton.SetActive(false);
					Random.InitState(profile.seed);
					<>4__this.generate = false;
					<i>5__1 = 0;
					while (<i>5__1 < <>4__this.generatedObjects.Count)
					{
						Object.Destroy((Object)(object)<>4__this.generatedObjects[<i>5__1]);
						<i>5__1++;
					}
					<>4__this.generatedObjects.Clear();
					<i>5__2 = 0;
					while (<i>5__2 < MG_Menu.instance.themeLoading.Length)
					{
						MG_Menu.instance.themeLoading[<i>5__2].gameObject.SetActive(true);
						<i>5__2++;
					}
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(MG_ModLoader.instance.LoadThemes(profile.loadedThemes.ToArray()));
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<i>5__3 = 0;
					while (<i>5__3 < MG_Menu.instance.themeLoading.Length)
					{
						MG_Menu.instance.themeLoading[<i>5__3].gameObject.SetActive(false);
						<i>5__3++;
					}
					<>2__current = null;
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					if (profile.hub)
					{
						if (<>4__this.hubs.Count > 0)
						{
							<hubPrefab>5__4 = <>4__this.hubs[Random.Range(0, <>4__this.hubs.Count)];
							<newHub>5__5 = null;
							if (Object.op_Implicit((Object)(object)<hubPrefab>5__4))
							{
								<newHub>5__5 = Object.Instantiate<GameObject>(<hubPrefab>5__4, <>4__this.parentStructures);
							}
							if ((Object)(object)<newHub>5__5 == (Object)null)
							{
								<>4__this.hubStructure = <>4__this.hubDefault.transform;
							}
							else
							{
								<>4__this.hubStructure = <newHub>5__5.transform;
								<>4__this.generatedObjects.Add(<newHub>5__5);
							}
							<hubPrefab>5__4 = null;
							<newHub>5__5 = null;
						}
						else
						{
							<>4__this.hubStructure = <>4__this.hubDefault.transform;
						}
					}
					((Component)<>4__this.hubStructure).gameObject.SetActive(true);
					if ((Object)(object)<>4__this.skybox == (Object)null)
					{
						<>4__this.skybox = <>4__this.skyboxDefault;
					}
					<>4__this.skybox.transform.localScale = new Vector3((float)profile.mapSize * 2f, (float)(profile.mapSize * 2), (float)profile.mapSize * 2f);
					<>4__this.skybox.SetActive(true);
					<>4__this.SetupSections(profile.sections);
					<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.GenerateTerrain());
					<>1__state = 4;
					return true;
				case 4:
					<>1__state = -1;
					Random.InitState(profile.seed);
					if (MG_Manager.OnPostTerrainGenerateEvent != null)
					{
						MG_Manager.OnPostTerrainGenerateEvent();
					}
					Random.InitState(profile.seed);
					<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.generations[profile.generationSystem].GenerateProps());
					<>1__state = 5;
					return true;
				case 5:
					<>1__state = -1;
					Random.InitState(profile.seed);
					<i>5__6 = 0;
					while (<i>5__6 < <>4__this.generatedStructures.Count)
					{
						<x>5__7 = 0;
						while (<x>5__7 < <>4__this.generatedStructures[<i>5__6].reverbEnviroments.Length)
						{
							if ((Object)(object)<>4__this.generatedStructures[<i>5__6].reverbEnviroments[<x>5__7] != (Object)null)
							{
								<>4__this.reverbSystem.Environments.Add((FVRReverbEnvironment)(object)<>4__this.generatedStructures[<i>5__6].reverbEnviroments[<x>5__7]);
							}
							<x>5__7++;
						}
						<i>5__6++;
					}
					if ((Object)(object)<>4__this.reverbSystem != (Object)null && !<>4__this.inEditor)
					{
						<>4__this.reverbSystem.SetCurrentReverbSettings((FVRSoundEnvironment)20);
					}
					if (MG_Manager.OnPostPropGenerateEvent != null)
					{
						MG_Manager.OnPostPropGenerateEvent();
					}
					<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.SetupGamemode());
					<>1__state = 6;
					return true;
				case 6:
					<>1__state = -1;
					Random.InitState(profile.seed);
					if (MG_Manager.OnGamemodePostGenerateEvent != null)
					{
						MG_Manager.OnGamemodePostGenerateEvent();
					}
					<>4__this.surface.RemoveData();
					<>4__this.surface.size = new Vector3((float)(profile.mapSize * 2), <>4__this.raycastHeight - 1f, (float)(profile.mapSize * 2));
					<>2__current = null;
					<>1__state = 7;
					return true;
				case 7:
					<>1__state = -1;
					Random.InitState(profile.seed);
					<>4__this.surface.BuildNavMesh();
					<>2__current = null;
					<>1__state = 8;
					return true;
				case 8:
					<>1__state = -1;
					Random.InitState(profile.seed + 5);
					<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.generations[profile.generationSystem].GenerateInteriorProps());
					<>1__state = 9;
					return true;
				case 9:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 10;
					return true;
				case 10:
					<>1__state = -1;
					if (MG_Manager.OnPreFinalNavBakeEvent != null)
					{
						MG_Manager.OnPreFinalNavBakeEvent();
					}
					<>4__this.surface.RemoveData();
					Random.InitState(profile.seed);
					<>4__this.surface.BuildNavMesh();
					<>2__current = null;
					<>1__state = 11;
					return true;
				case 11:
					<>1__state = -1;
					((Collider)ItemCatcher.instance.floorCollision).enabled = true;
					((Component)ItemCatcher.instance).gameObject.layer = LayerMask.NameToLayer("Environment");
					Random.InitState(profile.seed);
					<i>5__8 = 0;
					while (<i>5__8 < <>4__this.disableOnGenerate.Length)
					{
						<>4__this.disableOnGenerate[<i>5__8].SetActive(false);
						<i>5__8++;
					}
					if (MG_Manager.OnPostGenerateEvent != null)
					{
						MG_Manager.OnPostGenerateEvent();
					}
					Debug.Log((object)"Map Generator: Generation Complete");
					if ((Object)(object)MG_Menu.instance.gamemodePostGenerate[(int)<>4__this.gamemode] != (Object)null)
					{
						MG_Menu.instance.gamemodePostGenerate[(int)<>4__this.gamemode].gameObject.SetActive(true);
					}
					<i>5__9 = 0;
					while (<i>5__9 < MG_Menu.instance.postGenerate.Length)
					{
						MG_Menu.instance.postGenerate[<i>5__9].SetActive(true);
						<i>5__9++;
					}
					if (Object.op_Implicit((Object)(object)<>4__this.generationIcon))
					{
						((Component)<>4__this.generationIcon.transform.parent).gameObject.SetActive(false);
					}
					<>4__this.mapGenerated = true;
					return false;
				}
			}

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

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

		[CompilerGenerated]
		private sealed class <GenerateTerrain>d__88 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public MG_Manager <>4__this;

			private int <boarderSize>5__1;

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

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

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

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

			private bool MoveNext()
			{
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<boarderSize>5__1 = (profile.mapSize - <>4__this.generationBuffer) * 2;
					<>4__this.baseTerrainBase.localScale = new Vector3((float)profile.mapSize * 2.05f, (float)profile.mapSize * 2f, (float)profile.mapSize * 2.05f);
					<>4__this.terrainManager.startPosition = new Vector2((float)(profile.seed * profile.mapSize), (float)(profile.seed * profile.mapSize));
					<>4__this.terrainManager.selectedLandscape = MG_ModLoader.GetLandscape(profile.selectedLandscape);
					if ((Object)(object)<>4__this.terrainManager.selectedLandscape == (Object)null)
					{
						Debug.LogError((object)"Map Generator: No Landscape Selected! Reverting to default landscape");
					}
					else
					{
						Debug.Log((object)("Map Generator: Selected Landscape - " + <>4__this.terrainManager.selectedLandscape.title));
					}
					<>2__current = <>4__this.terrainManager.Setup();
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					return false;
				}
			}

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

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

		[CompilerGenerated]
		private sealed class <SetupGamemode>d__85 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public MG_Manager <>4__this;

			private GamemodeEnum <>s__1;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					GamemodeEnum gamemode = <>4__this.gamemode;
					<>s__1 = gamemode;
					switch (<>s__1)
					{
					case GamemodeEnum.SupplyRaid:
						<>2__current = <>4__this.SetupSupplyRaid();
						<>1__state = 1;
						return true;
					}
					break;
				}
				case 1:
					<>1__state = -1;
					break;
				}
				return false;
			}

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

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

		[CompilerGenerated]
		private sealed class <SetupSupplyRaid>d__86 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public MG_Manager <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.gamemodes[(int)<>4__this.gamemode].GetComponent<SupplyRaidGame>().SetupSupplyPoints());
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					return false;
				}
			}

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

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

		public static MG_Manager instance;

		public bool inEditor = false;

		public bool generate = false;

		public GamemodeEnum gamemode = GamemodeEnum.Sandbox;

		public GameObject[] gamemodes;

		public bool mapGenerated = false;

		public bool isClient = false;

		public int generationBuffer = 16;

		[SerializeField]
		public static GenerationProfile profile = new GenerationProfile();

		private float extractionTimer = 10f;

		public Transform respawnPoint;

		public GameObject generationIcon;

		[Header("Audio")]
		public AudioSource backgroundSource;

		private bool isOutside = false;

		public float volumeOutside = 1f;

		public float volumeInside = 0.5f;

		public float volumeMaster = 1f;

		[Header("Terrain")]
		public TerrainManager terrainManager;

		[Header("Generation Objects")]
		public FVRReverbSystem reverbSystem;

		public Generation_Core[] generations;

		public LayerMask enviromentMask;

		public NavMeshSurface surface;

		public Mesh grassMesh;

		[Header("Hub")]
		public GameObject[] disableOnGenerate;

		public Transform hubStructure;

		public GameObject hubDefault;

		public GameObject skyboxDefault;

		[Header("Parents")]
		[HideInInspector]
		public GameObject skybox;

		public Transform baseTerrainBase;

		public Transform parentTerrain;

		public Transform parentEnviroment;

		public Transform parentStructures;

		public Transform parentExteriorProps;

		public Transform parentGrass;

		[Header("Generation Collection")]
		public List<GameObject> hubs = new List<GameObject>();

		public List<GameObject> interiorProps = new List<GameObject>();

		public List<GameObject> exteriorProps = new List<GameObject>();

		public List<GameObject> enviromental = new List<GameObject>();

		public List<GameObject> terrain = new List<GameObject>();

		public List<GameObject> structures = new List<GameObject>();

		public List<GameObject> oneOfAKind = new List<GameObject>();

		public MG_Package.MatDefEnum atlasMatDef = MG_Package.MatDefEnum.Ground_Dirt;

		[HideInInspector]
		public float raycastHeight = 125f;

		public List<GameObject> generatedObjects = new List<GameObject>();

		public List<MG_Structure> generatedStructures = new List<MG_Structure>();

		public List<GrassChunk> generatedGrass = new List<GrassChunk>();

		public static Section[] sections;

		private const float sectionBuffer = 0.1f;

		public static event OnGeneratorReady OnGeneratorReadyEvent;

		public static event OnGenerate OnGenerateEvent;

		public static event OnPostTerrainGenerate OnPostTerrainGenerateEvent;

		public static event OnPostPropGenerate OnPostPropGenerateEvent;

		public static event OnGamemodePostGenerate OnGamemodePostGenerateEvent;

		public static event OnPostGenerate OnPostGenerateEvent;

		public static event OnPreFinalNavBake OnPreFinalNavBakeEvent;

		private void Awake()
		{
			instance = this;
		}

		private void Start()
		{
			profile = new GenerationProfile();
			profile.seed = Random.Range(0, 100);
		}

		private void Update()
		{
			AudioManagerUpdate();
			if (MG_ModLoader.modsLoaded)
			{
				MG_ModLoader.modsLoaded = false;
				Debug.Log((object)"Map Generator Manager Started");
				for (int i = 0; i < disableOnGenerate.Length; i++)
				{
					if ((Object)(object)disableOnGenerate[i] != (Object)null)
					{
						disableOnGenerate[i].SetActive(true);
					}
				}
				MG_Menu.instance.PopulateThemes();
				MG_Menu.instance.PopulateLandscapes();
				if (MG_Manager.OnGeneratorReadyEvent != null)
				{
					MG_Manager.OnGeneratorReadyEvent();
				}
			}
			if (generationIcon.activeSelf)
			{
				generationIcon.transform.Rotate(0f, 0f, -90f * Time.deltaTime, (Space)1);
			}
			if (generate)
			{
				((MonoBehaviour)this).StartCoroutine(GenerateMap());
			}
			if (profile.extractionEdge)
			{
				PlayerOutsideMap();
			}
			if (generatedGrass != null)
			{
				for (int j = 0; j < generatedGrass.Count; j++)
				{
					Graphics.DrawMeshInstanced(grassMesh, 0, TerrainManager.instance.landscapeMaterial, generatedGrass[j].matrix);
				}
			}
		}

		private void PlayerOutsideMap()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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)
			if ((Object)(object)GM.CurrentPlayerBody == (Object)null)
			{
				return;
			}
			Vector3 position = ((Component)GM.CurrentPlayerBody).transform.position;
			if (position.x >= (float)(profile.mapSize - 5) || position.x <= (float)(-profile.mapSize + 5) || position.z >= (float)(profile.mapSize - 5) || position.z <= (float)(-profile.mapSize + 5))
			{
				extractionTimer -= Time.deltaTime;
				if (extractionTimer <= 0f)
				{
					FVRMovementManager currentMovementManager = GM.CurrentMovementManager;
					Vector3 position2 = respawnPoint.position;
					Quaternion rotation = respawnPoint.rotation;
					currentMovementManager.TeleportToPoint(position2, true, ((Quaternion)(ref rotation)).eulerAngles);
				}
				((Component)((Component)MG_Menu.instance.countDownText).transform.parent).gameObject.SetActive(true);
				MG_Menu.instance.countDownText.text = Mathf.RoundToInt(extractionTimer).ToString();
				((Component)MG_Menu.instance.countDownText).transform.parent.position = ((Component)GM.CurrentPlayerBody.Head).transform.position;
				((Component)MG_Menu.instance.countDownText).transform.parent.rotation = ((Component)GM.CurrentPlayerBody.Head).transform.rotation;
			}
			else if (extractionTimer != 10f)
			{
				extractionTimer = 10f;
				MG_Menu.instance.countDownText.text = "10";
				((Component)((Component)MG_Menu.instance.countDownText).transform.parent).gameObject.SetActive(false);
			}
		}

		private void AudioManagerUpdate()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_0051: 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_0054: Invalid comparison between Unknown and I4
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Invalid comparison between Unknown and I4
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Invalid comparison between Unknown and I4
			if (!((Object)(object)backgroundSource.clip == (Object)null) && !((Object)(object)reverbSystem == (Object)null) && !((Object)(object)reverbSystem.CurrentReverbEnvironment == (Object)null))
			{
				FVRSoundEnvironment environment = reverbSystem.CurrentReverbEnvironment.Environment;
				FVRSoundEnvironment val = environment;
				if ((int)val <= 1 || val - 20 <= 2 || (int)val == 31)
				{
					isOutside = true;
				}
				else
				{
					isOutside = false;
				}
				backgroundSource.volume = Mathf.MoveTowards(backgroundSource.volume, isOutside ? (volumeOutside * volumeMaster) : (volumeInside * volumeMaster), Time.deltaTime * 0.5f);
			}
		}

		private IEnumerator GenerateMap()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GenerateMap>d__82(0)
			{
				<>4__this = this
			};
		}

		private void SetGamemode(GamemodeEnum mode)
		{
			switch (mode)
			{
			case GamemodeEnum.SupplyRaid:
				if (MapGeneratorPlugin.SupplyRaid)
				{
					gamemode = GamemodeEnum.SupplyRaid;
					return;
				}
				break;
			case GamemodeEnum.TakeAndHold:
				if (MapGeneratorPlugin.TakeAndHold)
				{
					gamemode = GamemodeEnum.TakeAndHold;
					return;
				}
				break;
			case GamemodeEnum.Survival:
				if (MapGeneratorPlugin.Survival)
				{
					gamemode = GamemodeEnum.Survival;
					return;
				}
				break;
			}
			gamemode = GamemodeEnum.Sandbox;
		}

		public void SetGamemode(int i)
		{
			gamemode = (GamemodeEnum)i;
			MG_Menu.instance.gamemodeMenu.SetActive(false);
			MG_Menu.instance.EnableSettings();
			if ((Object)(object)gamemodes[i] != (Object)null)
			{
				gamemodes[i].SetActive(true);
			}
		}

		private IEnumerator SetupGamemode()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SetupGamemode>d__85(0)
			{
				<>4__this = this
			};
		}

		private IEnumerator SetupSupplyRaid()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SetupSupplyRaid>d__86(0)
			{
				<>4__this = this
			};
		}

		public Vector3 PhysicsCast(Vector3 start)
		{
			//IL_0003: 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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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)
			Ray val = default(Ray);
			((Ray)(ref val)).direction = Vector3.down;
			Ray val2 = val;
			Vector3 point = default(Vector3);
			((Vector3)(ref point))..ctor(start.x, raycastHeight, start.z);
			((Ray)(ref val2)).origin = point;
			RaycastHit val3 = default(RaycastHit);
			if (Physics.Raycast(val2, ref val3, raycastHeight + 1f, LayerMask.op_Implicit(enviromentMask)))
			{
				point = ((RaycastHit)(ref val3)).point;
				return point;
			}
			return point;
		}

		private IEnumerator GenerateTerrain()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GenerateTerrain>d__88(0)
			{
				<>4__this = this
			};
		}

		public Vector3 GetRandomMapPosition()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			float num = profile.mapSize - generationBuffer;
			Vector3 result = default(Vector3);
			((Vector3)(ref result))..ctor(Random.Range(0f - num, num), raycastHeight, Random.Range(0f - num, num));
			return result;
		}

		public Vector3 GetRandomMapPositionGrid(int spacing)
		{
			//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_0060: Unknown result type (might be due to invalid IL or missing references)
			int num = profile.mapSize - generationBuffer;
			int num2 = num * 2 / spacing;
			float num3 = Random.Range(0, num2 + 1);
			float num4 = Random.Range(0, num2 + 1);
			num3 -= (float)num2 * 0.5f;
			num4 -= (float)num2 * 0.5f;
			num3 *= (float)spacing;
			num4 *= (float)spacing;
			return new Vector3(num3, raycastHeight, num4);
		}

		public void TeleportPlayerToRandomPosition()
		{
			//IL_006c: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_0098: 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_00c5: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0059: Unknown result type (might be due to invalid IL or missing references)
			if (profile.hub)
			{
				MG_Structure component = ((Component)hubStructure).GetComponent<MG_Structure>();
				if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.playerSpawn))
				{
					FVRMovementManager currentMovementManager = GM.CurrentMovementManager;
					Vector3 position = component.playerSpawn.position;
					Quaternion rotation = component.playerSpawn.rotation;
					currentMovementManager.TeleportToPoint(position, true, ((Quaternion)(ref rotation)).eulerAngles);
					return;
				}
			}
			RaycastHit val = default(RaycastHit);
			Ray val2 = default(Ray);
			((Ray)(ref val2)).origin = GetRandomMapPosition();
			((Ray)(ref val2)).direction = Vector3.down;
			Ray val3 = val2;
			if (Physics.Raycast(val3, ref val, raycastHeight + 1f, LayerMask.op_Implicit(enviromentMask)))
			{
				GM.CurrentMovementManager.TeleportToPoint(((RaycastHit)(ref val)).point, true, Vector3.up * (float)Random.Range(-180, 180));
			}
		}

		public void SetGenerate()
		{
			generate = true;
		}

		public void SetupSections(int count)
		{
			sections = new Section[count];
			switch (count)
			{
			case 2:
				sections[0] = new Section(0.05f, 0.5f, 0.05f, 0.95f, 0.1f);
				sections[1] = new Section(0.5f, 0.95f, 0.05f, 0.95f, 0.1f);
				break;
			case 3:
				sections[0] = new Section(0.33f, 0.64f, 0.05f, 0.95f, 0.1f);
				sections[1] = new Section(0.05f, 0.33f, 0.05f, 0.95f, 0.1f);
				sections[2] = new Section(0.64f, 0.95f, 0.05f, 0.95f, 0.1f);
				break;
			case 4:
				sections[0] = new Section(0.05f, 0.5f, 0.05f, 0.5f, 0.1f);
				sections[1] = new Section(0.5f, 0.95f, 0.05f, 0.5f, 0.1f);
				sections[2] = new Section(0.05f, 0.5f, 0.5f, 0.95f, 0.1f);
				sections[3] = new Section(0.5f, 0.95f, 0.5f, 0.95f, 0.1f);
				break;
			default:
				sections[0] = new Section(0.33f, 0.67f, 0.33f, 0.67f, 0.1f);
				sections[1] = new Section(0.05f, 0.33f, 0.05f, 0.33f, 0.1f);
				sections[2] = new Section(0.67f, 0.95f, 0.05f, 0.33f, 0.1f);
				sections[3] = new Section(0.05f, 0.33f, 0.67f, 0.95f, 0.1f);
				sections[4] = new Section(0.67f, 0.95f, 0.67f, 0.95f, 0.1f);
				break;
			case 6:
				sections[0] = new Section(0.05f, 0.5f, 0.67f, 0.95f, 0.1f);
				sections[1] = new Section(0.5f, 0.95f, 0.67f, 0.95f, 0.1f);
				sections[2] = new Section(0.05f, 0.5f, 0.05f, 0.33f, 0.1f);
				sections[3] = new Section(0.5f, 0.95f, 0.05f, 0.33f, 0.1f);
				sections[4] = new Section(0.05f, 0.5f, 0.33f, 0.67f, 0.1f);
				sections[5] = new Section(0.5f, 0.95f, 0.33f, 0.67f, 0.1f);
				break;
			case 7:
				sections[0] = new Section(0.05f, 0.33f, 0.33f, 0.64f, 0.1f);
				sections[1] = new Section(0.33f, 0.64f, 0.33f, 0.64f, 0.1f);
				sections[2] = new Section(0.64f, 0.95f, 0.33f, 0.64f, 0.1f);
				sections[3] = new Section(0.05f, 0.5f, 0.05f, 0.33f, 0.1f);
				sections[4] = new Section(0.5f, 0.95f, 0.05f, 0.33f, 0.1f);
				sections[5] = new Section(0.05f, 0.5f, 0.33f, 0.67f, 0.1f);
				sections[6] = new Section(0.5f, 0.95f, 0.33f, 0.67f, 0.1f);
				break;
			case 8:
				sections[0] = new Section(0.05f, 0.33f, 0.33f, 0.64f, 0.1f);
				sections[1] = new Section(0.64f, 0.95f, 0.33f, 0.64f, 0.1f);
				sections[2] = new Section(0.05f, 0.33f, 0.05f, 0.33f, 0.1f);
				sections[3] = new Section(0.33f, 0.64f, 0.05f, 0.33f, 0.1f);
				sections[4] = new Section(0.64f, 0.95f, 0.05f, 0.33f, 0.1f);
				sections[5] = new Section(0.05f, 0.33f, 0.64f, 0.95f, 0.1f);
				sections[6] = new Section(0.33f, 0.64f, 0.64f, 0.95f, 0.1f);
				sections[7] = new Section(0.64f, 0.95f, 0.64f, 0.95f, 0.1f);
				break;
			case 9:
				sections[0] = new Section(0.05f, 0.33f, 0.33f, 0.64f, 0.1f);
				sections[1] = new Section(0.33f, 0.64f, 0.33f, 0.64f, 0.1f);
				sections[2] = new Section(0.64f, 0.95f, 0.33f, 0.64f, 0.1f);
				sections[3] = new Section(0.05f, 0.33f, 0.05f, 0.33f, 0.1f);
				sections[4] = new Section(0.33f, 0.64f, 0.05f, 0.33f, 0.1f);
				sections[5] = new Section(0.64f, 0.95f, 0.05f, 0.33f, 0.1f);
				sections[6] = new Section(0.05f, 0.33f, 0.64f, 0.95f, 0.1f);
				sections[7] = new Section(0.33f, 0.64f, 0.64f, 0.95f, 0.1f);
				sections[8] = new Section(0.64f, 0.95f, 0.64f, 0.95f, 0.1f);
				break;
			}
		}
	}
	public class Section
	{
		public float minX;

		public float minZ;

		public float maxX;

		public float maxZ;

		public bool isFlat = false;

		public Section(float xMin, float xMax, float zMin, float zMax, float buffer)
		{
			float num = (xMax - xMin) * buffer;
			float num2 = (zMax - zMin) * buffer;
			minX = xMin + num;
			minZ = zMin + num2;
			maxX = xMax - num;
			maxZ = zMax - num2;
		}
	}
	public enum GamemodeEnum
	{
		Sandbox,
		SupplyRaid,
		TakeAndHold,
		Survival
	}
	public class MG_Menu : MonoBehaviour
	{
		public static MG_Menu instance;

		private GenerationProfile profile;

		[Header("Menu")]
		[HideInInspector]
		public bool canGenerate = true;

		public GameObject generateButton;

		public GameObject settingsMenus;

		private int maxProps = 2048;

		public int propMin = 64;

		public int propLimit = 192;

		[SerializeField]
		private Color redText = new Color(0.75f, 0.25f, 0.25f, 1f);

		[Header("H3MP")]
		public GameObject networkObject;

		public GameObject[] disableClient;

		public GameObject[] enableClient;

		[Header("Settings")]
		public Text mapSizeText;

		public Text seedText;

		public Text structureText;

		public Text terrainText;

		public Text interiorPropsText;

		public Text exteriorPropsText;

		public Text enviromentalText;

		public Text oneOfAKindText;

		public Text hubText;

		public Text staticSRPointText;

		public Text sectionsText;

		public Text structureCityGridText;

		public Text structureSpacingText;

		public Text structureSmoothText;

		public Text volumeText;

		public Text SRLootText;

		public Text extractionText;

		public Text grassText;

		[Header("Gamemodes")]
		public GameObject gamemodeMenu;

		public GameObject[] gamemodeButtons;

		public GameObject[] gamemodePostGenerate;

		public GameObject[] postGenerate;

		[Header("Themes")]
		public Image themePreview;

		public Text themeTitle;

		public Text themeDescription;

		public GameObject themeBtnPrefab;

		[HideInInspector]
		public List<MG_Button> themeButtons = new List<MG_Button>();

		[HideInInspector]
		private MG_Button themeMain;

		public GameObject[] themeLoading;

		[Header("Landscapes")]
		public Image landscapePreview;

		public Text landscapeTitle;

		public Text landscapeDescription;

		public GameObject landscapeBtnPrefab;

		[Header("Profiles")]
		public GameObject profileMenu;

		public InputField profileInput;

		public GameObject profileBtnPrefab;

		public List<MG_Button> profileButtons = new List<MG_Button>();

		public MG_Button profileSelected;

		[Header("Leaving Zone")]
		public Text countDownText;

		[Header("Debug")]
		public GameObject navigator;

		private void Awake()
		{
			instance = this;
		}

		private void Start()
		{
			profile = MG_Manager.profile;
			settingsMenus.SetActive(false);
			gamemodeMenu.SetActive(true);
			gamemodeButtons[1].SetActive(MapGeneratorPlugin.SupplyRaid);
			gamemodeButtons[2].SetActive(MapGeneratorPlugin.TakeAndHold);
			gamemodeButtons[3].SetActive(MapGeneratorPlugin.Survival);
			gamemodePostGenerate[0].gameObject.SetActive(false);
			networkObject.SetActive(MapGeneratorPlugin.H3MP);
		}

		public void GenerateButton()
		{
			((Component)this).gameObject.SetActive(false);
		}

		public void ToggleNavigator()
		{
			navigator.SetActive(!navigator.activeSelf);
		}

		public void EnableSettings()
		{
			settingsMenus.SetActive(true);
			UpdateUI();
			profileMenu.SetActive(true);
			switch (MG_Manager.instance.gamemode)
			{
			case GamemodeEnum.SupplyRaid:
				((Component)((Component)SRLootText).transform.parent).gameObject.SetActive(false);
				return;
			case GamemodeEnum.TakeAndHold:
				return;
			case GamemodeEnum.Survival:
				return;
			}
			((Component)((Component)sectionsText).transform.parent).gameObject.SetActive(false);
			((Component)((Component)staticSRPointText).transform.parent).gameObject.SetActive(false);
			((Component)((Component)SRLootText).transform.parent).gameObject.SetActive(false);
		}

		public void PopulateProfiles()
		{
			for (int i = 0; i < profileButtons.Count; i++)
			{
				Object.Destroy((Object)(object)((Component)profileButtons[i]).gameObject);
			}
			profileButtons.Clear();
			for (int j = 0; j < MG_ModLoader.profiles.Count; j++)
			{
				if (MG_ModLoader.profiles[j] != null)
				{
					MG_Butt

Packers_MapGenerator.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using Atlas;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEditor;
using UnityEngine;
using UnityEngine.Profiling;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace Packer.Packers_MapGenerator;

[BepInPlugin("Packer.Packers_MapGenerator", "Packers_MapGenerator", "1.1.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("nrgill28.Atlas", "1.0.1")]
public class Packers_MapGeneratorPlugin : BaseUnityPlugin
{
	private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

	internal static ManualLogSource Logger;

	private void Awake()
	{
		Logger = ((BaseUnityPlugin)this).Logger;
		LoadAssets();
	}

	private void LoadAssets()
	{
		Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "Packer.Packers_MapGenerator");
		AtlasPlugin.RegisterScene(Path.Combine(BasePath, "packers_mapgenerator"));
	}
}
public class TOD_Animation : MonoBehaviour
{
	[Tooltip("How much to move the clouds when the camera moves.")]
	[TOD_Min(0f)]
	public float CameraMovement = 1f;

	[Tooltip("Wind direction in degrees.")]
	[TOD_Range(0f, 360f)]
	public float WindDegrees = 0f;

	[Tooltip("Speed of the wind that is acting on the clouds.")]
	[TOD_Min(0f)]
	public float WindSpeed = 1f;

	private TOD_Sky sky;

	public Vector3 CloudUV { get; set; }

	public Vector3 OffsetUV
	{
		get
		{
			//IL_0007: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)this).transform.position * (CameraMovement * 0.0001f);
			Quaternion rotation = ((Component)this).transform.rotation;
			Quaternion val2 = Quaternion.Euler(0f, 0f - ((Quaternion)(ref rotation)).eulerAngles.y, 0f);
			return val2 * val;
		}
	}

	protected void Start()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		sky = ((Component)this).GetComponent<TOD_Sky>();
		CloudUV = new Vector3(Random.value, Random.value, Random.value);
	}

	protected void Update()
	{
		//IL_003b: 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_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: 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)
		float num = Mathf.Sin((float)Math.PI / 180f * WindDegrees);
		float num2 = Mathf.Cos((float)Math.PI / 180f * WindDegrees);
		float num3 = 0.001f * Time.deltaTime;
		float num4 = WindSpeed * num3;
		float x = CloudUV.x;
		float y = CloudUV.y;
		float z = CloudUV.z;
		y += num3 * 0.1f;
		x -= num4 * num;
		z -= num4 * num2;
		x -= Mathf.Floor(x);
		y -= Mathf.Floor(y);
		z -= Mathf.Floor(z);
		CloudUV = new Vector3(x, y, z);
		sky.Components.BillboardTransform.localRotation = Quaternion.Euler(0f, y * 360f, 0f);
	}
}
[AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)]
public class TOD_MinAttribute : PropertyAttribute
{
	public float min;

	public TOD_MinAttribute(float min)
	{
		this.min = min;
	}
}
[AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)]
public class TOD_MaxAttribute : PropertyAttribute
{
	public float max;

	public TOD_MaxAttribute(float max)
	{
		this.max = max;
	}
}
[AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)]
public class TOD_RangeAttribute : PropertyAttribute
{
	public float min;

	public float max;

	public TOD_RangeAttribute(float min, float max)
	{
		this.min = min;
		this.max = max;
	}
}
public class TOD_Billboard : MonoBehaviour
{
	public float Altitude = 0f;

	public float Azimuth = 0f;

	public float Distance = 1f;

	public float Size = 1f;

	private T GetComponentInParents<T>() where T : Component
	{
		Transform val = ((Component)this).transform;
		T component = ((Component)val).GetComponent<T>();
		while ((Object)(object)component == (Object)null && (Object)(object)val.parent != (Object)null)
		{
			val = val.parent;
			component = ((Component)val).GetComponent<T>();
		}
		return component;
	}

	protected void OnValidate()
	{
		//IL_0042: 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_004e: 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_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: 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_00c9: 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)
		TOD_Sky componentInParents = GetComponentInParents<TOD_Sky>();
		if (!((Object)(object)componentInParents == (Object)null))
		{
			float theta = (90f - Altitude) * ((float)Math.PI / 180f);
			float phi = Azimuth * ((float)Math.PI / 180f);
			Vector3 val = componentInParents.OrbitalToUnity(Distance, theta, phi);
			if (((Component)this).transform.localPosition != val)
			{
				((Component)this).transform.localPosition = val;
			}
			float num = 2f * Mathf.Tan((float)Math.PI / 90f * Size);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(num, num, num);
			if (((Component)this).transform.localScale != val2)
			{
				((Component)this).transform.localScale = val2;
			}
			((Component)this).transform.LookAt(((Component)componentInParents).transform.position, Vector3.up);
		}
	}
}
[ExecuteInEditMode]
[RequireComponent(typeof(Camera))]
[AddComponentMenu("Time of Day/Camera Main Script")]
public class TOD_Camera : MonoBehaviour
{
	public TOD_Sky sky;

	public bool DomePosToCamera = true;

	public Vector3 DomePosOffset = Vector3.zero;

	public bool DomeScaleToFarClip = true;

	public float DomeScaleFactor = 0.95f;

	private Camera cameraComponent = null;

	private Transform cameraTransform = null;

	public bool HDR => Object.op_Implicit((Object)(object)cameraComponent) && cameraComponent.allowHDR;

	public float NearClipPlane => (!Object.op_Implicit((Object)(object)cameraComponent)) ? 0.1f : cameraComponent.nearClipPlane;

	public float FarClipPlane => (!Object.op_Implicit((Object)(object)cameraComponent)) ? 1000f : cameraComponent.farClipPlane;

	public Color BackgroundColor => (!Object.op_Implicit((Object)(object)cameraComponent)) ? Color.black : cameraComponent.backgroundColor;

	protected void OnValidate()
	{
		DomeScaleFactor = Mathf.Clamp(DomeScaleFactor, 0.01f, 1f);
	}

	protected void OnEnable()
	{
		cameraComponent = ((Component)this).GetComponent<Camera>();
		cameraTransform = ((Component)this).GetComponent<Transform>();
		if (!Object.op_Implicit((Object)(object)sky))
		{
			sky = FindSky(fallback: true);
		}
	}

	protected void Update()
	{
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Invalid comparison between Unknown and I4
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)sky))
		{
			sky = FindSky();
		}
		if (Object.op_Implicit((Object)(object)sky) && sky.Initialized)
		{
			sky.Components.Camera = this;
			if ((int)cameraComponent.clearFlags != 2)
			{
				cameraComponent.clearFlags = (CameraClearFlags)2;
			}
			if (cameraComponent.backgroundColor != Color.clear)
			{
				cameraComponent.backgroundColor = Color.clear;
			}
			if ((Object)(object)RenderSettings.skybox != (Object)(object)sky.Resources.NewSkybox)
			{
				RenderSettings.skybox = sky.Resources.NewSkybox;
				DynamicGI.UpdateEnvironment();
			}
		}
	}

	protected void OnPreCull()
	{
		if (!Object.op_Implicit((Object)(object)sky))
		{
			sky = FindSky();
		}
		if (Object.op_Implicit((Object)(object)sky) && sky.Initialized)
		{
			if (DomeScaleToFarClip)
			{
				DoDomeScaleToFarClip();
			}
			if (DomePosToCamera)
			{
				DoDomePosToCamera();
			}
		}
	}

	private TOD_Sky FindSky(bool fallback = false)
	{
		if (Object.op_Implicit((Object)(object)TOD_Sky.Instance))
		{
			return TOD_Sky.Instance;
		}
		if (fallback)
		{
			return Object.FindObjectOfType(typeof(TOD_Sky)) as TOD_Sky;
		}
		return null;
	}

	public void DoDomeScaleToFarClip()
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		float num = DomeScaleFactor * cameraComponent.farClipPlane;
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(num, num, num);
		if (sky.Components.DomeTransform.localScale != val)
		{
			sky.Components.DomeTransform.localScale = val;
		}
	}

	public void DoDomePosToCamera()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: 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_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: 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_0059: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = cameraTransform.position + cameraTransform.rotation * DomePosOffset;
		if (sky.Components.DomeTransform.position != val)
		{
			sky.Components.DomeTransform.position = val;
		}
	}
}
[ExecuteInEditMode]
public class TOD_Components : MonoBehaviour
{
	public GameObject Space = null;

	public GameObject Stars = null;

	public GameObject Sun = null;

	public GameObject Moon = null;

	public GameObject Atmosphere = null;

	public GameObject Clear = null;

	public GameObject Clouds = null;

	public GameObject Billboards = null;

	public GameObject Light = null;

	public Transform DomeTransform { get; set; }

	public Transform SpaceTransform { get; set; }

	public Transform StarTransform { get; set; }

	public Transform SunTransform { get; set; }

	public Transform MoonTransform { get; set; }

	public Transform AtmosphereTransform { get; set; }

	public Transform ClearTransform { get; set; }

	public Transform CloudTransform { get; set; }

	public Transform BillboardTransform { get; set; }

	public Transform LightTransform { get; set; }

	public Renderer SpaceRenderer { get; set; }

	public Renderer StarRenderer { get; set; }

	public Renderer SunRenderer { get; set; }

	public Renderer MoonRenderer { get; set; }

	public Renderer AtmosphereRenderer { get; set; }

	public Renderer ClearRenderer { get; set; }

	public Renderer CloudRenderer { get; set; }

	public Renderer[] BillboardRenderers { get; set; }

	public MeshFilter SpaceMeshFilter { get; set; }

	public MeshFilter StarMeshFilter { get; set; }

	public MeshFilter SunMeshFilter { get; set; }

	public MeshFilter MoonMeshFilter { get; set; }

	public MeshFilter AtmosphereMeshFilter { get; set; }

	public MeshFilter ClearMeshFilter { get; set; }

	public MeshFilter CloudMeshFilter { get; set; }

	public MeshFilter[] BillboardMeshFilters { get; set; }

	public Material SpaceMaterial { get; set; }

	public Material StarMaterial { get; set; }

	public Material SunMaterial { get; set; }

	public Material MoonMaterial { get; set; }

	public Material AtmosphereMaterial { get; set; }

	public Material ClearMaterial { get; set; }

	public Material CloudMaterial { get; set; }

	public Material[] BillboardMaterials { get; set; }

	public Light LightSource { get; set; }

	public TOD_Sky Sky { get; set; }

	public TOD_Animation Animation { get; set; }

	public TOD_Time Time { get; set; }

	public TOD_Camera Camera { get; set; }

	public TOD_Rays Rays { get; set; }

	public TOD_Scattering Scattering { get; set; }

	public TOD_Shadows Shadows { get; set; }

	public void Initialize()
	{
		DomeTransform = ((Component)this).GetComponent<Transform>();
		Sky = ((Component)this).GetComponent<TOD_Sky>();
		Animation = ((Component)this).GetComponent<TOD_Animation>();
		Time = ((Component)this).GetComponent<TOD_Time>();
		if (Object.op_Implicit((Object)(object)Space))
		{
			SpaceTransform = Space.GetComponent<Transform>();
			SpaceRenderer = Space.GetComponent<Renderer>();
			SpaceMeshFilter = Space.GetComponent<MeshFilter>();
			SpaceMaterial = SpaceRenderer.sharedMaterial;
		}
		if (Object.op_Implicit((Object)(object)Stars))
		{
			StarTransform = Stars.GetComponent<Transform>();
			StarRenderer = Stars.GetComponent<Renderer>();
			StarMeshFilter = Stars.GetComponent<MeshFilter>();
			StarMaterial = StarRenderer.sharedMaterial;
		}
		if (Object.op_Implicit((Object)(object)Sun))
		{
			SunTransform = Sun.GetComponent<Transform>();
			SunRenderer = Sun.GetComponent<Renderer>();
			SunMeshFilter = Sun.GetComponent<MeshFilter>();
			SunMaterial = SunRenderer.sharedMaterial;
		}
		if (Object.op_Implicit((Object)(object)Moon))
		{
			MoonTransform = Moon.GetComponent<Transform>();
			MoonRenderer = Moon.GetComponent<Renderer>();
			MoonMeshFilter = Moon.GetComponent<MeshFilter>();
			MoonMaterial = MoonRenderer.sharedMaterial;
		}
		if (Object.op_Implicit((Object)(object)Atmosphere))
		{
			AtmosphereTransform = Atmosphere.GetComponent<Transform>();
			AtmosphereRenderer = Atmosphere.GetComponent<Renderer>();
			AtmosphereMeshFilter = Atmosphere.GetComponent<MeshFilter>();
			AtmosphereMaterial = AtmosphereRenderer.sharedMaterial;
		}
		if (Object.op_Implicit((Object)(object)Clear))
		{
			ClearTransform = Clear.GetComponent<Transform>();
			ClearRenderer = Clear.GetComponent<Renderer>();
			ClearMeshFilter = Clear.GetComponent<MeshFilter>();
			ClearMaterial = ClearRenderer.sharedMaterial;
		}
		if (Object.op_Implicit((Object)(object)Clouds))
		{
			CloudTransform = Clouds.GetComponent<Transform>();
			CloudRenderer = Clouds.GetComponent<Renderer>();
			CloudMeshFilter = Clouds.GetComponent<MeshFilter>();
			CloudMaterial = CloudRenderer.sharedMaterial;
		}
		if (Object.op_Implicit((Object)(object)Billboards))
		{
			BillboardTransform = Billboards.GetComponent<Transform>();
			BillboardRenderers = Billboards.GetComponentsInChildren<Renderer>();
			BillboardMeshFilters = Billboards.GetComponentsInChildren<MeshFilter>();
			BillboardMaterials = (Material[])(object)new Material[BillboardRenderers.Length];
			for (int i = 0; i < BillboardRenderers.Length; i++)
			{
				BillboardMaterials[i] = BillboardRenderers[i].sharedMaterial;
			}
		}
		if (Object.op_Implicit((Object)(object)Light))
		{
			LightTransform = Light.GetComponent<Transform>();
			LightSource = Light.GetComponent<Light>();
		}
	}
}
public enum TOD_MoonPositionType
{
	OppositeToSun,
	Realistic
}
public enum TOD_StarsPositionType
{
	Static,
	Rotating
}
public enum TOD_FogType
{
	None,
	Atmosphere,
	Directional,
	Gradient
}
public enum TOD_AmbientType
{
	None,
	Color,
	Gradient,
	Spherical
}
public enum TOD_ReflectionType
{
	None,
	Cubemap
}
public enum TOD_ColorSpaceType
{
	Auto,
	Linear,
	Gamma
}
public enum TOD_ColorRangeType
{
	Auto,
	HDR,
	LDR
}
public enum TOD_ColorOutputType
{
	Raw,
	Dithered
}
public enum TOD_CloudQualityType
{
	Low,
	Medium,
	High
}
public enum TOD_MeshQualityType
{
	Low,
	Medium,
	High
}
public enum TOD_StarQualityType
{
	Low,
	Medium,
	High
}
public enum TOD_SkyQualityType
{
	PerVertex,
	PerPixel
}
[ExecuteInEditMode]
[RequireComponent(typeof(Camera))]
public abstract class TOD_ImageEffect : MonoBehaviour
{
	public enum ResolutionType
	{
		Low,
		Normal,
		High
	}

	public TOD_Sky sky = null;

	protected Camera cam = null;

	private static Vector3[] frustumCornersArray = (Vector3[])(object)new Vector3[4];

	protected Material CreateMaterial(Shader shader)
	{
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Expected O, but got Unknown
		if (!Object.op_Implicit((Object)(object)shader))
		{
			Debug.Log((object)("Missing shader in " + ((object)this).ToString()));
			((Behaviour)this).enabled = false;
			return null;
		}
		if (!shader.isSupported)
		{
			Debug.LogError((object)("The shader " + ((object)shader).ToString() + " on effect " + ((object)this).ToString() + " is not supported on this platform!"));
			((Behaviour)this).enabled = false;
			return null;
		}
		Material val = new Material(shader);
		((Object)val).hideFlags = (HideFlags)52;
		return val;
	}

	private TOD_Sky FindSky(bool fallback = false)
	{
		if (Object.op_Implicit((Object)(object)TOD_Sky.Instance))
		{
			return TOD_Sky.Instance;
		}
		if (fallback)
		{
			return Object.FindObjectOfType(typeof(TOD_Sky)) as TOD_Sky;
		}
		return null;
	}

	protected void Awake()
	{
		if (!Object.op_Implicit((Object)(object)cam))
		{
			cam = ((Component)this).GetComponent<Camera>();
		}
		if (!Object.op_Implicit((Object)(object)sky))
		{
			sky = FindSky(fallback: true);
		}
	}

	protected bool CheckSupport(bool needDepth = false, bool needHdr = false)
	{
		//IL_012d: 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)
		if (!Object.op_Implicit((Object)(object)cam))
		{
			cam = ((Component)this).GetComponent<Camera>();
		}
		if (!Object.op_Implicit((Object)(object)cam))
		{
			return false;
		}
		if (!Object.op_Implicit((Object)(object)sky))
		{
			sky = FindSky();
		}
		if (!Object.op_Implicit((Object)(object)sky) || !sky.Initialized)
		{
			return false;
		}
		if (!SystemInfo.supportsImageEffects)
		{
			Debug.LogWarning((object)("The image effect " + ((object)this).ToString() + " has been disabled as it's not supported on the current platform."));
			((Behaviour)this).enabled = false;
			return false;
		}
		if (needDepth && !SystemInfo.SupportsRenderTextureFormat((RenderTextureFormat)1))
		{
			Debug.LogWarning((object)("The image effect " + ((object)this).ToString() + " has been disabled as it requires a depth texture."));
			((Behaviour)this).enabled = false;
			return false;
		}
		if (needHdr && !SystemInfo.SupportsRenderTextureFormat((RenderTextureFormat)2))
		{
			Debug.LogWarning((object)("The image effect " + ((object)this).ToString() + " has been disabled as it requires HDR."));
			((Behaviour)this).enabled = false;
			return false;
		}
		if (needDepth)
		{
			Camera obj = cam;
			obj.depthTextureMode = (DepthTextureMode)(obj.depthTextureMode | 1);
		}
		if (needHdr)
		{
			cam.allowHDR = true;
		}
		return true;
	}

	protected void DrawBorder(RenderTexture dest, Material material)
	{
		RenderTexture.active = dest;
		bool flag = true;
		GL.PushMatrix();
		GL.LoadOrtho();
		for (int i = 0; i < material.passCount; i++)
		{
			material.SetPass(i);
			float num;
			float num2;
			if (flag)
			{
				num = 1f;
				num2 = 0f;
			}
			else
			{
				num = 0f;
				num2 = 1f;
			}
			float num3 = 0f;
			float num4 = 1f / ((float)((Texture)dest).width * 1f);
			float num5 = 0f;
			float num6 = 1f;
			GL.Begin(7);
			GL.TexCoord2(0f, num);
			GL.Vertex3(num3, num5, 0.1f);
			GL.TexCoord2(1f, num);
			GL.Vertex3(num4, num5, 0.1f);
			GL.TexCoord2(1f, num2);
			GL.Vertex3(num4, num6, 0.1f);
			GL.TexCoord2(0f, num2);
			GL.Vertex3(num3, num6, 0.1f);
			num3 = 1f - 1f / ((float)((Texture)dest).width * 1f);
			num4 = 1f;
			num5 = 0f;
			num6 = 1f;
			GL.TexCoord2(0f, num);
			GL.Vertex3(num3, num5, 0.1f);
			GL.TexCoord2(1f, num);
			GL.Vertex3(num4, num5, 0.1f);
			GL.TexCoord2(1f, num2);
			GL.Vertex3(num4, num6, 0.1f);
			GL.TexCoord2(0f, num2);
			GL.Vertex3(num3, num6, 0.1f);
			num3 = 0f;
			num4 = 1f;
			num5 = 0f;
			num6 = 1f / ((float)((Texture)dest).height * 1f);
			GL.TexCoord2(0f, num);
			GL.Vertex3(num3, num5, 0.1f);
			GL.TexCoord2(1f, num);
			GL.Vertex3(num4, num5, 0.1f);
			GL.TexCoord2(1f, num2);
			GL.Vertex3(num4, num6, 0.1f);
			GL.TexCoord2(0f, num2);
			GL.Vertex3(num3, num6, 0.1f);
			num3 = 0f;
			num4 = 1f;
			num5 = 1f - 1f / ((float)((Texture)dest).height * 1f);
			num6 = 1f;
			GL.TexCoord2(0f, num);
			GL.Vertex3(num3, num5, 0.1f);
			GL.TexCoord2(1f, num);
			GL.Vertex3(num4, num5, 0.1f);
			GL.TexCoord2(1f, num2);
			GL.Vertex3(num4, num6, 0.1f);
			GL.TexCoord2(0f, num2);
			GL.Vertex3(num3, num6, 0.1f);
			GL.End();
		}
		GL.PopMatrix();
	}

	protected Matrix4x4 FrustumCorners()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: 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_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_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: 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_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_00c4: 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_00cf: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		cam.CalculateFrustumCorners(new Rect(0f, 0f, 1f, 1f), cam.farClipPlane, cam.stereoActiveEye, frustumCornersArray);
		Vector3 val = ((Component)cam).transform.TransformVector(frustumCornersArray[0]);
		Vector3 val2 = ((Component)cam).transform.TransformVector(frustumCornersArray[1]);
		Vector3 val3 = ((Component)cam).transform.TransformVector(frustumCornersArray[2]);
		Vector3 val4 = ((Component)cam).transform.TransformVector(frustumCornersArray[3]);
		Matrix4x4 identity = Matrix4x4.identity;
		((Matrix4x4)(ref identity)).SetRow(0, Vector4.op_Implicit(val));
		((Matrix4x4)(ref identity)).SetRow(1, Vector4.op_Implicit(val4));
		((Matrix4x4)(ref identity)).SetRow(2, Vector4.op_Implicit(val2));
		((Matrix4x4)(ref identity)).SetRow(3, Vector4.op_Implicit(val3));
		return identity;
	}

	protected RenderTexture GetSkyMask(RenderTexture source, Material skyMaskMaterial, Material screenClearMaterial, ResolutionType resolution, Vector3 lightPos, int blurIterations, float blurRadius, float maxRadius)
	{
		//IL_007f: 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_00ad: 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_00c3: 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_00f0: Invalid comparison between Unknown and I4
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: 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)
		int num;
		int num2;
		int num3;
		switch (resolution)
		{
		case ResolutionType.High:
			num = ((Texture)source).width;
			num2 = ((Texture)source).height;
			num3 = 0;
			break;
		case ResolutionType.Normal:
			num = ((Texture)source).width / 2;
			num2 = ((Texture)source).height / 2;
			num3 = 0;
			break;
		default:
			num = ((Texture)source).width / 4;
			num2 = ((Texture)source).height / 4;
			num3 = 0;
			break;
		}
		RenderTexture temporary = RenderTexture.GetTemporary(num, num2, num3);
		RenderTexture val = null;
		skyMaskMaterial.SetVector("_BlurRadius4", new Vector4(1f, 1f, 0f, 0f) * blurRadius);
		skyMaskMaterial.SetVector("_LightPosition", new Vector4(lightPos.x, lightPos.y, lightPos.z, maxRadius));
		if ((cam.depthTextureMode & 1) != 0)
		{
			Graphics.Blit((Texture)(object)source, temporary, skyMaskMaterial, 1);
		}
		else
		{
			Graphics.Blit((Texture)(object)source, temporary, skyMaskMaterial, 2);
		}
		if ((int)cam.stereoActiveEye == 2)
		{
			DrawBorder(temporary, screenClearMaterial);
		}
		float num4 = blurRadius * 0.0013020834f;
		skyMaskMaterial.SetVector("_BlurRadius4", new Vector4(num4, num4, 0f, 0f));
		skyMaskMaterial.SetVector("_LightPosition", new Vector4(lightPos.x, lightPos.y, lightPos.z, maxRadius));
		for (int i = 0; i < blurIterations; i++)
		{
			val = RenderTexture.GetTemporary(num, num2, num3);
			Graphics.Blit((Texture)(object)temporary, val, skyMaskMaterial, 0);
			RenderTexture.ReleaseTemporary(temporary);
			num4 = blurRadius * (((float)i * 2f + 1f) * 6f) / 768f;
			skyMaskMaterial.SetVector("_BlurRadius4", new Vector4(num4, num4, 0f, 0f));
			temporary = RenderTexture.GetTemporary(num, num2, num3);
			Graphics.Blit((Texture)(object)val, temporary, skyMaskMaterial, 0);
			RenderTexture.ReleaseTemporary(val);
			num4 = blurRadius * (((float)i * 2f + 2f) * 6f) / 768f;
			skyMaskMaterial.SetVector("_BlurRadius4", new Vector4(num4, num4, 0f, 0f));
		}
		return temporary;
	}
}
[Serializable]
public class TOD_Parameters
{
	public TOD_CycleParameters Cycle;

	public TOD_WorldParameters World;

	public TOD_AtmosphereParameters Atmosphere;

	public TOD_DayParameters Day;

	public TOD_NightParameters Night;

	public TOD_SunParameters Sun;

	public TOD_MoonParameters Moon;

	public TOD_LightParameters Light;

	public TOD_StarParameters Stars;

	public TOD_CloudParameters Clouds;

	public TOD_FogParameters Fog;

	public TOD_AmbientParameters Ambient;

	public TOD_ReflectionParameters Reflection;

	public TOD_Parameters()
	{
	}

	public TOD_Parameters(TOD_Sky sky)
	{
		Cycle = sky.Cycle;
		World = sky.World;
		Atmosphere = sky.Atmosphere;
		Day = sky.Day;
		Night = sky.Night;
		Sun = sky.Sun;
		Moon = sky.Moon;
		Light = sky.Light;
		Stars = sky.Stars;
		Clouds = sky.Clouds;
		Fog = sky.Fog;
		Ambient = sky.Ambient;
		Reflection = sky.Reflection;
	}

	public void ToSky(TOD_Sky sky)
	{
		sky.Cycle = Cycle;
		sky.World = World;
		sky.Atmosphere = Atmosphere;
		sky.Day = Day;
		sky.Night = Night;
		sky.Sun = Sun;
		sky.Moon = Moon;
		sky.Light = Light;
		sky.Stars = Stars;
		sky.Clouds = Clouds;
		sky.Fog = Fog;
		sky.Ambient = Ambient;
		sky.Reflection = Reflection;
	}
}
[Serializable]
public class TOD_CycleParameters
{
	[Tooltip("Current hour of the day.")]
	public float Hour = 12f;

	[Tooltip("Current day of the month.")]
	public int Day = 15;

	[Tooltip("Current month of the year.")]
	public int Month = 6;

	[Tooltip("Current year.")]
	[TOD_Range(1f, 9999f)]
	public int Year = 2000;

	public DateTime DateTime
	{
		get
		{
			DateTime result = new DateTime(0L, DateTimeKind.Utc);
			if (Year > 0)
			{
				result = result.AddYears(Year - 1);
			}
			if (Month > 0)
			{
				result = result.AddMonths(Month - 1);
			}
			if (Day > 0)
			{
				result = result.AddDays(Day - 1);
			}
			if (Hour > 0f)
			{
				result = result.AddHours(Hour);
			}
			return result;
		}
		set
		{
			Year = value.Year;
			Month = value.Month;
			Day = value.Day;
			Hour = (float)value.Hour + (float)value.Minute / 60f + (float)value.Second / 3600f + (float)value.Millisecond / 3600000f;
		}
	}

	public long Ticks
	{
		get
		{
			return DateTime.Ticks;
		}
		set
		{
			DateTime = new DateTime(value, DateTimeKind.Utc);
		}
	}
}
[Serializable]
public class TOD_WorldParameters
{
	[Tooltip("Latitude of the current location in degrees.")]
	[Range(-90f, 90f)]
	public float Latitude = 0f;

	[Tooltip("Longitude of the current location in degrees.")]
	[Range(-180f, 180f)]
	public float Longitude = 0f;

	[Tooltip("UTC/GMT time zone of the current location in hours.")]
	[Range(-14f, 14f)]
	public float UTC = 0f;
}
[Serializable]
public class TOD_AtmosphereParameters
{
	[Tooltip("Intensity of the atmospheric Rayleigh scattering.")]
	[TOD_Min(0f)]
	public float RayleighMultiplier = 1f;

	[Tooltip("Intensity of the atmospheric Mie scattering.")]
	[TOD_Min(0f)]
	public float MieMultiplier = 1f;

	[Tooltip("Overall brightness of the atmosphere.")]
	[TOD_Min(0f)]
	public float Brightness = 1.5f;

	[Tooltip("Overall contrast of the atmosphere.")]
	[TOD_Min(0f)]
	public float Contrast = 1.5f;

	[Tooltip("Directionality factor that determines the size of the glow around the sun.")]
	[TOD_Range(0f, 1f)]
	public float Directionality = 0.7f;

	[Tooltip("Density of the fog covering the sky.")]
	[TOD_Range(0f, 1f)]
	public float Fogginess = 0f;
}
[Serializable]
public class TOD_DayParameters
{
	[Tooltip("Color of the sun spot.\nLeft value: Sun at zenith.\nRight value: Sun at horizon.")]
	public Gradient SunColor = null;

	[Tooltip("Color of the light that hits the ground.\nLeft value: Sun at zenith.\nRight value: Sun at horizon.")]
	public Gradient LightColor = null;

	[Tooltip("Color of the god rays.\nLeft value: Sun at zenith.\nRight value: Sun at horizon.")]
	public Gradient RayColor = null;

	[Tooltip("Color of the light that hits the atmosphere.\nLeft value: Sun at zenith.\nRight value: Sun at horizon.")]
	public Gradient SkyColor = null;

	[Tooltip("Color of the clouds.\nLeft value: Sun at zenith.\nRight value: Sun at horizon.")]
	public Gradient CloudColor = null;

	[Tooltip("Color of the atmosphere fog.\nLeft value: Sun at zenith.\nRight value: Sun at horizon.")]
	public Gradient FogColor = null;

	[Tooltip("Color of the ambient light.\nLeft value: Sun at zenith.\nRight value: Sun at horizon.")]
	public Gradient AmbientColor = null;

	[Tooltip("Intensity of the light source.")]
	[Range(0f, 8f)]
	public float LightIntensity = 1f;

	[Tooltip("Opacity of the shadows dropped by the light source.")]
	[Range(0f, 1f)]
	public float ShadowStrength = 1f;

	[Tooltip("Brightness multiplier of the ambient light.")]
	[Range(0f, 8f)]
	public float AmbientMultiplier = 1f;

	[Tooltip("Brightness multiplier of the reflection probe.")]
	[Range(0f, 1f)]
	public float ReflectionMultiplier = 1f;
}
[Serializable]
public class TOD_NightParameters
{
	[Tooltip("Color of the moon mesh.\nLeft value: Sun at horizon.\nRight value: Sun opposite to zenith.")]
	public Gradient MoonColor = null;

	[Tooltip("Color of the light that hits the ground.\nLeft value: Sun at horizon.\nRight value: Sun opposite to zenith.")]
	public Gradient LightColor = null;

	[Tooltip("Color of the god rays.\nLeft value: Sun at horizon.\nRight value: Sun opposite to zenith.")]
	public Gradient RayColor = null;

	[Tooltip("Color of the light that hits the atmosphere.\nLeft value: Sun at horizon.\nRight value: Sun opposite to zenith.")]
	public Gradient SkyColor = null;

	[Tooltip("Color of the clouds.\nLeft value: Sun at horizon.\nRight value: Sun opposite to zenith.")]
	public Gradient CloudColor = null;

	[Tooltip("Color of the atmosphere fog.\nLeft value: Sun at horizon.\nRight value: Sun opposite to zenith.")]
	public Gradient FogColor = null;

	[Tooltip("Color of the ambient light.\nLeft value: Sun at horizon.\nRight value: Sun opposite to zenith.")]
	public Gradient AmbientColor = null;

	[Tooltip("Intensity of the light source.")]
	[Range(0f, 8f)]
	public float LightIntensity = 0.1f;

	[Tooltip("Opacity of the shadows dropped by the light source.")]
	[Range(0f, 1f)]
	public float ShadowStrength = 1f;

	[Tooltip("Brightness multiplier of the ambient light.")]
	[Range(0f, 8f)]
	public float AmbientMultiplier = 1f;

	[Tooltip("Brightness multiplier of the reflection probe.")]
	[Range(0f, 1f)]
	public float ReflectionMultiplier = 1f;
}
[Serializable]
public class TOD_SunParameters
{
	[Tooltip("Diameter of the sun in degrees.\nThe diameter as seen from earth is 0.5 degrees.")]
	[TOD_Min(0f)]
	public float MeshSize = 1f;

	[Tooltip("Brightness of the sun.")]
	[TOD_Min(0f)]
	public float MeshBrightness = 2f;

	[Tooltip("Contrast of the sun.")]
	[TOD_Min(0f)]
	public float MeshContrast = 1f;
}
[Serializable]
public class TOD_MoonParameters
{
	[Tooltip("Diameter of the moon in degrees.\nThe diameter as seen from earth is 0.5 degrees.")]
	[TOD_Min(0f)]
	public float MeshSize = 1f;

	[Tooltip("Brightness of the moon.")]
	[TOD_Min(0f)]
	public float MeshBrightness = 2f;

	[Tooltip("Contrast of the moon.")]
	[TOD_Min(0f)]
	public float MeshContrast = 1f;

	[Tooltip("Size of the moon halo.")]
	[TOD_Min(0f)]
	public float HaloSize = 0.1f;

	[Tooltip("Brightness of the moon halo.")]
	[TOD_Min(0f)]
	public float HaloBrightness = 1f;

	[Tooltip("Type of the moon position calculation.")]
	public TOD_MoonPositionType Position = TOD_MoonPositionType.Realistic;
}
[Serializable]
public class TOD_StarParameters
{
	[Tooltip("Size of the stars.")]
	[TOD_Min(0f)]
	public float Size = 1f;

	[Tooltip("Brightness of the stars.")]
	[TOD_Min(0f)]
	public float Brightness = 1f;

	[Tooltip("Type of the stars position calculation.")]
	public TOD_StarsPositionType Position = TOD_StarsPositionType.Rotating;
}
[Serializable]
public class TOD_CloudParameters
{
	[Tooltip("Size of the clouds.")]
	[TOD_Min(1f)]
	public float Size = 2f;

	[Tooltip("Opacity of the clouds.")]
	[TOD_Range(0f, 1f)]
	public float Opacity = 1f;

	[Tooltip("How much sky is covered by clouds.")]
	[TOD_Range(0f, 1f)]
	public float Coverage = 0.5f;

	[Tooltip("Sharpness of the cloud to sky transition.")]
	[TOD_Range(0f, 1f)]
	public float Sharpness = 0.5f;

	[Tooltip("Coloring of the clouds.")]
	[TOD_Range(0f, 1f)]
	public float Coloring = 0.5f;

	[Tooltip("Amount of skylight that is blocked.")]
	[TOD_Range(0f, 1f)]
	public float Attenuation = 0.5f;

	[Tooltip("Amount of sunlight that is blocked.\nOnly affects the highest cloud quality setting.")]
	[TOD_Range(0f, 1f)]
	public float Saturation = 0.5f;

	[Tooltip("Intensity of the cloud translucency glow.\nOnly affects the highest cloud quality setting.")]
	[TOD_Min(0f)]
	public float Scattering = 1f;

	[Tooltip("Brightness of the clouds.")]
	[TOD_Min(0f)]
	public float Brightness = 1.5f;
}
[Serializable]
public class TOD_LightParameters
{
	[Tooltip("Refresh interval of the light source position in seconds.")]
	[TOD_Min(0f)]
	public float UpdateInterval = 0f;

	[Tooltip("Controls how low the light source is allowed to go.\n = -1 light source can go as low as it wants.\n = 0 light source will never go below the horizon.\n = +1 light source will never leave zenith.")]
	[TOD_Range(-1f, 1f)]
	public float MinimumHeight = 0f;
}
[Serializable]
public class TOD_FogParameters
{
	[Tooltip("Fog color mode.")]
	public TOD_FogType Mode = TOD_FogType.Atmosphere;

	[Tooltip("Fog color sampling height.\n = 0 fog is atmosphere color at horizon.\n = 1 fog is atmosphere color at zenith.")]
	[TOD_Range(0f, 1f)]
	public float HeightBias = 0f;
}
[Serializable]
public class TOD_AmbientParameters
{
	[Tooltip("Ambient light mode.")]
	public TOD_AmbientType Mode = TOD_AmbientType.Color;

	[Tooltip("Saturation of the ambient light.")]
	[TOD_Min(0f)]
	public float Saturation = 1f;

	[Tooltip("Refresh interval of the ambient light probe in seconds.")]
	[TOD_Min(0f)]
	public float UpdateInterval = 1f;
}
[Serializable]
public class TOD_ReflectionParameters
{
	[Tooltip("Reflection probe mode.")]
	public TOD_ReflectionType Mode = TOD_ReflectionType.None;

	[Tooltip("Clear flags to use for the reflection.")]
	public ReflectionProbeClearFlags ClearFlags = (ReflectionProbeClearFlags)1;

	[Tooltip("Layers to include in the reflection.")]
	public LayerMask CullingMask = LayerMask.op_Implicit(0);

	[Tooltip("Time slicing behaviour to spread out rendering cost over multiple frames.")]
	public ReflectionProbeTimeSlicingMode TimeSlicing = (ReflectionProbeTimeSlicingMode)0;

	[Tooltip("Resolution of the reflection bake.")]
	[TOD_Range(16f, 2048f)]
	public int Resolution = 128;

	[Tooltip("Refresh interval of the reflection cubemap in seconds.")]
	[TOD_Min(0f)]
	public float UpdateInterval = 1f;
}
[ExecuteInEditMode]
[RequireComponent(typeof(Camera))]
[AddComponentMenu("Time of Day/Camera God Rays")]
public class TOD_Rays : TOD_ImageEffect
{
	public enum BlendModeType
	{
		Screen,
		Add
	}

	public Shader GodRayShader = null;

	public Shader ScreenClearShader = null;

	public Shader SkyMaskShader = null;

	[Tooltip("Whether or not to use the depth buffer.")]
	public bool UseDepthTexture = true;

	[Header("Rays")]
	[Tooltip("The god ray rendering blend mode.")]
	public BlendModeType BlendMode = BlendModeType.Screen;

	[Tooltip("The intensity of the god rays.")]
	[TOD_Min(0f)]
	public float Intensity = 1f;

	[Header("Blur")]
	[Tooltip("The god ray rendering resolution.")]
	public ResolutionType Resolution = ResolutionType.Normal;

	[Tooltip("The number of blur iterations to be performed.")]
	[TOD_Range(0f, 4f)]
	public int BlurIterations = 2;

	[Tooltip("The radius to blur filter applied to the god rays.")]
	[TOD_Min(0f)]
	public float BlurRadius = 2f;

	[Tooltip("The maximum radius of the god rays.")]
	[TOD_Min(0f)]
	public float MaxRadius = 0.5f;

	private Material godRayMaterial = null;

	private Material screenClearMaterial = null;

	private Material skyMaskMaterial = null;

	private const int PASS_SCREEN = 0;

	private const int PASS_ADD = 1;

	protected void OnEnable()
	{
		if (!Object.op_Implicit((Object)(object)GodRayShader))
		{
			GodRayShader = Shader.Find("Hidden/Time of Day/God Rays");
		}
		if (!Object.op_Implicit((Object)(object)ScreenClearShader))
		{
			ScreenClearShader = Shader.Find("Hidden/Time of Day/Screen Clear");
		}
		if (!Object.op_Implicit((Object)(object)SkyMaskShader))
		{
			SkyMaskShader = Shader.Find("Hidden/Time of Day/Sky Mask");
		}
		godRayMaterial = CreateMaterial(GodRayShader);
		screenClearMaterial = CreateMaterial(ScreenClearShader);
		skyMaskMaterial = CreateMaterial(SkyMaskShader);
	}

	protected void OnDisable()
	{
		if (Object.op_Implicit((Object)(object)godRayMaterial))
		{
			Object.DestroyImmediate((Object)(object)godRayMaterial);
		}
		if (Object.op_Implicit((Object)(object)screenClearMaterial))
		{
			Object.DestroyImmediate((Object)(object)screenClearMaterial);
		}
		if (Object.op_Implicit((Object)(object)skyMaskMaterial))
		{
			Object.DestroyImmediate((Object)(object)skyMaskMaterial);
		}
	}

	protected void OnRenderImage(RenderTexture source, RenderTexture destination)
	{
		//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_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: 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_00f5: 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_00c6: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
		if (!CheckSupport(UseDepthTexture))
		{
			Graphics.Blit((Texture)(object)source, destination);
			return;
		}
		sky.Components.Rays = this;
		Vector3 lightPos = cam.WorldToViewportPoint(sky.Components.LightTransform.position);
		RenderTexture skyMask = GetSkyMask(source, skyMaskMaterial, screenClearMaterial, Resolution, lightPos, BlurIterations, BlurRadius, MaxRadius);
		Color val = Color.black;
		if ((double)lightPos.z >= 0.0)
		{
			val = ((!sky.IsDay) ? (Intensity * sky.MoonVisibility * sky.MoonRayColor) : (Intensity * sky.SunVisibility * sky.SunRayColor));
		}
		godRayMaterial.SetColor("_LightColor", val);
		godRayMaterial.SetTexture("_SkyMask", (Texture)(object)skyMask);
		if (BlendMode == BlendModeType.Screen)
		{
			Graphics.Blit((Texture)(object)source, destination, godRayMaterial, 0);
		}
		else
		{
			Graphics.Blit((Texture)(object)source, destination, godRayMaterial, 1);
		}
		RenderTexture.ReleaseTemporary(skyMask);
	}
}
public class TOD_Resources : MonoBehaviour
{
	public Material Skybox;

	public Material NewSkybox;

	public Mesh MoonLOD0;

	public Mesh MoonLOD1;

	public Mesh MoonLOD2;

	public Mesh SkyLOD0;

	public Mesh SkyLOD1;

	public Mesh SkyLOD2;

	public Mesh CloudsLOD0;

	public Mesh CloudsLOD1;

	public Mesh CloudsLOD2;

	public Mesh StarsLOD0;

	public Mesh StarsLOD1;

	public Mesh StarsLOD2;

	public int ID_SunLightColor { get; private set; }

	public int ID_MoonLightColor { get; private set; }

	public int ID_SunSkyColor { get; private set; }

	public int ID_MoonSkyColor { get; private set; }

	public int ID_SunMeshColor { get; private set; }

	public int ID_MoonMeshColor { get; private set; }

	public int ID_SunCloudColor { get; private set; }

	public int ID_MoonCloudColor { get; private set; }

	public int ID_FogColor { get; private set; }

	public int ID_GroundColor { get; private set; }

	public int ID_AmbientColor { get; private set; }

	public int ID_SunDirection { get; private set; }

	public int ID_MoonDirection { get; private set; }

	public int ID_LightDirection { get; private set; }

	public int ID_LocalSunDirection { get; private set; }

	public int ID_LocalMoonDirection { get; private set; }

	public int ID_LocalLightDirection { get; private set; }

	public int ID_Contrast { get; private set; }

	public int ID_Brightness { get; private set; }

	public int ID_Fogginess { get; private set; }

	public int ID_Directionality { get; private set; }

	public int ID_MoonHaloPower { get; private set; }

	public int ID_MoonHaloColor { get; private set; }

	public int ID_CloudSize { get; private set; }

	public int ID_CloudOpacity { get; private set; }

	public int ID_CloudCoverage { get; private set; }

	public int ID_CloudSharpness { get; private set; }

	public int ID_CloudDensity { get; private set; }

	public int ID_CloudColoring { get; private set; }

	public int ID_CloudAttenuation { get; private set; }

	public int ID_CloudSaturation { get; private set; }

	public int ID_CloudScattering { get; private set; }

	public int ID_CloudBrightness { get; private set; }

	public int ID_CloudMultiplier { get; private set; }

	public int ID_CloudOffset { get; private set; }

	public int ID_CloudWind { get; private set; }

	public int ID_StarSize { get; private set; }

	public int ID_StarBrightness { get; private set; }

	public int ID_StarVisibility { get; private set; }

	public int ID_SunMeshContrast { get; private set; }

	public int ID_SunMeshBrightness { get; private set; }

	public int ID_MoonMeshContrast { get; private set; }

	public int ID_MoonMeshBrightness { get; private set; }

	public int ID_kBetaMie { get; private set; }

	public int ID_kSun { get; private set; }

	public int ID_k4PI { get; private set; }

	public int ID_kRadius { get; private set; }

	public int ID_kScale { get; private set; }

	public int ID_World2Sky { get; private set; }

	public int ID_Sky2World { get; private set; }

	public void Initialize()
	{
		ID_SunLightColor = Shader.PropertyToID("TOD_SunLightColor");
		ID_MoonLightColor = Shader.PropertyToID("TOD_MoonLightColor");
		ID_SunSkyColor = Shader.PropertyToID("TOD_SunSkyColor");
		ID_MoonSkyColor = Shader.PropertyToID("TOD_MoonSkyColor");
		ID_SunMeshColor = Shader.PropertyToID("TOD_SunMeshColor");
		ID_MoonMeshColor = Shader.PropertyToID("TOD_MoonMeshColor");
		ID_SunCloudColor = Shader.PropertyToID("TOD_SunCloudColor");
		ID_MoonCloudColor = Shader.PropertyToID("TOD_MoonCloudColor");
		ID_FogColor = Shader.PropertyToID("TOD_FogColor");
		ID_GroundColor = Shader.PropertyToID("TOD_GroundColor");
		ID_AmbientColor = Shader.PropertyToID("TOD_AmbientColor");
		ID_SunDirection = Shader.PropertyToID("TOD_SunDirection");
		ID_MoonDirection = Shader.PropertyToID("TOD_MoonDirection");
		ID_LightDirection = Shader.PropertyToID("TOD_LightDirection");
		ID_LocalSunDirection = Shader.PropertyToID("TOD_LocalSunDirection");
		ID_LocalMoonDirection = Shader.PropertyToID("TOD_LocalMoonDirection");
		ID_LocalLightDirection = Shader.PropertyToID("TOD_LocalLightDirection");
		ID_Contrast = Shader.PropertyToID("TOD_Contrast");
		ID_Brightness = Shader.PropertyToID("TOD_Brightness");
		ID_Fogginess = Shader.PropertyToID("TOD_Fogginess");
		ID_Directionality = Shader.PropertyToID("TOD_Directionality");
		ID_MoonHaloPower = Shader.PropertyToID("TOD_MoonHaloPower");
		ID_MoonHaloColor = Shader.PropertyToID("TOD_MoonHaloColor");
		ID_CloudSize = Shader.PropertyToID("TOD_CloudSize");
		ID_CloudOpacity = Shader.PropertyToID("TOD_CloudOpacity");
		ID_CloudCoverage = Shader.PropertyToID("TOD_CloudCoverage");
		ID_CloudSharpness = Shader.PropertyToID("TOD_CloudSharpness");
		ID_CloudDensity = Shader.PropertyToID("TOD_CloudDensity");
		ID_CloudColoring = Shader.PropertyToID("TOD_CloudColoring");
		ID_CloudAttenuation = Shader.PropertyToID("TOD_CloudAttenuation");
		ID_CloudSaturation = Shader.PropertyToID("TOD_CloudSaturation");
		ID_CloudScattering = Shader.PropertyToID("TOD_CloudScattering");
		ID_CloudBrightness = Shader.PropertyToID("TOD_CloudBrightness");
		ID_CloudOffset = Shader.PropertyToID("TOD_CloudOffset");
		ID_CloudWind = Shader.PropertyToID("TOD_CloudWind");
		ID_StarSize = Shader.PropertyToID("TOD_StarSize");
		ID_StarBrightness = Shader.PropertyToID("TOD_StarBrightness");
		ID_StarVisibility = Shader.PropertyToID("TOD_StarVisibility");
		ID_SunMeshContrast = Shader.PropertyToID("TOD_SunMeshContrast");
		ID_SunMeshBrightness = Shader.PropertyToID("TOD_SunMeshBrightness");
		ID_MoonMeshContrast = Shader.PropertyToID("TOD_MoonMeshContrast");
		ID_MoonMeshBrightness = Shader.PropertyToID("TOD_MoonMeshBrightness");
		ID_kBetaMie = Shader.PropertyToID("TOD_kBetaMie");
		ID_kSun = Shader.PropertyToID("TOD_kSun");
		ID_k4PI = Shader.PropertyToID("TOD_k4PI");
		ID_kRadius = Shader.PropertyToID("TOD_kRadius");
		ID_kScale = Shader.PropertyToID("TOD_kScale");
		ID_World2Sky = Shader.PropertyToID("TOD_World2Sky");
		ID_Sky2World = Shader.PropertyToID("TOD_Sky2World");
	}
}
[ExecuteInEditMode]
[RequireComponent(typeof(Camera))]
[AddComponentMenu("Time of Day/Camera Atmospheric Scattering")]
public class TOD_Scattering : TOD_ImageEffect
{
	public Shader ScatteringShader = null;

	public Shader ScreenClearShader = null;

	public Shader SkyMaskShader = null;

	public Texture2D DitheringTexture = null;

	[Tooltip("Whether to render atmosphere and fog in a single pass or two separate passes. Disable when using anti-aliasing in forward rendering or when your manual reflection scripts need the sky dome to be present before the image effects are rendered.")]
	public bool SinglePass = true;

	[Header("Fog")]
	[Tooltip("How quickly the fog thickens with increasing distance.")]
	[Range(0f, 1f)]
	public float GlobalDensity = 0.01f;

	[Tooltip("How quickly the fog falls off with increasing altitude.")]
	[Range(0f, 1f)]
	public float HeightFalloff = 0.01f;

	[Tooltip("The distance the fog starts at.")]
	public float StartDistance = 0f;

	[Tooltip("The height where the fog reaches its maximum density.")]
	public float ZeroLevel = 0f;

	[Header("Blur")]
	[Tooltip("The scattering resolution.")]
	public ResolutionType Resolution = ResolutionType.Normal;

	[Tooltip("The number of blur iterations to be performed.")]
	[TOD_Range(0f, 4f)]
	public int BlurIterations = 2;

	[Tooltip("The radius to blur filter applied to the directional scattering.")]
	[TOD_Min(0f)]
	public float BlurRadius = 2f;

	[Tooltip("The maximum radius of the directional scattering.")]
	[TOD_Min(0f)]
	public float MaxRadius = 1f;

	private Material scatteringMaterial = null;

	private Material screenClearMaterial = null;

	private Material skyMaskMaterial = null;

	protected void OnEnable()
	{
		if (!Object.op_Implicit((Object)(object)ScatteringShader))
		{
			ScatteringShader = Shader.Find("Hidden/Time of Day/Scattering");
		}
		if (!Object.op_Implicit((Object)(object)ScreenClearShader))
		{
			ScreenClearShader = Shader.Find("Hidden/Time of Day/Screen Clear");
		}
		if (!Object.op_Implicit((Object)(object)SkyMaskShader))
		{
			SkyMaskShader = Shader.Find("Hidden/Time of Day/Sky Mask");
		}
		scatteringMaterial = CreateMaterial(ScatteringShader);
		screenClearMaterial = CreateMaterial(ScreenClearShader);
		skyMaskMaterial = CreateMaterial(SkyMaskShader);
	}

	protected void OnDisable()
	{
		if (Object.op_Implicit((Object)(object)scatteringMaterial))
		{
			Object.DestroyImmediate((Object)(object)scatteringMaterial);
		}
		if (Object.op_Implicit((Object)(object)screenClearMaterial))
		{
			Object.DestroyImmediate((Object)(object)screenClearMaterial);
		}
		if (Object.op_Implicit((Object)(object)skyMaskMaterial))
		{
			Object.DestroyImmediate((Object)(object)skyMaskMaterial);
		}
	}

	protected void OnPreCull()
	{
		if (SinglePass && Object.op_Implicit((Object)(object)sky) && sky.Initialized)
		{
			sky.Components.AtmosphereRenderer.enabled = false;
		}
	}

	protected void OnPostRender()
	{
		if (SinglePass && Object.op_Implicit((Object)(object)sky) && sky.Initialized)
		{
			sky.Components.AtmosphereRenderer.enabled = true;
		}
	}

	[ImageEffectOpaque]
	protected void OnRenderImage(RenderTexture source, RenderTexture destination)
	{
		//IL_0042: 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_0061: 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_0102: Unknown result type (might be due to invalid IL or missing references)
		if (!CheckSupport(needDepth: true))
		{
			Graphics.Blit((Texture)(object)source, destination);
			return;
		}
		sky.Components.Scattering = this;
		Vector3 lightPos = cam.WorldToViewportPoint(sky.Components.SunTransform.position);
		RenderTexture skyMask = GetSkyMask(source, skyMaskMaterial, screenClearMaterial, Resolution, lightPos, BlurIterations, BlurRadius, MaxRadius);
		scatteringMaterial.SetMatrix("_FrustumCornersWS", FrustumCorners());
		scatteringMaterial.SetTexture("_SkyMask", (Texture)(object)skyMask);
		if (SinglePass)
		{
			scatteringMaterial.EnableKeyword("TOD_SCATTERING_SINGLE_PASS");
		}
		else
		{
			scatteringMaterial.DisableKeyword("TOD_SCATTERING_SINGLE_PASS");
		}
		Shader.SetGlobalTexture("TOD_BayerTexture", (Texture)(object)DitheringTexture);
		Shader.SetGlobalVector("TOD_ScatterDensity", new Vector4(HeightFalloff, ZeroLevel, GlobalDensity, StartDistance));
		Graphics.Blit((Texture)(object)source, destination, scatteringMaterial);
		RenderTexture.ReleaseTemporary(skyMask);
	}
}
[ExecuteInEditMode]
[RequireComponent(typeof(Camera))]
[AddComponentMenu("Time of Day/Camera Cloud Shadows")]
public class TOD_Shadows : TOD_ImageEffect
{
	public Shader ShadowShader = null;

	public Texture2D CloudTexture = null;

	[Header("Shadows")]
	[Range(0f, 1f)]
	public float Cutoff = 0f;

	[Range(0f, 1f)]
	public float Fade = 0f;

	[Range(0f, 1f)]
	public float Intensity = 0.5f;

	private Material shadowMaterial = null;

	protected void OnEnable()
	{
		if (!Object.op_Implicit((Object)(object)ShadowShader))
		{
			ShadowShader = Shader.Find("Hidden/Time of Day/Cloud Shadows");
		}
		shadowMaterial = CreateMaterial(ShadowShader);
	}

	protected void OnDisable()
	{
		if (Object.op_Implicit((Object)(object)shadowMaterial))
		{
			Object.DestroyImmediate((Object)(object)shadowMaterial);
		}
	}

	[ImageEffectOpaque]
	protected void OnRenderImage(RenderTexture source, RenderTexture destination)
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		if (!CheckSupport(needDepth: true))
		{
			Graphics.Blit((Texture)(object)source, destination);
			return;
		}
		sky.Components.Shadows = this;
		shadowMaterial.SetMatrix("_FrustumCornersWS", FrustumCorners());
		Shader.SetGlobalTexture("TOD_CloudTexture", (Texture)(object)CloudTexture);
		Shader.SetGlobalFloat("TOD_CloudShadowCutoff", Cutoff);
		Shader.SetGlobalFloat("TOD_CloudShadowFade", Fade);
		Shader.SetGlobalFloat("TOD_CloudShadowIntensity", Intensity * Mathf.Clamp01(1f - sky.SunZenith / 90f));
		Graphics.Blit((Texture)(object)source, destination, shadowMaterial);
	}
}
[ExecuteInEditMode]
[RequireComponent(typeof(TOD_Resources))]
[RequireComponent(typeof(TOD_Components))]
public class TOD_Sky : MonoBehaviour
{
	private static List<TOD_Sky> instances = new List<TOD_Sky>();

	private int probeRenderID = -1;

	[Tooltip("Auto: Use the player settings.\nLinear: Force linear color space.\nGamma: Force gamma color space.")]
	public TOD_ColorSpaceType ColorSpace = TOD_ColorSpaceType.Auto;

	[Tooltip("Auto: Use the camera settings.\nHDR: Force high dynamic range.\nLDR: Force low dynamic range.")]
	public TOD_ColorRangeType ColorRange = TOD_ColorRangeType.Auto;

	[Tooltip("Raw: Write color without modifications.\nDithered: Add dithering to reduce banding.")]
	public TOD_ColorOutputType ColorOutput = TOD_ColorOutputType.Dithered;

	[Tooltip("Per Vertex: Calculate sky color per vertex.\nPer Pixel: Calculate sky color per pixel.")]
	public TOD_SkyQualityType SkyQuality = TOD_SkyQualityType.PerVertex;

	[Tooltip("Low: Only recommended for very old mobile devices.\nMedium: Simplified cloud shading.\nHigh: Physically based cloud shading.")]
	public TOD_CloudQualityType CloudQuality = TOD_CloudQualityType.High;

	[Tooltip("Low: Only recommended for very old mobile devices.\nMedium: Simplified mesh geometry.\nHigh: Detailed mesh geometry.")]
	public TOD_MeshQualityType MeshQuality = TOD_MeshQualityType.High;

	[Tooltip("Low: Recommended for most mobile devices.\nMedium: Includes most visible stars.\nHigh: Includes all visible stars.")]
	public TOD_StarQualityType StarQuality = TOD_StarQualityType.High;

	public TOD_CycleParameters Cycle;

	public TOD_WorldParameters World;

	public TOD_AtmosphereParameters Atmosphere;

	public TOD_DayParameters Day;

	public TOD_NightParameters Night;

	public TOD_SunParameters Sun;

	public TOD_MoonParameters Moon;

	public TOD_StarParameters Stars;

	public TOD_CloudParameters Clouds;

	public TOD_LightParameters Light;

	public TOD_FogParameters Fog;

	public TOD_AmbientParameters Ambient;

	public TOD_ReflectionParameters Reflection;

	private float timeSinceLightUpdate = float.MaxValue;

	private float timeSinceAmbientUpdate = float.MaxValue;

	private float timeSinceReflectionUpdate = float.MaxValue;

	private const int TOD_SAMPLES = 2;

	private Vector3 kBetaMie;

	private Vector4 kSun;

	private Vector4 k4PI;

	private Vector4 kRadius;

	private Vector4 kScale;

	private const float pi = (float)Math.PI;

	private const float tau = (float)Math.PI * 2f;

	public static List<TOD_Sky> Instances => instances;

	public static TOD_Sky Instance => (instances.Count != 0) ? instances[instances.Count - 1] : null;

	public bool Initialized { get; private set; }

	public bool Headless => false;

	public TOD_Components Components { get; private set; }

	public TOD_Resources Resources { get; private set; }

	public bool IsDay { get; private set; }

	public bool IsNight { get; private set; }

	public float Radius => Components.DomeTransform.lossyScale.y;

	public float Diameter => Components.DomeTransform.lossyScale.y * 2f;

	public float LerpValue { get; private set; }

	public float SunZenith { get; private set; }

	public float SunAltitude { get; private set; }

	public float SunAzimuth { get; private set; }

	public float MoonZenith { get; private set; }

	public float MoonAltitude { get; private set; }

	public float MoonAzimuth { get; private set; }

	public float SunsetTime { get; private set; }

	public float SunriseTime { get; private set; }

	public float LocalSiderealTime { get; private set; }

	public float LightZenith => Mathf.Min(SunZenith, MoonZenith);

	public float LightIntensity => Components.LightSource.intensity;

	public float SunVisibility { get; private set; }

	public float MoonVisibility { get; private set; }

	public Vector3 SunDirection { get; private set; }

	public Vector3 MoonDirection { get; private set; }

	public Vector3 LightDirection { get; private set; }

	public Vector3 LocalSunDirection { get; private set; }

	public Vector3 LocalMoonDirection { get; private set; }

	public Vector3 LocalLightDirection { get; private set; }

	public Color SunLightColor { get; private set; }

	public Color MoonLightColor { get; private set; }

	public Color LightColor => Components.LightSource.color;

	public Color SunRayColor { get; private set; }

	public Color MoonRayColor { get; private set; }

	public Color SunSkyColor { get; private set; }

	public Color MoonSkyColor { get; private set; }

	public Color SunMeshColor { get; private set; }

	public Color MoonMeshColor { get; private set; }

	public Color SunCloudColor { get; private set; }

	public Color MoonCloudColor { get; private set; }

	public Color FogColor { get; private set; }

	public Color GroundColor { get; private set; }

	public Color AmbientColor { get; private set; }

	public Color MoonHaloColor { get; private set; }

	public ReflectionProbe Probe { get; private set; }

	public Vector3 OrbitalToUnity(float radius, float theta, float phi)
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		float num = Mathf.Sin(theta);
		float num2 = Mathf.Cos(theta);
		float num3 = Mathf.Sin(phi);
		float num4 = Mathf.Cos(phi);
		Vector3 result = default(Vector3);
		result.z = radius * num * num4;
		result.y = radius * num2;
		result.x = radius * num * num3;
		return result;
	}

	public Vector3 OrbitalToLocal(float theta, float phi)
	{
		//IL_003b: 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_0043: Unknown result type (might be due to invalid IL or missing references)
		float num = Mathf.Sin(theta);
		float y = Mathf.Cos(theta);
		float num2 = Mathf.Sin(phi);
		float num3 = Mathf.Cos(phi);
		Vector3 result = default(Vector3);
		result.z = num * num3;
		result.y = y;
		result.x = num * num2;
		return result;
	}

	public Color SampleAtmosphere(Vector3 direction, bool directLight = true)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: 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_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: 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_002c: 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_0033: Unknown result type (might be due to invalid IL or missing references)
		Vector3 dir = Components.DomeTransform.InverseTransformDirection(direction);
		Color color = ShaderScatteringColor(dir, directLight);
		color = TOD_HDR2LDR(color);
		return TOD_LINEAR2GAMMA(color);
	}

	public SphericalHarmonicsL2 RenderToSphericalHarmonics()
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		float saturation = Ambient.Saturation;
		float intensity = Mathf.Lerp(Night.AmbientMultiplier, Day.AmbientMultiplier, LerpValue);
		return RenderToSphericalHarmonics(intensity, saturation);
	}

	public SphericalHarmonicsL2 RenderToSphericalHarmonics(float intensity, float saturation)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: 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_0038: 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_0040: 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_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: 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_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: 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_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: 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_00dd: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: 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_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: 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_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: 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_0184: 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_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: 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_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: 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_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_01d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: 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_0208: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0218: 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_0220: 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_022c: 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_0233: 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_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: 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_025b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: Unknown result type (might be due to invalid IL or missing references)
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		//IL_0269: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_0278: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02da: Unknown result type (might be due to invalid IL or missing references)
		//IL_0307: Unknown result type (might be due to invalid IL or missing references)
		//IL_0309: Unknown result type (might be due to invalid IL or missing references)
		//IL_0335: Unknown result type (might be due to invalid IL or missing references)
		//IL_0337: Unknown result type (might be due to invalid IL or missing references)
		//IL_0344: Unknown result type (might be due to invalid IL or missing references)
		//IL_0349: Unknown result type (might be due to invalid IL or missing references)
		//IL_034d: 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_035b: Unknown result type (might be due to invalid IL or missing references)
		//IL_035c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0363: Unknown result type (might be due to invalid IL or missing references)
		SphericalHarmonicsL2 result = default(SphericalHarmonicsL2);
		bool directLight = false;
		Color ambientColor = AmbientColor;
		Color val = TOD_Util.AdjustRGB(((Color)(ref ambientColor)).linear, intensity, saturation);
		Vector3 val2 = default(Vector3);
		((Vector3)(ref val2))..ctor(0.61237246f, 0.5f, 0.61237246f);
		Vector3 up = Vector3.up;
		Color val3 = SampleAtmosphere(up, directLight);
		Color linear = ((Color)(ref val3)).linear;
		Color val4 = TOD_Util.AdjustRGB(linear, intensity, saturation);
		((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(up, val4, 0.42857143f);
		Vector3 val5 = default(Vector3);
		((Vector3)(ref val5))..ctor(0f - val2.x, val2.y, 0f - val2.z);
		Color val6 = SampleAtmosphere(val5, directLight);
		Color linear2 = ((Color)(ref val6)).linear;
		Color val7 = TOD_Util.AdjustRGB(linear2, intensity, saturation);
		((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(val5, val7, 0.2857143f);
		Vector3 val8 = default(Vector3);
		((Vector3)(ref val8))..ctor(val2.x, val2.y, 0f - val2.z);
		Color val9 = SampleAtmosphere(val8, directLight);
		Color linear3 = ((Color)(ref val9)).linear;
		Color val10 = TOD_Util.AdjustRGB(linear3, intensity, saturation);
		((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(val8, val10, 0.2857143f);
		Vector3 val11 = default(Vector3);
		((Vector3)(ref val11))..ctor(0f - val2.x, val2.y, val2.z);
		Color val12 = SampleAtmosphere(val11, directLight);
		Color linear4 = ((Color)(ref val12)).linear;
		Color val13 = TOD_Util.AdjustRGB(linear4, intensity, saturation);
		((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(val11, val13, 0.2857143f);
		Vector3 val14 = default(Vector3);
		((Vector3)(ref val14))..ctor(val2.x, val2.y, val2.z);
		Color val15 = SampleAtmosphere(val14, directLight);
		Color linear5 = ((Color)(ref val15)).linear;
		Color val16 = TOD_Util.AdjustRGB(linear5, intensity, saturation);
		((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(val14, val16, 0.2857143f);
		Vector3 left = Vector3.left;
		Color val17 = SampleAtmosphere(left, directLight);
		Color linear6 = ((Color)(ref val17)).linear;
		Color val18 = TOD_Util.AdjustRGB(linear6, intensity, saturation);
		((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(left, val18, 1f / 7f);
		Vector3 right = Vector3.right;
		Color val19 = SampleAtmosphere(right, directLight);
		Color linear7 = ((Color)(ref val19)).linear;
		Color val20 = TOD_Util.AdjustRGB(linear7, intensity, saturation);
		((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(right, val20, 1f / 7f);
		Vector3 back = Vector3.back;
		Color val21 = SampleAtmosphere(back, directLight);
		Color linear8 = ((Color)(ref val21)).linear;
		Color val22 = TOD_Util.AdjustRGB(linear8, intensity, saturation);
		((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(back, val22, 1f / 7f);
		Vector3 forward = Vector3.forward;
		Color val23 = SampleAtmosphere(forward, directLight);
		Color linear9 = ((Color)(ref val23)).linear;
		Color val24 = TOD_Util.AdjustRGB(linear9, intensity, saturation);
		((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(forward, val24, 1f / 7f);
		Vector3 val25 = default(Vector3);
		((Vector3)(ref val25))..ctor(0f - val2.x, 0f - val2.y, 0f - val2.z);
		((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(val25, val, 0.2857143f);
		Vector3 val26 = default(Vector3);
		((Vector3)(ref val26))..ctor(val2.x, 0f - val2.y, 0f - val2.z);
		((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(val26, val, 0.2857143f);
		Vector3 val27 = default(Vector3);
		((Vector3)(ref val27))..ctor(0f - val2.x, 0f - val2.y, val2.z);
		((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(val27, val, 0.2857143f);
		Vector3 val28 = default(Vector3);
		((Vector3)(ref val28))..ctor(val2.x, 0f - val2.y, val2.z);
		((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(val28, val, 0.2857143f);
		Vector3 down = Vector3.down;
		((SphericalHarmonicsL2)(ref result)).AddDirectionalLight(down, val, 0.42857143f);
		return result;
	}

	public void RenderToCubemap(RenderTexture targetTexture = null)
	{
		//IL_0013: 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_00a1: 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_00dd: 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_0151: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)Probe))
		{
			Probe = new GameObject().AddComponent<ReflectionProbe>();
			((Object)Probe).name = ((Object)((Component)this).gameObject).name + " Reflection Probe";
			Probe.mode = (ReflectionProbeMode)1;
		}
		if (probeRenderID < 0 || Probe.IsFinishedRendering(probeRenderID))
		{
			float num = float.MaxValue;
			((Component)Probe).transform.position = Components.DomeTransform.position;
			Probe.size = new Vector3(num, num, num);
			Probe.intensity = RenderSettings.reflectionIntensity;
			Probe.clearFlags = Reflection.ClearFlags;
			Probe.cullingMask = LayerMask.op_Implicit(Reflection.CullingMask);
			Probe.refreshMode = (ReflectionProbeRefreshMode)2;
			Probe.timeSlicingMode = Reflection.TimeSlicing;
			Probe.resolution = Mathf.ClosestPowerOfTwo(Reflection.Resolution);
			if ((Object)(object)Components.Camera != (Object)null)
			{
				Probe.backgroundColor = Components.Camera.BackgroundColor;
				Probe.nearClipPlane = Components.Camera.NearClipPlane;
				Probe.farClipPlane = Components.Camera.FarClipPlane;
			}
			probeRenderID = Probe.RenderProbe(targetTexture);
		}
	}

	public Color SampleFogColor(bool directLight = true)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: 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_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: 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_0038: 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_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: 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_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_00a7: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = Vector3.forward;
		if ((Object)(object)Components.Camera != (Object)null)
		{
			Quaternion rotation = ((Component)Components.Camera).transform.rotation;
			val = Quaternion.Euler(0f, ((Quaternion)(ref rotation)).eulerAngles.y, 0f) * val;
		}
		Vector3 val2 = Vector3.Lerp(val, Vector3.up, Fog.HeightBias);
		Color val3 = SampleAtmosphere(((Vector3)(ref val2)).normalized, directLight);
		return new Color(val3.r, val3.g, val3.b, 1f);
	}

	public Color SampleSkyColor()
	{
		//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_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		Vector3 sunDirection = SunDirection;
		sunDirection.y = Mathf.Abs(sunDirection.y);
		Color val = SampleAtmosphere(((Vector3)(ref sunDirection)).normalized, directLight: false);
		return new Color(val.r, val.g, val.b, 1f);
	}

	public Color SampleEquatorColor()
	{
		//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_0017: 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_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		Vector3 sunDirection = SunDirection;
		sunDirection.y = 0f;
		Color val = SampleAtmosphere(((Vector3)(ref sunDirection)).normalized, directLight: false);
		return new Color(val.r, val.g, val.b, 1f);
	}

	public void UpdateFog()
	{
		//IL_002f: 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_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: 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_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: 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_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: 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)
		switch (Fog.Mode)
		{
		case TOD_FogType.None:
			break;
		case TOD_FogType.Atmosphere:
		{
			Color val = SampleFogColor(directLight: false);
			if (RenderSettings.fogColor != val)
			{
				RenderSettings.fogColor = val;
			}
			break;
		}
		case TOD_FogType.Directional:
		{
			Color val2 = SampleFogColor();
			if (RenderSettings.fogColor != val2)
			{
				RenderSettings.fogColor = val2;
			}
			break;
		}
		case TOD_FogType.Gradient:
			if (RenderSettings.fogColor != FogColor)
			{
				RenderSettings.fogColor = FogColor;
			}
			break;
		}
	}

	public void UpdateAmbient()
	{
		//IL_0056: 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_0062: 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_0069: Invalid comparison between Unknown and I4
		//IL_0076: 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_00a7: 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_00b3: 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_00bd: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Invalid comparison between Unknown and I4
		//IL_0087: 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)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: 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_0105: 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_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: 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_019d: Unknown result type (might be due to invalid IL or missing references)
		float saturation = Ambient.Saturation;
		float num = Mathf.Lerp(Night.AmbientMultiplier, Day.AmbientMultiplier, LerpValue);
		switch (Ambient.Mode)
		{
		case TOD_AmbientType.Color:
		{
			Color val2 = TOD_Util.AdjustRGB(AmbientColor, num, saturation);
			if ((int)RenderSettings.ambientMode != 3)
			{
				RenderSettings.ambientMode = (AmbientMode)3;
			}
			if (RenderSettings.ambientLight != val2)
			{
				RenderSettings.ambientLight = val2;
			}
			if (RenderSettings.ambientIntensity != num)
			{
				RenderSettings.ambientIntensity = num;
			}
			break;
		}
		case TOD_AmbientType.Gradient:
		{
			Color val3 = TOD_Util.AdjustRGB(AmbientColor, num, saturation);
			Color val4 = TOD_Util.AdjustRGB(SampleEquatorColor(), num, saturation);
			Color val5 = TOD_Util.AdjustRGB(SampleSkyColor(), num, saturation);
			if ((int)RenderSettings.ambientMode != 1)
			{
				RenderSettings.ambientMode = (AmbientMode)1;
			}
			if (RenderSettings.ambientSkyColor != val5)
			{
				RenderSettings.ambientSkyColor = val5;
			}
			if (RenderSettings.ambientEquatorColor != val4)
			{
				RenderSettings.ambientEquatorColor = val4;
			}
			if (RenderSettings.ambientGroundColor != val3)
			{
				RenderSettings.ambientGroundColor = val3;
			}
			if (RenderSettings.ambientIntensity != num)
			{
				RenderSettings.ambientIntensity = num;
			}
			break;
		}
		case TOD_AmbientType.Spherical:
		{
			Color val = TOD_Util.AdjustRGB(AmbientColor, num, saturation);
			if ((int)RenderSettings.ambientMode != 0)
			{
				RenderSettings.ambientMode = (AmbientMode)0;
			}
			if (RenderSettings.ambientLight != val)
			{
				RenderSettings.ambientLight = val;
			}
			if (RenderSettings.ambientIntensity != num)
			{
				RenderSettings.ambientIntensity = num;
			}
			RenderSettings.ambientProbe = RenderToSphericalHarmonics(num, saturation);
			break;
		}
		}
	}

	public void UpdateReflection()
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		TOD_ReflectionType mode = Reflection.Mode;
		if (mode == TOD_ReflectionType.Cubemap)
		{
			float num = Mathf.Lerp(Night.ReflectionMultiplier, Day.ReflectionMultiplier, LerpValue);
			if ((int)RenderSettings.defaultReflectionMode != 0)
			{
				RenderSettings.defaultReflectionMode = (DefaultReflectionMode)0;
			}
			if (RenderSettings.reflectionIntensity != num)
			{
				RenderSettings.reflectionIntensity = num;
			}
			if (Application.isPlaying)
			{
				RenderToCubemap();
			}
		}
	}

	public void LoadParameters(string xml)
	{
		using StringReader input = new StringReader(xml);
		using XmlTextReader xmlReader = new XmlTextReader(input);
		XmlSerializer xmlSerializer = new XmlSerializer(typeof(TOD_Parameters));
		TOD_Parameters tOD_Parameters = xmlSerializer.Deserialize(xmlReader) as TOD_Parameters;
		tOD_Parameters.ToSky(this);
	}

	public string SaveParameters()
	{
		StringBuilder stringBuilder = new StringBuilder();
		using (StringWriter w = new StringWriter(stringBuilder))
		{
			using XmlTextWriter xmlTextWriter = new XmlTextWriter(w);
			xmlTextWriter.Formatting = Formatting.Indented;
			XmlSerializer xmlSerializer = new XmlSerializer(typeof(TOD_Parameters));
			TOD_Parameters o = new TOD_Parameters(this);
			xmlSerializer.Serialize(xmlTextWriter, o);
		}
		return stringBuilder.ToString();
	}

	private void UpdateQualitySettings()
	{
		if (!Headless)
		{
			Mesh val = null;
			Mesh val2 = null;
			Mesh val3 = null;
			Mesh val4 = null;
			Mesh val5 = null;
			Mesh val6 = null;
			switch (MeshQuality)
			{
			case TOD_MeshQualityType.Low:
				val = Resources.SkyLOD2;
				val2 = Resources.SkyLOD2;
				val3 = Resources.SkyLOD2;
				val4 = Resources.CloudsLOD2;
				val5 = Resources.MoonLOD2;
				break;
			case TOD_MeshQualityType.Medium:
				val = Resources.SkyLOD1;
				val2 = Resources.SkyLOD1;
				val3 = Resources.SkyLOD2;
				val4 = Resources.CloudsLOD1;
				val5 = Resources.MoonLOD1;
				break;
			case TOD_MeshQualityType.High:
				val = Resources.SkyLOD0;
				val2 = Resources.SkyLOD0;
				val3 = Resources.SkyLOD2;
				val4 = Resources.CloudsLOD0;
				val5 = Resources.MoonLOD0;
				break;
			}
			switch (StarQuality)
			{
			case TOD_StarQualityType.Low:
				val6 = Resources.StarsLOD2;
				break;
			case TOD_StarQualityType.Medium:
				val6 = Resources.StarsLOD1;
				break;
			case TOD_StarQualityType.High:
				val6 = Resources.StarsLOD0;
				break;
			}
			if (Object.op_Implicit((Object)(object)Components.SpaceMeshFilter) && (Object)(object)Components.SpaceMeshFilter.sharedMesh != (Object)(object)val)
			{
				Components.SpaceMeshFilter.mesh = val;
			}
			if (Object.op_Implicit((Object)(object)Components.MoonMeshFilter) && (Object)(object)Components.MoonMeshFilter.sharedMesh != (Object)(object)val5)
			{
				Components.MoonMeshFilter.mesh = val5;
			}
			if (Object.op_Implicit((Object)(object)Components.AtmosphereMeshFilter) && (Object)(object)Components.AtmosphereMeshFilter.sharedMesh != (Object)(object)val2)
			{
				Components.AtmosphereMeshFilter.mesh = val2;
			}
			if (Object.op_Implicit((Object)(object)Components.ClearMeshFilter) && (Object)(object)Components.ClearMeshFilter.sharedMesh != (Object)(object)val3)
			{
				Components.ClearMeshFilter.mesh = val3;
			}
			if (Object.op_Implicit((Object)(object)Components.CloudMeshFilter) && (Object)(object)Components.CloudMeshFilter.sharedMesh != (Object)(object)val4)
			{
				Components.CloudMeshFilter.mesh = val4;
			}
			if (Object.op_Implicit((Object)(object)Components.StarMeshFilter) && (Object)(object)Components.StarMeshFilter.sharedMesh != (Object)(object)val6)
			{
				Components.StarMeshFilter.mesh = val6;
			}
		}
	}

	private void UpdateRenderSettings()
	{
		if (!Headless)
		{
			UpdateFog();
			if (!Application.isPlaying || timeSinceAmbientUpdate >= Ambient.UpdateInterval)
			{
				timeSinceAmbientUpdate = 0f;
				UpdateAmbient();
			}
			else
			{
				timeSinceAmbientUpdate += Time.deltaTime;
			}
			if (!Application.isPlaying || timeSinceReflectionUpdate >= Reflection.UpdateInterval)
			{
				timeSinceReflectionUpdate = 0f;
				UpdateReflection();
			}
			else
			{
				timeSinceReflectionUpdate += Time.deltaTime;
			}
		}
	}

	private void UpdateShaderKeywords()
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Invalid comparison between Unknown and I4
		if (Headless)
		{
			return;
		}
		switch (ColorSpace)
		{
		case TOD_ColorSpaceType.Auto:
			if ((int)QualitySettings.activeColorSpace == 1)
			{
				Shader.EnableKeyword("TOD_OUTPUT_LINEAR");
			}
			else
			{
				Shader.DisableKeyword("TOD_OUTPUT_LINEAR");
			}
			break;
		case TOD_ColorSpaceType.Linear:
			Shader.EnableKeyword("TOD_OUTPUT_LINEAR");
			break;
		case TOD_ColorSpaceType.Gamma:
			Shader.DisableKeyword("TOD_OUTPUT_LINEAR");
			break;
		}
		switch (ColorRange)
		{
		case TOD_ColorRangeType.Auto:
			if (Object.op_Implicit((Object)(object)Components.Camera) && Components.Camera.HDR)
			{
				Shader.EnableKeyword("TOD_OUTPUT_HDR");
			}
			else
			{
				Shader.DisableKeyword("TOD_OUTPUT_HDR");
			}
			break;
		case TOD_ColorRangeType.HDR:
			Shader.EnableKeyword("TOD_OUTPUT_HDR");
			break;
		case TOD_ColorRangeType.LDR:
			Shader.DisableKeyword("TOD_OUTPUT_HDR");
			break;
		}
		switch (ColorOutput)
		{
		case TOD_ColorOutputType.Raw:
			Shader.DisableKeyword("TOD_OUTPUT_DITHERING");
			break;
		case TOD_ColorOutputType.Dithered:
			Shader.EnableKeyword("TOD_OUTPUT_DITHERING");
			break;
		}
		switch (SkyQuality)
		{
		case TOD_SkyQualityType.PerVertex:
			Shader.DisableKeyword("TOD_SCATTERING_PER_PIXEL");
			break;
		case TOD_SkyQualityType.PerPixel:
			Shader.EnableKeyword("TOD_SCATTERING_PER_PIXEL");
			break;
		}
		switch (CloudQuality)
		{
		case TOD_CloudQualityType.Low:
			Shader.DisableKeyword("TOD_CLOUDS_DENSITY");
			Shader.DisableKeyword("TOD_CLOUDS_BUMPED");
			break;
		case TOD_CloudQualityType.Medium:
			Shader.EnableKeyword("TOD_CLOUDS_DENSITY");
			Shader.DisableKeyword("TOD_CLOUDS_BUMPED");
			break;
		case TOD_CloudQualityType.High:
			Shader.EnableKeyword("TOD_CLOUDS_DENSITY");
			Shader.EnableKeyword("TOD_CLOUDS_BUMPED");
			break;
		}
	}

	private void UpdateShaderProperties()
	{
		//IL_001d: 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_0049: 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_0075: 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_00a1: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: 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_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: 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_0145: 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_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: 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_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0391: Unknown result type (might be due to invalid IL or missing references)
		//IL_0396: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bb: 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_052c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0531: Unknown result type (might be due to invalid IL or missing references)
		//IL_0547: Unknown result type (might be due to invalid IL or missing references)
		//IL_055d: 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_0589: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c9: Unknown result type (might be due to invalid IL or missing references)
		if (!Headless)
		{
			Shader.SetGlobalColor(Resources.ID_SunLightColor, SunLightColor);
			Shader.SetGlobalColor(Resources.ID_MoonLightColor, MoonLightColor);
			Shader.SetGlobalColor(Resources.ID_SunSkyColor, SunSkyColor);
			Shader.SetGlobalColor(Resources.ID_MoonSkyColor, MoonSkyColor);
			Shader.SetGlobalColor(Resources.ID_SunMeshColor, SunMeshColor);
			Shader.SetGlobalColor(Resources.ID_MoonMeshColor, MoonMeshColor);
			Shader.SetGlobalColor(Resources.ID_SunCloudColor, SunCloudColor);
			Shader.SetGlobalColor(Resources.ID_MoonCloudColor, MoonCloudColor);
			Shader.SetGlobalColor(Resources.ID_FogColor, FogColor);
			Shader.SetGlobalColor(Resources.ID_GroundColor, GroundColor);
			Shader.SetGlobalColor(Resources.ID_AmbientColor, AmbientColor);
			Shader.SetGlobalVector(Resources.ID_SunDirection, Vector4.op_Implicit(SunDirection));
			Shader.SetGlobalVector(Resources.ID_MoonDirection, Vector4.op_Implicit(MoonDirection));
			Shader.SetGlobalVector(Resources.ID_LightDirection, Vector4.op_Implicit(LightDirection));
			Shader.SetGlobalVector(Resources.ID_LocalSunDirection, Vector4.op_Implicit(LocalSunDirection));
			Shader.SetGlobalVector(Resources.ID_LocalMoonDirection, Vector4.op_Implicit(LocalMoonDirection));
			Shader.SetGlobalVector(Resources.ID_LocalLightDirection, Vector4.op_Implicit(LocalLightDirection));
			Shader.SetGlobalFloat(Resources.ID_Contrast, Atmosphere.Contrast);
			Shader.SetGlobalFloat(Resources.ID_Brightness, Atmosphere.Brightness);
			Shader.SetGlobalFloat(Resources.ID_Fogginess, Atmosphere.Fogginess);
			Shader.SetGlobalFloat(Resources.ID_Directionality, Atmosphere.Directionality);
			Shader.SetGlobalFloat(Resources.ID_MoonHaloPower