Decompiled source of Fort Bratwurst 2 v1.1.0

Fort_Bratwurst_2.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using Atlas;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using Sodalite.Api;
using Sodalite.Utilities;
using Technie.PhysicsCreator.QHull;
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 CameraRange : MonoBehaviour
{
	public float minDistance = 0.02f;

	public float maxDistance = 2000f;

	private Camera[] cameras;

	private GameObject[] dndObjects;

	private void Start()
	{
		((MonoBehaviour)this).Invoke("DelayedStart", 5f);
	}

	private void DelayedStart()
	{
		Debug.Log((object)"Attempting to find cameras");
		dndObjects = GetDontDestroyOnLoadObjects();
		cameras = Object.FindObjectsOfType<Camera>();
		for (int i = 0; i < cameras.Length; i++)
		{
			Debug.Log((object)("Camera " + i + " default Near/Far values: " + cameras[i].nearClipPlane + " / " + cameras[i].farClipPlane));
			cameras[i].nearClipPlane = minDistance;
			cameras[i].farClipPlane = maxDistance;
		}
		if (dndObjects == null)
		{
			return;
		}
		for (int j = 0; j < dndObjects.Length; j++)
		{
			Camera component = dndObjects[j].GetComponent<Camera>();
			if ((Object)(object)component != (Object)null)
			{
				Debug.Log((object)("Camera " + j + " default Near/Far values: " + component.nearClipPlane + " / " + component.farClipPlane));
				component.nearClipPlane = minDistance;
				component.farClipPlane = maxDistance;
			}
		}
	}

	public static GameObject[] GetDontDestroyOnLoadObjects()
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Expected O, but got Unknown
		//IL_0011: 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)
		GameObject val = null;
		try
		{
			val = new GameObject();
			Object.DontDestroyOnLoad((Object)(object)val);
			Scene scene = val.scene;
			Object.DestroyImmediate((Object)(object)val);
			val = null;
			return ((Scene)(ref scene)).GetRootGameObjects();
		}
		finally
		{
			if ((Object)(object)val != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)val);
			}
		}
	}
}
namespace Packer
{
	public class Packer_Platform : MovingPlatformBase
	{
		public void Awake()
		{
			((MovingPlatformBase)this).Awake();
		}

		public void FixedUpdate()
		{
			//IL_000d: 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)
			base.refT.position = ((Component)this).transform.position;
			base.refT.rotation = ((Component)this).transform.rotation;
		}

		public override Vector3 PhysicsStep()
		{
			//IL_000d: 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_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)
			base.refT.position = ((Component)this).transform.position;
			base.refT.rotation = ((Component)this).transform.rotation;
			return ((MovingPlatformBase)this).PhysicsStep();
		}
	}
}
public class SniperRange : MonoBehaviour
{
	public int initialSections;

	public GameObject sectionPrefab;

	public Transform startingPoint;

	public float offsetDistance = 100f;

	public Text sectionText;

	public Text teleportText;

	public AudioSource audSource;

	public AudioClip positiveclip;

	public AudioClip negativeclip;

	private int sectionindex;

	private int teleportindex;

	private List<GameObject> sections = new List<GameObject>();

	private void Start()
	{
		for (int i = 0; i < initialSections; i++)
		{
			CreateNewSection();
		}
	}

	public void CreateNewSection()
	{
		//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_001c: 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_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: 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_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(startingPoint.position.x, startingPoint.position.y, startingPoint.position.z);
		val += startingPoint.forward * ((float)teleportindex * offsetDistance);
		GameObject item = Object.Instantiate<GameObject>(sectionPrefab, val, startingPoint.rotation);
		sections.Add(item);
		sectionindex++;
		audSource.PlayOneShot(positiveclip);
		teleportindex++;
		UpdateVis();
	}

	public void DeleteSection()
	{
		if (sectionindex > 1)
		{
			GameObject val = sections.Last();
			sections.Remove(val);
			Object.Destroy((Object)(object)val);
			sectionindex--;
			audSource.PlayOneShot(negativeclip);
			if (teleportindex > sectionindex)
			{
				teleportindex = sectionindex;
			}
			UpdateVis();
		}
	}

	public void ChangeTeleportIndex(int change)
	{
		if (teleportindex + change >= 1 && teleportindex + change <= sections.Count)
		{
			teleportindex += change;
			UpdateVis();
		}
	}

	public void TeleportToTargetSection()
	{
		//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_001c: 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_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: 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_0061: 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_006d: 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)
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(startingPoint.position.x, startingPoint.position.y, startingPoint.position.z);
		val += startingPoint.forward * ((float)teleportindex * offsetDistance - 2f);
		Teleport(val, startingPoint.forward);
	}

	private void Teleport(Vector3 pos, Vector3 rot)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		GM.CurrentMovementManager.TeleportToPoint(pos, true, rot);
	}

	public void ToggleFog()
	{
		if (RenderSettings.fog)
		{
			RenderSettings.fog = false;
			audSource.PlayOneShot(negativeclip);
		}
		else
		{
			RenderSettings.fog = true;
			audSource.PlayOneShot(positiveclip);
		}
	}

	private void UpdateVis()
	{
		teleportText.text = "Teleport: " + teleportindex * 100 + " Meters";
		sectionText.text = "Range Length: " + sectionindex * 100 + " Meters";
	}
}
namespace MeatKit
{
	public class HideInNormalInspectorAttribute : PropertyAttribute
	{
	}
}
namespace Andr3a.Fort_Bratwurst_2
{
	[BepInPlugin("Andr3a.Fort_Bratwurst_2", "Fort_Bratwurst_2", "1.1.0")]
	[BepInProcess("h3vr.exe")]
	[Description("Built with MeatKit")]
	[BepInDependency("nrgill28.Atlas", "1.0.1")]
	public class Fort_Bratwurst_2Plugin : 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(), "Andr3a.Fort_Bratwurst_2");
			AtlasPlugin.RegisterScene(Path.Combine(BasePath, "fb2"));
		}
	}
}
namespace SimpleLightProbePlacer
{
	[RequireComponent(typeof(LightProbeGroup))]
	[AddComponentMenu("Rendering/Light Probe Group Control")]
	public class LightProbeGroupControl : MonoBehaviour
	{
		[SerializeField]
		private float m_mergeDistance = 0.5f;

		[SerializeField]
		private bool m_usePointLights = true;

		[SerializeField]
		private float m_pointLightRange = 1f;

		private int m_mergedProbes;

		private LightProbeGroup m_lightProbeGroup;

		public float MergeDistance
		{
			get
			{
				return m_mergeDistance;
			}
			set
			{
				m_mergeDistance = value;
			}
		}

		public int MergedProbes => m_mergedProbes;

		public bool UsePointLights
		{
			get
			{
				return m_usePointLights;
			}
			set
			{
				m_usePointLights = value;
			}
		}

		public float PointLightRange
		{
			get
			{
				return m_pointLightRange;
			}
			set
			{
				m_pointLightRange = value;
			}
		}

		public LightProbeGroup LightProbeGroup
		{
			get
			{
				if ((Object)(object)m_lightProbeGroup != (Object)null)
				{
					return m_lightProbeGroup;
				}
				return m_lightProbeGroup = ((Component)this).GetComponent<LightProbeGroup>();
			}
		}

		public void DeleteAll()
		{
			LightProbeGroup.probePositions = null;
			m_mergedProbes = 0;
		}

		public void Create()
		{
			DeleteAll();
			List<Vector3> list = CreatePositions();
			list.AddRange(CreateAroundPointLights(m_pointLightRange));
			list = MergeClosestPositions(list, m_mergeDistance, out m_mergedProbes);
			ApplyPositions(list);
		}

		public void Merge()
		{
			if (LightProbeGroup.probePositions != null)
			{
				List<Vector3> source = MergeClosestPositions(LightProbeGroup.probePositions.ToList(), m_mergeDistance, out m_mergedProbes);
				source = source.Select((Vector3 x) => ((Component)this).transform.TransformPoint(x)).ToList();
				ApplyPositions(source);
			}
		}

		private void ApplyPositions(List<Vector3> positions)
		{
			LightProbeGroup.probePositions = positions.Select((Vector3 x) => ((Component)this).transform.InverseTransformPoint(x)).ToArray();
		}

		private static List<Vector3> CreatePositions()
		{
			LightProbeVolume[] array = Object.FindObjectsOfType<LightProbeVolume>();
			if (array.Length == 0)
			{
				return new List<Vector3>();
			}
			List<Vector3> list = new List<Vector3>();
			for (int i = 0; i < array.Length; i++)
			{
				list.AddRange(array[i].CreatePositions());
			}
			return list;
		}

		private static List<Vector3> CreateAroundPointLights(float range)
		{
			List<Light> list = (from x in Object.FindObjectsOfType<Light>()
				where (int)x.type == 2
				select x).ToList();
			if (list.Count == 0)
			{
				return new List<Vector3>();
			}
			List<Vector3> list2 = new List<Vector3>();
			for (int num = 0; num < list.Count; num++)
			{
				list2.AddRange(CreatePositionsAround(((Component)list[num]).transform, range));
			}
			return list2;
		}

