Decompiled source of HVT Tutorial v0.0.1

HVT_Tutorial.dll

Decompiled a year ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using Atlas;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using Sodalite.Api;
using Sodalite.Utilities;
using UnityEngine;
using UnityEngine.AI;
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 BgStrikeLights : MonoBehaviour
{
	public List<Transform> customItemList = new List<Transform>();

	public List<AudioClip> soundItemList = new List<AudioClip>();

	public float lightDuration = 1f;

	public float skipProbability = 0.9f;

	private void Start()
	{
	}

	private void Update()
	{
		if (!((double)Random.value < 0.005))
		{
			return;
		}
		foreach (Transform customItem in customItemList)
		{
			if (!(Random.value < skipProbability) && soundItemList.Count > 0)
			{
				int index = Random.Range(0, soundItemList.Count);
				AudioClip clip = soundItemList[index];
				Light component = ((Component)customItem).GetComponent<Light>();
				AudioSource componentInChildren = ((Component)customItem).GetComponentInChildren<AudioSource>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					componentInChildren.clip = clip;
				}
				if ((Object)(object)component != (Object)null && !((Behaviour)component).enabled)
				{
					((Behaviour)component).enabled = true;
					((MonoBehaviour)this).StartCoroutine(TurnOffLightAfterDelay(component, componentInChildren));
				}
			}
		}
	}

	private IEnumerator TurnOffLightAfterDelay(Light light, AudioSource sound)
	{
		sound.Play();
		yield return (object)new WaitForSeconds(lightDuration);
		((Behaviour)light).enabled = false;
	}
}
public class ConnectWall : MonoBehaviour
{
	public Rigidbody rb;

	public GameObject objectToSpawnPrefab;

	public float spawnDistance = 0.5f;

	public int numberOfObjectsToSpawn = 6;

	public bool enabled = true;

	private bool fired = false;

	private void Start()
	{
	}

	private void OnCollisionEnter(Collision collision)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		Vector3 position = ((Component)this).transform.position;
		Vector3 normal = ((ContactPoint)(ref collision.contacts[0])).normal;
		((Component)this).transform.rotation = Quaternion.LookRotation(((Component)this).transform.TransformDirection(Quaternion.Euler(90f, 0f, 0f) * normal), normal);
		rb.isKinematic = true;
		if (!fired)
		{
			fired = true;
			((MonoBehaviour)this).StartCoroutine(SpawnBombies());
		}
	}

	private void Update()
	{
	}

	private Vector3 GenerateRandomForwardDirection(float minAngle, float maxAngle)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		float num = Random.Range(minAngle, maxAngle);
		Vector3 result = default(Vector3);
		((Vector3)(ref result))..ctor(Random.Range(minAngle, maxAngle), Random.Range(minAngle, maxAngle), Random.Range(minAngle, maxAngle));
		return result;
	}

	private IEnumerator SpawnBombies()
	{
		yield return (object)new WaitForSeconds(1f);
		for (int i = 0; i < numberOfObjectsToSpawn; i++)
		{
			Vector3 spawnPosition = ((Component)this).transform.position + ((Component)this).transform.TransformDirection(new Vector3(0f, -1f, 0f));
			GameObject newObject = Object.Instantiate<GameObject>(objectToSpawnPrefab, spawnPosition, Quaternion.identity);
			Rigidbody newObjectRigidbody = newObject.GetComponent<Rigidbody>();
			if ((Object)(object)newObjectRigidbody != (Object)null)
			{
				Vector3 val = ((Component)this).transform.position + ((Component)this).transform.TransformDirection(new Vector3(0f, -1f, 0f));
				newObjectRigidbody.velocity = ((Vector3)(ref val)).normalized * Random.Range(1f, 5f);
			}
			yield return (object)new WaitForSeconds(0.5f);
		}
	}
}
public class DestroyLight : MonoBehaviour, IFVRDamageable
{
	public List<Transform> objsToDelete = new List<Transform>();

	private void Start()
	{
	}

	private void OnCollisionEnter(Collision collision)
	{
	}

	private void OnTriggerEnter(Collider other)
	{
	}

