Decompiled source of Modmas 2024 v5.0.1

Modmas2023QuickBeltSlotPatch.dll

Decompiled 6 days ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using FistVR;
using Microsoft.CodeAnalysis;
using On.FistVR;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Modmas2023QuickBeltSlotPatch")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Modmas2023QuickBeltSlotPatch")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("100db80a-981d-45c2-91ad-527e9e635a25")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[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 Cityrobo
{
	[BepInPlugin("h3vr.cityrobo.Modmas2023QuickBeltSlotPatch", "Modmas2023 QuickBeltSlot Patch", "1.0.0")]
	public class Modmas2023QuickBeltSlotPatch : BaseUnityPlugin
	{
		public void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			FVRInteractiveObject.Start += new hook_Start(FVRInteractiveObject_Start);
		}

		public void OnDestroy()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			FVRInteractiveObject.Start -= new hook_Start(FVRInteractiveObject_Start);
		}

		private void FVRInteractiveObject_Start(orig_Start orig, FVRInteractiveObject self)
		{
			orig.Invoke(self);
			FVRPhysicalObject val = (FVRPhysicalObject)(object)((self is FVRPhysicalObject) ? self : null);
			if (val != null && val.Slots != null && val.Slots.Length != 0)
			{
				((MonoBehaviour)val).StartCoroutine(FurtherDelayedRegister(val));
			}
		}

		private IEnumerator FurtherDelayedRegister(FVRPhysicalObject physicalObject)
		{
			yield return (object)new WaitForSeconds(0.5f);
			if (!physicalObject.Slots.All(GM.CurrentPlayerBody.QBSlots_Added.Contains))
			{
				physicalObject.RegisterQuickbeltSlots();
			}
		}
	}
}

Modmas2024_SosigResources.dll

Decompiled 6 days ago
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 BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using OtherLoader;
using UnityEngine;
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 Modmas2024.Modmas2024_SosigResources;

[BepInPlugin("Modmas2024.Modmas2024_SosigResources", "Modmas2024_SosigResources", "1.0.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class Modmas2024_SosigResourcesPlugin : 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(), "Modmas2024.Modmas2024_SosigResources");
		OtherLoader.RegisterDirectLoad(BasePath, "Modmas2024.Modmas2024_SosigResources", "", "", "modmas2024_sosigresources", "");
	}
}
public class ScopeEditingPanel : MonoBehaviour
{
	public Text selectedItemText;

	public Text baseMagnificationText;

	public Text baseFOVText;

	public Text reticleFOVText;

	public Text lensDistortionText;

	public Text stockZPositionText;

	private bool isEditingScopes = true;

	private int selectedFirearmIndex;

	private int selectedScopeIndex;

	private List<PIPScope> scopesInScene = new List<PIPScope>();

	private List<FVRFireArm> firearmsInScene = new List<FVRFireArm>();

	public void UpdateScopePanel()
	{
		//IL_0114: 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)
		PIPScope val = scopesInScene[selectedScopeIndex];
		FVRFireArm val2 = firearmsInScene[selectedFirearmIndex];
		if (isEditingScopes)
		{
			selectedItemText.text = ((FVRPhysicalObject)((Component)((Component)val).transform.root).GetComponent<FVRFireArmAttachment>()).ObjectWrapper.DisplayName;
			baseMagnificationText.text = "Base Magnification: " + val.baseMagnification;
			baseFOVText.text = "Base FOV: " + val.baseFOV;
			reticleFOVText.text = "Reticle FOV: " + val.reticle.reticleFOV;
			lensDistortionText.text = "Lens Distortion: " + val.distortion;
		}
		else if (!isEditingScopes)
		{
			selectedItemText.text = ((FVRPhysicalObject)val2).ObjectWrapper.DisplayName;
			stockZPositionText.text = ((Component)val2.StockPos).transform.position.z.ToString();
		}
	}

	public void GrabFirearmsInScene()
	{
		firearmsInScene.Clear();
		firearmsInScene.AddRange(Object.FindObjectsOfType<FVRFireArm>());
		selectedFirearmIndex = 0;
	}

	public void GrabScopesInScene()
	{
		scopesInScene.Clear();
		scopesInScene.AddRange(Object.FindObjectsOfType<PIPScope>());
		selectedScopeIndex = 0;
	}

	public void IndexForward()
	{
		if (isEditingScopes)
		{
			if (selectedScopeIndex == scopesInScene.Count)
			{
				selectedScopeIndex = 0;
			}
			else
			{
				selectedScopeIndex++;
			}
		}
		else if (!isEditingScopes)
		{
			if (selectedFirearmIndex == firearmsInScene.Count)
			{
				selectedFirearmIndex = 0;
			}
			else
			{
				selectedFirearmIndex++;
			}
		}
		UpdateScopePanel();
	}

	public void IndexBackward()
	{
		if (isEditingScopes)
		{
			if (selectedScopeIndex == 0)
			{
				selectedScopeIndex = scopesInScene.Count;
			}
			else
			{
				selectedScopeIndex--;
			}
		}
		else if (!isEditingScopes)
		{
			if (selectedFirearmIndex == 0)
			{
				selectedFirearmIndex = firearmsInScene.Count;
			}
			else
			{
				selectedFirearmIndex--;
			}
		}
		UpdateScopePanel();
	}

	public void IndexRefresh()
	{
		GrabFirearmsInScene();
		GrabScopesInScene();
		UpdateScopePanel();
	}
}

Modmas2024Base.dll

Decompiled 6 days ago
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 Atlas;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using OtherLoader;
using UnityEngine;
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]
public class SceneLoaderObject : FVRPhysicalObject
{
	[Header("Scene Loading")]
	public string sceneToLoad = "";

	private static readonly Collider[] Colliders = (Collider[])(object)new Collider[32];

	private Rigidbody _rb;

	public override void Awake()
	{
		((FVRPhysicalObject)this).Awake();
		_rb = ((Component)this).GetComponent<Rigidbody>();
	}

	public override void UpdateInteraction(FVRViveHand hand)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		((FVRPhysicalObject)this).UpdateInteraction(hand);
		int num = Physics.OverlapSphereNonAlloc(GM.CurrentPlayerBody.Head.position + Vector3.up * -0.1f, 0.1f, Colliders, -1, (QueryTriggerInteraction)1);
		bool flag = false;
		for (int i = 0; i < num; i++)
		{
			if ((Object)(object)Colliders[i].attachedRigidbody == (Object)(object)_rb)
			{
				flag = true;
			}
		}
		if (flag)
		{
			LoadMap();
		}
	}

	public void LoadMap()
	{
		AtlasPlugin.LoadCustomScene(sceneToLoad);
	}
}
namespace Modmas2024.Modmas2024Base;

[BepInPlugin("Modmas2024.Modmas2024Base", "Modmas2024Base", "5.0.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class Modmas2024BasePlugin : 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(), "Modmas2024.Modmas2024Base");
		OtherLoader.RegisterDirectLoad(BasePath, "Modmas2024.Modmas2024Base", "", "", "modmas 2024 base", "");
		OtherLoader.RegisterDirectLoad(BasePath, "Modmas2024.Modmas2024Base", "", "", "sirtatoesnote", "");
	}
}
public class ScopeEditingPanel : MonoBehaviour
{
	public Text selectedItemText;

	public Text baseMagnificationText;

	public Text baseFOVText;

	public Text reticleFOVText;

	public Text lensDistortionText;

	public Text stockZPositionText;

	private bool isEditingScopes = true;

	private int selectedFirearmIndex;

	private int selectedScopeIndex;

	private List<PIPScope> scopesInScene = new List<PIPScope>();

	private List<FVRFireArm> firearmsInScene = new List<FVRFireArm>();

	public void UpdateScopePanel()
	{
		//IL_0114: 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)
		PIPScope val = scopesInScene[selectedScopeIndex];
		FVRFireArm val2 = firearmsInScene[selectedFirearmIndex];
		if (isEditingScopes)
		{
			selectedItemText.text = ((FVRPhysicalObject)((Component)((Component)val).transform.root).GetComponent<FVRFireArmAttachment>()).ObjectWrapper.DisplayName;
			baseMagnificationText.text = "Base Magnification: " + val.baseMagnification;
			baseFOVText.text = "Base FOV: " + val.baseFOV;
			reticleFOVText.text = "Reticle FOV: " + val.reticle.reticleFOV;
			lensDistortionText.text = "Lens Distortion: " + val.distortion;
		}
		else if (!isEditingScopes)
		{
			selectedItemText.text = ((FVRPhysicalObject)val2).ObjectWrapper.DisplayName;
			stockZPositionText.text = ((Component)val2.StockPos).transform.position.z.ToString();
		}
	}

	public void GrabFirearmsInScene()
	{
		firearmsInScene.Clear();
		firearmsInScene.AddRange(Object.FindObjectsOfType<FVRFireArm>());
		selectedFirearmIndex = 0;
	}

	public void GrabScopesInScene()
	{
		scopesInScene.Clear();
		scopesInScene.AddRange(Object.FindObjectsOfType<PIPScope>());
		selectedScopeIndex = 0;
	}

	public void IndexForward()
	{
		if (isEditingScopes)
		{
			if (selectedScopeIndex == scopesInScene.Count)
			{
				selectedScopeIndex = 0;
			}
			else
			{
				selectedScopeIndex++;
			}
		}
		else if (!isEditingScopes)
		{
			if (selectedFirearmIndex == firearmsInScene.Count)
			{
				selectedFirearmIndex = 0;
			}
			else
			{
				selectedFirearmIndex++;
			}
		}
		UpdateScopePanel();
	}

	public void IndexBackward()
	{
		if (isEditingScopes)
		{
			if (selectedScopeIndex == 0)
			{
				selectedScopeIndex = scopesInScene.Count;
			}
			else
			{
				selectedScopeIndex--;
			}
		}
		else if (!isEditingScopes)
		{
			if (selectedFirearmIndex == 0)
			{
				selectedFirearmIndex = firearmsInScene.Count;
			}
			else
			{
				selectedFirearmIndex--;
			}
		}
		UpdateScopePanel();
	}

	public void IndexRefresh()
	{
		GrabFirearmsInScene();
		GrabScopesInScene();
		UpdateScopePanel();
	}
}

Modmas2024Map.dll

Decompiled 6 days ago
using System;
using System.Collections;
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.Bootstrap;
using BepInEx.Logging;
using BossFight.src;
using FistVR;
using HarmonyLib;
using OtherLoader;
using Sodalite.Api;
using Sodalite.Utilities;
using UnityEditor;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Profiling;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
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]
public class Modmas2024_BountyBoard : MonoBehaviour
{
	private void Start()
	{
	}

	private void Update()
	{
	}
}
public class FlickerLight : MonoBehaviour
{
	public float MinLightIntensity = 0.5f;

	public float MaxLightIntensity = 2.3f;

	public float AccelerateTime = 0.15f;

	private float _targetIntensity = 1f;

	private float _lastIntensity = 1f;

	private float _timePassed = 0f;

	private Light _lt;

	private const double Tolerance = 0.0001;

	private void Start()
	{
		_lt = ((Component)this).GetComponent<Light>();
		_lastIntensity = _lt.intensity;
		FixedUpdate();
	}

	private void FixedUpdate()
	{
		_timePassed += Time.deltaTime;
		_lt.intensity = Mathf.Lerp(_lastIntensity, _targetIntensity, _timePassed / AccelerateTime);
		if ((double)Mathf.Abs(_lt.intensity - _targetIntensity) < 0.0001)
		{
			_lastIntensity = _lt.intensity;
			_targetIntensity = Random.Range(MinLightIntensity, MaxLightIntensity);
			_timePassed = 0f;
		}
	}
}
[RequireComponent(typeof(MeshRenderer))]
public class UVOffset : MonoBehaviour
{
	public float scrollSpeed = 0.5f;

	public bool scrollY = true;

	private MeshRenderer renderer;

	private void Start()
	{
		renderer = ((Component)this).GetComponent<MeshRenderer>();
	}

	private void Update()
	{
		//IL_003f: 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)
		float num = Time.time * scrollSpeed;
		((Renderer)renderer).material.SetTextureOffset("_MainTex", (!scrollY) ? new Vector2(0f, num) : new Vector2(num, 0f));
	}
}
namespace Modmas2024.Modmas2024Map
{
	[BepInPlugin("Modmas2024.Modmas2024Map", "Modmas2024Map", "5.0.1")]
	[BepInProcess("h3vr.exe")]
	[Description("Built with MeatKit")]
	[BepInDependency("nrgill28.Atlas", "1.0.1")]
	public class Modmas2024MapPlugin : 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(), "Modmas2024.Modmas2024Map");
			AtlasPlugin.RegisterScene(Path.Combine(BasePath, "modmas2024newmap"));
		}
	}
}
namespace Modmas2023.Modmas_2023
{
	public class Nuke : MonoBehaviour, IFVRDamageable
	{
		[Header("Nuke-Specific Parameters")]
		[SerializeField]
		private float health = 10000f;

		[SerializeField]
		private GameObject mesh;

		[Header("Explosion parameters")]
		[SerializeField]
		private AudioEvent explosionSound;

		[Tooltip("What material the bomb is set to during the explosion.")]
		[SerializeField]
		private Material explosionMaterial;

		[SerializeField]
		private float expansionSpeed = 10f;

		[SerializeField]
		private GameObject[] enableOnExplode;

		[SerializeField]
		private GameObject[] disableOnExplode;

		private bool hasExploded;

		private IEnumerator expansionCoroutine;

		private float bombScale = 1f;

		public void Start()
		{
			expansionCoroutine = bombExpansion();
		}

		public void Damage(Damage d)
		{
			health -= d.Dam_TotalKinetic;
			if ((health <= 0f || d.Dam_EMP > 0f) && !hasExploded)
			{
				hasExploded = true;
				Detonate();
			}
		}

		private void Detonate()
		{
			//IL_000e: 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_0037: 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_010c: 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)
			SM.PlayCoreSound((FVRPooledAudioType)5, explosionSound, ((Component)this).transform.position);
			ScreenShake.TriggerShake(new ShakeProfile(3.5f, 0.4f), new VignetteProfile(3.4f, 1f, 0.35f, Color.black));
			if (enableOnExplode.Length > 0)
			{
				GameObject[] array = enableOnExplode;
				foreach (GameObject val in array)
				{
					val.SetActive(true);
				}
			}
			if (disableOnExplode.Length > 0)
			{
				GameObject[] array2 = disableOnExplode;
				foreach (GameObject val2 in array2)
				{
					val2.SetActive(false);
				}
			}
			if ((Object)(object)mesh.GetComponent<MeshRenderer>() != (Object)null && (Object)(object)explosionMaterial != (Object)null)
			{
				((Renderer)mesh.GetComponent<MeshRenderer>()).material = explosionMaterial;
				((MonoBehaviour)this).StartCoroutine(expansionCoroutine);
			}
			Scene activeScene = SceneManager.GetActiveScene();
			SteamVR_LoadLevel.Begin(((Scene)(ref activeScene)).name, false, 0.1f, 0f, 0f, 0f, 1f);
		}