		private static List<Vector3> MergeClosestPositions(List<Vector3> positions, float distance, out int mergedCount)
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: 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_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: 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_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			if (positions == null)
			{
				mergedCount = 0;
				return new List<Vector3>();
			}
			int count = positions.Count;
			bool flag = false;
			while (!flag)
			{
				Dictionary<Vector3, List<Vector3>> dictionary = new Dictionary<Vector3, List<Vector3>>();
				for (int i = 0; i < positions.Count; i++)
				{
					List<Vector3> list = positions.Where(delegate(Vector3 x)
					{
						//IL_0000: Unknown result type (might be due to invalid IL or missing references)
						//IL_0012: Unknown result type (might be due to invalid IL or missing references)
						//IL_0017: Unknown result type (might be due to invalid IL or missing references)
						//IL_001c: Unknown result type (might be due to invalid IL or missing references)
						Vector3 val = x - positions[i];
						return ((Vector3)(ref val)).magnitude < distance;
					}).ToList();
					if (list.Count > 0 && !dictionary.ContainsKey(positions[i]))
					{
						dictionary.Add(positions[i], list);
					}
				}
				positions.Clear();
				List<Vector3> list2 = dictionary.Keys.ToList();
				for (int num = 0; num < list2.Count; num++)
				{
					Vector3 center = dictionary[list2[num]].Aggregate(Vector3.zero, (Vector3 result, Vector3 target) => result + target) / (float)dictionary[list2[num]].Count;
					if (!positions.Exists((Vector3 x) => x == center))
					{
						positions.Add(center);
					}
				}
				flag = positions.Select((Vector3 x) => positions.Where(delegate(Vector3 y)
				{
					//IL_0000: 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_0011: Unknown result type (might be due to invalid IL or missing references)
					//IL_0013: Unknown result type (might be due to invalid IL or missing references)
					//IL_0018: Unknown result type (might be due to invalid IL or missing references)
					//IL_001d: Unknown result type (might be due to invalid IL or missing references)
					int result;
					if (y != x)
					{
						Vector3 val = y - x;
						result = ((((Vector3)(ref val)).magnitude < distance) ? 1 : 0);
					}
					else
					{
						result = 0;
					}
					return (byte)result != 0;
				})).All((IEnumerable<Vector3> x) => !x.Any());
			}
			mergedCount = count - positions.Count;
			return positions;
		}

		public static List<Vector3> CreatePositionsAround(Transform transform, float range)
		{
			//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_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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: 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)
			Vector3[] source = (Vector3[])(object)new Vector3[8]
			{
				new Vector3(-0.5f, 0.5f, -0.5f),
				new Vector3(-0.5f, 0.5f, 0.5f),
				new Vector3(0.5f, 0.5f, 0.5f),
				new Vector3(0.5f, 0.5f, -0.5f),
				new Vector3(-0.5f, -0.5f, -0.5f),
				new Vector3(-0.5f, -0.5f, 0.5f),
				new Vector3(0.5f, -0.5f, 0.5f),
				new Vector3(0.5f, -0.5f, -0.5f)
			};
			return source.Select((Vector3 x) => transform.TransformPoint(x * range)).ToList();
		}
	}
	public enum LightProbeVolumeType
	{
		Fixed,
		Float
	}
	[AddComponentMenu("Rendering/Light Probe Volume")]
	public class LightProbeVolume : TransformVolume
	{
		[SerializeField]
		private LightProbeVolumeType m_type = LightProbeVolumeType.Fixed;

		[SerializeField]
		private Vector3 m_densityFixed = Vector3.one;

		[SerializeField]
		private Vector3 m_densityFloat = Vector3.one;

		public LightProbeVolumeType Type
		{
			get
			{
				return m_type;
			}
			set
			{
				m_type = value;
			}
		}

		public Vector3 Density
		{
			get
			{
				//IL_0018: 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_001d: 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)
				return (m_type != LightProbeVolumeType.Fixed) ? m_densityFloat : m_densityFixed;
			}
			set
			{
				//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_000d: 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)
				if (m_type == LightProbeVolumeType.Fixed)
				{
					m_densityFixed = value;
				}
				else
				{
					m_densityFloat = value;
				}
			}
		}

		public static Color EditorColor => new Color(1f, 0.9f, 0.25f);

		public List<Vector3> CreatePositions()
		{
			return CreatePositions(m_type);
		}

		public List<Vector3> CreatePositions(LightProbeVolumeType type)
		{
			//IL_0030: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			return (type != LightProbeVolumeType.Fixed) ? CreatePositionsFloat(((Component)this).transform, base.Origin, base.Size, Density) : CreatePositionsFixed(((Component)this).transform, base.Origin, base.Size, Density);
		}

		public static List<Vector3> CreatePositionsFixed(Transform volumeTransform, Vector3 origin, Vector3 size, Vector3 density)
		{
			//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_004c: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>();
			Vector3 val = origin;
			float num = size.x / (float)Mathf.FloorToInt(density.x);
			float num2 = size.y / (float)Mathf.FloorToInt(density.y);
			float num3 = size.z / (float)Mathf.FloorToInt(density.z);
			val -= size * 0.5f;
			for (int i = 0; (float)i <= density.x; i++)
			{
				for (int j = 0; (float)j <= density.y; j++)
				{
					for (int k = 0; (float)k <= density.z; k++)
					{
						Vector3 val2 = val + new Vector3((float)i * num, (float)j * num2, (float)k * num3);
						val2 = volumeTransform.TransformPoint(val2);
						list.Add(val2);
					}
				}
			}
			return list;
		}

		public static List<Vector3> CreatePositionsFloat(Transform volumeTransform, Vector3 origin, Vector3 size, Vector3 density)
		{
			//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_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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>();
			Vector3 val = origin;
			int num = Mathf.FloorToInt(size.x / density.x);
			int num2 = Mathf.FloorToInt(size.y / density.y);
			int num3 = Mathf.FloorToInt(size.z / density.z);
			val -= size * 0.5f;
			val.x += (size.x - (float)num * density.x) * 0.5f;
			val.y += (size.y - (float)num2 * density.y) * 0.5f;
			val.z += (size.z - (float)num3 * density.z) * 0.5f;
			for (int i = 0; i <= num; i++)
			{
				for (int j = 0; j <= num2; j++)
				{
					for (int k = 0; k <= num3; k++)
					{
						Vector3 val2 = val + new Vector3((float)i * density.x, (float)j * density.y, (float)k * density.z);
						val2 = volumeTransform.TransformPoint(val2);
						list.Add(val2);
					}
				}
			}
			return list;
		}
	}
	[AddComponentMenu("")]
	public class TransformVolume : MonoBehaviour
	{
		[SerializeField]
		private Volume m_volume = new Volume(Vector3.zero, Vector3.one);

		public Volume Volume
		{
			get
			{
				return m_volume;
			}
			set
			{
				m_volume = value;
			}
		}

		public Vector3 Origin => m_volume.Origin;

		public Vector3 Size => m_volume.Size;

		public bool IsInBounds(Vector3[] points)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			Bounds bounds = GetBounds();
			return ((Bounds)(ref bounds)).Intersects(GetBounds(points));
		}

		public bool IsOnBorder(Vector3[] points)
		{
			if (points.All((Vector3 x) => !IsInVolume(x)))
			{
				return false;
			}
			return !points.All(IsInVolume);
		}

		public bool IsInVolume(Vector3[] points)
		{
			return points.All(IsInVolume);
		}

		public bool IsInVolume(Vector3 position)
		{
			//IL_000d: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			Plane val = default(Plane);
			for (int i = 0; i < 6; i++)
			{
				((Plane)(ref val))..ctor(GetSideDirection(i), GetSidePosition(i));
				if (((Plane)(ref val)).GetSide(position))
				{
					return false;
				}
			}
			return true;
		}

		public Vector3[] GetCorners()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_007d: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = (Vector3[])(object)new Vector3[8]
			{
				new Vector3(-0.5f, 0.5f, -0.5f),
				new Vector3(-0.5f, 0.5f, 0.5f),
				new Vector3(0.5f, 0.5f, 0.5f),
				new Vector3(0.5f, 0.5f, -0.5f),
				new Vector3(-0.5f, -0.5f, -0.5f),
				new Vector3(-0.5f, -0.5f, 0.5f),
				new Vector3(0.5f, -0.5f, 0.5f),
				new Vector3(0.5f, -0.5f, -0.5f)
			};
			for (int i = 0; i < array.Length; i++)
			{
				ref Vector3 reference = ref array[i];
				reference.x *= m_volume.Size.x;
				ref Vector3 reference2 = ref array[i];
				reference2.y *= m_volume.Size.y;
				ref Vector3 reference3 = ref array[i];
				reference3.z *= m_volume.Size.z;
				ref Vector3 reference4 = ref array[i];
				reference4 = ((Component)this).transform.TransformPoint(m_volume.Origin + array[i]);
			}
			return array;
		}

		public Bounds GetBounds()
		{
			//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 GetBounds(GetCorners());
		}

		public Bounds GetBounds(Vector3[] points)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = points.Aggregate(Vector3.zero, (Vector3 val2, Vector3 point) => val2 + point) / (float)points.Length;
			Bounds result = default(Bounds);
			((Bounds)(ref result))..ctor(val, Vector3.zero);
			for (int num = 0; num < points.Length; num++)
			{
				((Bounds)(ref result)).Encapsulate(points[num]);
			}
			return result;
		}

		public GameObject[] GetGameObjectsInBounds(LayerMask layerMask)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			MeshRenderer[] array = Object.FindObjectsOfType<MeshRenderer>();
			List<GameObject> list = new List<GameObject>();
			Bounds bounds = GetBounds();
			for (int i = 0; i < array.Length; i++)
			{
				if (!((Object)(object)((Component)array[i]).gameObject == (Object)(object)((Component)((Component)this).transform).gameObject) && !((Object)(object)((Component)array[i]).GetComponent<TransformVolume>() != (Object)null) && ((1 << ((Component)array[i]).gameObject.layer) & ((LayerMask)(ref layerMask)).value) != 0 && ((Bounds)(ref bounds)).Intersects(((Renderer)array[i]).bounds))
				{
					list.Add(((Component)array[i]).gameObject);
				}
			}
			return list.ToArray();
		}

		public Vector3 GetSideDirection(int side)
		{
			//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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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_0021: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = (Vector3[])(object)new Vector3[6];
			Vector3 right = Vector3.right;
			Vector3 up = Vector3.up;
			Vector3 forward = Vector3.forward;
			array[0] = right;
			ref Vector3 reference = ref array[1];
			reference = -right;
			array[2] = up;
			ref Vector3 reference2 = ref array[3];
			reference2 = -up;
			array[4] = forward;
			ref Vector3 reference3 = ref array[5];
			reference3 = -forward;
			return ((Component)this).transform.TransformDirection(array[side]);
		}

		public Vector3 GetSidePosition(int side)
		{
			//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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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_0021: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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)
			//IL_0084: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = (Vector3[])(object)new Vector3[6];
			Vector3 right = Vector3.right;
			Vector3 up = Vector3.up;
			Vector3 forward = Vector3.forward;
			array[0] = right;
			ref Vector3 reference = ref array[1];
			reference = -right;
			array[2] = up;
			ref Vector3 reference2 = ref array[3];
			reference2 = -up;
			array[4] = forward;
			ref Vector3 reference3 = ref array[5];
			reference3 = -forward;
			return ((Component)this).transform.TransformPoint(array[side] * GetSizeAxis(side) + m_volume.Origin);
		}

		public float GetSizeAxis(int side)
		{
			//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_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_0060: 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)
			switch (side)
			{
			case 0:
			case 1:
				return m_volume.Size.x * 0.5f;
			case 2:
			case 3:
				return m_volume.Size.y * 0.5f;
			default:
				return m_volume.Size.z * 0.5f;
			}
		}

		public static Volume EditorVolumeControl(TransformVolume transformVolume, float handleSize, Color color)
		{
			//IL_000f: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//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_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Expected O, but got Unknown
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Expected O, but got Unknown
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: 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_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: 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_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Expected O, but got Unknown
			Vector3[] array = (Vector3[])(object)new Vector3[6];
			Transform transform = ((Component)transformVolume).transform;
			Handles.color = color;
			for (int i = 0; i < array.Length; i++)
			{
				ref Vector3 reference = ref array[i];
				reference = transformVolume.GetSidePosition(i);
			}
			ref Vector3 reference2 = ref array[0];
			reference2 = Handles.Slider(array[0], transform.right, handleSize, new CapFunction(Handles.DotHandleCap), 1f);
			ref Vector3 reference3 = ref array[1];
			reference3 = Handles.Slider(array[1], transform.right, handleSize, new CapFunction(Handles.DotHandleCap), 1f);
			ref Vector3 reference4 = ref array[2];
			reference4 = Handles.Slider(array[2], transform.up, handleSize, new CapFunction(Handles.DotHandleCap), 1f);
			ref Vector3 reference5 = ref array[3];
			reference5 = Handles.Slider(array[3], transform.up, handleSize, new CapFunction(Handles.DotHandleCap), 1f);
			ref Vector3 reference6 = ref array[4];
			reference6 = Handles.Slider(array[4], transform.forward, handleSize, new CapFunction(Handles.DotHandleCap), 1f);
			ref Vector3 reference7 = ref array[5];
			reference7 = Handles.Slider(array[5], transform.forward, handleSize, new CapFunction(Handles.DotHandleCap), 1f);
			Vector3 origin = default(Vector3);
			origin.x = transform.InverseTransformPoint((array[0] + array[1]) * 0.5f).x;
			origin.y = transform.InverseTransformPoint((array[2] + array[3]) * 0.5f).y;
			origin.z = transform.InverseTransformPoint((array[4] + array[5]) * 0.5f).z;
			Vector3 size = default(Vector3);
			size.x = transform.InverseTransformPoint(array[0]).x - transform.InverseTransformPoint(array[1]).x;
			size.y = transform.InverseTransformPoint(array[2]).y - transform.InverseTransformPoint(array[3]).y;
			size.z = transform.InverseTransformPoint(array[4]).z - transform.InverseTransformPoint(array[5]).z;
			return new Volume(origin, size);
		}
	}
	[Serializable]
	public struct Volume
	{
		[SerializeField]
		private Vector3 m_origin;

		[SerializeField]
		private Vector3 m_size;

		public Vector3 Origin => m_origin;

		public Vector3 Size => m_size;

		public Volume(Vector3 origin, Vector3 size)
		{
			//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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			m_origin = origin;
			m_size = size;
		}

		public static bool operator ==(Volume left, Volume right)
		{
			return left.Equals(right);
		}

		public static bool operator !=(Volume left, Volume right)
		{
			return !left.Equals(right);
		}

		public bool Equals(Volume other)
		{
			//IL_0002: 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_0019: 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)
			return Origin == other.Origin && Size == other.Size;
		}

		public override bool Equals(object obj)
		{
			if (object.ReferenceEquals(null, obj))
			{
				return false;
			}
			return obj is Volume && Equals((Volume)obj);
		}

		public override int GetHashCode()
		{
			//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_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)
			return (((object)Origin/*cast due to .constrained prefix*/).GetHashCode() * 397) ^ ((object)Size/*cast due to .constrained prefix*/).GetHashCode();
		}

		public override string ToString()
		{
			//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)
			return $"Origin: {Origin}, Size: {Size}";
		}
	}
}
namespace nrgill28.AtlasSampleScene
{
	public class CTF_CaptureZone : MonoBehaviour
	{
		public CTF_Manager Manager;