	void IFVRDamageable.Damage(Damage dam)
	{
		foreach (Transform item in objsToDelete)
		{
			if ((Object)(object)item != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)item).gameObject.gameObject);
			}
		}
	}

	private void Update()
	{
	}
}
public class EnableChildrenss : MonoBehaviour
{
	private void Start()
	{
		((MonoBehaviour)this).StartCoroutine(ThreeSecondWait());
	}

	private IEnumerator ThreeSecondWait()
	{
		yield return (object)new WaitForSeconds(1f);
		IEnumerator enumerator = ((Component)this).transform.GetEnumerator();
		try
		{
			while (enumerator.MoveNext())
			{
				Transform val = (Transform)enumerator.Current;
				((Component)val).gameObject.SetActive(true);
			}
		}
		finally
		{
			IDisposable disposable;
			IDisposable disposable2 = (disposable = enumerator as IDisposable);
			if (disposable != null)
			{
				disposable2.Dispose();
			}
		}
	}

	private void Update()
	{
	}
}
namespace nrgill28.AtlasSampleScene
{
	public class HR_CaptureZone : MonoBehaviour
	{
		public HR_Manager Manager;

		public HR_Team Team;

		public void OnTriggerEnter(Collider other)
		{
			Debug.LogWarning((object)"CaptureZone_OnTriggEnter");
			Debug.LogError((object)other);
			HR_Flag component = ((Component)other).GetComponent<HR_Flag>();
			if (Object.op_Implicit((Object)(object)component) && component.Team != Team)
			{
				Manager.FlagCaptured(component);
			}
			if (((Object)((Component)other).gameObject).name == "hvt_trigger")
			{
				Debug.LogError((object)"Found hvt_trigger!");
				HR_Flag hR_Flag = new HR_Flag();
				hR_Flag.Team = HR_Team.Blue;
				Manager.FlagCaptured(hR_Flag);
			}
		}
	}
	public class HR_Flag : FVRPhysicalObject
	{
		[Header("Flag stuffs")]
		public HR_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 HR_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;
			}
			HR_Sosig componentInParent = ((Component)other).GetComponentInParent<HR_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 HR_Manager : MonoBehaviour
	{
		[Header("References")]
		public Text[] ScoreTexts;

		public Transform[] AttackPoints;

		public Text StartButtonText;

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

		public int RedTeamSize;

		public Transform[] RedSpawns;

		public SosigEnemyID[] RedTeam;

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

		public int BlueTeamSize;

		public Transform[] BlueSpawns;

		public SosigEnemyID[] BlueTeam;

		public Transform[] HostageSpawns;

		public int _maxNumCivies = 1;

		private int _blueScore;

		private int _redScore;

		private bool _running;

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

		private int _numCivies = 0;

		private readonly SpawnOptions _spawnOptions;

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

		private void Start()
		{
			StartButtonText.text = "Start Game";
			UpdateScoreText();
		}

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

		private void StartGame()
		{
			ResetGame();
			_running = true;
			((MonoBehaviour)this).StartCoroutine(DoInitialSpawns());
		}

		private void EndGame()
		{
			foreach (HR_Sosig sosig in _sosigs)
			{
				if (Object.op_Implicit((Object)(object)sosig) && Object.op_Implicit((Object)(object)sosig.Sosig))
				{
					sosig.Sosig.ClearSosig();
				}
			}
			_running = false;
		}

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

		private void SpawnSosig(HR_Team team, int index = 0, bool isHostage = false)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Expected O, but got Unknown
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			_spawnOptions.IFF = (int)team;
			Transform transform = ((Component)BlueSpawns[index]).transform;
			SosigEnemyID key = SodaliteUtils.GetRandom<SosigEnemyID>((IList<SosigEnemyID>)BlueTeam);
			if (isHostage)
			{
				Debug.LogWarning((object)"Im spawning civvies");
				if (HostageSpawns.Length > 0)
				{
					Debug.LogWarning((object)"for real civvies");
					transform = ((Component)HostageSpawns[_numCivies % HostageSpawns.Length]).transform;
					_spawnOptions.SosigTargetPosition = transform.position;
					key = (SosigEnemyID)0;
					_spawnOptions.IFF = -1;
				}
			}
			else
			{
				switch (team)
				{
				case HR_Team.Red:
					Debug.LogWarning((object)"Non civie spawning!");
					transform = ((Component)RedSpawns[index]).transform;
					_spawnOptions.SosigTargetPosition = ((Component)RedSpawns[index]).transform.position;
					key = SodaliteUtils.GetRandom<SosigEnemyID>((IList<SosigEnemyID>)RedTeam);
					break;
				case HR_Team.Blue:
					Debug.LogWarning((object)"Non civie spawning!");
					_spawnOptions.SosigTargetPosition = ((Component)BlueSpawns[index]).transform.position;
					transform = ((Component)BlueSpawns[index]).transform;
					key = SodaliteUtils.GetRandom<SosigEnemyID>((IList<SosigEnemyID>)BlueTeam);
					break;
				}
			}
			Sosig val = SosigAPI.Spawn(ManagerSingleton<IM>.Instance.odicSosigObjsByID[key], _spawnOptions, transform.position, transform.rotation);
			if (isHostage)
			{
				GameObject val2 = new GameObject("hvt_trigger");
				int layer = LayerMask.NameToLayer("PlayerAndRBTrigger");
				val2.layer = layer;
				val2.transform.position = ((Component)val).transform.position - ((Component)val).transform.forward * 1f;
				Collider val3 = (Collider)(object)val2.AddComponent<BoxCollider>();
				val3.isTrigger = true;
				Rigidbody val4 = val2.AddComponent<Rigidbody>();
				val4.isKinematic = true;
				val2.transform.SetParent(((Component)val).transform);
			}
			HR_Sosig hR_Sosig = ((Component)val).gameObject.AddComponent<HR_Sosig>();
			hR_Sosig.Sosig = val;
			hR_Sosig.Team = team;
			hR_Sosig.IsHostage = isHostage;
			_sosigs.Add(hR_Sosig);
		}