		private IEnumerator bombExpansion()
		{
			while (true)
			{
				bombScale += expansionSpeed * Time.deltaTime;
				mesh.transform.localScale = new Vector3(bombScale, bombScale, bombScale);
				yield return null;
			}
		}
	}
}
namespace Modmas2023
{
	public class FollowTarget : MonoBehaviour
	{
		[Header("Only fill if the target is not the main camera or player head")]
		public Transform target;

		private bool attached;

		private Vector3 playerOffset;

		private void Update()
		{
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			if (!attached)
			{
				if ((Object)(object)target == (Object)null)
				{
					if ((Object)(object)GM.CurrentPlayerBody != (Object)null)
					{
						if ((Object)(object)GM.CurrentPlayerBody.Head != (Object)null)
						{
							target = GM.CurrentPlayerBody.Head;
							playerOffset = target.position - ((Component)this).transform.position;
							attached = true;
						}
						else
						{
							Debug.Log((object)"FollowTarget needs a target to be assigned");
							attached = false;
						}
					}
				}
				else
				{
					playerOffset = target.position - ((Component)this).transform.position;
					attached = true;
				}
			}
			else
			{
				((Component)this).transform.position = target.position - playerOffset;
			}
		}
	}
}
public class FollowTargetDebug : MonoBehaviour
{
	private bool check;

	private void OnLevelWasLoaded()
	{
		Debug.Log((object)("OnLevelWasLoaded, player head exists: " + GM.CurrentPlayerBody != null));
	}

	private void Awake()
	{
		Debug.Log((object)("OnAwake, player head exists: " + GM.CurrentPlayerBody != null));
	}

	private void Start()
	{
		Debug.Log((object)("Start, player head exists: " + GM.CurrentPlayerBody != null));
	}

	private void Update()
	{
		if (!check)
		{
			Debug.Log((object)("Update, player head exists: " + GM.CurrentPlayerBody != null));
		}
		check = true;
	}
}
public class OBJExporter : ScriptableWizard
{
	public bool onlySelectedObjects = false;

	public bool applyPosition = true;

	public bool applyRotation = true;

	public bool applyScale = true;

	public bool generateMaterials = true;

	public bool exportTextures = true;

	public bool splitObjects = true;

	public bool autoMarkTexReadable = false;

	public bool objNameAddIdNum = false;

	private string versionString = "v2.0";

	private string lastExportFolder;

	private bool StaticBatchingEnabled()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Expected O, but got Unknown
		PlayerSettings[] array = Resources.FindObjectsOfTypeAll<PlayerSettings>();
		if (array == null)
		{
			return false;
		}
		SerializedObject val = new SerializedObject((Object[])(object)array);
		SerializedProperty val2 = val.FindProperty("m_BuildTargetBatching");
		for (int i = 0; i < val2.arraySize; i++)
		{
			SerializedProperty arrayElementAtIndex = val2.GetArrayElementAtIndex(i);
			if (arrayElementAtIndex == null)
			{
				continue;
			}
			IEnumerator enumerator = arrayElementAtIndex.GetEnumerator();
			if (enumerator == null)
			{
				continue;
			}
			while (enumerator.MoveNext())
			{
				SerializedProperty val3 = (SerializedProperty)enumerator.Current;
				if (val3 != null && val3.name == "m_StaticBatching")
				{
					return val3.boolValue;
				}
			}
		}
		return false;
	}

	private void OnWizardUpdate()
	{
		((ScriptableWizard)this).helpString = "Aaro4130's OBJ Exporter " + versionString;
	}

	private Vector3 RotateAroundPoint(Vector3 point, Vector3 pivot, Quaternion angle)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: 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_001a: Unknown result type (might be due to invalid IL or missing references)
		return angle * (point - pivot) + pivot;
	}

	private Vector3 MultiplyVec3s(Vector3 v1, Vector3 v2)
	{
		//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_0039: Unknown result type (might be due to invalid IL or missing references)
		return new Vector3(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z);
	}

	private void OnWizardCreate()
	{
		if (StaticBatchingEnabled() && Application.isPlaying)
		{
			EditorUtility.DisplayDialog("Error", "Static batching is enabled. This will cause the export file to look like a mess, as well as be a large filesize. Disable this option, and restart the player, before continuing.", "OK");
			return;
		}
		if (autoMarkTexReadable)
		{
			int num = EditorUtility.DisplayDialogComplex("Warning", "This will convert all textures to Advanced type with the read/write option set. This is not reversible and will permanently affect your project. Continue?", "Yes", "No", "Cancel");
			if (num > 0)
			{
				return;
			}
		}
		string @string = EditorPrefs.GetString("a4_OBJExport_lastPath", "");
		string string2 = EditorPrefs.GetString("a4_OBJExport_lastFile", "unityexport.obj");
		string text = EditorUtility.SaveFilePanel("Export OBJ", @string, string2, "obj");
		if (text.Length > 0)
		{
			FileInfo fileInfo = new FileInfo(text);
			EditorPrefs.SetString("a4_OBJExport_lastFile", fileInfo.Name);
			EditorPrefs.SetString("a4_OBJExport_lastPath", fileInfo.Directory.FullName);
			Export(text);
		}
	}

	private void Export(string exportPath)
	{
		//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f2: 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_030c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0343: Unknown result type (might be due to invalid IL or missing references)
		//IL_0348: Unknown result type (might be due to invalid IL or missing references)
		//IL_034b: 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_035c: Unknown result type (might be due to invalid IL or missing references)
		//IL_036a: Unknown result type (might be due to invalid IL or missing references)
		//IL_036f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0374: Unknown result type (might be due to invalid IL or missing references)
		//IL_0384: Unknown result type (might be due to invalid IL or missing references)
		//IL_0386: Unknown result type (might be due to invalid IL or missing references)
		//IL_0397: Unknown result type (might be due to invalid IL or missing references)
		//IL_039c: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0463: Unknown result type (might be due to invalid IL or missing references)
		//IL_0468: Unknown result type (might be due to invalid IL or missing references)
		//IL_046b: Unknown result type (might be due to invalid IL or missing references)
		//IL_046d: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03be: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_047c: Unknown result type (might be due to invalid IL or missing references)
		//IL_048a: Unknown result type (might be due to invalid IL or missing references)
		//IL_048f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0493: Unknown result type (might be due to invalid IL or missing references)
		//IL_0498: Unknown result type (might be due to invalid IL or missing references)
		//IL_049d: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_04af: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_0565: Unknown result type (might be due to invalid IL or missing references)
		//IL_056a: Unknown result type (might be due to invalid IL or missing references)
		Dictionary<string, bool> dictionary = new Dictionary<string, bool>();
		FileInfo fileInfo = new FileInfo(exportPath);
		lastExportFolder = fileInfo.Directory.FullName;
		string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(exportPath);
		EditorUtility.DisplayProgressBar("Exporting OBJ", "Please wait.. Starting export.", 0f);
		MeshFilter[] array;
		if (onlySelectedObjects)
		{
			List<MeshFilter> list = new List<MeshFilter>();
			GameObject[] gameObjects = Selection.gameObjects;
			foreach (GameObject val in gameObjects)
			{
				MeshFilter component = val.GetComponent<MeshFilter>();
				if ((Object)(object)component != (Object)null)
				{
					list.Add(component);
				}
			}
			array = list.ToArray();
		}
		else
		{
			array = Object.FindObjectsOfType(typeof(MeshFilter)) as MeshFilter[];
		}
		if (Application.isPlaying)
		{
			MeshFilter[] array2 = array;
			foreach (MeshFilter val2 in array2)
			{
				MeshRenderer component2 = ((Component)val2).gameObject.GetComponent<MeshRenderer>();
				if ((Object)(object)component2 != (Object)null && ((Renderer)component2).isPartOfStaticBatch)
				{
					EditorUtility.ClearProgressBar();
					EditorUtility.DisplayDialog("Error", "Static batched object detected. Static batching is not compatible with this exporter. Please disable it before starting the player.", "OK");
					return;
				}
			}
		}
		StringBuilder stringBuilder = new StringBuilder();
		StringBuilder stringBuilder2 = new StringBuilder();
		stringBuilder.AppendLine("# Export of " + Application.loadedLevelName);
		stringBuilder.AppendLine("# from Aaro4130 OBJ Exporter " + versionString);
		if (generateMaterials)
		{
			stringBuilder.AppendLine("mtllib " + fileNameWithoutExtension + ".mtl");
		}
		float num = array.Length + 1;
		int num2 = 0;
		for (int k = 0; k < array.Length; k++)
		{
			string name = ((Object)((Component)array[k]).gameObject).name;
			float num3 = (float)(k + 1) / num;
			EditorUtility.DisplayProgressBar("Exporting objects... (" + Mathf.Round(num3 * 100f) + "%)", "Exporting object " + name, num3);
			MeshFilter val3 = array[k];
			MeshRenderer component3 = ((Component)array[k]).gameObject.GetComponent<MeshRenderer>();
			if (splitObjects)
			{
				string text = name;
				if (objNameAddIdNum)
				{
					text = text + "_" + k;
				}
				stringBuilder.AppendLine("g " + text);
			}
			if ((Object)(object)component3 != (Object)null && generateMaterials)
			{
				Material[] sharedMaterials = ((Renderer)component3).sharedMaterials;
				foreach (Material val4 in sharedMaterials)
				{
					if (!dictionary.ContainsKey(((Object)val4).name))
					{
						dictionary[((Object)val4).name] = true;
						stringBuilder2.Append(MaterialToString(val4));
						stringBuilder2.AppendLine();
					}
				}
			}
			Mesh sharedMesh = val3.sharedMesh;
			int num4 = (int)Mathf.Clamp(((Component)val3).gameObject.transform.lossyScale.x * ((Component)val3).gameObject.transform.lossyScale.z, -1f, 1f);
			Vector3[] vertices = sharedMesh.vertices;
			foreach (Vector3 val5 in vertices)
			{
				Vector3 val6 = val5;
				if (applyScale)
				{
					val6 = MultiplyVec3s(val6, ((Component)val3).gameObject.transform.lossyScale);
				}
				if (applyRotation)
				{
					val6 = RotateAroundPoint(val6, Vector3.zero, ((Component)val3).gameObject.transform.rotation);
				}
				if (applyPosition)
				{
					val6 += ((Component)val3).gameObject.transform.position;
				}
				val6.x *= -1f;
				stringBuilder.AppendLine("v " + val6.x + " " + val6.y + " " + val6.z);
			}
			Vector3[] normals = sharedMesh.normals;
			foreach (Vector3 val7 in normals)
			{
				Vector3 val8 = val7;
				if (applyScale)
				{
					Vector3 v = val8;
					Vector3 lossyScale = ((Component)val3).gameObject.transform.lossyScale;
					val8 = MultiplyVec3s(v, ((Vector3)(ref lossyScale)).normalized);
				}
				if (applyRotation)
				{
					val8 = RotateAroundPoint(val8, Vector3.zero, ((Component)val3).gameObject.transform.rotation);
				}
				val8.x *= -1f;
				stringBuilder.AppendLine("vn " + val8.x + " " + val8.y + " " + val8.z);
			}
			Vector2[] uv = sharedMesh.uv;
			for (int num5 = 0; num5 < uv.Length; num5++)
			{
				Vector2 val9 = uv[num5];
				stringBuilder.AppendLine("vt " + val9.x + " " + val9.y);
			}
			for (int num6 = 0; num6 < sharedMesh.subMeshCount; num6++)
			{
				if ((Object)(object)component3 != (Object)null && num6 < ((Renderer)component3).sharedMaterials.Length)
				{
					string name2 = ((Object)((Renderer)component3).sharedMaterials[num6]).name;
					stringBuilder.AppendLine("usemtl " + name2);
				}
				else
				{
					stringBuilder.AppendLine("usemtl " + name + "_sm" + num6);
				}
				int[] triangles = sharedMesh.GetTriangles(num6);
				for (int num7 = 0; num7 < triangles.Length; num7 += 3)
				{
					int index = triangles[num7] + 1 + num2;
					int index2 = triangles[num7 + 1] + 1 + num2;
					int index3 = triangles[num7 + 2] + 1 + num2;
					if (num4 < 0)
					{
						stringBuilder.AppendLine("f " + ConstructOBJString(index) + " " + ConstructOBJString(index2) + " " + ConstructOBJString(index3));
					}
					else
					{
						stringBuilder.AppendLine("f " + ConstructOBJString(index3) + " " + ConstructOBJString(index2) + " " + ConstructOBJString(index));
					}
				}
			}
			num2 += sharedMesh.vertices.Length;
		}
		File.WriteAllText(exportPath, stringBuilder.ToString());
		if (generateMaterials)
		{
			File.WriteAllText(fileInfo.Directory.FullName + "\\" + fileNameWithoutExtension + ".mtl", stringBuilder2.ToString());
		}
		EditorUtility.ClearProgressBar();
	}

	private string TryExportTexture(string propertyName, Material m)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Expected O, but got Unknown
		if (m.HasProperty(propertyName))
		{
			Texture texture = m.GetTexture(propertyName);
			if ((Object)(object)texture != (Object)null)
			{
				return ExportTexture((Texture2D)texture);
			}
		}
		return "false";
	}

	private string ExportTexture(Texture2D t)
	{
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Expected O, but got Unknown
		try
		{
			if (autoMarkTexReadable)
			{
				string assetPath = AssetDatabase.GetAssetPath((Object)(object)t);
				AssetImporter atPath = AssetImporter.GetAtPath(assetPath);
				TextureImporter val = (TextureImporter)(object)((atPath is TextureImporter) ? atPath : null);
				if ((Object)(object)val != (Object)null)
				{
					val.textureType = (TextureImporterType)0;
					if (!val.isReadable)
					{
						val.isReadable = true;
						AssetDatabase.ImportAsset(assetPath);
						AssetDatabase.Refresh();
					}
				}
			}
			string text = lastExportFolder + "\\" + ((Object)t).name + ".png";
			Texture2D val2 = new Texture2D(((Texture)t).width, ((Texture)t).height, (TextureFormat)5, false);
			val2.SetPixels(t.GetPixels());
			File.WriteAllBytes(text, val2.EncodeToPNG());
			return text;
		}
		catch (Exception)
		{
			Debug.Log((object)("Could not export texture : " + ((Object)t).name + ". is it readable?"));
			return "null";
		}
	}

	private string ConstructOBJString(int index)
	{
		string text = index.ToString();
		return text + "/" + text + "/" + text;
	}

	private string MaterialToString(Material m)
	{
		//IL_0041: 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_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0140: 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_00d3: 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_0103: 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)
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("newmtl " + ((Object)m).name);
		if (m.HasProperty("_Color"))
		{
			stringBuilder.AppendLine("Kd " + m.color.r + " " + m.color.g + " " + m.color.b);
			if (m.color.a < 1f)
			{
				stringBuilder.AppendLine("Tr " + (1f - m.color.a));
				stringBuilder.AppendLine("d " + m.color.a);
			}
		}
		if (m.HasProperty("_SpecColor"))
		{
			Color color = m.GetColor("_SpecColor");
			stringBuilder.AppendLine("Ks " + color.r + " " + color.g + " " + color.b);
		}
		if (exportTextures)
		{
			string text = TryExportTexture("_MainTex", m);
			if (text != "false")
			{
				stringBuilder.AppendLine("map_Kd " + text);
			}
			text = TryExportTexture("_SpecMap", m);
			if (text != "false")
			{
				stringBuilder.AppendLine("map_Ks " + text);
			}
			text = TryExportTexture("_BumpMap", m);
			if (text != "false")
			{
				stringBuilder.AppendLine("map_Bump " + text);
			}
		}
		stringBuilder.AppendLine("illum 2");
		return stringBuilder.ToString();
	}

	[MenuItem("File/Export/Wavefront OBJ")]
	private static void CreateWizard()
	{
		ScriptableWizard.DisplayWizard("Export OBJ", typeof(OBJExporter), "Export");
	}
}
public class TSR_Course : MonoBehaviour
{
	[Header("Target Setter/Resetter Setup")]
	[Tooltip("Array of targets")]
	public TSR_Target[] targets;