		public CTF_Team Team;

		public void OnTriggerEnter(Collider other)
		{
			CTF_Flag component = ((Component)other).GetComponent<CTF_Flag>();
			if (Object.op_Implicit((Object)(object)component) && component.Team != Team)
			{
				Manager.FlagCaptured(component);
			}
		}
	}
	public class CTF_Flag : FVRPhysicalObject
	{
		[Header("Flag stuffs")]
		public CTF_Team Team;

		public float RespawnDelay = 10f;

		public Vector3 FloorOffset = new Vector3(0f, 0.25f, 0f);

		private Vector3 _resetPosition;

		private Quaternion _resetRotation;

		private Transform _followTransform;

		private bool _isHeld;

		private bool _isTaken;

		private float _timer;

		private CTF_Sosig _heldBy;

		public override void Awake()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			((FVRPhysicalObject)this).Awake();
			_resetPosition = ((Component)this).transform.position;
			_resetRotation = ((Component)this).transform.rotation;
		}

		private void Update()
		{
			if (_isTaken && !_isHeld)
			{
				_timer -= Time.deltaTime;
				if (_timer < 0f)
				{
					ReturnFlag();
				}
			}
		}

		public void Take()
		{
			_isHeld = true;
			_isTaken = true;
		}

		public void Drop()
		{
			//IL_001a: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			((FVRInteractiveObject)this).IsHeld = false;
			_timer = RespawnDelay;
			NavMeshHit val = default(NavMeshHit);
			NavMesh.SamplePosition(((Component)this).transform.position, ref val, 100f, -1);
			((Component)this).transform.position = ((NavMeshHit)(ref val)).position + FloorOffset;
			((Component)this).transform.rotation = Quaternion.identity;
		}

		public void ReturnFlag()
		{
			//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)
			if (((FVRInteractiveObject)this).IsHeld)
			{
				((FVRInteractiveObject)this).ForceBreakInteraction();
			}
			if (Object.op_Implicit((Object)(object)_heldBy))
			{
				_heldBy.HeldFlag = null;
			}
			((Component)this).transform.SetPositionAndRotation(_resetPosition, _resetRotation);
			_isTaken = false;
		}