		private IEnumerator DoInitialSpawns()
		{
			ShuffleArray(BlueSpawns);
			ShuffleArray(RedSpawns);
			ShuffleArray(HostageSpawns);
			while (_numCivies < _maxNumCivies)
			{
				SpawnSosig(HR_Team.Red, _numCivies, isHostage: true);
				_numCivies++;
				yield return (object)new WaitForSeconds(0.5f);
			}
			int i = 0;
			while (i < BlueSpawns.Length)
			{
				SpawnSosig(HR_Team.Blue, i);
				i++;
				yield return (object)new WaitForSeconds(0.5f);
			}
			int j = 0;
			while (j < RedSpawns.Length)
			{
				SpawnSosig(HR_Team.Red, j);
				j++;
				yield return (object)new WaitForSeconds(0.5f);
			}
		}

		private void ShuffleArray(Transform[] arr)
		{
			for (int num = arr.Length - 1; num > 0; num--)
			{
				int num2 = Random.Range(0, num + 1);
				Transform val = arr[num];
				arr[num] = arr[num2];
				arr[num2] = val;
			}
		}

		private IEnumerator RespawnSosig(HR_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((HR_Sosig x) => x.Team == sosig.Team);
				int teamSize = ((sosig.Team != 0) ? BlueTeamSize : RedTeamSize);
				if (sosigsLeft < teamSize)
				{
					SpawnSosig(sosig.Team);
				}
			}
		}

		public void ResetGame()
		{
			Debug.LogWarning((object)"restting game");
			_blueScore = 0;
			_redScore = 0;
			_numCivies = 0;
			UpdateScoreText();
			Debug.LogWarning((object)"returning flags if they exist");
			if (Object.op_Implicit((Object)(object)RedFlag))
			{
				RedFlag.ReturnFlag();
			}
			if (Object.op_Implicit((Object)(object)BlueFlag))
			{
				BlueFlag.ReturnFlag();
			}
		}

		public void FlagCaptured(HR_Flag flag)
		{
			if (flag.Team == HR_Team.Red)
			{
				_blueScore++;
			}
			else
			{
				_redScore++;
			}
			UpdateScoreText();
		}

		public void UpdateScoreText()
		{
			Debug.LogWarning((object)"updating text score");
			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)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			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);
			}
			Gizmos.color = Color.gray;
			Transform[] hostageSpawns = HostageSpawns;
			foreach (Transform val4 in hostageSpawns)
			{
				Gizmos.DrawSphere(val4.position, 0.15f);
			}
		}
	}
	public class HR_Sosig : MonoBehaviour
	{
		public HR_Team Team;

		public HR_Flag HeldFlag;

		public Sosig Sosig;

		public bool IsHostage;

		private float timer = 0f;

		private float interval = 1f;

		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);
			}
			if (!IsHostage)
			{
			}
		}
	}
	public enum HR_Team
	{
		Red,
		Blue
	}
}
public class KillAfterX : MonoBehaviour
{
	public float x = 3f;