	[Tooltip("Whether this button and its targets is enabled or disabled whenever the map starts")]
	public bool isTargetsEnabledAtStart;

	[Tooltip("Game Object thats enabled whenever the targets are turned on")]
	public GameObject enabledVis;

	[Tooltip("Game Object thats enabled whenever the targets are turned off")]
	public GameObject disabledVis;

	[HideInInspector]
	public bool isTargetsActive;

	private FVRObject mainObject;

	[HideInInspector]
	public List<GameObject> allTargets = new List<GameObject>();

	[HideInInspector]
	public bool buttonPressed;

	private void Start()
	{
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < targets.Length; i++)
		{
			for (int num = ((Component)targets[i]).transform.childCount - 1; num >= 0; num--)
			{
				Object.Destroy((Object)(object)((Component)((Component)targets[i]).transform.GetChild(num)).gameObject);
			}
		}
		if (isTargetsEnabledAtStart)
		{
			for (int j = 0; j < targets.Length; j++)
			{
				if (targets[j].itemID != null && (Object)(object)targets[j].targetPrefab == (Object)null)
				{
					if (IM.OD.TryGetValue(targets[j].itemID, out mainObject))
					{
						GameObject val = Object.Instantiate<GameObject>(((AnvilAsset)mainObject).GetGameObject(), ((Component)targets[j]).transform.position, ((Component)targets[j]).transform.rotation);
						allTargets.Add(val);
						if (targets[j].isPhysicsLocked)
						{
							val.GetComponent<Rigidbody>().isKinematic = true;
						}
					}
					continue;
				}
				if ((Object)(object)targets[j].targetPrefab != (Object)null && targets[j].itemID == null)
				{
					GameObject val2 = Object.Instantiate<GameObject>(targets[j].targetPrefab, ((Component)targets[j]).transform.position, ((Component)targets[j]).transform.rotation);
					allTargets.Add(val2);
					if (targets[j].isPhysicsLocked)
					{
						val2.GetComponent<Rigidbody>().isKinematic = true;
					}
					continue;
				}
				return;
			}
			isTargetsActive = true;
			enabledVis.SetActive(true);
			disabledVis.SetActive(false);
		}
		else if (!isTargetsEnabledAtStart)
		{
			isTargetsActive = false;
			enabledVis.SetActive(false);
			disabledVis.SetActive(true);
		}
	}

	public void ResetTargets()
	{
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		if (!isTargetsActive || !isTargetsActive)
		{
			return;
		}
		for (int i = 0; i < allTargets.Count; i++)
		{
			if ((Object)(object)allTargets[i] != (Object)null)
			{
				Object.Destroy((Object)(object)allTargets[i]);
			}
		}
		allTargets.Clear();
		for (int j = 0; j < targets.Length; j++)
		{
			if (targets[j].itemID != null && (Object)(object)targets[j].targetPrefab == (Object)null)
			{
				if (IM.OD.TryGetValue(targets[j].itemID, out mainObject))
				{
					GameObject val = Object.Instantiate<GameObject>(((AnvilAsset)mainObject).GetGameObject(), ((Component)targets[j]).transform.position, ((Component)targets[j]).transform.rotation);
					allTargets.Add(val);
					if (targets[j].isPhysicsLocked)
					{
						val.GetComponent<Rigidbody>().isKinematic = true;
					}
				}
				continue;
			}
			if ((Object)(object)targets[j].targetPrefab != (Object)null && targets[j].itemID == null)
			{
				GameObject val2 = Object.Instantiate<GameObject>(targets[j].targetPrefab, ((Component)targets[j]).transform.position, ((Component)targets[j]).transform.rotation);
				allTargets.Add(val2);
				if (targets[j].isPhysicsLocked)
				{
					val2.GetComponent<Rigidbody>().isKinematic = true;
				}
				continue;
			}
			break;
		}
	}

	public void SpawnTargets()
	{
		//IL_0121: 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_007b: 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)
		if (!isTargetsActive)
		{
			for (int i = 0; i < targets.Length; i++)
			{
				if (targets[i].itemID != null && (Object)(object)targets[i].targetPrefab == (Object)null)
				{
					if (IM.OD.TryGetValue(targets[i].itemID, out mainObject))
					{
						GameObject val = Object.Instantiate<GameObject>(((AnvilAsset)mainObject).GetGameObject(), ((Component)targets[i]).transform.position, ((Component)targets[i]).transform.rotation);
						allTargets.Add(val);
						if (targets[i].isPhysicsLocked && (Object)(object)val.GetComponent<Rigidbody>() != (Object)null)
						{
							val.GetComponent<Rigidbody>().isKinematic = true;
						}
					}
					continue;
				}
				if ((Object)(object)targets[i].targetPrefab != (Object)null && targets[i].itemID == null)
				{
					GameObject val2 = Object.Instantiate<GameObject>(targets[i].targetPrefab, ((Component)targets[i]).transform.position, ((Component)targets[i]).transform.rotation);
					allTargets.Add(val2);
					if (targets[i].isPhysicsLocked && (Object)(object)val2.GetComponent<Rigidbody>() != (Object)null)
					{
						val2.GetComponent<Rigidbody>().isKinematic = true;
					}
					continue;
				}
				return;
			}
			enabledVis.SetActive(true);
			disabledVis.SetActive(false);
			isTargetsActive = true;
		}
		else
		{
			if (!isTargetsActive)
			{
				return;
			}
			for (int j = 0; j < allTargets.Count; j++)
			{
				if ((Object)(object)allTargets[j] != (Object)null)
				{
					Object.Destroy((Object)(object)allTargets[j]);
				}
			}
			allTargets.Clear();
			enabledVis.SetActive(false);
			disabledVis.SetActive(true);
			isTargetsActive = false;
		}
	}

	private void OnTriggerEnter(Collider collider)
	{
		if (!buttonPressed && ((Component)collider).gameObject.tag == "GameController")
		{
			SpawnTargets();
			buttonPressed = true;
		}
	}

	private void OnTriggerExit(Collider collider)
	{
		if (((Component)collider).gameObject.tag == "GameController")
		{
			buttonPressed = false;
		}
	}

	private void OnDrawGizmos()
	{
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: 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_011a: 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_00ed: 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_016e: 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)
		if (targets == null)
		{
			return;
		}
		for (int i = 0; i < targets.Length; i++)
		{
			if ((Object)(object)targets[i].targetPrefab != (Object)null && !string.IsNullOrEmpty(targets[i].itemID))
			{
				Gizmos.color = Color.red;
				Gizmos.DrawSphere(((Component)targets[i]).transform.position, 0.1f);
				Debug.LogWarning((object)("Target " + i + " has both filled at the same time!"));
			}
			else if (!string.IsNullOrEmpty(targets[i].itemID))
			{
				Gizmos.color = Color.yellow;
				Gizmos.DrawSphere(((Component)targets[i]).transform.position, 0.1f);
			}
			else if ((Object)(object)targets[i].targetPrefab != (Object)null)
			{
				Gizmos.color = Color.cyan;
				Gizmos.DrawSphere(((Component)targets[i]).transform.position, 0.1f);
			}
			else
			{
				Gizmos.color = Color.gray;
				Gizmos.DrawWireSphere(((Component)targets[i]).transform.position, 0.1f);
				Debug.LogWarning((object)("Target " + i + " is empty!"));
			}
			if (targets[i].isPhysicsLocked)
			{
				Gizmos.color = Color.green;
				Gizmos.DrawWireSphere(((Component)targets[i]).transform.position, 0.11f);
			}
		}
	}
}
public class TSR_ExternalButton : MonoBehaviour
{
	public TSR_Course mainButton;

	public bool isResetButton;

	public AudioSource resetAudio;

	[Tooltip("Game Object thats enabled whenever the targets are turned on")]
	public GameObject enabledVis;

	[Tooltip("Game Object thats enabled whenever the targets are turned off")]
	public GameObject disabledVis;

	[HideInInspector]
	public bool buttonPressed;

	private void FixedUpdate()
	{
		if (!((Object)(object)enabledVis == (Object)null) && !((Object)(object)disabledVis == (Object)null))
		{
			if (mainButton.isTargetsActive)
			{
				enabledVis.SetActive(true);
				disabledVis.SetActive(false);
			}
			else
			{
				enabledVis.SetActive(false);
				disabledVis.SetActive(true);
			}
		}
	}

	private void OnTriggerEnter(Collider collider)
	{
		if (!buttonPressed && ((Component)collider).gameObject.tag == "GameController")
		{
			if (isResetButton)
			{
				mainButton.ResetTargets();
				resetAudio.Play();
			}
			else
			{
				mainButton.SpawnTargets();
			}
			buttonPressed = true;
		}
	}

	private void OnTriggerExit(Collider collider)
	{
		if (((Component)collider).gameObject.tag == "GameController")
		{
			buttonPressed = false;
		}
	}
}
public class TSR_Target : MonoBehaviour
{
	[Header("Target Setup")]
	[Tooltip("Spawn this object ID at this transform (dont use both of these at the same time)")]
	public string itemID;

	[Tooltip("Spawn a custom prefab at this transform (dont use both of these at the same time)")]
	public GameObject targetPrefab;

	[Tooltip("Makes sure the object that is spawned is unable to be affected by physics (by checking for rigidbodies and making them kinematic)")]
	public bool isPhysicsLocked;
}
public class ArenaStart : MonoBehaviour
{
	[SerializeField]
	private GameObject flip;

	[SerializeField]
	private GameObject flop;

	[SerializeField]
	private GameObject gate;

	[SerializeField]
	private bool isEnd;

	[SerializeField]
	private Transform gateUpPos;

	[SerializeField]
	private Transform gateDownPos;

	[SerializeField]
	private float gateMoveSpeed = 1f;

	[SerializeField]
	private Collider startTrigger;

	[SerializeField]
	private Collider endTrigger;

	[SerializeField]
	private AudioSource beginHorn;

	public void OnTriggerEnter(Collider other)
	{
		if (((Component)other).gameObject.tag == "GameController")
		{
			Debug.Log((object)"player entered me!");
			flip.SetActive(true);
			Debug.Log((object)"flip");
			if (isEnd)
			{
				((MonoBehaviour)this).StartCoroutine(MoveGateUp());
				startTrigger.enabled = true;
				endTrigger.enabled = false;
				Debug.Log((object)"Triggers flipped");
			}
			else
			{
				((MonoBehaviour)this).StartCoroutine(MoveGateDown());
				startTrigger.enabled = false;
				endTrigger.enabled = true;
				beginHorn.Play();
				Debug.Log((object)"Triggers flopped");
			}
			flop.SetActive(false);
			Debug.Log((object)"flop");
		}
	}

	private IEnumerator MoveGateUp()
	{
		Debug.Log((object)"Starting to move gate up");
		while (Vector3.Distance(gate.transform.position, gateUpPos.position) > 0.01f)
		{
			gate.GetComponent<Rigidbody>().MovePosition(Vector3.MoveTowards(gate.transform.position, gateUpPos.position, gateMoveSpeed * Time.fixedDeltaTime));
			yield return null;
		}
	}

	private IEnumerator MoveGateDown()
	{
		Debug.Log((object)"Starting to move gate down");
		while (Vector3.Distance(gate.transform.position, gateDownPos.position) > 0.01f)
		{
			gate.GetComponent<Rigidbody>().MovePosition(Vector3.MoveTowards(gate.transform.position, gateDownPos.position, gateMoveSpeed * Time.fixedDeltaTime));
			yield return null;
		}
	}
}
public class AutoLoadSceneOnStart : MonoBehaviour
{
	private VaultFile FileToSpawn = new VaultFile();

	public string FileName;

	private string SceneVaultFileName;

	public string PluginDictionaryString;

	public float timer = 1f;

	private bool sceneSpawned = false;

	public GameObject treeGifts;

	private IEnumerator Start()
	{
		while (LoaderStatus.GetLoaderProgress() != 1f)
		{
			yield return null;
		}
		PreloadSceneFile();
		if (BossCombatant.isDefeated)
		{
			treeGifts.SetActive(true);
		}
	}

	public void PreloadSceneFile()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		PluginInfo value = new PluginInfo();
		Chainloader.PluginInfos.TryGetValue(PluginDictionaryString, out value);
		string directoryName = Path.GetDirectoryName(value.Location);
		Load<VaultFile>(Path.Combine(directoryName, FileName), FileToSpawn);
		((MonoBehaviour)this).StartCoroutine(LoadVaultFile());
	}

	public void Load<T>(string path, T objectToOverwrite)
	{
		string empty = string.Empty;
		Debug.Log((object)path);
		JsonUtility.FromJsonOverwrite(File.ReadAllText(path), (object)objectToOverwrite);
	}

	private IEnumerator LoadVaultFile()
	{
		yield return (object)new WaitForSeconds(timer);
		string text = default(string);
		VaultSystem.SpawnObjects((VaultFileDisplayMode)2, FileToSpawn, ref text, (Transform)null, Vector3.zero);
	}
}
public class BeginBoss : MonoBehaviour
{
	public GameObject bossPrefab;

	public GameObject spawnedBoss;

	public bool isBossActive;

	public bool isBossStarted;

	public void OnTriggerEnter(Collider other)
	{
		if (((Component)other).gameObject.tag == "GameController" && !isBossActive)
		{
			BossStart();
		}
	}

	public void BossStart()
	{
		//IL_0019: 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)
		isBossActive = true;
		GameObject val = Object.Instantiate<GameObject>(bossPrefab, bossPrefab.transform.position, bossPrefab.transform.rotation);
		val.SetActive(true);
		spawnedBoss = val;
	}

	public void BossBegin()
	{
		isBossStarted = true;
		spawnedBoss.GetComponent<BossManager>().playerDistanceCheck = true;
	}

	public void BossEnd()
	{
		Object.Destroy((Object)(object)spawnedBoss);
		isBossActive = false;
		isBossStarted = false;
	}

	private void PlayerDeathMethod()
	{
		BossEnd();
	}

	private void OnEnable()
	{
		PlayerDeathTracker.OnPlayerDeathEvent += PlayerDeathMethod;
	}

	private void OnDisable()
	{
		PlayerDeathTracker.OnPlayerDeathEvent -= PlayerDeathMethod;
	}
}
public class BinaryExplosive : MonoBehaviour, IFVRDamageable
{
	public FVRPhysicalObject BaseObj;

	public float Durability;

	public GameObject[] SpawnOnDet;