		private void OnTriggerEnter(Collider other)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (_isHeld)
			{
				return;
			}
			CTF_Sosig componentInParent = ((Component)other).GetComponentInParent<CTF_Sosig>();
			if (Object.op_Implicit((Object)(object)componentInParent) && (int)componentInParent.Sosig.BodyState == 0)
			{
				if (componentInParent.Team == Team)
				{
					ReturnFlag();
					return;
				}
				_heldBy = componentInParent;
				componentInParent.HeldFlag = this;
				Take();
			}
		}

		public override void BeginInteraction(FVRViveHand hand)
		{
			((FVRPhysicalObject)this).BeginInteraction(hand);
			Take();
		}

		public override void EndInteraction(FVRViveHand hand)
		{
			((FVRPhysicalObject)this).EndInteraction(hand);
			Drop();
		}
	}
	public class CTF_Manager : MonoBehaviour
	{
		[Header("References")]
		public Text[] ScoreTexts;

		public Transform[] AttackPoints;

		public Text StartButtonText;

		[Header("Red Team")]
		public CTF_Flag RedFlag;

		public int RedTeamSize;

		public Transform[] RedSpawns;

		public SosigEnemyID[] RedTeam;

		[Header("Blue Team")]
		public CTF_Flag BlueFlag;

		public int BlueTeamSize;

		public Transform[] BlueSpawns;

		public SosigEnemyID[] BlueTeam;

		private int _blueScore;

		private int _redScore;

		private bool _running;

		private readonly List<CTF_Sosig> _sosigs = new List<CTF_Sosig>();

		private readonly SpawnOptions _spawnOptions;

		public CTF_Manager()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			SpawnOptions val = new SpawnOptions();
			val.SpawnState = (SosigOrder)7;
			val.SpawnActivated = true;
			val.EquipmentMode = (EquipmentSlots)7;
			val.SpawnWithFullAmmo = true;
			_spawnOptions = val;
			((MonoBehaviour)this)..ctor();
		}

		private void Start()
		{
			UpdateScoreText();
		}

		public void ToggleGame()
		{
			if (_running)
			{
				EndGame();
				StartButtonText.text = "Start Game";
			}
			else
			{
				StartGame();
				StartButtonText.text = "Stop Game";
			}
		}

		private void StartGame()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			ResetGame();
			_running = true;
			GM.CurrentSceneSettings.SosigKillEvent += new SosigKill(CurrentSceneSettingsOnSosigKillEvent);
			((MonoBehaviour)this).StartCoroutine(DoInitialSpawns());
		}

		private void EndGame()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			GM.CurrentSceneSettings.SosigKillEvent -= new SosigKill(CurrentSceneSettingsOnSosigKillEvent);
			foreach (CTF_Sosig sosig in _sosigs)
			{
				sosig.Sosig.ClearSosig();
			}
			_running = false;
		}

		private void CurrentSceneSettingsOnSosigKillEvent(Sosig s)
		{
			CTF_Sosig cTF_Sosig = _sosigs.FirstOrDefault((CTF_Sosig x) => (Object)(object)x.Sosig == (Object)(object)s);
			if (Object.op_Implicit((Object)(object)cTF_Sosig))
			{
				((MonoBehaviour)this).StartCoroutine(RespawnSosig(cTF_Sosig));
			}
		}

		private void SpawnSosig(CTF_Team team)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			_spawnOptions.IFF = (int)team;
			_spawnOptions.SosigTargetPosition = SodaliteUtils.GetRandom<Transform>((IList<Transform>)AttackPoints).position;
			Transform transform;
			SosigEnemyID random;
			if (team == CTF_Team.Red)
			{
				transform = ((Component)SodaliteUtils.GetRandom<Transform>((IList<Transform>)RedSpawns)).transform;
				random = SodaliteUtils.GetRandom<SosigEnemyID>((IList<SosigEnemyID>)RedTeam);
			}
			else
			{
				transform = ((Component)SodaliteUtils.GetRandom<Transform>((IList<Transform>)BlueSpawns)).transform;
				random = SodaliteUtils.GetRandom<SosigEnemyID>((IList<SosigEnemyID>)BlueTeam);
			}
			Sosig val = SosigAPI.Spawn(ManagerSingleton<IM>.Instance.odicSosigObjsByID[random], _spawnOptions, transform.position, transform.rotation);
			CTF_Sosig cTF_Sosig = ((Component)val).gameObject.AddComponent<CTF_Sosig>();
			_sosigs.Add(cTF_Sosig);
			cTF_Sosig.Sosig = val;
			cTF_Sosig.Team = team;
		}

		private IEnumerator DoInitialSpawns()
		{
			int i = 0;
			while (i < Mathf.Max(RedTeamSize, BlueTeamSize))
			{
				if (i < RedTeamSize)
				{
					SpawnSosig(CTF_Team.Red);
				}
				if (i < BlueTeamSize)
				{
					SpawnSosig(CTF_Team.Blue);
				}
				i++;
				yield return (object)new WaitForSeconds(2.5f);
			}
		}

		private IEnumerator RespawnSosig(CTF_Sosig sosig)
		{
			yield return (object)new WaitForSeconds(5f);
			sosig.Sosig.ClearSosig();
			_sosigs.Remove(sosig);
			yield return (object)new WaitForSeconds(5f);
			if (_running)
			{
				int sosigsLeft = _sosigs.Count((CTF_Sosig x) => x.Team == sosig.Team);
				int teamSize = ((sosig.Team != CTF_Team.Red) ? BlueTeamSize : RedTeamSize);
				if (sosigsLeft < teamSize)
				{
					SpawnSosig(sosig.Team);
				}
			}
		}

		public void ResetGame()
		{
			_blueScore = 0;
			_redScore = 0;
			UpdateScoreText();
			if (Object.op_Implicit((Object)(object)RedFlag))
			{
				RedFlag.ReturnFlag();
			}
			if (Object.op_Implicit((Object)(object)BlueFlag))
			{
				BlueFlag.ReturnFlag();
			}
		}

		public void FlagCaptured(CTF_Flag flag)
		{
			if (flag.Team == CTF_Team.Red)
			{
				_blueScore++;
			}
			else
			{
				_redScore++;
			}
			UpdateScoreText();
			flag.ReturnFlag();
		}

		public void UpdateScoreText()
		{
			Text[] scoreTexts = ScoreTexts;
			foreach (Text val in scoreTexts)
			{
				val.text = "<color=red>" + _redScore + "</color> - <color=blue>" + _blueScore + "</color>";
			}
		}

		private void OnDrawGizmos()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			Gizmos.color = Color.red;
			Transform[] redSpawns = RedSpawns;
			foreach (Transform val in redSpawns)
			{
				Gizmos.DrawSphere(val.position, 0.15f);
			}
			Gizmos.color = Color.blue;
			Transform[] blueSpawns = BlueSpawns;
			foreach (Transform val2 in blueSpawns)
			{
				Gizmos.DrawSphere(val2.position, 0.15f);
			}
			Gizmos.color = Color.green;
			Transform[] attackPoints = AttackPoints;
			foreach (Transform val3 in attackPoints)
			{
				Gizmos.DrawSphere(val3.position, 0.15f);
			}
		}
	}
	public class CTF_Sosig : MonoBehaviour
	{
		public CTF_Team Team;

		public CTF_Flag HeldFlag;

		public Sosig Sosig;

		private void Awake()
		{
			Sosig = ((Component)this).GetComponent<Sosig>();
		}

		private void Update()
		{
			//IL_001d: 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_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_0041: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)HeldFlag))
			{
				Vector3 val = ((Component)Sosig).transform.position - ((Component)Sosig).transform.forward * 0.1f;
				((Component)HeldFlag).transform.SetPositionAndRotation(val, ((Component)Sosig).transform.rotation);
			}
		}
	}
	public enum CTF_Team
	{
		Red,
		Blue
	}
	public class PopupTarget : MonoBehaviour, IFVRDamageable
	{
		[Flags]
		public enum TargetRange
		{
			Near = 1,
			Mid = 2,
			Far = 4,
			All = 7
		}

		public PopupTargetManager Manager;

		public TargetRange Range;

		public Transform Pivot;

		public Vector3 SetRotation;

		private Quaternion _startRotation;

		private Quaternion _endRotation;

		private bool _set;

		public bool Set
		{
			get
			{
				return _set;
			}
			set
			{
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: 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)
				if (_set != value)
				{
					_set = value;
					((MonoBehaviour)this).StartCoroutine((!_set) ? RotateTo(_endRotation, _startRotation) : RotateTo(_startRotation, _endRotation));
				}
			}
		}

		private void Awake()
		{
			//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_0014: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			_startRotation = Pivot.rotation;
			_endRotation = Quaternion.Euler(SetRotation + ((Quaternion)(ref _startRotation)).eulerAngles);
		}

		void IFVRDamageable.Damage(Damage dam)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			if (Set && (int)dam.Class == 1)
			{
				Set = false;
				Manager.TargetHit(this);
			}
		}

		private IEnumerator RotateTo(Quaternion from, Quaternion to)
		{
			//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_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)
			float elapsed = 0f;
			while (elapsed < 0.25f)
			{
				yield return null;
				elapsed += Time.deltaTime;
				Pivot.localRotation = Quaternion.Slerp(from, to, elapsed / 0.25f);
			}
			Pivot.rotation = to;
		}
	}
	public class PopupTargetManager : MonoBehaviour
	{
		public List<PopupTarget> Targets;

		private readonly List<PopupTarget> _setTargets = new List<PopupTarget>();

		private void Awake()
		{
			((MonoBehaviour)this).StartCoroutine(StartSetAsync(3f, 8f, 5, PopupTarget.TargetRange.All));
		}

		private IEnumerator StartSetAsync(float minDelay, float maxDelay, int numTargets, PopupTarget.TargetRange ranges)
		{
			yield return (object)new WaitForSeconds(Random.Range(minDelay, maxDelay));
			IListExtensions.Shuffle<PopupTarget>((IList<PopupTarget>)Targets);
			_setTargets.Clear();
			foreach (PopupTarget target in Targets)
			{
				if ((target.Range & ranges) != 0)
				{
					target.Set = true;
					_setTargets.Add(target);
					numTargets--;
				}
				if (numTargets == 0)
				{
					break;
				}
			}
		}

		public void TargetHit(PopupTarget target)
		{
			if (_setTargets.Contains(target))
			{
				_setTargets.Remove(target);
				if (_setTargets.Count == 0)
				{
					((MonoBehaviour)this).StartCoroutine(StartSetAsync(3f, 8f, 5, PopupTarget.TargetRange.All));
				}
			}
		}
	}
}
namespace TSR
{
	public class TSR_Configurable_Course : MonoBehaviour
	{
		[Header("Course Setup")]
		[Tooltip("The courses to cycle through")]
		public TSR_Course[] courses;