	private void Start()
	{
		((MonoBehaviour)this).StartCoroutine(ThreeSecondWait());
	}

	private IEnumerator ThreeSecondWait()
	{
		yield return (object)new WaitForSeconds(x);
		Object.Destroy((Object)(object)((Component)this).gameObject);
	}

	private void Update()
	{
	}
}
public class LeafBlow : MonoBehaviour
{
	private bool fired = false;

	private bool enabled = false;

	public GameObject objectToSpawnPrefab;

	private void Start()
	{
	}

	private void OnCollisionEnter(Collision collision)
	{
		//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)
		GameObject gameObject = collision.gameObject;
		Debug.Log((object)"Collision occurred.");
		if (gameObject.layer != LayerMask.NameToLayer("Environment") && !fired)
		{
			fired = true;
			GameObject val = Object.Instantiate<GameObject>(objectToSpawnPrefab, ((Component)this).transform.position, Quaternion.identity);
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}

	private void Update()
	{
	}
}
namespace NGA.HVT_Tutorial
{
	[BepInPlugin("NGA.HVT_Tutorial", "HVT_Tutorial", "0.0.1")]
	[BepInProcess("h3vr.exe")]
	[Description("Built with MeatKit")]
	[BepInDependency("nrgill28.Atlas", "1.0.1")]
	public class HVT_TutorialPlugin : 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(), "NGA.HVT_Tutorial");
			AtlasPlugin.RegisterScene(Path.Combine(BasePath, "lescene"));
		}
	}
}
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 != 0) ? 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));
				}
			}
		}
	}
	public class SpawnHomie : MonoBehaviour
	{
		public Transform[] AttackPoints;

		public Transform[] BlueSpawns;

		public SosigEnemyID[] BlueTeam;

		private readonly SpawnOptions _spawnOptions;

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

		private void Start()
		{
			SpawnSosig();
		}

		private void Update()
		{
		}

		private void SpawnSosig()
		{
			//IL_0020: 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_0059: 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_006c: Expected O, but got Unknown
			//IL_0073: 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)
			bool flag = true;
			_spawnOptions.IFF = 0;
			_spawnOptions.SosigTargetPosition = SodaliteUtils.GetRandom<Transform>((IList<Transform>)AttackPoints).position;
			Transform transform = ((Component)SodaliteUtils.GetRandom<Transform>((IList<Transform>)BlueSpawns)).transform;
			SosigEnemyID random = SodaliteUtils.GetRandom<SosigEnemyID>((IList<SosigEnemyID>)BlueTeam);
			transform = ((Component)SodaliteUtils.GetRandom<Transform>((IList<Transform>)BlueSpawns)).transform;
			random = (SosigEnemyID)0;
			if (flag)
			{
				GameObject val = new GameObject("hvt_trigger");
				val.transform.position = transform.position;
				val.transform.rotation = transform.rotation;
				int layer = LayerMask.NameToLayer("PlayerAndRBTrigger");
				val.layer = layer;
				Collider val2 = (Collider)(object)val.AddComponent<BoxCollider>();
				val2.isTrigger = true;
			}
		}
	}
}