	public bool IsDebug = false;

	public float _damageTaken;

	public void FixedUpdate()
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		if (!(_damageTaken >= Durability))
		{
			return;
		}
		for (int i = 0; i < SpawnOnDet.Length; i++)
		{
			GameObject val = Object.Instantiate<GameObject>(SpawnOnDet[i], SpawnOnDet[i].transform.position, SpawnOnDet[i].transform.rotation);
			val.SetActive(true);
			Explosion component = val.GetComponent<Explosion>();
			if ((Object)(object)component != (Object)null)
			{
				component.IFF = GM.CurrentPlayerBody.GetPlayerIFF();
			}
			ExplosionSound component2 = val.GetComponent<ExplosionSound>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.IFF = GM.CurrentPlayerBody.GetPlayerIFF();
			}
			GrenadeExplosion component3 = val.GetComponent<GrenadeExplosion>();
			if ((Object)(object)component3 != (Object)null)
			{
				component3.IFF = GM.CurrentPlayerBody.GetPlayerIFF();
			}
		}
		if ((Object)(object)BaseObj != (Object)null)
		{
			if (((FVRInteractiveObject)BaseObj).IsHeld)
			{
				FVRViveHand hand = ((FVRInteractiveObject)BaseObj).m_hand;
				hand.ForceSetInteractable((FVRInteractiveObject)null);
				((FVRInteractiveObject)BaseObj).EndInteraction(hand);
			}
			Object.Destroy((Object)(object)((Component)BaseObj).gameObject);
		}
		Object.Destroy((Object)(object)((Component)this).gameObject);
	}

	public void Damage(Damage d)
	{
		_damageTaken += d.Dam_TotalKinetic;
		if (IsDebug)
		{
			Debug.Log((object)("Damange taken: " + d.Dam_TotalKinetic));
			Debug.Log((object)("Total Damange taken: " + _damageTaken));
		}
	}
}
public class CSL_SosigManager : MonoBehaviour
{
	[HideInInspector]
	public List<Sosig> activeSosigs;

	public CSL_SosigSpawner[] civvieSpawners;

	private IEnumerator Start()
	{
		while (LoaderStatus.GetLoaderProgress() != 1f)
		{
			yield return null;
		}
		yield return (object)new WaitForSeconds(5f);
		SpawnCivvies();
		Debug.Log((object)"SOSIG SPAWN HERE");
	}

	private void Update()
	{
		UpdateAllSosigs();
	}

	public void SpawnCivvies()
	{
		for (int i = 0; i < civvieSpawners.Length; i++)
		{
			civvieSpawners[i].SpawnSosig();
		}
	}

	public void UpdateAllSosigs()
	{
		CSL_SosigSpawner[] array = civvieSpawners;
		foreach (CSL_SosigSpawner cSL_SosigSpawner in array)
		{
			cSL_SosigSpawner.UpdateSosig();
		}
	}

	public void ClearSosigs()
	{
		for (int i = 0; i < activeSosigs.Count; i++)
		{
			activeSosigs[i].DeSpawnSosig();
		}
		activeSosigs.Clear();
	}
}
public class CSL_SosigSpawner : MonoBehaviour
{
	private Sosig mySosig;

	public CSL_SosigManager sosigManager;

	public int id;

	public SosigOrder spawnState = (SosigOrder)6;

	public int IFF;

	public bool SpawnActive;

	public SosigSpeechSet speechSetOverride;

	public Transform[] pathPoints;

	private List<Vector3> pathpos = new List<Vector3>();

	private List<Vector3> pathrot = new List<Vector3>();

	private void Start()
	{
		//IL_009a: 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)
		List<int> list = new List<int>();
		for (int i = 0; i < pathPoints.Length; i++)
		{
			list.Add(i);
		}
		for (int j = 0; j < list.Count; j++)
		{
			int index = Random.Range(j, list.Count);
			int value = list[j];
			list[j] = list[index];
			list[index] = value;
		}
		foreach (int item in list)
		{
			Transform val = pathPoints[item];
			pathpos.Add(val.position);
			pathrot.Add(val.eulerAngles);
		}
	}

	public void SpawnSosig()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_0009: 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_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
		SpawnOptions val = new SpawnOptions();
		val.SpawnState = spawnState;
		val.SpawnActivated = SpawnActive;
		val.EquipmentMode = (EquipmentSlots)7;
		val.SpawnWithFullAmmo = true;
		val.IFF = IFF;
		val.SosigTargetPosition = ((Component)this).transform.position;
		val.SosigTargetRotation = ((Component)this).transform.eulerAngles;
		SpawnOptions val2 = val;
		Sosig val3 = SosigAPI.Spawn(ManagerSingleton<IM>.Instance.odicSosigObjsByID[(SosigEnemyID)id], val2, ((Component)this).transform.position, ((Component)this).transform.rotation);
		((Component)val3).GetComponent<NavMeshAgent>().obstacleAvoidanceType = (ObstacleAvoidanceType)1;
		val3.Speech = speechSetOverride;
		sosigManager.activeSosigs.Add(val3);
		val3.IgnoresNeedForWeapons = true;
		mySosig = val3;
		mySosig.CommandPathTo(pathpos, pathrot, 1f, Vector2.one * 4f, 2f, (SosigMoveSpeed)3, (PathLoopType)4, (List<Sosig>)null, 0.2f, 1f, false, 50f);
		UpdateSosig();
	}

	public void UpdateSosig()
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Invalid comparison between Unknown and I4
		if ((Object)(object)mySosig != (Object)null && mySosig.CanSpeakState() && (int)mySosig.CurrentOrder == 10)
		{
			mySosig.Speak_State(speechSetOverride.OnWander);
		}
	}

	private void OnDrawGizmos()
	{
		//IL_0015: 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_0045: 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_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)
		Gizmos.color = new Color(0.8f, 0.2f, 0.2f, 0.5f);
		Gizmos.DrawSphere(((Component)this).transform.position, 0.1f);
		Gizmos.DrawLine(((Component)this).transform.position, ((Component)this).transform.position + ((Component)this).transform.forward * 0.25f);
	}
}
public class CustomSosigEnableTrigger : MonoBehaviour
{
	public CustomSosigSpawner[] spawners;

	public bool sosigsSpawned;

	public void OnTriggerEnter(Collider other)
	{
		if (((Component)other).gameObject.tag == "GameController" && !sosigsSpawned)
		{
			for (int i = 0; i < spawners.Length; i++)
			{
				((Component)spawners[i]).gameObject.SetActive(true);
			}
			sosigsSpawned = true;
		}
	}
}
public class CustomSosigSpawner : MonoBehaviour
{
	private Sosig mySosig;

	public int id;

	public SosigOrder spawnState = (SosigOrder)6;

	public int IFF;

	public bool SpawnActive;

	public SosigSpeechSet speechSetOverride;

	public void OnEnable()
	{
		SpawnSosig();
	}

	public void SpawnSosig()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_0009: 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_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		SpawnOptions val = new SpawnOptions();
		val.SpawnState = spawnState;
		val.SpawnActivated = SpawnActive;
		val.EquipmentMode = (EquipmentSlots)7;
		val.SpawnWithFullAmmo = true;
		val.IFF = IFF;
		val.SosigTargetPosition = ((Component)this).transform.position;
		val.SosigTargetRotation = ((Component)this).transform.eulerAngles;
		SpawnOptions val2 = val;
		Sosig val3 = SosigAPI.Spawn(ManagerSingleton<IM>.Instance.odicSosigObjsByID[(SosigEnemyID)id], val2, ((Component)this).transform.position, ((Component)this).transform.rotation);
		((Component)val3).GetComponent<NavMeshAgent>().obstacleAvoidanceType = (ObstacleAvoidanceType)1;
		val3.Speech = speechSetOverride;
	}

	private void OnDrawGizmos()
	{
		//IL_0015: 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_0045: 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_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)
		Gizmos.color = new Color(0.8f, 0.2f, 0.2f, 0.5f);
		Gizmos.DrawSphere(((Component)this).transform.position, 0.1f);
		Gizmos.DrawLine(((Component)this).transform.position, ((Component)this).transform.position + ((Component)this).transform.forward * 0.25f);
	}
}
public class DelayedObjectSpawnPoint : MonoBehaviour
{
	public string ObjectId = "";

	public bool SpawnOnStart = true;

	private IEnumerator Start()
	{
		if (SpawnOnStart)
		{
			while (LoaderStatus.GetLoaderProgress() != 1f)
			{
				yield return null;
			}
			yield return (object)new WaitForSeconds(5f);
			Spawn();
		}
	}

	public void Spawn()
	{
		((MonoBehaviour)this).StartCoroutine(SpawnAsync());
	}

	private IEnumerator SpawnAsync()
	{
		if (IM.OD.TryGetValue(ObjectId, out var obj))
		{
			AnvilCallback<GameObject> callback = ((AnvilAsset)obj).GetGameObjectAsync();
			yield return callback;
			Object.Instantiate<GameObject>(callback.Result, ((Component)this).transform.position, ((Component)this).transform.rotation).SetActive(true);
		}
	}

	private void OnDrawGizmos()
	{
		//IL_0015: 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_0045: 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_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)
		Gizmos.color = new Color(0f, 0f, 0.6f, 0.5f);
		Gizmos.DrawSphere(((Component)this).transform.position, 0.1f);
		Gizmos.DrawLine(((Component)this).transform.position, ((Component)this).transform.position + ((Component)this).transform.forward * 0.25f);
	}
}
public class FlipFlopLights : MonoBehaviour
{
	public GameObject[] lights;

	public bool flopped;

	public void FlipFlop()
	{
		if (!flopped)
		{
			for (int i = 0; i < lights.Length; i++)
			{
				lights[i].SetActive(false);
			}
			flopped = true;
		}
		else if (flopped)
		{
			for (int j = 0; j < lights.Length; j++)
			{
				lights[j].SetActive(true);
			}
			flopped = false;
		}
	}
}
public class LinkedBinaryExplosive : MonoBehaviour, IFVRDamageable
{
	public BinaryExplosive binaryExplosive;

	public void Damage(Damage d)
	{
		binaryExplosive._damageTaken += d.Dam_TotalKinetic;
	}
}
public class ModmasArena : MonoBehaviour
{
	private List<Sosig> spawnedSosigs = new List<Sosig>();

	private bool canSpawn;

	private float spawnTimer;

	[SerializeField]
	private SosigSpeechSet speechSetOverride;

	[SerializeField]
	private Transform[] spawnPoints;

	[SerializeField]
	private int maxSosigs;

	[SerializeField]
	private int[] sosigID;

	[SerializeField]
	private SosigOrder spawnState = (SosigOrder)6;

	[SerializeField]
	private int sosigIFF;

	[SerializeField]
	private bool SpawnActive;

	[SerializeField]
	private float SpawnDelay;

	private Vector3 playerPos;

	private void Update()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: 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_00ae: Invalid comparison between Unknown and I4
		if (!canSpawn)
		{
			return;
		}
		playerPos = GM.CurrentPlayerRoot.position - Vector3.down;
		if (spawnedSosigs.Count <= maxSosigs && spawnTimer <= Time.time)
		{
			SpawnSosig(SodaliteUtils.GetRandom<Transform>((IList<Transform>)spawnPoints), SodaliteUtils.GetRandom<int>((IList<int>)sosigID));
			spawnTimer = SpawnDelay + Time.time;
		}
		for (int i = 0; i < spawnedSosigs.Count; i++)
		{
			spawnedSosigs[i].UpdateAssaultPoint(playerPos);
			if ((int)spawnedSosigs[i].BodyState == 3)
			{
				spawnedSosigs[i].ClearSosig();
				spawnedSosigs.Remove(spawnedSosigs[i]);
			}
		}
	}

	private void SpawnSosig(Transform sp, int id)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_0009: 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_0047: 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_006b: Unknown result type (might be due to invalid IL or missing references)
		SpawnOptions val = new SpawnOptions();
		val.SpawnState = spawnState;
		val.SpawnActivated = SpawnActive;
		val.EquipmentMode = (EquipmentSlots)7;
		val.SpawnWithFullAmmo = true;
		val.IFF = sosigIFF;
		val.SosigTargetPosition = sp.position;
		val.SosigTargetRotation = sp.eulerAngles;
		SpawnOptions val2 = val;
		Sosig val3 = SosigAPI.Spawn(ManagerSingleton<IM>.Instance.odicSosigObjsByID[(SosigEnemyID)id], val2, sp.position, sp.rotation);
		if ((Object)(object)speechSetOverride != (Object)null)
		{
			val3.Speech = speechSetOverride;
		}
		spawnedSosigs.Add(val3);
	}

	public void OnTriggerEnter(Collider other)
	{
		if (((Component)other).gameObject.tag == "GameController")
		{
			canSpawn = true;
		}
	}

	public void OnTriggerExit(Collider other)
	{
		if (!(((Component)other).gameObject.tag == "GameController"))
		{
			return;
		}
		canSpawn = false;
		if (spawnedSosigs.Count <= 0)
		{
			return;
		}
		foreach (Sosig spawnedSosig in spawnedSosigs)
		{
			spawnedSosig.ClearSosig();
		}
		spawnedSosigs.Clear();
	}

	private void OnDrawGizmos()
	{
		//IL_0029: 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_0044: 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_0050: 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)
		Transform[] array = spawnPoints;
		foreach (Transform val in array)
		{
			Gizmos.color = new Color(0.8f, 0.2f, 0.2f, 0.5f);
			Gizmos.DrawSphere(val.position, 0.1f);
			Gizmos.DrawLine(val.position, val.position + val.forward * 0.25f);
		}
	}

	private void PlayerDeathMethod()
	{
		canSpawn = false;
		if (spawnedSosigs.Count <= 0)
		{
			return;
		}
		foreach (Sosig spawnedSosig in spawnedSosigs)
		{
			spawnedSosig.ClearSosig();
		}
		spawnedSosigs.Clear();
	}

	private void OnEnable()
	{
		PlayerDeathTracker.OnPlayerDeathEvent += PlayerDeathMethod;
	}

	private void OnDisable()
	{
		PlayerDeathTracker.OnPlayerDeathEvent -= PlayerDeathMethod;
	}
}
public class PlayerDeathTracker : MonoBehaviour
{
	public delegate void OnPlayerDeath();

	public static PlayerDeathTracker instance;

	private bool hasDied = false;

	public static event OnPlayerDeath OnPlayerDeathEvent;

	private void Awake()
	{
		instance = this;
	}

	private void Update()
	{
		if ((Object)(object)GM.CurrentPlayerBody == (Object)null)
		{
			return;
		}
		if (GM.CurrentPlayerBody.Health <= 0f)
		{
			if (PlayerDeathTracker.OnPlayerDeathEvent != null)
			{
				hasDied = true;
				PlayerDeathTracker.OnPlayerDeathEvent();
			}
		}
		else if (hasDied && GM.CurrentPlayerBody.Health > 0f)
		{
			hasDied = false;
		}
	}
}
public class SlideOutOfGround : MonoBehaviour
{
	public GameObject cover;

	public Transform coverUpPos;

	public Transform coverDownPos;

	public float coverMoveSpeed;

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

	public void OnDisable()
	{
		((MonoBehaviour)this).StartCoroutine(MoveCoverDown());
	}