		[Tooltip("The names of each course (name 1 goes to course 1 and so on)")]
		public string[] courseNames;

		[Tooltip("Game Object to enable whenever its corresponding course is selected (and disabled when another course is swapped to)")]
		public GameObject[] courseGameObjects;

		[Tooltip("The default course that is selected")]
		public int defaultCourseIndex;

		[Header("Objects")]
		[Tooltip("Text component that the name of the current course is displayed to")]
		public Text[] currentCourseNameDisplays;

		[HideInInspector]
		public int courseIndex;

		private void OnValidate()
		{
			if (courses != null)
			{
				if (courseNames == null || courseNames.Length != courses.Length)
				{
					Array.Resize(ref courseNames, courses.Length);
				}
				if (courseGameObjects == null || courseGameObjects.Length != courses.Length)
				{
					Array.Resize(ref courseGameObjects, courses.Length);
				}
			}
		}

		private void Start()
		{
			courseIndex = Mathf.Clamp(defaultCourseIndex, 0, courses.Length - 1);
			UpdateVis();
		}

		public void CycleCourseFoward()
		{
			if (courses != null && courses.Length != 0)
			{
				bool flag = false;
				if (courses[courseIndex].isTargetsActive)
				{
					courses[courseIndex].SpawnTargets();
					flag = true;
				}
				courseIndex = (courseIndex + 1) % courses.Length;
				if (flag)
				{
					courses[courseIndex].SpawnTargets();
				}
				UpdateVis();
			}
		}

		public void CycleCourseBackward()
		{
			if (courses != null && courses.Length != 0)
			{
				bool flag = false;
				if (courses[courseIndex].isTargetsActive)
				{
					courses[courseIndex].SpawnTargets();
					flag = true;
				}
				courseIndex = (courseIndex - 1 + courses.Length) % courses.Length;
				if (flag)
				{
					courses[courseIndex].SpawnTargets();
				}
				UpdateVis();
			}
		}

		public void UpdateVis()
		{
			string text = "";
			if (courseNames != null && courseIndex >= 0 && courseIndex < courseNames.Length && courseNames[courseIndex] != null)
			{
				text = courseNames[courseIndex];
			}
			if (currentCourseNameDisplays != null)
			{
				Text[] array = currentCourseNameDisplays;
				foreach (Text val in array)
				{
					if ((Object)(object)val != (Object)null)
					{
						val.text = text;
					}
				}
			}
			if (courseGameObjects != null)
			{
				for (int j = 0; j < courseGameObjects.Length; j++)
				{
					if ((Object)(object)courseGameObjects[j] != (Object)null)
					{
						courseGameObjects[j].SetActive(false);
					}
				}
				if (courseIndex >= 0 && courseIndex < courseGameObjects.Length && (Object)(object)courseGameObjects[courseIndex] != (Object)null)
				{
					courseGameObjects[courseIndex].SetActive(true);
				}
			}
			if (courseGameObjects != null && (Object)(object)courseGameObjects[courseIndex] != (Object)null)
			{
				courseGameObjects[courseIndex].SetActive(true);
			}
		}
	}
	public class TSR_Course : MonoBehaviour
	{
		[Header("Target Setup")]
		[Tooltip("Array of targets")]
		public TSR_Target[] targets;

		[Tooltip("Total ammount of targets to spawn (leave -1 to spawn all targets)")]
		public int targetsToSpawn = -1;

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

		[Tooltip("The range (x = min, y = max) in random seconds of delay from pressing reset/enable on this course to the targets actually spawning and scoring starting if enabled. (leave either x or y -1 to instead start immediately)")]
		public Vector2 startDelay = new Vector2(-1f, -1f);

		[Tooltip("Bypasses the start delay when turning the course on, meaning the delayed start only happens on a reset.")]
		public bool instantEnable = true;

		[Tooltip("Audio source that is played when the course starts after a delay. (Think shotclock starting beep)")]
		public AudioSource[] delayedStartAudio;

		[Header("Sosig Settings")]
		[Tooltip("Whether sosigs under this course will splode or silently dissapear when despawned or reset. (warning! sosigs sploding creates alot of lag)")]
		public bool doSosigsSplodeWhenDespawned = false;

		[Tooltip("Whether sosigs under this course will splode after after a short delay once dead like in TNH or stay as a dead body till reset or despawned.")]
		public bool doSosigsSplodeWhenKilled = false;

		[Header("Visuals")]
		[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;

		[Header("Scoring")]
		[Tooltip("Whether or not to have scoring (timer or score) enabled for this course.")]
		public bool isScoringEnabled = false;

		[Tooltip("Text components that the course score displays to. (does nothing if isScoringEnabled is not true)")]
		public Text[] scoreDisplays;

		[Tooltip("Text components that the course timer displays to. (does nothing if isScoringEnabled is not true)")]
		public Text[] timeDisplays;

		[HideInInspector]
		public bool isTargetsActive;

		[HideInInspector]
		public FVRObject mainObject;

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

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

		[HideInInspector]
		public bool buttonPressed;

		[HideInInspector]
		public List<TSR_ExternalButton> externalButtons = new List<TSR_ExternalButton>();

		[HideInInspector]
		public float score;

		[HideInInspector]
		public float maxscore;

		[HideInInspector]
		public float timeTaken;

		[HideInInspector]
		public float timetillStart = 0f;

		[HideInInspector]
		public bool isDelayingStart;

		[HideInInspector]
		public int delayType = 0;

		[HideInInspector]
		public TSR_Course_Linker linkedcourse;

		private void Start()
		{
			for (int i = 0; i < targets.Length; i++)
			{
				for (int num = ((Component)targets[i]).transform.childCount - 1; num >= 0; num--)
				{
					((Component)((Component)targets[i]).transform.GetChild(num)).gameObject.SetActive(false);
				}
			}
		}

		private void Update()
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Invalid comparison between Unknown and I4
			if (isDelayingStart)
			{
				CheckDelay();
			}
			else if (isTargetsActive && isScoringEnabled)
			{
				timeTaken += Time.deltaTime;
			}
			if (!doSosigsSplodeWhenKilled)
			{
				return;
			}
			for (int i = 0; i < activeSosigs.Count; i++)
			{
				if ((Object)(object)activeSosigs[i] != (Object)null && (int)activeSosigs[i].BodyState == 3)
				{
					activeSosigs[i].ClearSosig();
					activeSosigs.Remove(activeSosigs[i]);
				}
			}
		}

		public void ResetTargets()
		{
			if (!isTargetsActive || !isTargetsActive)
			{
				return;
			}
			if ((startDelay.x > -1f && !isDelayingStart) || (startDelay.y > -1f && !isDelayingStart))
			{
				BeginDelayingStart(1);
				return;
			}
			if (isDelayingStart && timetillStart <= 0f)
			{
				isDelayingStart = false;
			}
			else if (isDelayingStart)
			{
				return;
			}
			for (int i = 0; i < allTargets.Count; i++)
			{
				if ((Object)(object)allTargets[i] != (Object)null)
				{
					FVRPhysicalObject component = allTargets[i].GetComponent<FVRPhysicalObject>();
					if ((Object)(object)component != (Object)null && ((FVRInteractiveObject)component).IsHeld)
					{
						FVRViveHand hand = ((FVRInteractiveObject)component).m_hand;
						hand.ForceSetInteractable((FVRInteractiveObject)null);
						((FVRInteractiveObject)component).EndInteraction(hand);
					}
					Object.Destroy((Object)(object)allTargets[i]);
				}
			}
			allTargets.Clear();
			for (int j = 0; j < activeSosigs.Count; j++)
			{
				if ((Object)(object)activeSosigs[j] != (Object)null)
				{
					if (!doSosigsSplodeWhenDespawned)
					{
						activeSosigs[j].DeSpawnSosig();
					}
					else
					{
						activeSosigs[j].ClearSosig();
					}
				}
			}
			activeSosigs.Clear();
			TSR_Target[] array = targets;
			foreach (TSR_Target tSR_Target in array)
			{
				tSR_Target.isActive = false;
			}
			if (isScoringEnabled)
			{
				if ((Object)(object)linkedcourse != (Object)null)
				{
					linkedcourse.maxscore -= maxscore;
					linkedcourse.score -= maxscore;
					linkedcourse.timeTaken -= linkedcourse.timeTaken - timeTaken;
				}
				maxscore = 0f;
				score = 0f;
				timeTaken = 0f;
			}
			if (targetsToSpawn < 0 || targetsToSpawn > targets.Length)
			{
				for (int l = 0; l < targets.Length; l++)
				{
					SpawnTarget(targets[l]);
				}
			}
			else
			{
				int num = 0;
				while (num < targetsToSpawn)
				{
					int num2 = Random.Range(0, targets.Length);
					TSR_Target tSR_Target2 = targets[num2];
					if (!tSR_Target2.isActive)
					{
						SpawnTarget(tSR_Target2);
						num++;
					}
				}
			}
			UpdateScore();
		}

		public void SpawnTargets()
		{
			if (!isTargetsActive)
			{
				if (!instantEnable)
				{
					if ((startDelay.x > -1f && !isDelayingStart) || (startDelay.y > -1f && !isDelayingStart))
					{
						BeginDelayingStart(2);
						return;
					}
					if (isDelayingStart && timetillStart <= 0f)
					{
						isDelayingStart = false;
					}
					else if (isDelayingStart)
					{
						isDelayingStart = false;
						return;
					}
				}
				if (targets != null)
				{
					if (targetsToSpawn < 0 || targetsToSpawn > targets.Length)
					{
						for (int i = 0; i < targets.Length; i++)
						{
							SpawnTarget(targets[i]);
						}
					}
					else
					{
						int num = 0;
						while (num < targetsToSpawn)
						{
							int num2 = Random.Range(0, targets.Length);
							TSR_Target tSR_Target = targets[num2];
							if (!tSR_Target.isActive)
							{
								SpawnTarget(tSR_Target);
								num++;
							}
						}
					}
				}
				isTargetsActive = true;
				UpdateVis();
				UpdateScore();
			}
			else
			{
				if (!isTargetsActive)
				{
					return;
				}
				if (allTargets != null)
				{
					for (int j = 0; j < allTargets.Count; j++)
					{
						if ((Object)(object)allTargets[j] != (Object)null)
						{
							FVRPhysicalObject component = allTargets[j].GetComponent<FVRPhysicalObject>();
							if ((Object)(object)component != (Object)null && ((FVRInteractiveObject)component).IsHeld)
							{
								FVRViveHand hand = ((FVRInteractiveObject)component).m_hand;
								hand.ForceSetInteractable((FVRInteractiveObject)null);
								((FVRInteractiveObject)component).EndInteraction(hand);
							}
							Object.Destroy((Object)(object)allTargets[j]);
						}
					}
					allTargets.Clear();
				}
				if (activeSosigs != null)
				{
					for (int k = 0; k < activeSosigs.Count; k++)
					{
						if ((Object)(object)activeSosigs[k] != (Object)null)
						{
							if (!doSosigsSplodeWhenDespawned)
							{
								activeSosigs[k].DeSpawnSosig();
							}
							else
							{
								activeSosigs[k].ClearSosig();
							}
						}
					}
					activeSosigs.Clear();
				}
				if (targets != null)
				{
					TSR_Target[] array = targets;
					foreach (TSR_Target tSR_Target2 in array)
					{
						tSR_Target2.isActive = false;
					}
				}
				if (isScoringEnabled)
				{
					if ((Object)(object)linkedcourse != (Object)null)
					{
						linkedcourse.maxscore -= maxscore;
						linkedcourse.score -= maxscore;
						linkedcourse.timeTaken -= linkedcourse.timeTaken - timeTaken;
					}
					maxscore = 0f;
					score = 0f;
					timeTaken = 0f;
				}
				isTargetsActive = false;
				UpdateVis();
				UpdateScore();
			}
		}

		public void SpawnTarget(TSR_Target target)
		{
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected O, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Expected O, but got Unknown
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Expected O, but got Unknown
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			if (Random.Range(0f, 1f) > target.spawnChance)
			{
				return;
			}
			int num = 0;
			if (target.mixedTargets.Count <= 0)
			{
				return;
			}
			num = Random.Range(0, target.mixedTargets.Count);
			target.isActive = true;
			if (target.mixedTargets[num] is string)
			{
				string key = (string)target.mixedTargets[num];
				if (IM.OD.TryGetValue(key, out mainObject))
				{
					GameObject val = Object.Instantiate<GameObject>(((AnvilAsset)mainObject).GetGameObject(), ((Component)target).transform.position, ((Component)target).transform.rotation);
					allTargets.Add(val);
					if (target.isPhysicsLocked)
					{
						PhysLock(val);
					}
					if (isScoringEnabled && target.isScored)
					{
						SetupScoring(val, target);
					}
				}
			}
			else if (target.mixedTargets[num] is GameObject)
			{
				GameObject val2 = (GameObject)target.mixedTargets[num];
				GameObject val3 = Object.Instantiate<GameObject>(val2, ((Component)target).transform.position, ((Component)target).transform.rotation);
				allTargets.Add(val3);
				if (target.isPhysicsLocked)
				{
					PhysLock(val3);
				}
				if (isScoringEnabled && target.isScored)
				{
					SetupScoring(val3, target);
				}
				val3.SetActive(true);
			}
			else if (target.mixedTargets[num] is TSR_Target_Sosig)
			{
				TSR_Target_Sosig tSR_Target_Sosig = (TSR_Target_Sosig)target.mixedTargets[num];
				SpawnOptions val4 = new SpawnOptions();
				val4.SpawnState = tSR_Target_Sosig.spawnState;
				val4.SpawnActivated = tSR_Target_Sosig.spawnActive;
				val4.EquipmentMode = tSR_Target_Sosig.equipmentMode;
				val4.SpawnWithFullAmmo = tSR_Target_Sosig.spawnWithFullAmmo;
				val4.IFF = tSR_Target_Sosig.iFF;
				val4.SosigTargetPosition = ((Component)target).transform.position;
				val4.SosigTargetRotation = ((Component)target).transform.eulerAngles;
				SpawnOptions val5 = val4;
				Sosig val6 = new Sosig();
				val6 = ((!tSR_Target_Sosig.usesCustomSosigID) ? SosigAPI.Spawn(ManagerSingleton<IM>.Instance.odicSosigObjsByID[tSR_Target_Sosig.vanillaSosigType], val5, ((Component)target).transform.position, ((Component)target).transform.rotation) : SosigAPI.Spawn(ManagerSingleton<IM>.Instance.odicSosigObjsByID[(SosigEnemyID)tSR_Target_Sosig.customSosigID], val5, ((Component)target).transform.position, ((Component)target).transform.rotation));
				activeSosigs.Add(val6);
				val6.IgnoresNeedForWeapons = tSR_Target_Sosig.ignoresNeedForWeapon;
				if (tSR_Target_Sosig.doesPath)
				{
					List<Vector3> list = new List<Vector3>();
					List<Vector3> list2 = new List<Vector3>();
					list = tSR_Target_Sosig.pathPoints.Select((Transform t) => t.position).ToList();
					list2 = tSR_Target_Sosig.pathPoints.Select((Transform t) => t.eulerAngles).ToList();
					val6.CommandPathTo(list, list2, 1f, Vector2.one * 4f, 2f, tSR_Target_Sosig.pathingMoveSpeed, tSR_Target_Sosig.pathingLoopType, (List<Sosig>)null, 0.2f, 1f, tSR_Target_Sosig.pathingIsPatrol, 50f);
				}
				else
				{
					List<Vector3> list3 = new List<Vector3>();
					List<Vector3> list4 = new List<Vector3>();
					list3.Add(((Component)target).transform.position);
					list4.Add(((Component)target).transform.eulerAngles);
					val6.CommandPathTo(list3, list4, 1f, Vector2.one * 4f, 2f, tSR_Target_Sosig.pathingMoveSpeed, (PathLoopType)0, (List<Sosig>)null, 0.2f, 1f, tSR_Target_Sosig.pathingIsPatrol, 50f);
				}
			}
			else
			{
				Debug.LogWarning((object)("TSR_Target: \"" + ((Object)((Component)target).gameObject).name + "\" picked an invalid data type? Honestly idk how this could happen"));
			}
		}

		public void BeginDelayingStart(int delaytype)
		{
			timetillStart = Random.Range(startDelay.x, startDelay.y);
			delayType = delaytype;
			isDelayingStart = true;
		}

		public void CheckDelay()
		{
			timetillStart -= Time.deltaTime;
			if (timetillStart <= 0f)
			{
				if (delayType == 1)
				{
					ResetTargets();
				}
				else if (delayType == 2)
				{
					SpawnTargets();
				}
				AudioSource[] array = delayedStartAudio;
				foreach (AudioSource val in array)
				{
					val.Play();
				}
			}
		}

		public void PhysLock(GameObject obj)
		{
			Rigidbody component = obj.GetComponent<Rigidbody>();
			if ((Object)(object)component != (Object)null)
			{
				component.isKinematic = true;
			}
		}

		public void UpdateVis()
		{
			if (isTargetsActive)
			{
				if ((Object)(object)enabledVis != (Object)null)
				{
					enabledVis.SetActive(true);
				}
				if ((Object)(object)disabledVis != (Object)null)
				{
					disabledVis.SetActive(false);
				}
			}
			else
			{
				if ((Object)(object)enabledVis != (Object)null)
				{
					enabledVis.SetActive(false);
				}
				if ((Object)(object)disabledVis != (Object)null)
				{
					disabledVis.SetActive(true);
				}
			}
			externalButtons.ForEach(delegate(TSR_ExternalButton b)
			{
				b.UpdateVis();
			});
		}