	private IEnumerator MoveCoverUp()
	{
		while (Vector3.Distance(cover.transform.position, coverUpPos.position) > 0.01f)
		{
			cover.GetComponent<Rigidbody>().MovePosition(Vector3.MoveTowards(cover.transform.position, coverUpPos.position, coverMoveSpeed * Time.fixedDeltaTime));
			yield return null;
		}
	}

	private IEnumerator MoveCoverDown()
	{
		while (Vector3.Distance(cover.transform.position, coverDownPos.position) > 0.01f)
		{
			cover.GetComponent<Rigidbody>().MovePosition(Vector3.MoveTowards(cover.transform.position, coverDownPos.position, coverMoveSpeed * Time.fixedDeltaTime));
			yield return null;
		}
	}
}
public class SpawnVaultFile : MonoBehaviour
{
	private VaultFile FileToSpawn = new VaultFile();

	public string FileName;

	private string SceneVaultFileName;

	public string PluginDictionaryString;

	public float timer = 1f;

	public void OnEnable()
	{
		PreloadSceneFile();
	}

	public void PreloadSceneFile()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		PluginInfo value = new PluginInfo();
		Chainloader.PluginInfos.TryGetValue(PluginDictionaryString, out value);
		string directoryName = Path.GetDirectoryName(value.Location);
		Load<VaultFile>(Path.Combine(directoryName, FileName), FileToSpawn);
		((MonoBehaviour)this).StartCoroutine(LoadVaultFile());
	}

	public void Load<T>(string path, T objectToOverwrite)
	{
		string empty = string.Empty;
		Debug.Log((object)path);
		JsonUtility.FromJsonOverwrite(File.ReadAllText(path), (object)objectToOverwrite);
	}

	private IEnumerator LoadVaultFile()
	{
		yield return (object)new WaitForSeconds(timer);
		string text = default(string);
		VaultSystem.SpawnObjects((VaultFileDisplayMode)0, FileToSpawn, ref text, ((Component)this).transform, Vector3.zero);
	}
}
public class StartBoss : MonoBehaviour
{
	public BeginBoss bossBegin;

	public void OnTriggerEnter(Collider other)
	{
		if (((Component)other).gameObject.tag == "GameController" && !bossBegin.isBossStarted)
		{
			bossBegin.BossBegin();
		}
	}
}
public class StopBoss : MonoBehaviour
{
	public BeginBoss bossBegin;

	public void OnTriggerEnter(Collider other)
	{
		if (((Component)other).gameObject.tag == "GameController" && bossBegin.isBossActive)
		{
			bossBegin.BossEnd();
		}
	}
}
public class ToggleSnowQuality : MonoBehaviour
{
	public ParticleSystem[] hQSnowSystems;

	public ParticleSystem[] lQSnowSystems;

	public bool isSnowCheap;

	public void OnTriggerEnter(Collider other)
	{
		if (((Component)other).gameObject.tag == "GameController" && isSnowCheap)
		{
			for (int i = 0; i < lQSnowSystems.Length; i++)
			{
				((Component)lQSnowSystems[i]).gameObject.SetActive(false);
			}
		}
	}

	public void OnTriggerExit(Collider other)
	{
		if (((Component)other).gameObject.tag == "GameController" && isSnowCheap)
		{
			for (int i = 0; i < lQSnowSystems.Length; i++)
			{
				((Component)lQSnowSystems[i]).gameObject.SetActive(true);
			}
		}
	}

	public void FlipFlop()
	{
		if (!isSnowCheap)
		{
			for (int i = 0; i < hQSnowSystems.Length; i++)
			{
				((Component)hQSnowSystems[i]).gameObject.SetActive(false);
			}
			for (int j = 0; j < lQSnowSystems.Length; j++)
			{
				((Component)lQSnowSystems[j]).gameObject.SetActive(true);
			}
			isSnowCheap = true;
		}
		else if (isSnowCheap)
		{
			for (int k = 0; k < hQSnowSystems.Length; k++)
			{
				((Component)hQSnowSystems[k]).gameObject.SetActive(true);
			}
			for (int l = 0; l < lQSnowSystems.Length; l++)
			{
				((Component)lQSnowSystems[l]).gameObject.SetActive(false);
			}
			isSnowCheap = false;
		}
	}
}
public class ToggleSosigs : MonoBehaviour
{
	public CSL_SosigManager manager;

	public bool flopped;

	public void FlipFlop()
	{
		if (!flopped)
		{
			manager.ClearSosigs();
			flopped = true;
		}
		else if (flopped)
		{
			manager.SpawnCivvies();
			flopped = false;
		}
	}
}
public class CuttableMesh
{
	private MeshRenderer inputMeshRenderer;

	private bool hasUvs;

	private bool hasUv1s;

	private bool hasColours;

	private List<CuttableSubMesh> subMeshes;

	public CuttableMesh(Mesh inputMesh)
	{
		Init(inputMesh, ((Object)inputMesh).name);
	}

	public CuttableMesh(MeshRenderer input)
	{
		inputMeshRenderer = input;
		MeshFilter component = ((Component)input).GetComponent<MeshFilter>();
		Mesh sharedMesh = component.sharedMesh;
		Init(sharedMesh, ((Object)input).name);
	}

	public CuttableMesh(CuttableMesh inputMesh, List<CuttableSubMesh> newSubMeshes)
	{
		inputMeshRenderer = inputMesh.inputMeshRenderer;
		hasUvs = inputMesh.hasUvs;
		hasUv1s = inputMesh.hasUv1s;
		hasColours = inputMesh.hasColours;
		subMeshes = new List<CuttableSubMesh>();
		subMeshes.AddRange(newSubMeshes);
	}

	private void Init(Mesh inputMesh, string debugName)
	{
		subMeshes = new List<CuttableSubMesh>();
		if (inputMesh.isReadable)
		{
			Vector3[] vertices = inputMesh.vertices;
			Vector3[] normals = inputMesh.normals;
			Vector2[] uv = inputMesh.uv;
			Vector2[] uv2 = inputMesh.uv2;
			Color32[] colors = inputMesh.colors32;
			hasUvs = uv != null && uv.Length > 0;
			hasUv1s = uv2 != null && uv2.Length > 0;
			hasColours = colors != null && colors.Length > 0;
			for (int i = 0; i < inputMesh.subMeshCount; i++)
			{
				int[] indices = inputMesh.GetIndices(i);
				CuttableSubMesh item = new CuttableSubMesh(indices, vertices, normals, colors, uv, uv2);
				subMeshes.Add(item);
			}
		}
		else
		{
			Debug.LogError((object)("CuttableMesh's input mesh is not readable: " + debugName), (Object)(object)inputMesh);
		}
	}

	public void Add(CuttableMesh other)
	{
		if (subMeshes.Count != other.subMeshes.Count)
		{
			throw new Exception("Mismatched submesh count");
		}
		for (int i = 0; i < subMeshes.Count; i++)
		{
			subMeshes[i].Add(other.subMeshes[i]);
		}
	}

	public int NumSubMeshes()
	{
		return subMeshes.Count;
	}

	public bool HasUvs()
	{
		return hasUvs;
	}

	public bool HasColours()
	{
		return hasColours;
	}

	public List<CuttableSubMesh> GetSubMeshes()
	{
		return subMeshes;
	}

	public CuttableSubMesh GetSubMesh(int index)
	{
		return subMeshes[index];
	}

	public Transform GetTransform()
	{
		if ((Object)(object)inputMeshRenderer != (Object)null)
		{
			return ((Component)inputMeshRenderer).transform;
		}
		return null;
	}

	public MeshRenderer ConvertToRenderer(string newObjectName)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_003d: 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_005d: 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_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		Mesh val = CreateMesh();
		if (val.vertexCount == 0)
		{
			return null;
		}
		GameObject val2 = new GameObject(newObjectName);
		val2.transform.SetParent(((Component)inputMeshRenderer).transform);
		val2.transform.localPosition = Vector3.zero;
		val2.transform.localRotation = Quaternion.identity;
		val2.transform.localScale = Vector3.one;
		MeshFilter val3 = val2.AddComponent<MeshFilter>();
		val3.mesh = val;
		MeshRenderer val4 = val2.AddComponent<MeshRenderer>();
		((Renderer)val4).shadowCastingMode = ((Renderer)inputMeshRenderer).shadowCastingMode;
		((Renderer)val4).reflectionProbeUsage = ((Renderer)inputMeshRenderer).reflectionProbeUsage;
		((Renderer)val4).lightProbeUsage = ((Renderer)inputMeshRenderer).lightProbeUsage;
		((Renderer)val4).sharedMaterials = ((Renderer)inputMeshRenderer).sharedMaterials;
		return val4;
	}

	public Mesh CreateMesh()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		Mesh val = new Mesh();
		int num = 0;
		for (int i = 0; i < subMeshes.Count; i++)
		{
			num += subMeshes[i].NumIndices();
		}
		List<Vector3> list = new List<Vector3>();
		List<Vector3> list2 = new List<Vector3>();
		List<Color32> list3 = ((!hasColours) ? null : new List<Color32>());
		List<Vector2> list4 = ((!hasUvs) ? null : new List<Vector2>());
		List<Vector2> list5 = ((!hasUv1s) ? null : new List<Vector2>());
		List<int> list6 = new List<int>();
		foreach (CuttableSubMesh subMesh in subMeshes)
		{
			list6.Add(list.Count);
			subMesh.AddTo(list, list2, list3, list4, list5);
		}
		val.vertices = list.ToArray();
		val.normals = list2.ToArray();
		val.colors32 = ((!hasColours) ? null : list3.ToArray());
		val.uv = ((!hasUvs) ? null : list4.ToArray());
		val.uv2 = ((!hasUv1s) ? null : list5.ToArray());
		val.subMeshCount = subMeshes.Count;
		for (int j = 0; j < subMeshes.Count; j++)
		{
			CuttableSubMesh cuttableSubMesh = subMeshes[j];
			int num2 = list6[j];
			int[] array = cuttableSubMesh.GenIndices();
			for (int k = 0; k < array.Length; k++)
			{
				array[k] += num2;
			}
			val.SetTriangles(array, j, true);
		}
		return val;
	}
}
public class CuttableSubMesh
{
	private List<Vector3> vertices;

	private List<Vector3> normals;

	private List<Color32> colours;

	private List<Vector2> uvs;

	private List<Vector2> uv1s;

	public CuttableSubMesh(bool hasNormals, bool hasColours, bool hasUvs, bool hasUv1)
	{
		vertices = new List<Vector3>();
		if (hasNormals)
		{
			normals = new List<Vector3>();
		}
		if (hasColours)
		{
			colours = new List<Color32>();
		}
		if (hasUvs)
		{
			uvs = new List<Vector2>();
		}
		if (hasUv1)
		{
			uv1s = new List<Vector2>();
		}
	}

	public CuttableSubMesh(int[] indices, Vector3[] inputVertices, Vector3[] inputNormals, Color32[] inputColours, Vector2[] inputUvs, Vector2[] inputUv1)
	{
		//IL_0099: 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_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		vertices = new List<Vector3>();
		if (inputNormals != null && inputNormals.Length > 0)
		{
			normals = new List<Vector3>();
		}
		if (inputColours != null && inputColours.Length > 0)
		{
			colours = new List<Color32>();
		}
		if (inputUvs != null && inputUvs.Length > 0)
		{
			uvs = new List<Vector2>();
		}
		if (inputUv1 != null && inputUv1.Length > 0)
		{
			uv1s = new List<Vector2>();
		}
		foreach (int num in indices)
		{
			vertices.Add(inputVertices[num]);
			if (normals != null)
			{
				normals.Add(inputNormals[num]);
			}
			if (colours != null)
			{
				colours.Add(inputColours[num]);
			}
			if (uvs != null)
			{
				uvs.Add(inputUvs[num]);
			}
			if (uv1s != null)
			{
				uv1s.Add(inputUv1[num]);
			}
		}
	}

	public void Add(CuttableSubMesh other)
	{
		for (int i = 0; i < other.vertices.Count; i++)
		{
			CopyVertex(i, other);
		}
	}

	public int NumVertices()
	{
		return vertices.Count;
	}

	public Vector3 GetVertex(int index)
	{
		//IL_0008: 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_0013: Unknown result type (might be due to invalid IL or missing references)
		return vertices[index];
	}

	public bool HasNormals()
	{
		return normals != null;
	}

	public bool HasColours()
	{
		return colours != null;
	}

	public bool HasUvs()
	{
		return uvs != null;
	}

	public bool HasUv1()
	{
		return uv1s != null;
	}

	public void CopyVertex(int srcIndex, CuttableSubMesh srcMesh)
	{
		//IL_000e: 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_0052: 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_0096: Unknown result type (might be due to invalid IL or missing references)
		vertices.Add(srcMesh.vertices[srcIndex]);
		if (normals != null)
		{
			normals.Add(srcMesh.normals[srcIndex]);
		}
		if (colours != null)
		{
			colours.Add(srcMesh.colours[srcIndex]);
		}
		if (uvs != null)
		{
			uvs.Add(srcMesh.uvs[srcIndex]);
		}
		if (uv1s != null)
		{
			uv1s.Add(srcMesh.uv1s[srcIndex]);
		}
	}

	public void AddInterpolatedVertex(int i0, int i1, float weight, CuttableSubMesh srcMesh)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: 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_0019: 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_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: 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_0090: 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_00c0: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		Vector3 vertex = srcMesh.GetVertex(i0);
		Vector3 vertex2 = srcMesh.GetVertex(i1);
		vertices.Add(Vector3.Lerp(vertex, vertex2, weight));
		if (normals != null)
		{
			List<Vector3> list = normals;
			Vector3 val = Vector3.Lerp(srcMesh.normals[i0], srcMesh.normals[i1], weight);
			list.Add(((Vector3)(ref val)).normalized);
		}
		if (colours != null)
		{
			colours.Add(Color32.Lerp(srcMesh.colours[i0], srcMesh.colours[i1], weight));
		}
		if (uvs != null)
		{
			uvs.Add(Vector2.Lerp(srcMesh.uvs[i0], srcMesh.uvs[i1], weight));
		}
		if (uv1s != null)
		{
			uv1s.Add(Vector2.Lerp(srcMesh.uv1s[i0], srcMesh.uv1s[i1], weight));
		}
	}

	public void AddTo(List<Vector3> destVertices, List<Vector3> destNormals, List<Color32> destColours, List<Vector2> destUvs, List<Vector2> destUv1s)
	{
		destVertices.AddRange(vertices);
		if (normals != null)
		{
			destNormals.AddRange(normals);
		}
		if (colours != null)
		{
			destColours.AddRange(colours);
		}
		if (uvs != null)
		{
			destUvs.AddRange(uvs);
		}
		if (uv1s != null)
		{
			destUv1s.AddRange(uv1s);
		}
	}

	public int NumIndices()
	{
		return vertices.Count;
	}

	public int[] GenIndices()
	{
		int[] array = new int[vertices.Count];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = i;
		}
		return array;
	}
}
public enum VertexClassification
{
	Front = 1,
	Back = 2,
	OnPlane = 4
}
public class MeshCutter
{
	private CuttableMesh inputMesh;

	private List<CuttableSubMesh> outputFrontSubMeshes;

	private List<CuttableSubMesh> outputBackSubMeshes;

	public void Cut(CuttableMesh input, Plane worldCutPlane)
	{
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: 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_0056: 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_008a: Unknown result type (might be due to invalid IL or missing references)
		inputMesh = input;
		outputFrontSubMeshes = new List<CuttableSubMesh>();
		outputBackSubMeshes = new List<CuttableSubMesh>();
		Transform transform = inputMesh.GetTransform();
		Plane cutPlane = default(Plane);
		if ((Object)(object)transform != (Object)null)
		{
			Vector3 val = transform.InverseTransformPoint(ClosestPointOnPlane(worldCutPlane, Vector3.zero));
			Vector3 val2 = transform.InverseTransformDirection(((Plane)(ref worldCutPlane)).normal);
			((Plane)(ref cutPlane))..ctor(val2, val);
		}
		else
		{
			cutPlane = worldCutPlane;
		}
		foreach (CuttableSubMesh subMesh in input.GetSubMeshes())
		{
			Cut(subMesh, cutPlane);
		}
	}

	private static Vector3 ClosestPointOnPlane(Plane plane, Vector3 point)
	{
		//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_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)
		//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_0045: 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_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_004b: Unknown result type (might be due to invalid IL or missing references)
		float distanceToPoint = ((Plane)(ref plane)).GetDistanceToPoint(point);
		if (((Plane)(ref plane)).GetSide(point))
		{
			return point - ((Plane)(ref plane)).normal * distanceToPoint;
		}
		return point + ((Plane)(ref plane)).normal * distanceToPoint;
	}

	public CuttableMesh GetFrontOutput()
	{
		return new CuttableMesh(inputMesh, outputFrontSubMeshes);
	}

	public CuttableMesh GetBackOutput()
	{
		return new CuttableMesh(inputMesh, outputBackSubMeshes);
	}

	private void Cut(CuttableSubMesh inputSubMesh, Plane cutPlane)
	{
		//IL_004f: 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_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: 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_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: 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_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: 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_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d6: 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_02dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02df: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: 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_0204: 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_0284: Unknown result type (might be due to invalid IL or missing references)
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		bool hasNormals = inputSubMesh.HasNormals();
		bool hasColours = inputSubMesh.HasColours();
		bool hasUvs = inputSubMesh.HasUvs();
		bool hasUv = inputSubMesh.HasUv1();
		CuttableSubMesh cuttableSubMesh = new CuttableSubMesh(hasNormals, hasColours, hasUvs, hasUv);
		CuttableSubMesh cuttableSubMesh2 = new CuttableSubMesh(hasNormals, hasColours, hasUvs, hasUv);
		for (int i = 0; i < inputSubMesh.NumVertices(); i += 3)
		{
			int num = i;
			int num2 = i + 1;
			int num3 = i + 2;
			Vector3 vertex = inputSubMesh.GetVertex(num);
			Vector3 vertex2 = inputSubMesh.GetVertex(num2);
			Vector3 vertex3 = inputSubMesh.GetVertex(num3);
			VertexClassification vertexClassification = Classify(vertex, cutPlane);
			VertexClassification vertexClassification2 = Classify(vertex2, cutPlane);
			VertexClassification vertexClassification3 = Classify(vertex3, cutPlane);
			int numFront = 0;
			int numBehind = 0;
			CountSides(vertexClassification, ref numFront, ref numBehind);
			CountSides(vertexClassification2, ref numFront, ref numBehind);
			CountSides(vertexClassification3, ref numFront, ref numBehind);
			if (numFront > 0 && numBehind == 0)
			{
				KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh);
			}
			else if (numFront == 0 && numBehind > 0)
			{
				KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh2);
			}
			else if (numFront == 2 && numBehind == 1)
			{
				if (vertexClassification == VertexClassification.Back)
				{
					SplitA(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh2, cuttableSubMesh);
				}
				else if (vertexClassification2 == VertexClassification.Back)
				{
					SplitA(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh2, cuttableSubMesh);
				}
				else
				{
					SplitA(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh2, cuttableSubMesh);
				}
			}
			else if (numFront == 1 && numBehind == 2)
			{
				if (vertexClassification == VertexClassification.Front)
				{
					SplitA(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
				}
				else if (vertexClassification2 == VertexClassification.Front)
				{
					SplitA(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
				}
				else
				{
					SplitA(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
				}
			}
			else if (numFront == 1 && numBehind == 1)
			{
				if (vertexClassification == VertexClassification.OnPlane)
				{
					if (vertexClassification3 == VertexClassification.Front)
					{
						SplitB(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
					}
					else
					{
						SplitBFlipped(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
					}
					continue;
				}
				switch (vertexClassification2)
				{
				case VertexClassification.OnPlane:
					if (vertexClassification == VertexClassification.Front)
					{
						SplitB(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
					}
					else
					{
						SplitBFlipped(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
					}
					break;
				case VertexClassification.Front:
					SplitB(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
					break;
				default:
					SplitBFlipped(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
					break;
				}
			}
			else if (numFront == 0 && numBehind == 0)
			{
				Vector3 val = vertex2 - vertex;
				Vector3 val2 = vertex3 - vertex;
				Vector3 val3 = Vector3.Cross(val, val2);
				if (Vector3.Dot(val3, ((Plane)(ref cutPlane)).normal) > 0f)
				{
					KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh2);
				}
				else
				{
					KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh);
				}
			}
		}
		outputFrontSubMeshes.Add(cuttableSubMesh);
		outputBackSubMeshes.Add(cuttableSubMesh2);
	}

	private VertexClassification Classify(Vector3 vertex, Plane cutPlane)
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(vertex.x, vertex.y, vertex.z);
		float distanceToPoint = ((Plane)(ref cutPlane)).GetDistanceToPoint(val);
		double num = 9.999999747378752E-06;
		if ((double)distanceToPoint > 0.0 - num && (double)distanceToPoint < num)
		{
			return VertexClassification.OnPlane;
		}
		if (distanceToPoint > 0f)
		{
			return VertexClassification.Front;
		}
		return VertexClassification.Back;
	}

	private void CountSides(VertexClassification c, ref int numFront, ref int numBehind)
	{
		switch (c)
		{
		case VertexClassification.Front:
			numFront++;
			break;
		case VertexClassification.Back:
			numBehind++;
			break;
		}
	}

	private void KeepTriangle(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, CuttableSubMesh destSubMesh)
	{
		destSubMesh.CopyVertex(i0, inputSubMesh);
		destSubMesh.CopyVertex(i1, inputSubMesh);
		destSubMesh.CopyVertex(i2, inputSubMesh);
	}

	private void SplitA(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, Plane cutPlane, CuttableSubMesh frontSubMesh, CuttableSubMesh backSubMesh)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: 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_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_001f: 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_002a: 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_0030: Unknown result type (might be due to invalid IL or missing references)
		Vector3 vertex = inputSubMesh.GetVertex(i0);
		Vector3 vertex2 = inputSubMesh.GetVertex(i1);
		Vector3 vertex3 = inputSubMesh.GetVertex(i2);
		CalcIntersection(vertex, vertex2, cutPlane, out var weight);
		CalcIntersection(vertex3, vertex, cutPlane, out var weight2);
		frontSubMesh.CopyVertex(i0, inputSubMesh);
		frontSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh);
		frontSubMesh.AddInterpolatedVertex(i2, i0, weight2, inputSubMesh);
		backSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh);
		backSubMesh.CopyVertex(i1, inputSubMesh);
		backSubMesh.CopyVertex(i2, inputSubMesh);
		backSubMesh.CopyVertex(i2, inputSubMesh);
		backSubMesh.AddInterpolatedVertex(i2, i0, weight2, inputSubMesh);
		backSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh);
	}

	private void SplitB(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, Plane cutPlane, CuttableSubMesh frontSubMesh, CuttableSubMesh backSubMesh)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: 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_0015: 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_001a: Unknown result type (might be due to invalid IL or missing references)
		Vector3 vertex = inputSubMesh.GetVertex(i0);
		Vector3 vertex2 = inputSubMesh.GetVertex(i2);
		CalcIntersection(vertex2, vertex, cutPlane, out var weight);
		frontSubMesh.CopyVertex(i0, inputSubMesh);
		frontSubMesh.CopyVertex(i1, inputSubMesh);
		frontSubMesh.AddInterpolatedVertex(i2, i0, weight, inputSubMesh);
		backSubMesh.CopyVertex(i1, inputSubMesh);
		backSubMesh.CopyVertex(i2, inputSubMesh);
		backSubMesh.AddInterpolatedVertex(i2, i0, weight, inputSubMesh);
	}

	private void SplitBFlipped(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, Plane cutPlane, CuttableSubMesh frontSubMesh, CuttableSubMesh backSubMesh)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: 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_0015: 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_001a: Unknown result type (might be due to invalid IL or missing references)
		Vector3 vertex = inputSubMesh.GetVertex(i0);
		Vector3 vertex2 = inputSubMesh.GetVertex(i1);
		CalcIntersection(vertex, vertex2, cutPlane, out var weight);
		frontSubMesh.CopyVertex(i0, inputSubMesh);
		frontSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh);
		frontSubMesh.CopyVertex(i2, inputSubMesh);
		backSubMesh.CopyVertex(i1, inputSubMesh);
		backSubMesh.CopyVertex(i2, inputSubMesh);
		backSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh);
	}

	private Vector3 CalcIntersection(Vector3 v0, Vector3 v1, Plane plane, out float weight)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: 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_0022: 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_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: 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_004e: 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)
		Vector3 val = v1 - v0;
		float magnitude = ((Vector3)(ref val)).magnitude;
		Ray val2 = default(Ray);
		((Ray)(ref val2))..ctor(v0, val / magnitude);
		float num = default(float);
		((Plane)(ref plane)).Raycast(val2, ref num);
		Vector3 result = ((Ray)(ref val2)).origin + ((Ray)(ref val2)).direction * num;
		weight = num / magnitude;
		return result;
	}
}
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.Skybox)
			{
				RenderSettings.skybox = sky.Resources.Skybox;
				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.

Packer.BossFight.dll

Decompiled 6 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using Microsoft.CodeAnalysis;
using Sodalite.Api;
using UnityEngine;
using UnityEngine.AI;

[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("A script library for creating a simplistic Boss Fight in H3VR")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+b167bc7f18a21d746c634550470bb1f4c7a5056a")]
[assembly: AssemblyProduct("Packer.BossFight")]
[assembly: AssemblyTitle("Boss Fight")]
[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;
		}
	}
}
public class PlayerDeathTracker : MonoBehaviour
{
	public delegate void OnPlayerDeath();

	public static PlayerDeathTracker instance;

	private bool hasDied = false;

	public static event OnPlayerDeath OnPlayerDeathEvent;

	private void Awake()
	{
		instance = this;
	}

	private void Update()
	{
		if ((Object)(object)GM.CurrentPlayerBody == (Object)null)
		{
			return;
		}
		if (GM.CurrentPlayerBody.Health <= 0f)
		{
			if (PlayerDeathTracker.OnPlayerDeathEvent != null)
			{
				hasDied = true;
				PlayerDeathTracker.OnPlayerDeathEvent();
			}
		}
		else if (hasDied && GM.CurrentPlayerBody.Health > 0f)
		{
			hasDied = false;
		}
	}
}
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 Packer
{
	[BepInPlugin("Packer.BossFight", "BossFight", "1.0.0")]
	[BepInProcess("h3vr.exe")]
	public class BossFightPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
		}
	}
}
namespace BossFight.src
{
	public class BossBody : MonoBehaviour, IFVRDamageable
	{
		public void Damage(Damage dam)
		{
			BossCombatant.instance.Damage(dam);
		}
	}
	public class BossCombatant : MonoBehaviour
	{
		[Serializable]
		public class StageEffects
		{
			public string name;

			public GameObject[] activate;

			public GameObject[] deactivate;

			public bool audioOverwrites = false;

			public AudioClip[] audioClips;

			public void SetEffects(bool value)
			{
				for (int i = 0; i < activate.Length; i++)
				{
					if (Object.op_Implicit((Object)(object)activate[i]))
					{
						activate[i].SetActive(value);
					}
				}
				for (int j = 0; j < deactivate.Length; j++)
				{
					if (Object.op_Implicit((Object)(object)deactivate[j]))
					{
						deactivate[j].SetActive(!value);
					}
				}
				if (value && audioClips != null && audioClips.Length != 0)
				{
					AudioClip val = audioClips[Random.Range(0, audioClips.Length)];
					if ((Object)(object)val != (Object)null)
					{
						instance.PlayAudioClip(audioClips[Random.Range(0, audioClips.Length)], audioOverwrites);
					}
				}
			}
		}

		public static BossCombatant instance;

		public static bool isDefeated = false;

		[Header("--Boss--")]
		[Header("Movement")]
		public float headTurnSpeed = 2f;

		public float handRotateSpeed = 45f;

		public float moveSpeed = 5f;

		public float locationPauseTime = 15f;

		public float damagedTimeout = 3f;

		public float phaseDamagedTimeout = 10f;

		private float phaseTimeout = 0f;

		[Header("Navigation")]
		public Transform[] moveToLocations;

		public int moveTarget = 0;

		[Tooltip("Location move to on introduction or victory")]
		public Transform centerLocation;

		[Header("Boss State")]
		[HideInInspector]
		public bool wounded = false;

		[HideInInspector]
		public int damagedPhase = 0;

		public float damageThreshold = 10000f;

		[SerializeField]
		private float currentDamage = 0f;

		[Header("Boss Body")]
		public Rigidbody rb;

		public Transform[] bossEyes;

		public Transform[] bossHands;

		private Vector3[] eyeDefault = (Vector3[])(object)new Vector3[2];

		public GameObject bossProjectile;

		private FVRFireArm[] bossWeapons = (FVRFireArm[])(object)new FVRFireArm[2];

		private float[] bossWeaponCooldown = new float[2];

		[Tooltip("Time between shots randomly between X and Y")]
		public Vector2 bossFireDelayMinMax = new Vector2(8f, 12f);

		public Vector2 bossFireDelayMinMaxPhase2 = new Vector2(8f, 12f);

		[Header("Animation")]
		public Animator bossAnimator;

		public SkinnedMeshRenderer bossHeadSkin;

		public SkinnedMeshRenderer[] bossHandsSkin;

		public Transform headSosigSpawnPoint;

		public Sosig headSosig;

		public int blendShapeIndex = 0;

		private float[] spectrumData = new float[1024];

		public float sensitivity = 100f;

		public int frequencyBand = 0;

		public int blendMin = 0;

		public int blendMax = 1;

		private float introScale = 0.01f;

		public StageEffects[] effects = new StageEffects[7];

		public int headSosigID = 0;

		[Header("--Audio--")]
		public static bool firstTry = true;

		public AudioSource voiceSource;

		public AudioSource gunSource;

		[Header("Introduction Stage")]
		public AudioClip introductionGreetings;

		[Tooltip("Lines the boss will say when spawned")]
		public AudioClip[] introductionMonologue;

		[Tooltip("Lines the boss will say when the player has to try again after spawning")]
		public AudioClip[] introductionSecondMonologue;