		public void SetupScoring(GameObject target, TSR_Target targetSettings)
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			TSR_Scoring component = target.GetComponent<TSR_Scoring>();
			if ((Object)(object)component != (Object)null)
			{
				component.course = this;
				component.CalculateValue();
				return;
			}
			TSR_Scoring tSR_Scoring = target.AddComponent<TSR_Scoring>();
			tSR_Scoring.hitsToScore = targetSettings.hitsToScore;
			tSR_Scoring.bestHitsScore = targetSettings.bestHitsScore;
			Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>(true);
			Collider[] array = componentsInChildren;
			foreach (Collider val in array)
			{
				if ((Object)(object)((Component)val).GetComponent<TSR_ScoringHitbox>() == (Object)null && ((Component)val).gameObject.layer == 0)
				{
					TSR_ScoringHitbox tSR_ScoringHitbox = ((Component)val).gameObject.AddComponent<TSR_ScoringHitbox>();
					component.hitBoxes.Add(tSR_ScoringHitbox);
					tSR_ScoringHitbox.hitValue = targetSettings.hitsToScore;
					tSR_ScoringHitbox.hitPowerFactor = targetSettings.hitPowerFactor;
					tSR_ScoringHitbox.hitPowerFactorThresholds = targetSettings.hitPowerFactorThresholds;
					tSR_ScoringHitbox.hitTime = targetSettings.hitTime;
					tSR_ScoringHitbox.damageThreshold = targetSettings.damageThreshold;
					tSR_ScoringHitbox.ignoreMelee = targetSettings.ignoreMelee;
					tSR_ScoringHitbox.doesDebugLogHits = targetSettings.doesDebugLogHits;
				}
			}
			tSR_Scoring.course = this;
			tSR_Scoring.CalculateValue();
		}

		public void UpdateScore()
		{
			if (scoreDisplays != null)
			{
				string text = FormatScore(score, maxscore);
				Text[] array = scoreDisplays;
				foreach (Text val in array)
				{
					if ((Object)(object)val != (Object)null)
					{
						val.text = text;
					}
				}
			}
			if (timeDisplays == null)
			{
				return;
			}
			string text2 = FormatTime(timeTaken);
			Text[] array2 = timeDisplays;
			foreach (Text val2 in array2)
			{
				if ((Object)(object)val2 != (Object)null)
				{
					val2.text = text2;
				}
			}
		}

		private string FormatScore(float current, float max)
		{
			current = (float)Math.Round(current, 3);
			max = (float)Math.Round(max, 3);
			int decimalPlaces = GetDecimalPlaces(current);
			int decimalPlaces2 = GetDecimalPlaces(max);
			int num = Mathf.Max(decimalPlaces, decimalPlaces2);
			num = Mathf.Min(num, 3);
			string text = "F" + num;
			return $"{current.ToString(text, CultureInfo.InvariantCulture)}/{max.ToString(text, CultureInfo.InvariantCulture)}";
		}

		private int GetDecimalPlaces(float value)
		{
			string text = value.ToString(CultureInfo.InvariantCulture);
			int num = text.IndexOf('.');
			return (num >= 0) ? Mathf.Min(text.Length - num - 1, 3) : 0;
		}

		public static string FormatTime(float timeSeconds)
		{
			if (timeSeconds < 0f)
			{
				timeSeconds = 0f;
			}
			int num = Mathf.FloorToInt(timeSeconds / 60f);
			float num2 = timeSeconds % 60f;
			num2 = Mathf.Round(num2 * 1000f) / 1000f;
			if (num > 0)
			{
				return $"{num}:{num2:00.000}";
			}
			if (num2 >= 10f)
			{
				return $"{num2:00.000}";
			}
			return $"{num2:0.000}";
		}

		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 OnDisable()
		{
			if (isTargetsActive)
			{
				SpawnTargets();
			}
		}