		[Tooltip("If Boss is shot during the introduction")]
		public AudioClip[] introductionInterupted;

		private float audioClipLength = 0f;

		[Header("Combat Stage")]
		[Header("Boss")]
		[Tooltip("When the boss takes damage")]
		public AudioClip[] bossDamaged;

		[Tooltip("When the boss takes enough damage to complete phase")]
		public AudioClip[] bossPhaseDamaged;

		[Tooltip("When the boss shoot dah wepon")]
		public AudioClip[] bossShoot;

		[Tooltip("The voice lines that play waiting for the player to deliver the final blow")]
		public AudioClip[] bossDefeatedWaiting;

		public float bossDefeatedDelay = 10f;

		[Tooltip("Plays when the boss is destroyed")]
		public AudioClip[] bossFinalBlow;

		private float endDialogueTimeout = 10f;

		private float rampSpeed = 0f;

		private AudioReverbFilter reverb;

		private Vector3 facePlayerVector = Vector3.zero;

		private float sequenceTime = 0f;

		public void Awake()
		{
			instance = this;
			reverb = ((Component)voiceSource).GetComponent<AudioReverbFilter>();
		}

		private void Start()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			rb = ((Component)this).GetComponent<Rigidbody>();
			for (int i = 0; i < eyeDefault.Length; i++)
			{
				_ = ref eyeDefault[i];
				if ((Object)(object)bossEyes[i] != (Object)null)
				{
					eyeDefault[i] = bossEyes[i].localEulerAngles;
				}
			}
		}

		private void OnEnable()
		{
			if ((Object)(object)reverb != (Object)null)
			{
				((Behaviour)reverb).enabled = true;
			}
			if ((Object)(object)BossManager.instance != (Object)null && BossManager.instance.stage != 0)
			{
				SetStage(BossStage.Idle);
			}
			SosigTracker.OnSosigDeath += CurrentSceneSettingsOnSosigKillEvent;
		}

		private void OnDisable()
		{
			if ((Object)(object)reverb != (Object)null)
			{
				((Behaviour)reverb).enabled = false;
			}
			SetStage(BossStage.Idle);
			SosigTracker.OnSosigDeath -= CurrentSceneSettingsOnSosigKillEvent;
		}

		private void FixedUpdate()
		{
			//IL_00ae: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_009c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)BossManager.instance.playerHead == (Object)null && (Object)(object)GM.CurrentPlayerBody != (Object)null)
			{
				BossManager.instance.playerHead = GM.CurrentPlayerBody.Head;
			}
			if (!((Object)(object)BossManager.instance.playerHead == (Object)null))
			{
				if (BossManager.instance.stage == BossStage.BossDefeated)
				{
					facePlayerVector = Vector3.Normalize(BossManager.instance.playerHead.position - ((Component)this).transform.position) + Vector3.down * 0.75f;
				}
				else
				{
					facePlayerVector = Vector3.Normalize(BossManager.instance.playerHead.position - ((Component)this).transform.position);
				}
				Update_PhaseManager();
				Update_Movement();
				Update_Hands();
				Update_VoiceLines();
				Update_Eyes();
				UpdateSosigHead();
				if (BossManager.instance.stage == BossStage.BossDefeated && Time.time >= endDialogueTimeout)
				{
					endDialogueTimeout = Time.time + 10f;
					PlayAudioClip(bossDefeatedWaiting[Random.Range(0, bossDefeatedWaiting.Length)], forceStopAudio: true, gronch: true);
				}
			}
		}

		private void SetStage(BossStage stage)
		{
			//IL_0281: 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_03fe: Invalid comparison between Unknown and I4
			//IL_00fe: 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)
			if (stage == BossStage.Combat)
			{
				stage = BossStage.BossCombat;
			}
			BossManager.instance.stage = stage;
			effects[(int)stage].SetEffects(value: true);
			switch (stage)
			{
			case BossStage.Idle:
			{
				damagedPhase = 0;
				currentDamage = 0f;
				wounded = false;
				voiceSource.Stop();
				for (int i = 0; i < bossWeapons.Length; i++)
				{
					if ((Object)(object)bossWeapons[i] != (Object)null)
					{
						Object.Destroy((Object)(object)((Component)bossWeapons[i]).gameObject);
					}
				}
				if ((Object)(object)headSosig != (Object)null)
				{
					headSosig.ClearSosig();
				}
				sequenceTime = 0f;
				phaseTimeout = 0f;
				rb.MovePosition(((Component)this).transform.parent.position);
				rb.MoveRotation(Quaternion.identity);
				SosigManager.instance.ClearAllSosigs();
				break;
			}
			case BossStage.Introduction:
				break;
			case BossStage.BossCombat:
			{
				if (damagedPhase == 0)
				{
					bossAnimator.Play("Idle", 0);
				}
				else
				{
					bossAnimator.Play("DefendToIdle", 0);
				}
				for (int l = 0; l < bossWeaponCooldown.Length; l++)
				{
					if (damagedPhase == 0)
					{
						bossWeaponCooldown[l] = Time.time + Random.Range(bossFireDelayMinMax.x, bossFireDelayMinMax.y);
					}
					else
					{
						bossWeaponCooldown[l] = Time.time + Random.Range(bossFireDelayMinMaxPhase2.x, bossFireDelayMinMaxPhase2.y);
					}
				}
				break;
			}
			case BossStage.BossDamaged:
				phaseTimeout = Time.time + phaseDamagedTimeout;
				bossAnimator.Play("Defend", 0);
				break;
			case BossStage.BossDefeated:
			{
				phaseTimeout = Time.time + bossDefeatedDelay;
				SosigManager.instance.ClearAllSosigs();
				headSosig = SpawnHeadSosig();
				headSosig.SetIFF(-3);
				SosigTracker.instance.sosigs.Add(headSosig);
				((Component)headSosig).transform.parent = headSosigSpawnPoint;
				headSosig.CurrentOrder = (SosigOrder)0;
				for (int j = 0; j < headSosig.Links.Count; j++)
				{
					if ((Object)(object)headSosig.Links[j] != (Object)null && (Object)(object)headSosig.Links[j].R != (Object)null)
					{
						headSosig.Links[j].R.isKinematic = true;
					}
				}
				break;
			}
			case BossStage.BossDestroyed:
				SetStage(BossStage.Completed);
				PlayAudioClip(bossFinalBlow[Random.Range(0, bossFinalBlow.Length)], forceStopAudio: true);
				if (Object.op_Implicit((Object)(object)headSosig))
				{
					for (int k = 0; k < headSosig.Links.Count; k++)
					{
						if ((Object)(object)headSosig.Links[k] != (Object)null && (Object)(object)headSosig.Links[k].R != (Object)null)
						{
							headSosig.Links[k].R.isKinematic = false;
						}
					}
				}
				SosigManager.instance.ClearAllSosigs();
				break;
			case BossStage.Completed:
				isDefeated = true;
				if ((Object)(object)headSosig != (Object)null && (int)headSosig.BodyState != 3)
				{
					((MonoBehaviour)this).StartCoroutine(BrainSosigExplode(headSosig));
				}
				break;
			}
		}

		private void UpdateSosigHead()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)headSosig == (Object)null))
			{
				((Behaviour)headSosig.Agent).enabled = false;
				((Component)headSosig).transform.position = headSosigSpawnPoint.position;
			}
		}

		private void Update_PhaseManager()
		{
			//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_0082: 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_01ad: 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)
			switch (BossManager.instance.stage)
			{
			default:
				((Component)this).transform.localScale = Vector3.one * introScale;
				break;
			case BossStage.Introduction:
				introScale = Mathf.Clamp01(introScale + Time.deltaTime);
				((Component)this).transform.localScale = new Vector3(introScale, introScale, introScale);
				if (Time.time >= sequenceTime)
				{
					SetStage(BossStage.BossCombat);
				}
				break;
			case BossStage.BossCombat:
			{
				RandomizeNextMoveToLocation();
				for (int j = 0; j < bossHandsSkin.Length; j++)
				{
					if ((Object)(object)bossWeapons[j] != (Object)null)
					{
						bossHandsSkin[j].SetBlendShapeWeight(0, 100f);
					}
					else
					{
						bossHandsSkin[j].SetBlendShapeWeight(0, 0f);
					}
				}
				for (int k = 0; k < bossWeapons.Length; k++)
				{
					if (!Object.op_Implicit((Object)(object)bossWeapons[k]) || !(Time.time >= bossWeaponCooldown[k]))
					{
						continue;
					}
					bossWeaponCooldown[k] = Time.time + Random.Range(bossFireDelayMinMax.x, bossFireDelayMinMax.y);
					if (Object.op_Implicit((Object)(object)bossProjectile))
					{
						GameObject val = Object.Instantiate<GameObject>(bossProjectile, bossWeapons[k].MuzzlePos.position, bossWeapons[k].MuzzlePos.rotation);
						val.SetActive(true);
						BallisticProjectile component = val.GetComponent<BallisticProjectile>();
						if (Object.op_Implicit((Object)(object)component))
						{
							component.Fire(((Component)bossWeapons[k]).transform.forward, bossWeapons[k]);
						}
						if (bossShoot != null && bossShoot.Length != 0)
						{
							gunSource.PlayOneShot(bossShoot[Random.Range(0, bossShoot.Length)]);
						}
					}
				}
				break;
			}
			case BossStage.BossDamaged:
			{
				RandomizeNextMoveToLocation();
				for (int i = 0; i < bossHandsSkin.Length; i++)
				{
					bossHandsSkin[i].SetBlendShapeWeight(0, 0f);
				}
				if (Time.time >= phaseTimeout)
				{
					SetStage(BossStage.Combat);
				}
				break;
			}
			case BossStage.BossDefeated:
				break;
			case BossStage.BossDestroyed:
				break;
			case BossStage.Completed:
				break;
			}
		}

		private void RandomizeNextMoveToLocation()
		{
			if (Time.time >= sequenceTime)
			{
				rampSpeed = 0f;
				int num = moveTarget;
				while (num == moveTarget)
				{
					moveTarget = Random.Range(0, moveToLocations.Length);
				}
				sequenceTime = locationPauseTime + Time.time;
			}
		}

		public void Begin()
		{
			SetStage(BossStage.Introduction);
			float delayed = PlayAudioClip(introductionGreetings, forceStopAudio: true);
			((MonoBehaviour)this).StartCoroutine(IntroductionSpeech(delayed));
		}

		private IEnumerator IntroductionSpeech(float delayed)
		{
			AudioClip selectedClip;
			if (firstTry)
			{
				firstTry = false;
				selectedClip = introductionMonologue[Random.Range(0, introductionMonologue.Length)];
			}
			else
			{
				selectedClip = introductionSecondMonologue[Random.Range(0, introductionSecondMonologue.Length)];
			}
			sequenceTime = Time.time + delayed + 1f;
			yield return (object)new WaitForSeconds(delayed);
			sequenceTime = Time.time + PlayAudioClip(selectedClip, forceStopAudio: true);
		}

		private IEnumerator Defeated()
		{
			bossAnimator.Play("Defeated", 0);
			SetStage(BossStage.BossDefeated);
			yield return (object)new WaitForSeconds(bossDefeatedDelay);
		}

		private void CurrentSceneSettingsOnSosigKillEvent(Sosig s)
		{
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Invalid comparison between Unknown and I4
			if (!((Object)(object)s == (Object)(object)headSosig) || !((Object)(object)headSosig != (Object)null))
			{
				return;
			}
			for (int i = 0; i < headSosig.Links.Count; i++)
			{
				if ((Object)(object)headSosig.Links[i] != (Object)null && (Object)(object)headSosig.Links[i].R != (Object)null)
				{
					headSosig.Links[i].R.isKinematic = false;
				}
			}
			if ((int)s.BodyState != 3)
			{
				((MonoBehaviour)this).StartCoroutine(BrainSosigExplode(s));
			}
		}

		private IEnumerator BrainSosigExplode(Sosig sosig)
		{
			yield return (object)new WaitForSeconds(1.5f);
			if ((Object)(object)sosig != (Object)null)
			{
				sosig.ClearSosig();
			}
		}

		public void Damage(Damage dam)
		{
			switch (BossManager.instance.stage)
			{
			case BossStage.Introduction:
				sequenceTime = Time.time + PlayAudioClip(introductionInterupted[Random.Range(0, introductionInterupted.Length)], forceStopAudio: true);
				break;
			case BossStage.BossDefeated:
				if (Time.time < phaseTimeout)
				{
					return;
				}
				SetStage(BossStage.BossDestroyed);
				break;
			}
			if (BossManager.instance.stage != BossStage.BossCombat || !(currentDamage < damageThreshold))
			{
				return;
			}
			if (dam.Dam_TotalKinetic != 0f)
			{
				currentDamage += dam.Dam_TotalKinetic;
			}
			else
			{
				currentDamage += 500f;
			}
			if (currentDamage >= damageThreshold)
			{
				damagedPhase++;
				currentDamage = 0f;
				if (damagedPhase < 3)
				{
					SetStage(BossStage.BossDamaged);
					audioClipLength += PlayAudioClip(bossPhaseDamaged[Random.Range(0, bossPhaseDamaged.Length)], forceStopAudio: true) + 2f;
				}
				else
				{
					((MonoBehaviour)this).StartCoroutine(Defeated());
				}
				for (int i = 0; i < bossWeapons.Length; i++)
				{
					if ((Object)(object)bossWeapons[i] != (Object)null)
					{
						Object.Destroy((Object)(object)((Component)bossWeapons[i]).gameObject);
					}
				}
			}
			else
			{
				sequenceTime = Time.time + damagedTimeout;
				PlayAudioClip(bossDamaged[Random.Range(0, bossDamaged.Length)]);
			}
		}

		private void Update_Movement()
		{
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			if (moveTarget >= moveToLocations.Length || moveTarget < 0)
			{
				moveTarget = 0;
			}
			switch (BossManager.instance.stage)
			{
			case BossStage.Idle:
			case BossStage.BossDestroyed:
			case BossStage.Completed:
				break;
			case BossStage.BossCombat:
			case BossStage.BossDamaged:
				rb.MoveRotation(Quaternion.Slerp(((Component)this).transform.rotation, Quaternion.LookRotation(facePlayerVector, Vector3.up), headTurnSpeed * Time.deltaTime));
				rampSpeed = Mathf.Clamp(rampSpeed + Time.deltaTime, 0f, 1f);
				rb.MovePosition(Vector3.Lerp(rb.position, moveToLocations[moveTarget].position, rampSpeed * moveSpeed * Time.deltaTime));
				break;
			case BossStage.Introduction:
			case BossStage.BossDefeated:
				rb.MoveRotation(Quaternion.Slerp(((Component)this).transform.rotation, Quaternion.LookRotation(facePlayerVector, Vector3.up), headTurnSpeed * Time.deltaTime));
				if (BossManager.instance.stage == BossStage.Introduction)
				{
					rb.MovePosition(Vector3.Lerp(rb.position, centerLocation.position, moveSpeed * Time.deltaTime));
				}
				break;
			}
		}

		private void Update_Hands()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_00cc: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < bossWeapons.Length; i++)
			{
				if (!((Object)(object)bossWeapons[i] == (Object)null))
				{
					bossHands[i].LookAt(BossManager.instance.playerHead.position + Vector3.down);
				}
			}
			if (BossManager.instance.stage != BossStage.BossCombat)
			{
				return;
			}
			for (int j = 0; j < bossWeapons.Length; j++)
			{
				if ((Object)(object)bossWeapons[j] == (Object)null && (j == 0 || damagedPhase == 2))
				{
					bossWeapons[j] = SpawnObjectAtPlace(GetWeapon(), bossHands[j].position, bossHands[j].rotation).GetComponent<FVRFireArm>();
					((Component)bossWeapons[j]).transform.localScale = Vector3.one * 8f;
					((FVRPhysicalObject)bossWeapons[j]).SetIsKinematicLocked(true);
					((Component)bossWeapons[j]).transform.localScale = Vector3.one * 10f;
				}
				if (Object.op_Implicit((Object)(object)bossWeapons[j]))
				{
					((FVRPhysicalObject)bossWeapons[j]).RootRigidbody.MovePosition(bossHands[j].position);
					((FVRPhysicalObject)bossWeapons[j]).RootRigidbody.MoveRotation(bossHands[j].rotation);
				}
			}
		}

		public float PlayAudioClip(AudioClip clip, bool forceStopAudio = false, bool gronch = false)
		{
			if (forceStopAudio)
			{
				voiceSource.Stop();
			}
			else if (audioClipLength > Time.time)
			{
				return Time.time - audioClipLength;
			}
			if (gronch)
			{
				voiceSource.pitch = 1.15f;
				((Behaviour)reverb).enabled = false;
			}
			else
			{
				voiceSource.pitch = 1f;
				((Behaviour)reverb).enabled = true;
			}
			audioClipLength = clip.length + Time.time;
			voiceSource.clip = clip;
			voiceSource.Play();
			return clip.length;
		}

		public Sosig SpawnHeadSosig()
		{
			//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_000f: 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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			SpawnOptions spawnOptions = new SpawnOptions
			{
				SpawnState = (SosigOrder)10,
				SpawnActivated = true,
				EquipmentMode = (EquipmentSlots)7,
				SpawnWithFullAmmo = true
			};
			SosigManager.SosigWave sosigWave = new SosigManager.SosigWave();
			sosigWave.waveSize = 1;
			sosigWave.sosigEnemyIDs = new int[1];
			SosigManager.SosigWave sosigWave2 = sosigWave;
			sosigWave2.sosigEnemyIDs[0] = headSosigID;
			return SosigManager.instance.CreateSosig(spawnOptions, headSosigSpawnPoint.position, headSosigSpawnPoint.rotation, sosigWave2);
		}

		public FVRObject GetWeapon(string objectID = "M1911Classic")
		{
			IM.OD.TryGetValue(objectID, out var value);
			return value;
		}

		public static FVRObject GetLowestCapacityAmmoObject(FVRObject o, List<OTagEra> eras = null, int Min = -1, int Max = -1, List<OTagSet> sets = null)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			//IL_004f: 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)
			if ((Object)(object)o == (Object)null)
			{
				return null;
			}
			if ((int)o.MagazineType > 0)
			{
				List<FVRObject> list = new List<FVRObject>(ManagerSingleton<IM>.Instance.odicTagCategory[(ObjectCategory)2]);
				for (int num = list.Count - 1; num >= 0; num--)
				{
					if (list[num].MagazineType != o.MagazineType)
					{
						list.RemoveAt(num);
					}
				}
				if (list.Count == 0)
				{
					return null;
				}
				list = GetLowestCapacity(list, Min);
				return list[Random.Range(0, list.Count)];
			}
			return null;
		}

		public static List<FVRObject> GetLowestCapacity(List<FVRObject> ammo, int minCapacity)
		{
			List<FVRObject> list = new List<FVRObject>();
			int num = int.MaxValue;
			for (int i = 0; i < ammo.Count; i++)
			{
				if (ammo[i].MagazineCapacity < num && ammo[i].MagazineCapacity >= minCapacity)
				{
					num = ammo[i].MagazineCapacity;
				}
			}
			for (int j = 0; j < ammo.Count; j++)
			{
				if (ammo[j].MagazineCapacity == num)
				{
					list.Add(ammo[j]);
				}
			}
			return list;
		}

		public GameObject SpawnObjectAtPlace(FVRObject obj, Vector3 pos, Quaternion rotation)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			//IL_0039: 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)
			GameObject val = Object.Instantiate<GameObject>(((AnvilAsset)obj).GetGameObject(), pos, rotation);
			FVRFireArmMagazine component = val.GetComponent<FVRFireArmMagazine>();
			if ((Object)(object)component != (Object)null && (int)component.RoundType != 997)
			{
				component.ReloadMagWithTypeUpToPercentage(AM.GetDefaultRoundClass(component.RoundType), 1f);
			}
			return val;
		}

		private void Update_VoiceLines()
		{
			if (!voiceSource.isPlaying)
			{
				for (int i = blendMin; i < blendMax + 1; i++)
				{
					bossHeadSkin.SetBlendShapeWeight(i, 0f);
				}
				return;
			}
			voiceSource.GetSpectrumData(spectrumData, 0, (FFTWindow)4);
			for (int j = 0; j < spectrumData.Length && j < blendMax + 1; j++)
			{
				bossHeadSkin.SetBlendShapeWeight(j, Mathf.Clamp(spectrumData[(frequencyBand + j) * 100] * sensitivity, 0f, 100f));
			}
		}

		private void Update_Eyes()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_0084: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < bossEyes.Length; i++)
			{
				if (!((Object)(object)bossEyes[i] == (Object)null))
				{
					if (Vector3.Dot(bossEyes[i].forward, facePlayerVector) > 0.25f)
					{
						bossEyes[i].LookAt(BossManager.instance.playerHead.position);
					}
					else
					{
						bossEyes[i].localRotation = Quaternion.RotateTowards(bossEyes[i].localRotation, Quaternion.Euler(eyeDefault[i]), 45f * Time.deltaTime);
					}
				}
			}
		}
	}
	public class BossManager : MonoBehaviour
	{
		public static BossManager instance;

		[Header("Gameplay")]
		public BossStage stage = BossStage.Idle;

		public int currentPhase = 0;

		public float triggerDistance = 30f;

		public Transform debugPlayer;

		public Transform playerHead;

		[Header("Debug")]
		public bool playerDistanceCheck = true;

		private void Awake()
		{
			instance = this;
			if ((Object)(object)debugPlayer != (Object)null)
			{
				playerHead = debugPlayer;
			}
			else
			{
				playerHead = GM.CurrentPlayerBody.Head;
			}
		}

		private void OnEnable()
		{
		}

		private void OnDestroy()
		{
			for (int i = 0; i < SosigManager.instance.sosigs.Count; i++)
			{
				SosigManager.instance.sosigs[i].ClearSosig();
			}
			SosigManager.instance.sosigs.Clear();
		}

		private void Update()
		{
			switch (stage)
			{
			case BossStage.Introduction:
				break;
			case BossStage.BossCombat:
				break;
			case BossStage.BossDamaged:
				break;
			case BossStage.BossDefeated:
				break;
			case BossStage.BossDestroyed:
				break;
			case BossStage.Idle:
				if (playerDistanceCheck && PlayerInDistance())
				{
					BossCombatant.instance.Begin();
				}
				break;
			case BossStage.Completed:
				break;
			}
		}

		private bool PlayerInDistance()
		{
			//IL_004b: 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)
			if ((Object)(object)playerHead == (Object)null && (Object)(object)GM.CurrentPlayerBody != (Object)null)
			{
				playerHead = GM.CurrentPlayerBody.Head;
			}
			if ((Object)(object)playerHead == (Object)null)
			{
				return false;
			}
			return Vector3.Distance(playerHead.position, ((Component)this).transform.position) <= triggerDistance;
		}

		private void OnDrawGizmos()
		{
			//IL_000c: 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)
			if (playerDistanceCheck)
			{
				Gizmos.color = Color.blue;
				Gizmos.DrawWireSphere(((Component)this).transform.position, triggerDistance);
			}
		}
	}
	public enum BossStage
	{
		Idle = 0,
		Introduction = 1,
		BossCombat = 2,
		BossDamaged = 3,
		BossDefeated = 4,
		BossDestroyed = 5,
		Completed = 6,
		Combat = 69
	}
	internal class Hooks
	{
	}
	public class SosigManager : MonoBehaviour
	{
		[Serializable]
		public class SosigWave
		{
			public int waveSize = 4;

			public int[] sosigEnemyIDs;
		}

		public static SosigManager instance;

		[Header("Sosigs")]
		public SosigWave[] sosigWaves = new SosigWave[3];

		public const float spawnOffset = 25f;

		public Transform[] spawnLocations = (Transform[])(object)new Transform[4];

		public float spawnRadius = 2.5f;

		public ObstacleAvoidanceType avoidanceQuailty = (ObstacleAvoidanceType)1;

		private int lastSpawn = 0;

		[HideInInspector]
		public List<Sosig> sosigs = new List<Sosig>();

		public float sosigExplodeTime = 5f;

		public SosigSpeechSet sosigSpeech;

		public readonly SpawnOptions _spawnOptions = new SpawnOptions
		{
			SpawnState = (SosigOrder)10,
			SpawnActivated = true,
			EquipmentMode = (EquipmentSlots)7,
			SpawnWithFullAmmo = true,
			IFF = 1
		};

		private void Awake()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			instance = this;
			if ((Object)(object)sosigSpeech == (Object)null)
			{
				sosigSpeech = new SosigSpeechSet();
			}
		}

		private void OnEnable()
		{
			SosigTracker.OnSosigDeath += OnSosigDeathEvent;
		}

		private void OnDisable()
		{
			SosigTracker.OnSosigDeath -= OnSosigDeathEvent;
		}

		private void OnSosigDeathEvent(Sosig s)
		{
			if ((Object)(object)BossCombatant.instance.headSosig != (Object)(object)s)
			{
				((MonoBehaviour)this).StartCoroutine(ClearSosig(s));
			}
		}

		private void Start()
		{
			//IL_000e: 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)
			NavMeshHit val = default(NavMeshHit);
			for (int i = 0; i < spawnLocations.Length; i++)
			{
				if (NavMesh.SamplePosition(spawnLocations[i].position, ref val, spawnRadius, -1))
				{
					spawnLocations[i].position = ((NavMeshHit)(ref val)).position;
				}
			}
		}

		private void Update()
		{
			if ((Object)(object)BossManager.instance.playerHead == (Object)null && (Object)(object)GM.CurrentPlayerBody != (Object)null && (Object)(object)GM.CurrentPlayerBody.Head != (Object)null)
			{
				BossManager.instance.playerHead = GM.CurrentPlayerBody.Head;
			}
			SpawnSosigWaveUpdate();
		}

		private void SpawnSosigWaveUpdate()
		{
			//IL_006d: 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_0086: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: 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_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			if (sosigs.Count < sosigWaves[BossManager.instance.currentPhase].waveSize && (BossManager.instance.stage == BossStage.BossCombat || BossManager.instance.stage == BossStage.Combat || BossManager.instance.stage == BossStage.BossDamaged))
			{
				Quaternion rotation = Quaternion.Euler(spawnLocations[lastSpawn].position - BossManager.instance.playerHead.position);
				Sosig val = CreateSosig(_spawnOptions, spawnLocations[lastSpawn].position, rotation, sosigWaves[BossManager.instance.currentPhase]);
				SosigTracker.instance.sosigs.Add(val);
				val.Speech = sosigSpeech;
				sosigs.Add(val);
				val.m_pathToPoint = BossManager.instance.playerHead.position;
				List<Vector3> list = new List<Vector3>
				{
					val.m_pathToPoint,
					spawnLocations[lastSpawn].position
				};
				List<Vector3> list2 = new List<Vector3>();
				Quaternion rotation2 = BossManager.instance.playerHead.rotation;
				list2.Add(((Quaternion)(ref rotation2)).eulerAngles);
				list2.Add(((Quaternion)(ref rotation)).eulerAngles);
				List<Vector3> list3 = list2;
				val.CommandPathTo(list, list3, 1f, Vector2.one * 4f, 2f, (SosigMoveSpeed)3, (PathLoopType)4, (List<Sosig>)null, 0.2f, 1f, true, 75f);
				lastSpawn = ((lastSpawn < 3) ? (lastSpawn + 1) : 0);
			}
		}

		public Sosig CreateSosig(SpawnOptions spawnOptions, Vector3 position, Quaternion rotation, SosigWave pool)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Invalid comparison between Unknown and I4
			//IL_0064: 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_0066: 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_0076: 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_007e: 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)
			SosigEnemyID val = (SosigEnemyID)pool.sosigEnemyIDs[Random.Range(0, pool.sosigEnemyIDs.Length)];
			if ((int)val == -1)
			{
				Debug.LogError((object)"Boss Fight - ERROR Missing SosigEnemyID");
				return null;
			}
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(Random.Range(0f - spawnRadius, spawnRadius), 0f, Random.Range(0f - spawnRadius, spawnRadius));
			val2 += position;
			Sosig val3 = SosigAPI.Spawn(ManagerSingleton<IM>.Instance.odicSosigObjsByID[val], spawnOptions, position, rotation);
			NavMeshAgent component = ((Component)val3).GetComponent<NavMeshAgent>();
			component.obstacleAvoidanceType = avoidanceQuailty;
			component.stoppingDistance = 1f;
			return val3;
		}

		public void ClearAllSosigs()
		{
			for (int i = 0; i < sosigs.Count; i++)
			{
				((MonoBehaviour)this).StartCoroutine(ClearSosig(sosigs[i]));
			}
			sosigs.Clear();
		}

		public IEnumerator ClearSosig(Sosig sosig)
		{
			yield return (object)new WaitForSeconds(sosigExplodeTime);
			if ((Object)(object)sosig != (Object)null)
			{
				if (sosigs.Contains(sosig))
				{
					sosigs.Remove(sosig);
				}
				sosig.ClearSosig();
			}
		}

		private void OnDrawGizmos()
		{
			//IL_0014: 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_003b: 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)
			if (spawnLocations != null)
			{
				for (int i = 0; i < spawnLocations.Length; i++)
				{
					Gizmos.color = Color.grey;
					Gizmos.DrawWireCube(spawnLocations[i].position, new Vector3(1f, 0.1f, 1f) * spawnRadius);
				}
			}
		}
	}
	public class SosigTracker : MonoBehaviour
	{
		public delegate void SosigOnDeath(Sosig s);

		public static SosigTracker instance;

		public List<Sosig> sosigs = new List<Sosig>();

		private float updateTime = 0f;

		public static event SosigOnDeath OnSosigDeath;

		private void Awake()
		{
			instance = this;
		}

		private void Update()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Invalid comparison between Unknown and I4
			if (Time.time < updateTime)
			{
				return;
			}
			updateTime = Time.time + 0.166f;
			for (int num = sosigs.Count - 1; num >= 0; num--)
			{
				if (!((Object)(object)sosigs[num] == (Object)null) && (int)sosigs[num].BodyState == 3)
				{
					SosigTracker.OnSosigDeath(sosigs[num]);
					sosigs.RemoveAt(num);
				}
			}
		}
	}
}