		private void OnEnable()
		{
			if (isTargetsEnabledAtStart)
			{
				SpawnTargets();
			}
			else if (!isTargetsEnabledAtStart)
			{
				isTargetsActive = false;
				UpdateVis();
			}
		}
	}
	public class TSR_Course_Linker : MonoBehaviour
	{
		public TSR_Course[] normalCourses;

		public TSR_Configurable_Course[] configurableCourses;

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

		[Tooltip("The range (x = min, y = max) in random seconds of delay from pressing reset/enable on this course to the targets actually spawning and scoring starting if enabled. (leave either x or y -1 to instead start immediately)")]
		public Vector2 startDelay = new Vector2(-1f, -1f);

		[Tooltip("Bypasses the start delay when turning the course on, meaning the delayed start only happens on a reset.")]
		public bool instantEnable = true;

		[Tooltip("Audio source that is played when the course starts after a delay. (Think shotclock starting beep)")]
		public AudioSource[] delayedStartAudio;

		[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;

		[Header("Scoring")]
		[Tooltip("Whether or not to have scoring (timer or score) enabled for this course.")]
		public bool isScoringEnabled = false;

		[Tooltip("Text components that the course score displays to. (does nothing if isScoringEnabled is not true)")]
		public Text[] scoreDisplays;

		[Tooltip("Text components that the course timer displays to. (does nothing if isScoringEnabled is not true)")]
		public Text[] timeDisplays;

		[HideInInspector]
		public bool isCoursesActive;

		[HideInInspector]
		public List<TSR_ExternalButton> externalButtons = new List<TSR_ExternalButton>();

		[HideInInspector]
		public bool buttonPressed;

		[HideInInspector]
		public float score;

		[HideInInspector]
		public float maxscore;

		[HideInInspector]
		public float timeTaken;

		[HideInInspector]
		public float timetillStart = 0f;

		[HideInInspector]
		public bool isDelayingStart;

		[HideInInspector]
		public int delayType = 0;

		private void Start()
		{
			if (normalCourses != null)
			{
				TSR_Course[] array = normalCourses;
				foreach (TSR_Course tSR_Course in array)
				{
					tSR_Course.linkedcourse = this;
				}
			}
			if (configurableCourses == null)
			{
				return;
			}
			TSR_Configurable_Course[] array2 = configurableCourses;
			foreach (TSR_Configurable_Course tSR_Configurable_Course in array2)
			{
				TSR_Course[] courses = tSR_Configurable_Course.courses;
				foreach (TSR_Course tSR_Course2 in courses)
				{
					tSR_Course2.linkedcourse = this;
				}
			}
		}

		public void Update()
		{
			if (isDelayingStart)
			{
				CheckDelay();
			}
			else if (isCoursesActive && isScoringEnabled)
			{
				timeTaken += Time.deltaTime;
			}
		}

		public void StartCourses()
		{
			if (!instantEnable)
			{
				if ((startDelay.x > -1f && !isDelayingStart) || (startDelay.y > -1f && !isDelayingStart))
				{
					BeginDelayingStart(2);
					return;
				}
				if (isDelayingStart && timetillStart <= 0f)
				{
					isDelayingStart = false;
				}
				else if (isDelayingStart)
				{
					isDelayingStart = false;
					return;
				}
			}
			if (normalCourses != null)
			{
				TSR_Course[] array = normalCourses;
				foreach (TSR_Course tSR_Course in array)
				{
					tSR_Course.SpawnTargets();
				}
			}
			if (configurableCourses != null)
			{
				TSR_Configurable_Course[] array2 = configurableCourses;
				foreach (TSR_Configurable_Course tSR_Configurable_Course in array2)
				{
					tSR_Configurable_Course.courses[tSR_Configurable_Course.courseIndex].SpawnTargets();
				}
			}
			if (!isCoursesActive)
			{
				isCoursesActive = true;
			}
			else
			{
				isCoursesActive = false;
				if (isScoringEnabled)
				{
					maxscore = 0f;
					score = 0f;
					timeTaken = 0f;
				}
			}
			UpdateVis();
			UpdateScore();
		}

		public void ResetCourses()
		{
			if ((startDelay.x > -1f && !isDelayingStart) || (startDelay.y > -1f && !isDelayingStart))
			{
				BeginDelayingStart(1);
				return;
			}
			if (isDelayingStart && timetillStart <= 0f)
			{
				isDelayingStart = false;
			}
			else if (isDelayingStart)
			{
				return;
			}
			if (normalCourses != null)
			{
				TSR_Course[] array = normalCourses;
				foreach (TSR_Course tSR_Course in array)
				{
					tSR_Course.ResetTargets();
				}
			}
			if (configurableCourses != null)
			{
				TSR_Configurable_Course[] array2 = configurableCourses;
				foreach (TSR_Configurable_Course tSR_Configurable_Course in array2)
				{
					tSR_Configurable_Course.courses[tSR_Configurable_Course.courseIndex].ResetTargets();
				}
			}
			if (isScoringEnabled)
			{
				maxscore = 0f;
				score = 0f;
				timeTaken = 0f;
				UpdateScore();
			}
		}

		public void BeginDelayingStart(int delaytype)
		{
			timetillStart = Random.Range(startDelay.x, startDelay.y);
			delayType = delaytype;
			isDelayingStart = true;
		}

		public void CheckDelay()
		{
			timetillStart -= Time.deltaTime;
			if (timetillStart <= 0f)
			{
				if (delayType == 1)
				{
					ResetCourses();
				}
				else if (delayType == 2)
				{
					StartCourses();
				}
				AudioSource[] array = delayedStartAudio;
				foreach (AudioSource val in array)
				{
					val.Play();
				}
			}
		}

		public void UpdateVis()
		{
			if (isCoursesActive)
			{
				if ((Object)(object)enabledVis != (Object)null)
				{
					enabledVis.SetActive(true);
				}
				if ((Object)(object)disabledVis != (Object)null)
				{
					disabledVis.SetActive(false);
				}
			}
			else
			{
				if ((Object)(object)enabledVis != (Object)null)
				{
					enabledVis.SetActive(false);
				}
				if ((Object)(object)disabledVis != (Object)null)
				{
					disabledVis.SetActive(true);
				}
			}
			externalButtons.ForEach(delegate(TSR_ExternalButton b)
			{
				b.UpdateVis();
			});
		}

		public void UpdateScore()
		{
			if (scoreDisplays != null)
			{
				string text = FormatScore(score, maxscore);
				Text[] array = scoreDisplays;
				foreach (Text val in array)
				{
					if ((Object)(object)val != (Object)null)
					{
						val.text = text;
					}
				}
			}
			if (timeDisplays == null)
			{
				return;
			}
			string text2 = FormatTime(timeTaken);
			Text[] array2 = timeDisplays;
			foreach (Text val2 in array2)
			{
				if ((Object)(object)val2 != (Object)null)
				{
					val2.text = text2;
				}
			}
		}

		private string FormatScore(float current, float max)
		{
			current = (float)Math.Round(current, 3);
			max = (float)Math.Round(max, 3);
			int decimalPlaces = GetDecimalPlaces(current);
			int decimalPlaces2 = GetDecimalPlaces(max);
			int num = Mathf.Max(decimalPlaces, decimalPlaces2);
			num = Mathf.Min(num, 3);
			string text = "F" + num;
			return $"{current.ToString(text, CultureInfo.InvariantCulture)}/{max.ToString(text, CultureInfo.InvariantCulture)}";
		}

		private int GetDecimalPlaces(float value)
		{
			string text = value.ToString(CultureInfo.InvariantCulture);
			int num = text.IndexOf('.');
			return (num >= 0) ? Mathf.Min(text.Length - num - 1, 3) : 0;
		}

		public static string FormatTime(float timeSeconds)
		{
			if (timeSeconds < 0f)
			{
				timeSeconds = 0f;
			}
			int num = Mathf.FloorToInt(timeSeconds / 60f);
			float num2 = timeSeconds % 60f;
			num2 = Mathf.Round(num2 * 1000f) / 1000f;
			if (num > 0)
			{
				return $"{num}:{num2:00.000}";
			}
			if (num2 >= 10f)
			{
				return $"{num2:00.000}";
			}
			return $"{num2:0.000}";
		}

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

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

		private void OnDisable()
		{
			if (isCoursesActive)
			{
				StartCourses();
			}
		}

		private void OnEnable()
		{
			if (isCoursesEnabledAtStart && !isCoursesActive)
			{
				StartCourses();
			}
			else if (!isCoursesEnabledAtStart && !isCoursesActive)
			{
				isCoursesActive = false;
				UpdateVis();
			}
		}
	}
	public class TSR_ExternalButton : MonoBehaviour
	{
		public TSR_Course mainButton;

		public bool isLinkedCourseButton;

		public TSR_Course_Linker mainLinkedCourse;

		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 Start()
		{
			if ((Object)(object)mainButton != (Object)null)
			{
				mainButton.externalButtons.Add(this);
			}
			if ((Object)(object)mainLinkedCourse != (Object)null)
			{
				mainLinkedCourse.externalButtons.Add(this);
			}
			UpdateVis();
			if ((Object)(object)mainLinkedCourse != (Object)null && !isLinkedCourseButton)
			{
				Debug.LogWarning((object)("Linked course assigned on TSR_ExternalButton: \"" + ((Object)((Component)this).gameObject).name + "\" but is not marked as \"isLinkedCourseButton\""));
			}
			if ((Object)(object)mainButton != (Object)null && isLinkedCourseButton)
			{
				Debug.LogWarning((object)("Normal course assigned on TSR_ExternalButton: \"" + ((Object)((Component)this).gameObject).name + "\" but is marked as \"isLinkedCourseButton\""));
			}
			if ((Object)(object)mainButton != (Object)null && (Object)(object)mainLinkedCourse != (Object)null)
			{
				Debug.LogWarning((object)("TSR_ExternalButton: \"" + ((Object)((Component)this).gameObject).name + "\" has both a normal and linked course assigned. This is unsupported and may cause issues"));
			}
		}

		public void UpdateVis()
		{
			if (((Object)(object)mainButton != (Object)null && mainButton.isTargetsActive) || ((Object)(object)mainLinkedCourse != (Object)null && mainLinkedCourse.isCoursesActive))
			{
				if ((Object)(object)enabledVis != (Object)null)
				{
					enabledVis.SetActive(true);
				}
				if ((Object)(object)disabledVis != (Object)null)
				{
					disabledVis.SetActive(false);
				}
			}
			else
			{
				if ((Object)(object)enabledVis != (Object)null)
				{
					enabledVis.SetActive(false);
				}
				if ((Object)(object)disabledVis != (Object)null)
				{
					disabledVis.SetActive(true);
				}
			}
		}

		public void ClickButton()
		{
			if (isResetButton && !isLinkedCourseButton && mainButton.isTargetsActive)
			{
				mainButton.ResetTargets();
				resetAudio.Play();
			}
			else if (isResetButton && isLinkedCourseButton && mainLinkedCourse.isCoursesActive)
			{
				mainLinkedCourse.ResetCourses();
				resetAudio.Play();
			}
			else if (!isLinkedCourseButton && !isResetButton)
			{
				mainButton.SpawnTargets();
			}
			else if (isLinkedCourseButton && !isResetButton)
			{
				mainLinkedCourse.StartCourses();
			}
		}

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

		private void OnTriggerExit(Collider collider)
		{
			if (((Component)collider).gameObject.tag == "GameController")
			{
				buttonPressed = false;
			}
		}
	}
	public class TSR_Scoring : MonoBehaviour
	{
		[Tooltip("How many hits count for score.")]
		public int hitsToScore = 1;

		[Tooltip("Enables hitting the target more than it's hitsToScore, counting the best hits instead.")]
		public bool bestHitsScore = false;

		public List<TSR_ScoringHitbox> hitBoxes = new List<TSR_ScoringHitbox>();

		[HideInInspector]
		public List<Vector2> hits = new List<Vector2>();

		[HideInInspector]
		public float maxScore;

		[HideInInspector]
		public TSR_Course course;

		public void CalculateValue()
		{
			float num = 0f;
			for (int i = 0; i < hitBoxes.Count; i++)
			{
				hitBoxes[i].myScore = this;
				float num2 = hitBoxes[i].hitValue * hitBoxes[i].hitPowerFactor.y;
				if (num2 > num)
				{
					num = num2;
				}
			}
			maxScore = num * (float)hitsToScore;
			if ((Object)(object)course != (Object)null)
			{
				course.maxscore += maxScore;
			}
			if ((Object)(object)course != (Object)null && (Object)(object)course.linkedcourse != (Object)null)
			{
				course.linkedcourse.maxscore += maxScore;
			}
		}

		public void AddNewHit(Vector2 hit)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)course == (Object)null || course.isDelayingStart)
			{
				return;
			}
			if (hits.Count < hitsToScore)
			{
				hits.Add(hit);
				course.score += hit.x;
				if ((Object)(object)course.linkedcourse != (Object)null)
				{
					course.linkedcourse.score += hit.x;
				}
				if (hit.y != 0f)
				{
					course.timeTaken += hit.y;
					if ((Object)(object)course.linkedcourse != (Object)null)
					{
						course.linkedcourse.timeTaken += hit.y;
					}
				}
				course.UpdateScore();
				if ((Object)(object)course.linkedcourse != (Object)null)
				{
					course.linkedcourse.UpdateScore();
				}
			}
			else
			{
				if (!bestHitsScore)
				{
					return;
				}
				int index = 0;
				float x = hits[0].x;
				for (int i = 1; i < hits.Count; i++)
				{
					if (hits[i].x < x)
					{
						x = hits[i].x;
						index = i;
					}
				}
				if (!(hit.x > x))
				{
					return;
				}
				course.score -= x;
				if ((Object)(object)course.linkedcourse != (Object)null)
				{
					course.linkedcourse.score -= x;
				}
				if (hit.y != 0f)
				{
					course.timeTaken -= hits[index].y;
					if ((Object)(object)course.linkedcourse != (Object)null)
					{
						course.linkedcourse.timeTaken -= hits[index].y;
					}
				}
				hits[index] = hit;
				course.score += hit.x;
				if ((Object)(object)course.linkedcourse != (Object)null)
				{
					course.linkedcourse.score += hit.x;
				}
				if (hit.y != 0f)
				{
					course.timeTaken += hit.y;
					if ((Object)(object)course.linkedcourse != (Object)null)
					{
						course.linkedcourse.timeTaken += hit.y;
					}
				}
				course.UpdateScore();
				if ((Object)(object)course.linkedcourse != (Object)null)
				{
					course.linkedcourse.UpdateScore();
				}
			}
		}
	}
	public class TSR_ScoringHitbox : MonoBehaviour, IFVRDamageable
	{
		[Tooltip("Ammount of score this hitbox is worth when hit.")]
		public float hitValue = 1f;

		public Vector2 hitPowerFactor = new Vector2(1f, 1f);

		public Vector2 hitPowerFactorThresholds = new Vector2(-1f, -1f);

		[Tooltip("Time added (or removed with negative numbers) from the timer when this hit box is hit.")]
		public float hitTime = 0f;

		[Tooltip("The ammount of damage a hit has to exceed to score.")]
		public float damageThreshold = 5f;

		[Tooltip("Ignores damage from melee counting as a hit when true.")]
		public bool ignoreMelee = true;

		[Tooltip("Prints how much damage this hit box takes to the log for fine tuning the damage threshold. (respects whether ignoreMelee is true or not)")]
		public bool doesDebugLogHits;

		[HideInInspector]
		public Vector2 valuestoadd;

		[HideInInspector]
		public TSR_Scoring myScore;

		public