Decompiled source of SandpitGunGame v1.0.1

SandpitGunGame.dll

Decompiled a month 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 System.Text;
using System.Xml;
using System.Xml.Serialization;
using Atlas;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using GunGame.Scripts;
using GunGame.Scripts.Options;
using GunGame.Scripts.Weapons;
using HarmonyLib;
using Sodalite.Api;
using Technie.PhysicsCreator.QHull;
using UnityEditor;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Profiling;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
public class ModelCustomizer : MonoBehaviour
{
	private GameObject[] parts;

	[SerializeField]
	private bool[] bools;

	[SerializeField]
	private void Reset()
	{
		int childCount = ((Component)this).transform.childCount;
		parts = (GameObject[])(object)new GameObject[childCount];
		bools = new bool[childCount];
		for (int i = 0; i < childCount; i++)
		{
			parts[i] = ((Component)((Component)this).transform.GetChild(i)).gameObject;
			bools[i] = parts[i].activeSelf;
		}
		RefreshVisibility();
	}

	public void RefreshVisibility()
	{
		int num = parts.Length;
		for (int i = 0; i < num; i++)
		{
			parts[i].SetActive(bools[i]);
		}
	}

	public string[] GetNames()
	{
		int num = parts.Length;
		string[] array = new string[num];
		for (int i = 0; i < num; i++)
		{
			array[i] = ((Object)parts[i]).name;
		}
		return array;
	}

	public bool[] GetBools()
	{
		return bools;
	}

	public void SetBool(int i, bool b)
	{
		bools[i] = b;
		RefreshVisibility();
	}

	public void ApplyMaterial(Material material)
	{
		MeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<MeshRenderer>(true);
		foreach (MeshRenderer val in componentsInChildren)
		{
			Material[] sharedMaterials = ((Renderer)val).sharedMaterials;
			for (int j = 0; j < sharedMaterials.Length; j++)
			{
				sharedMaterials[j] = material;
			}
			((Renderer)val).sharedMaterials = sharedMaterials;
		}
	}

	public void DoReset()
	{
		Reset();
	}
}
public class CustomDebug : MonoBehaviourSingleton<CustomDebug>
{
	public Text DebugWeaponText;

	public Text DebugAmmoText;
}
namespace GunGame.Scripts
{
	public class CustomSosigSpawner : MonoBehaviour
	{
		public SosigOrder SpawnState;

		public int IFF;

		public SpawnedSosigInfo Spawn(SosigEnemyID SosigType)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0010: 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_004c: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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)
			SpawnOptions val = new SpawnOptions();
			val.SpawnActivated = true;
			val.SpawnState = SpawnState;
			val.IFF = IFF;
			val.SpawnWithFullAmmo = true;
			val.EquipmentMode = (EquipmentSlots)7;
			val.SosigTargetPosition = ((Component)this).transform.position;
			val.SosigTargetRotation = ((Component)this).transform.eulerAngles;
			SpawnOptions val2 = val;
			SosigEnemyTemplate val3 = ManagerSingleton<IM>.Instance.odicSosigObjsByID[SosigType];
			Sosig spawnedSosig = SosigAPI.Spawn(val3, val2, ((Component)this).transform.position, ((Component)this).transform.rotation);
			SpawnedSosigInfo result = default(SpawnedSosigInfo);
			result.SosigType = SosigType;
			result.SpawnedSosig = spawnedSosig;
			return result;
		}

		private void OnDrawGizmos()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			Gizmos.color = new Color(0.8f, 0.2f, 0.2f, 0.5f);
			Gizmos.DrawSphere(((Component)this).transform.position, 0.1f);
			Gizmos.DrawLine(((Component)this).transform.position, ((Component)this).transform.position + ((Component)this).transform.forward * 0.25f);
		}
	}
	public struct SpawnedSosigInfo
	{
		public SosigEnemyID SosigType;

		public Sosig SpawnedSosig;
	}
	public class EndArea : MonoBehaviour
	{
		public Text TimeText;

		public Text KillsText;

		public Text DeathsText;

		public Transform EndPos;

		public void EndGame()
		{
			//IL_000c: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			GM.CurrentMovementManager.TeleportToPoint(EndPos.position, true, ((Component)this).transform.position + ((Component)this).transform.forward);
			foreach (Transform playerSpawner in MonoBehaviourSingleton<GameManager>.Instance.PlayerSpawners)
			{
				((Component)playerSpawner).transform.position = EndPos.position;
			}
			KillsText.text = "Kills: " + MonoBehaviourSingleton<GameManager>.Instance.Kills;
			DeathsText.text = "Deaths: " + MonoBehaviourSingleton<GameManager>.Instance.Deaths;
			TimeSpan timeSpan = TimeSpan.FromSeconds(MonoBehaviourSingleton<GameManager>.Instance.GameTime);
			TimeText.text = "Time: " + timeSpan.Hours.ToString("00") + ":" + timeSpan.Minutes.ToString("00") + ":" + timeSpan.Seconds.ToString("00");
		}
	}
	public class GameManager : MonoBehaviourSingleton<GameManager>
	{
		[HideInInspector]
		public int Kills;

		[HideInInspector]
		public int Deaths;

		[HideInInspector]
		public bool GameEnded;

		public EndArea EndArea;

		public static Action BeforeGameStartedEvent;

		public static Action GameStartedEvent;

		public PlayerSpawner PlayerSpawner;

		public List<Transform> PlayerSpawners;

		private Progression _progression;

		private Harmony _harmony;

		private float _timer;

		public float GameTime => Time.time - _timer;

		public override void Awake()
		{
			base.Awake();
			_progression = ((Component)this).GetComponent<Progression>();
			_harmony = Harmony.CreateAndPatchAll(typeof(PlayerSpawner), (string)null);
			_harmony.PatchAll(typeof(SosigBehavior));
			_harmony.PatchAll(typeof(Progression));
		}

		public void StartGame()
		{
			GameEnded = false;
			if (BeforeGameStartedEvent != null)
			{
				BeforeGameStartedEvent();
			}
			_progression.SpawnAndEquip();
			PlayerSpawner.MovePlayerToRandomSpawn();
			if (GameStartedEvent != null)
			{
				GameStartedEvent();
			}
			_timer = Time.time;
		}

		public void RemovePausedTime(float timePaused)
		{
			_timer += timePaused;
		}

		public void EndGame()
		{
			EndArea.EndGame();
			GameEnded = true;
		}

		public void DebugAdvanceWeapon()
		{
			_progression.Promote();
		}

		public void DebugPreviousWeapon()
		{
			_progression.Demote();
		}

		public void DebugTeleport()
		{
			PlayerSpawner.MovePlayerToRandomSpawn();
		}

		public void DebugStart()
		{
			if (BeforeGameStartedEvent != null)
			{
				BeforeGameStartedEvent();
			}
			_progression.SpawnAndEquip();
			if (GameStartedEvent != null)
			{
				GameStartedEvent();
			}
			_timer = Time.time;
		}

		private void OnDestroy()
		{
			_harmony.UnpatchSelf();
		}
	}
}
public class GunsLeftUI : MonoBehaviour
{
	private Text _gunsLeftText;

	private void Awake()
	{
		_gunsLeftText = ((Component)this).GetComponent<Text>();
		Progression.WeaponChangedEvent = (Action)Delegate.Combine(Progression.WeaponChangedEvent, new Action(UpdateUI));
	}

	private void UpdateUI()
	{
		int num = Mathf.Min(GameSettings.CurrentPool.GetWeaponCount(), WeaponCountOption.WeaponCount);
		int num2 = MonoBehaviourSingleton<Progression>.Instance.CurrentWeaponId + 1;
		int num3 = num - num2;
		_gunsLeftText.text = "Guns left: " + num3;
	}

	private void OnDestroy()
	{
		Progression.WeaponChangedEvent = (Action)Delegate.Remove(Progression.WeaponChangedEvent, new Action(UpdateUI));
	}
}
namespace CustomScripts
{
	public class LeverWrapper : MonoBehaviour
	{
		public UnityEvent LeverToggleEvent;

		public UnityEvent LeverOnEvent;

		public UnityEvent LeverOffEvent;

		public UnityEvent LeverHoldStartEvent;

		public UnityEvent LeverHoldEndEvent;

		private TrapLever _lever;

		private bool _isOn;

		private bool _isHeld;

		private void Awake()
		{
			_lever = ((Component)this).GetComponentInChildren<TrapLever>();
			_lever.MessageTargets.Add(((Component)this).gameObject);
		}

		private void Update()
		{
			if (!_isHeld && ((FVRInteractiveObject)_lever).IsHeld)
			{
				OnHoldStart();
			}
			else if (_isHeld && !((FVRInteractiveObject)_lever).IsHeld)
			{
				OnHoldEnd();
			}
		}

		private void OnHoldStart()
		{
			_isHeld = true;
			if (LeverHoldStartEvent != null)
			{
				LeverHoldStartEvent.Invoke();
			}
		}

		private void OnHoldEnd()
		{
			_isHeld = false;
			if (LeverHoldEndEvent != null)
			{
				LeverHoldEndEvent.Invoke();
			}
		}

		public void ON()
		{
			if (!_isOn)
			{
				_isOn = true;
				if (LeverToggleEvent != null)
				{
					LeverToggleEvent.Invoke();
				}
				if (LeverOnEvent != null)
				{
					LeverOnEvent.Invoke();
				}
			}
		}

		public void OFF()
		{
			if (_isOn)
			{
				_isOn = false;
				if (LeverToggleEvent != null)
				{
					LeverToggleEvent.Invoke();
				}
				if (LeverOffEvent != null)
				{
					LeverOffEvent.Invoke();
				}
			}
		}
	}
}
namespace GunGame.Scripts
{
	public class MonoBehaviourSingleton<T> : MonoBehaviour where T : Component
	{
		public static T Instance { get; private set; }

		public virtual void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = (T)(object)((this is T) ? this : null);
			}
			else
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
}
namespace GunGame.Scripts.Options
{
	public class GameSettings : MonoBehaviourSingleton<GameSettings>
	{
		public static Action SettingsChanged;

		public static Action WeaponPoolChanged;

		public static bool DisabledAutoLoading;

		public static bool AlwaysChamberRounds;

		public static bool HealOnPromotion;

		public static bool AlwaysResetSosigs;

		[SerializeField]
		private Image DisabledAutoLoadingImage;

		[SerializeField]
		private Image AlwaysChamberRoundsImage;

		[SerializeField]
		private Image HealOnPromotionImage;

		[SerializeField]
		private Text MaxSosigCountText;

		public static int MaxSosigCount;

		public static WeaponPoolInterface CurrentPool { get; private set; }

		private void Start()
		{
			DisabledAutoLoading = false;
			AlwaysChamberRounds = false;
			HealOnPromotion = false;
			AlwaysResetSosigs = false;
			ResetMaxSosigCount();
		}

		public void IncreaseMaxSosigCount()
		{
			MaxSosigCount++;
			MaxSosigCountText.text = MaxSosigCount.ToString();
			if (SettingsChanged != null)
			{
				SettingsChanged();
			}
		}

		public void DecreaseMaxSosigCount()
		{
			MaxSosigCount--;
			if (MaxSosigCount < 1)
			{
				MaxSosigCount = 1;
			}
			MaxSosigCountText.text = MaxSosigCount.ToString();
			if (SettingsChanged != null)
			{
				SettingsChanged();
			}
		}

		public void ResetMaxSosigCount()
		{
			MaxSosigCount = MonoBehaviourSingleton<SosigBehavior>.Instance.MaxSosigCount;
			MaxSosigCountText.text = MaxSosigCount.ToString();
			if (SettingsChanged != null)
			{
				SettingsChanged();
			}
		}

		public void ToggleAutoLoading()
		{
			DisabledAutoLoading = !DisabledAutoLoading;
			((Behaviour)DisabledAutoLoadingImage).enabled = DisabledAutoLoading;
			if (SettingsChanged != null)
			{
				SettingsChanged();
			}
		}

		public void ToggleAlwaysChamberRounds()
		{
			AlwaysChamberRounds = !AlwaysChamberRounds;
			((Behaviour)AlwaysChamberRoundsImage).enabled = AlwaysChamberRounds;
			if (SettingsChanged != null)
			{
				SettingsChanged();
			}
		}

		public void ToggleHealOnPromotion()
		{
			HealOnPromotion = !HealOnPromotion;
			((Behaviour)HealOnPromotionImage).enabled = HealOnPromotion;
			if (SettingsChanged != null)
			{
				SettingsChanged();
			}
		}

		public static void ChangeCurrentPool(WeaponPoolInterface newPool)
		{
			CurrentPool = newPool;
			CurrentPool.Initialize();
			MonoBehaviourSingleton<Progression>.Instance.ProgressionType = CurrentPool.GetProgressionType();
			if (WeaponPoolChanged != null)
			{
				WeaponPoolChanged();
			}
			if (SettingsChanged != null)
			{
				SettingsChanged();
			}
		}
	}
	public class KillsPerWeaponOption : MonoBehaviour
	{
		public Action OptionChanged;

		public int DefaultCount;

		public static int KillsPerWeaponCount;

		public static string Description;

		[SerializeField]
		private Text _counterText;

		[SerializeField]
		private Text _descriptionText;

		private void Awake()
		{
			OptionChanged = (Action)Delegate.Combine(OptionChanged, new Action(UpdateUI));
			GameSettings.WeaponPoolChanged = (Action)Delegate.Combine(GameSettings.WeaponPoolChanged, new Action(ResetClicked));
		}

		private void Start()
		{
			ResetClicked();
		}

		public void ArrowLeftClicked()
		{
			KillsPerWeaponCount--;
			KillProgressionType progressionType = MonoBehaviourSingleton<Progression>.Instance.ProgressionType;
			if (KillsPerWeaponCount <= 1 && progressionType != KillProgressionType.Tiers)
			{
				KillsPerWeaponCount = 1;
			}
			else if (KillsPerWeaponCount <= 0)
			{
				KillsPerWeaponCount = 0;
			}
			if (OptionChanged != null)
			{
				OptionChanged();
			}
		}

		public void ArrowRightClicked()
		{
			KillsPerWeaponCount++;
			if (OptionChanged != null)
			{
				OptionChanged();
			}
		}

		public void ResetClicked()
		{
			UIData progressionTypeUIDefaults = MonoBehaviourSingleton<Progression>.Instance.GetProgressionTypeUIDefaults();
			KillsPerWeaponCount = progressionTypeUIDefaults.Value;
			Description = progressionTypeUIDefaults.Text;
			if (OptionChanged != null)
			{
				OptionChanged();
			}
		}

		private void UpdateUI()
		{
			_counterText.text = KillsPerWeaponCount.ToString();
			_descriptionText.text = Description;
		}

		private void OnDestroy()
		{
			OptionChanged = (Action)Delegate.Remove(OptionChanged, new Action(UpdateUI));
			GameSettings.WeaponPoolChanged = (Action)Delegate.Remove(GameSettings.WeaponPoolChanged, new Action(ResetClicked));
		}
	}
	public class LeftHandOption : MonoBehaviour
	{
		public Action OptionChanged;

		public static bool LeftHandModeEnabled;

		[SerializeField]
		private Image EnabledImage;

		private void Awake()
		{
			OptionChanged = (Action)Delegate.Combine(OptionChanged, new Action(UpdateUI));
			LeftHandModeEnabled = false;
			((Behaviour)EnabledImage).enabled = false;
		}

		public void ToggleClicked()
		{
			LeftHandModeEnabled = !LeftHandModeEnabled;
			if (OptionChanged != null)
			{
				OptionChanged();
			}
		}

		private void UpdateUI()
		{
			((Behaviour)EnabledImage).enabled = LeftHandModeEnabled;
		}

		private void OnDestroy()
		{
			OptionChanged = (Action)Delegate.Remove(OptionChanged, new Action(UpdateUI));
		}
	}
	public class MusicToggleOption : MonoBehaviour
	{
		public Action OptionChanged;

		public static bool MusicEnabled;

		public AudioSource MusicAudioSource;

		public bool MusicEnabledAtStart = false;

		[SerializeField]
		private Image EnabledImage;

		private void Awake()
		{
			OptionChanged = (Action)Delegate.Combine(OptionChanged, new Action(OnToggleMusic));
			MusicEnabled = MusicEnabledAtStart;
			((Behaviour)EnabledImage).enabled = MusicEnabled;
			OnToggleMusic();
		}

		public void ToggleClicked()
		{
			MusicEnabled = !MusicEnabled;
			if (OptionChanged != null)
			{
				OptionChanged();
			}
		}

		private void OnToggleMusic()
		{
			if (MusicEnabled)
			{
				MusicAudioSource.Play();
			}
			else
			{
				MusicAudioSource.Stop();
			}
			((Behaviour)EnabledImage).enabled = MusicEnabled;
		}

		private void OnDestroy()
		{
			OptionChanged = (Action)Delegate.Remove(OptionChanged, new Action(OnToggleMusic));
		}
	}
	public class QuickbeltOption : MonoBehaviour
	{
		public static FVRQuickBeltSlot AmmoQuickbeltSlot;

		public static FVRQuickBeltSlot ExtraQuickbeltSlot;

		private FVRPhysicalObject MagObject;

		private FVRPhysicalObject ExtraObject;

		public Transform MagSpawnPos;

		private string _magName = "MagazineStanag5rnd";

		private string _extraName = "ReflexGamepointRDS";

		private void Awake()
		{
			GameManager.BeforeGameStartedEvent = (Action)Delegate.Combine(GameManager.BeforeGameStartedEvent, new Action(OnGameStart));
		}

		private IEnumerator Start()
		{
			yield return (object)new WaitForSeconds(0.2f);
			SpawnMag();
			SpawnExtra();
		}

		private void OnGameStart()
		{
			AmmoQuickbeltSlot = GM.CurrentPlayerBody.QBSlots_Internal[0];
			ExtraQuickbeltSlot = GM.CurrentPlayerBody.QBSlots_Internal[1];
			if (Object.op_Implicit((Object)(object)MagObject.QuickbeltSlot))
			{
				Debug.Log((object)"Found mag slot item");
				AmmoQuickbeltSlot = MagObject.QuickbeltSlot;
			}
			else if ((Object)(object)ExtraObject.QuickbeltSlot == (Object)(object)GM.CurrentPlayerBody.QBSlots_Internal[0])
			{
				Debug.Log((object)"Default mag slot");
				AmmoQuickbeltSlot = GM.CurrentPlayerBody.QBSlots_Internal[1];
			}
			if (Object.op_Implicit((Object)(object)ExtraObject.QuickbeltSlot))
			{
				Debug.Log((object)"Found extra slot item");
				ExtraQuickbeltSlot = ExtraObject.QuickbeltSlot;
			}
			else if ((Object)(object)MagObject.QuickbeltSlot == (Object)(object)GM.CurrentPlayerBody.QBSlots_Internal[1])
			{
				Debug.Log((object)"Default extra slot");
				ExtraQuickbeltSlot = GM.CurrentPlayerBody.QBSlots_Internal[0];
			}
			if (Object.op_Implicit((Object)(object)AmmoQuickbeltSlot.CurObject))
			{
				AmmoQuickbeltSlot.CurObject.ClearQuickbeltState();
			}
			if (Object.op_Implicit((Object)(object)ExtraQuickbeltSlot.CurObject))
			{
				ExtraQuickbeltSlot.CurObject.ClearQuickbeltState();
			}
		}

		private void SpawnMag()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			FVRObject value = null;
			if (!IM.OD.TryGetValue(_magName, out value))
			{
				Debug.LogError((object)("No object found with id: " + _magName));
				return;
			}
			GameObject gameObject = ((AnvilAsset)value).GetGameObject();
			Vector3 position = ((Component)MagSpawnPos).transform.position;
			position.z -= 0.2f;
			GameObject val = Object.Instantiate<GameObject>(gameObject, position, ((Component)this).transform.rotation);
			val.SetActive(true);
			MagObject = val.GetComponent<FVRPhysicalObject>();
		}

		private void SpawnExtra()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			FVRObject value = null;
			if (!IM.OD.TryGetValue(_extraName, out value))
			{
				Debug.LogError((object)("No object found with id: " + _extraName));
				return;
			}
			GameObject gameObject = ((AnvilAsset)value).GetGameObject();
			Vector3 position = ((Component)MagSpawnPos).transform.position;
			position.z += 0.2f;
			GameObject val = Object.Instantiate<GameObject>(gameObject, position, ((Component)this).transform.rotation);
			val.SetActive(true);
			ExtraObject = val.GetComponent<FVRPhysicalObject>();
		}

		private void OnDestroy()
		{
			GameManager.BeforeGameStartedEvent = (Action)Delegate.Remove(GameManager.BeforeGameStartedEvent, new Action(OnGameStart));
		}
	}
	public class SelectedPoolUI : MonoBehaviour
	{
		public Text TitleText;

		public Text DescriptionText;

		private void Awake()
		{
			GameSettings.SettingsChanged = (Action)Delegate.Combine(GameSettings.SettingsChanged, new Action(OnSettingsChanged));
		}

		private void OnSettingsChanged()
		{
			TitleText.text = GameSettings.CurrentPool.GetName();
			DescriptionText.text = GameSettings.CurrentPool.GetDescription();
		}

		private void OnDestroy()
		{
			GameSettings.SettingsChanged = (Action)Delegate.Remove(GameSettings.SettingsChanged, new Action(OnSettingsChanged));
		}
	}
	public class StartingHealthOption : MonoBehaviour
	{
		public Action OptionChanged;

		public int[] PossibleHealth;

		private int _optionIndex = 1;

		public static int CurrentHealth = 1000;

		[SerializeField]
		private Text _healthText;

		private void Awake()
		{
			PossibleHealth = new int[5] { 100, 1000, 2000, 5000, 10000 };
			OptionChanged = (Action)Delegate.Combine(OptionChanged, new Action(UpdateUI));
			OptionChanged = (Action)Delegate.Combine(OptionChanged, new Action(UpdateHealth));
		}

		private IEnumerator Start()
		{
			yield return (object)new WaitForSeconds(0.1f);
			ResetClicked();
		}

		public void ArrowLeftClicked()
		{
			_optionIndex--;
			if (_optionIndex < 0)
			{
				_optionIndex = 0;
			}
			CurrentHealth = PossibleHealth[_optionIndex];
			if (OptionChanged != null)
			{
				OptionChanged();
			}
		}

		public void ArrowRightClicked()
		{
			_optionIndex++;
			if (_optionIndex >= PossibleHealth.Length)
			{
				_optionIndex = PossibleHealth.Length - 1;
			}
			CurrentHealth = PossibleHealth[_optionIndex];
			if (OptionChanged != null)
			{
				OptionChanged();
			}
		}

		public void ResetClicked()
		{
			_optionIndex = 1;
			CurrentHealth = PossibleHealth[_optionIndex];
			if (OptionChanged != null)
			{
				OptionChanged();
			}
		}

		private void UpdateHealth()
		{
			GM.CurrentPlayerBody.SetHealthThreshold((float)CurrentHealth);
			GM.CurrentPlayerBody.ResetHealth();
		}

		private void UpdateUI()
		{
			_healthText.text = CurrentHealth.ToString();
		}

		private void OnDestroy()
		{
			OptionChanged = (Action)Delegate.Remove(OptionChanged, new Action(UpdateUI));
			OptionChanged = (Action)Delegate.Remove(OptionChanged, new Action(UpdateHealth));
		}
	}
	public class WeaponCountOption : MonoBehaviour
	{
		public Action OptionChanged;

		public static int WeaponCount;

		[SerializeField]
		private Text _counterText;

		private void Awake()
		{
			OptionChanged = (Action)Delegate.Combine(OptionChanged, new Action(UpdateUI));
			GameSettings.WeaponPoolChanged = (Action)Delegate.Combine(GameSettings.WeaponPoolChanged, new Action(ResetClicked));
		}

		public void ArrowLeftClicked()
		{
			WeaponCount--;
			if (WeaponCount <= 1)
			{
				WeaponCount = 1;
			}
			if (OptionChanged != null)
			{
				OptionChanged();
			}
		}

		public void ArrowRightClicked()
		{
			WeaponCount++;
			if (WeaponCount > GameSettings.CurrentPool.GetWeaponCount())
			{
				WeaponCount = GameSettings.CurrentPool.GetWeaponCount();
			}
			if (OptionChanged != null)
			{
				OptionChanged();
			}
		}

		public void ArrowRight10Clicked()
		{
			WeaponCount += 20;
			if (WeaponCount > GameSettings.CurrentPool.GetWeaponCount())
			{
				WeaponCount = GameSettings.CurrentPool.GetWeaponCount();
			}
			if (OptionChanged != null)
			{
				OptionChanged();
			}
		}

		public void ArrowLeft10Clicked()
		{
			WeaponCount -= 20;
			if (WeaponCount <= 1)
			{
				WeaponCount = 1;
			}
			if (OptionChanged != null)
			{
				OptionChanged();
			}
		}

		public void ResetClicked()
		{
			WeaponCount = GameSettings.CurrentPool.GetWeaponCount();
			if (OptionChanged != null)
			{
				OptionChanged();
			}
		}

		private void UpdateUI()
		{
			_counterText.text = WeaponCount.ToString();
		}

		private void OnDestroy()
		{
			OptionChanged = (Action)Delegate.Remove(OptionChanged, new Action(UpdateUI));
			GameSettings.WeaponPoolChanged = (Action)Delegate.Remove(GameSettings.WeaponPoolChanged, new Action(ResetClicked));
		}
	}
}
public class Pause : MonoBehaviour
{
	[SerializeField]
	private Transform PauseWaypoint;

	[SerializeField]
	private Transform UnPauseWaypoint;

	[SerializeField]
	private Text TimeText;

	[SerializeField]
	private Text KillsText;

	[SerializeField]
	private Text DeathsText;

	private float _pauseTimer;

	public void PauseTheGame()
	{
		//IL_000c: 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_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		GM.CurrentMovementManager.TeleportToPoint(PauseWaypoint.position, true, ((Component)this).transform.position + ((Component)this).transform.forward);
		KillsText.text = "Kills: " + MonoBehaviourSingleton<GameManager>.Instance.Kills;
		DeathsText.text = "Deaths: " + MonoBehaviourSingleton<GameManager>.Instance.Deaths;
		TimeSpan timeSpan = TimeSpan.FromSeconds(MonoBehaviourSingleton<GameManager>.Instance.GameTime);
		TimeText.text = "Time: " + timeSpan.Hours.ToString("00") + ":" + timeSpan.Minutes.ToString("00") + ":" + timeSpan.Seconds.ToString("00");
		_pauseTimer = Time.time;
	}

	public void UnpauseTheGame()
	{
		//IL_000c: 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_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		GM.CurrentMovementManager.TeleportToPoint(UnPauseWaypoint.position, true, ((Component)this).transform.position + ((Component)this).transform.forward);
		float timePaused = Time.time - _pauseTimer;
		MonoBehaviourSingleton<GameManager>.Instance.RemovePausedTime(timePaused);
	}
}
public class PlayerFollower : MonoBehaviour
{
	private bool _isActive;

	private Transform _transform;

	private Transform _playerHeadTransform;

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

	private IEnumerator Start()
	{
		yield return (object)new WaitForSeconds(0.1f);
		_playerHeadTransform = ((Component)GM.CurrentPlayerBody.Head).transform;
		_isActive = true;
	}

	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_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_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		if (_isActive)
		{
			_transform.position = _playerHeadTransform.position;
			Quaternion rotation = _playerHeadTransform.rotation;
			float y = ((Quaternion)(ref rotation)).eulerAngles.y;
			Quaternion rotation2 = _transform.rotation;
			Vector3 eulerAngles = ((Quaternion)(ref rotation2)).eulerAngles;
			eulerAngles.y = y;
			_transform.rotation = Quaternion.Euler(eulerAngles);
		}
	}
}
namespace GunGame.Scripts
{
	public class PlayerSpawner : MonoBehaviourSingleton<PlayerSpawner>
	{
		public static Action BeingRevivedEvent;

		public Progression Progression;

		private IEnumerator Start()
		{
			yield return null;
			GM.CurrentSceneSettings.DeathResetPoint = ((Component)this).transform;
			GM.CurrentMovementManager.TeleportToPoint(((Component)this).transform.position, true, ((Component)this).transform.position + ((Component)this).transform.forward);
		}

		private IEnumerator DelayedRespawn()
		{
			MonoBehaviourSingleton<GameManager>.Instance.Deaths++;
			MonoBehaviourSingleton<Progression>.Instance.KillsWithCurrentWeapon = 0;
			MonoBehaviourSingleton<Progression>.Instance.CurrentTier = 0;
			yield return (object)new WaitForSeconds(3f);
			if (MonoBehaviourSingleton<Progression>.Instance.ProgressionType == KillProgressionType.Tiers || GameSettings.AlwaysResetSosigs)
			{
				((MonoBehaviour)this).StartCoroutine(MonoBehaviourSingleton<SosigBehavior>.Instance.ClearSosigs());
			}
			MonoBehaviourSingleton<Progression>.Instance.Demote();
			GM.CurrentPlayerBody.ActivatePower((PowerupType)3, (PowerUpIntensity)0, (PowerUpDuration)2, false, false, -1f);
			GM.CurrentPlayerBody.HealPercent(100f);
			MovePlayerToRandomSpawn();
			if (BeingRevivedEvent != null)
			{
				BeingRevivedEvent();
			}
		}

		[HarmonyPatch(typeof(GM), "KillPlayer", new Type[] { typeof(bool) })]
		[HarmonyPostfix]
		private static void Postfix(bool KilledSelf)
		{
			MonoBehaviourSingleton<PlayerSpawner>.Instance.OnPlayerDeath();
		}

		private void OnPlayerDeath()
		{
			((MonoBehaviour)this).StartCoroutine(DelayedRespawn());
		}

		public void MovePlayerToRandomSpawn()
		{
			//IL_002d: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			int index = Random.Range(0, MonoBehaviourSingleton<GameManager>.Instance.PlayerSpawners.Count);
			((Component)this).transform.position = MonoBehaviourSingleton<GameManager>.Instance.PlayerSpawners[index].position;
			GM.CurrentMovementManager.TeleportToPoint(((Component)this).transform.position, true, ((Component)this).transform.position + ((Component)this).transform.forward);
		}

		private void OnDrawGizmos()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			Gizmos.color = new Color(0.2f, 0.8f, 0.2f, 0.5f);
			Gizmos.DrawSphere(((Component)this).transform.position, 0.1f);
			Gizmos.DrawLine(((Component)this).transform.position, ((Component)this).transform.position + ((Component)this).transform.forward * 0.25f);
		}
	}
	public class Progression : MonoBehaviourSingleton<Progression>
	{
		public static Action SosigDespawnedEvent;

		public static Action WeaponChangedEvent;

		public AudioSource EquipSound;

		[HideInInspector]
		public int KillsWithCurrentWeapon = 0;

		public static List<int> DeadSosigs = new List<int>();

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

		private WeaponBuffer _weaponBuffer;

		[HideInInspector]
		public KillProgressionType ProgressionType = KillProgressionType.Count;

		[HideInInspector]
		private List<EnemyData> Enemies = new List<EnemyData>();

		[HideInInspector]
		public int CurrentTier = 0;

		[HideInInspector]
		private int ProbabilityTotal = 0;

		[HideInInspector]
		private int InverseProbabilityTotal = 0;

		public int CurrentWeaponId { get; private set; }

		public override void Awake()
		{
			base.Awake();
			_weaponBuffer = ((Component)this).GetComponent<WeaponBuffer>();
		}

		public void Demote()
		{
			if (!MonoBehaviourSingleton<GameManager>.Instance.GameEnded)
			{
				CurrentWeaponId--;
				if (CurrentWeaponId < 0)
				{
					CurrentWeaponId = 0;
				}
				SpawnAndEquip(demotion: true);
			}
		}

		public void Promote()
		{
			if (!MonoBehaviourSingleton<GameManager>.Instance.GameEnded)
			{
				if (GameSettings.HealOnPromotion)
				{
					GM.CurrentPlayerBody.HealPercent(100f);
				}
				CurrentWeaponId++;
				KillsWithCurrentWeapon = 0;
				if (CurrentWeaponId >= GameSettings.CurrentPool.GetWeaponCount() || CurrentWeaponId >= WeaponCountOption.WeaponCount)
				{
					CurrentWeaponId = GameSettings.CurrentPool.GetWeaponCount() - 1;
					MonoBehaviourSingleton<GameManager>.Instance.EndGame();
				}
				else
				{
					EquipSound.Play();
					SpawnAndEquip();
				}
			}
		}

		public void SpawnAndEquip(bool demotion = false)
		{
			DestroyOldEq();
			if (((Component)MonoBehaviourSingleton<CustomDebug>.Instance.DebugWeaponText).gameObject.activeInHierarchy)
			{
				MonoBehaviourSingleton<CustomDebug>.Instance.DebugWeaponText.text = "Weapon " + GameSettings.CurrentPool.GetWeapon(CurrentWeaponId).GunName;
				MonoBehaviourSingleton<CustomDebug>.Instance.DebugAmmoText.text = "Ammo " + GameSettings.CurrentPool.GetWeapon(CurrentWeaponId).MagName;
			}
			FVRPhysicalObject fromBuffer = _weaponBuffer.GetFromBuffer(ObjectType.Gun, CurrentWeaponId, demotion);
			if ((Object)(object)fromBuffer == (Object)null)
			{
				Debug.LogError((object)"Trying to equip null gun! Probably the ObjectId is invalid. Attempting a fix by promoting the player");
				Promote();
				return;
			}
			_currentEquipment.Add(((Component)fromBuffer).gameObject);
			if (Utility.IsNullOrWhiteSpace(GameSettings.CurrentPool.GetWeapon(CurrentWeaponId).MagName))
			{
				EquipWeapon(fromBuffer);
				_weaponBuffer.DestroyMagBuffer();
			}
			else
			{
				FVRPhysicalObject fromBuffer2 = _weaponBuffer.GetFromBuffer(ObjectType.MagazineToLoad, CurrentWeaponId, demotion);
				if ((Object)(object)fromBuffer2 == (Object)null)
				{
					Debug.LogError((object)"Trying to equip null magazine! Probably the ObjectId is invalid. Attempting a fix by promoting the player");
					Promote();
					return;
				}
				fromBuffer2.UsesGravity = false;
				fromBuffer2.RootRigidbody.isKinematic = true;
				FVRPhysicalObject fromBuffer3 = _weaponBuffer.GetFromBuffer(ObjectType.MagazineForQuickbelt, CurrentWeaponId, demotion);
				_currentEquipment.Add(((Component)fromBuffer2).gameObject);
				_currentEquipment.Add(((Component)fromBuffer3).gameObject);
				if (!GameSettings.DisabledAutoLoading)
				{
					LoadTheGun(fromBuffer, fromBuffer2);
				}
				EquipWeapon(fromBuffer);
				FixAmmoRotation();
				MoveMagazineToSlot(fromBuffer3);
			}
			if (!Utility.IsNullOrWhiteSpace(GameSettings.CurrentPool.GetWeapon(CurrentWeaponId).Extra))
			{
				FVRPhysicalObject fromBuffer4 = _weaponBuffer.GetFromBuffer(ObjectType.Extra, CurrentWeaponId, demotion);
				_currentEquipment.Add(((Component)fromBuffer4).gameObject);
				MoveExtraToSlot(fromBuffer4);
			}
			_weaponBuffer.ClearBuffer();
			_weaponBuffer.GenerateBuffer(CurrentWeaponId);
			if (WeaponChangedEvent != null)
			{
				WeaponChangedEvent();
			}
		}

		private void DestroyOldEq()
		{
			for (int i = 0; i < _currentEquipment.Count; i++)
			{
				if (Object.op_Implicit((Object)(object)_currentEquipment[i]) && Object.op_Implicit((Object)(object)_currentEquipment[i].GetComponent<FVRPhysicalObject>()))
				{
					((FVRInteractiveObject)_currentEquipment[i].GetComponent<FVRPhysicalObject>()).ForceBreakInteraction();
				}
				Object.Destroy((Object)(object)_currentEquipment[i]);
			}
			_currentEquipment.Clear();
		}

		private void MoveMagazineToSlot(FVRPhysicalObject magazine)
		{
			if (Object.op_Implicit((Object)(object)QuickbeltOption.AmmoQuickbeltSlot.CurObject))
			{
				QuickbeltOption.AmmoQuickbeltSlot.CurObject.ClearQuickbeltState();
			}
			magazine.ForceObjectIntoInventorySlot(QuickbeltOption.AmmoQuickbeltSlot);
			magazine.m_isSpawnLock = true;
		}

		private void MoveExtraToSlot(FVRPhysicalObject extra)
		{
			if (Object.op_Implicit((Object)(object)QuickbeltOption.ExtraQuickbeltSlot.CurObject))
			{
				QuickbeltOption.ExtraQuickbeltSlot.CurObject.ClearQuickbeltState();
			}
			extra.ForceObjectIntoInventorySlot(QuickbeltOption.ExtraQuickbeltSlot);
		}

		private void LoadTheGun(FVRPhysicalObject weapon, FVRPhysicalObject ammo)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((ammo is FVRFireArmMagazine) ? ammo : null) != (Object)null)
			{
				try
				{
					((FVRFireArmMagazine)ammo).Load((FVRFireArm)(object)((weapon is FVRFireArm) ? weapon : null));
				}
				catch (Exception)
				{
					Debug.LogWarning((object)("Weapon failed to load magazine for gun " + weapon.ObjectWrapper.DisplayName + " with magazine " + ammo.ObjectWrapper.DisplayName));
				}
			}
			else if (Object.op_Implicit((Object)(object)((Component)weapon).GetComponentInChildren<RevolverCylinder>()) && (Object)(object)((ammo is Speedloader) ? ammo : null) != (Object)null)
			{
				((Component)weapon).GetComponentInChildren<RevolverCylinder>().LoadFromSpeedLoader((Speedloader)ammo);
			}
			else if (GameSettings.AlwaysChamberRounds || ((Object)(object)((ammo is FVRFireArmMagazine) ? ammo : null) == (Object)null && (Object)(object)((Component)weapon).GetComponentInChildren<FVRFireArmMagazine>() == (Object)null && (Object)(object)((weapon is FVRFireArm) ? weapon : null) != (Object)null))
			{
				try
				{
					List<FVRFireArmChamber> chambers = ((Component)weapon).GetComponent<FVRFireArm>().GetChambers();
					foreach (FVRFireArmChamber item in chambers)
					{
						FVRFireArmRound component = ((Component)_weaponBuffer.SpawnImmediate(ObjectType.MagazineToLoad, GameSettings.CurrentPool.GetWeapon(CurrentWeaponId))).GetComponent<FVRFireArmRound>();
						item.SetRound(component, false);
					}
					BreakActionWeapon componentInChildren = ((Component)weapon).GetComponentInChildren<BreakActionWeapon>();
					if ((Object)(object)componentInChildren != (Object)null)
					{
						componentInChildren.CockAllHammers();
					}
				}
				catch (Exception)
				{
					Debug.LogWarning((object)("Error while trying to load gun chambers manually for a gun: " + ((Object)weapon).name + " and ammo: " + ((Object)ammo).name));
				}
			}
			FVRFireArmMagazine componentInChildren2 = ((Component)weapon).GetComponentInChildren<FVRFireArmMagazine>();
			if (Object.op_Implicit((Object)(object)componentInChildren2))
			{
				FireArmRoundClass @class = AM.SRoundDisplayDataDic[componentInChildren2.RoundType].Classes[0].Class;
				componentInChildren2.ReloadMagWithType(@class);
			}
		}

		public void FixAmmoRotation()
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)_currentEquipment[0]) && Object.op_Implicit((Object)(object)_currentEquipment[1]) && Object.op_Implicit((Object)(object)_currentEquipment[0].GetComponent<FVRFireArm>()) && Object.op_Implicit((Object)(object)_currentEquipment[0].GetComponent<FVRFireArm>().MagazineMountPos))
			{
				_currentEquipment[1].transform.rotation = ((Component)_currentEquipment[0].GetComponent<FVRFireArm>().MagazineMountPos).transform.rotation;
			}
		}

		private void EquipWeapon(FVRPhysicalObject weapon)
		{
			FVRViveHand val = GM.CurrentMovementManager.Hands[1];
			if (LeftHandOption.LeftHandModeEnabled)
			{
				val = GM.CurrentMovementManager.Hands[0];
			}
			val.RetrieveObject(weapon);
		}

		private static void OnSosigKilledByPlayer(Sosig killedSosig)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			MonoBehaviourSingleton<GameManager>.Instance.Kills++;
			SosigEnemyID val = MonoBehaviourSingleton<SosigBehavior>.Instance.Sosigs[killedSosig];
			if (MonoBehaviourSingleton<Progression>.Instance.ProgressionType == KillProgressionType.Points)
			{
				int num = 1;
				foreach (EnemyData enemy in MonoBehaviourSingleton<Progression>.Instance.Enemies)
				{
					if (enemy.EnemyName == val)
					{
						num = enemy.Value;
						break;
					}
				}
				MonoBehaviourSingleton<Progression>.Instance.KillsWithCurrentWeapon += num;
				if (MonoBehaviourSingleton<Progression>.Instance.KillsWithCurrentWeapon >= KillsPerWeaponOption.KillsPerWeaponCount)
				{
					MonoBehaviourSingleton<Progression>.Instance.Promote();
				}
			}
			else if (MonoBehaviourSingleton<Progression>.Instance.ProgressionType == KillProgressionType.Tiers)
			{
				int num2 = -1;
				int num3 = -1;
				foreach (EnemyData enemy2 in MonoBehaviourSingleton<Progression>.Instance.Enemies)
				{
					num3++;
					if (enemy2.EnemyName == val)
					{
						num2 = num3;
						break;
					}
				}
				if (num2 == -1)
				{
					MonoBehaviourSingleton<Progression>.Instance.KillsWithCurrentWeapon = 0;
					MonoBehaviourSingleton<Progression>.Instance.CurrentTier = 0;
					MonoBehaviourSingleton<Progression>.Instance.Promote();
				}
				else
				{
					if (num2 != MonoBehaviourSingleton<Progression>.Instance.CurrentTier)
					{
						return;
					}
					MonoBehaviourSingleton<Progression>.Instance.KillsWithCurrentWeapon++;
					if (MonoBehaviourSingleton<Progression>.Instance.KillsWithCurrentWeapon >= MonoBehaviourSingleton<Progression>.Instance.Enemies[MonoBehaviourSingleton<Progression>.Instance.CurrentTier].Value + KillsPerWeaponOption.KillsPerWeaponCount)
					{
						MonoBehaviourSingleton<Progression>.Instance.CurrentTier++;
						MonoBehaviourSingleton<Progression>.Instance.KillsWithCurrentWeapon = 0;
						if (MonoBehaviourSingleton<Progression>.Instance.CurrentTier == MonoBehaviourSingleton<Progression>.Instance.Enemies.Count)
						{
							MonoBehaviourSingleton<Progression>.Instance.CurrentTier = 0;
							MonoBehaviourSingleton<Progression>.Instance.Promote();
						}
					}
				}
			}
			else
			{
				MonoBehaviourSingleton<Progression>.Instance.KillsWithCurrentWeapon++;
				if (MonoBehaviourSingleton<Progression>.Instance.KillsWithCurrentWeapon >= KillsPerWeaponOption.KillsPerWeaponCount)
				{
					MonoBehaviourSingleton<Progression>.Instance.Promote();
				}
			}
		}

		[HarmonyPatch(typeof(Sosig), "SosigDies")]
		[HarmonyPostfix]
		private static void OnSosigDied(Sosig __instance, DamageClass damClass, SosigDeathType deathType)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			if (!DeadSosigs.Contains(((Object)__instance).GetInstanceID()))
			{
				DeadSosigs.Add(((Object)__instance).GetInstanceID());
				if (__instance.GetDiedFromIFF() == GM.CurrentPlayerBody.GetPlayerIFF())
				{
					OnSosigKilledByPlayer(__instance);
				}
				__instance.DeSpawnSosig();
				MonoBehaviourSingleton<SosigBehavior>.Instance.OnSosigKilled(__instance);
				SosigEnemyID nextSosigType = GetNextSosigType();
				MonoBehaviourSingleton<SosigBehavior>.Instance.SpawnSosigRandomPlace(nextSosigType);
			}
		}

		public void InitEnemyProgression()
		{
			ProbabilityTotal = 0;
			InverseProbabilityTotal = 0;
			ProgressionType = GameSettings.CurrentPool.GetProgressionType();
			Enemies = GameSettings.CurrentPool.GetEnemies();
			foreach (EnemyData enemy in MonoBehaviourSingleton<Progression>.Instance.Enemies)
			{
				if (enemy.Value == 0)
				{
					enemy.Value = 1;
				}
			}
			if (MonoBehaviourSingleton<Progression>.Instance.ProgressionType == KillProgressionType.Points)
			{
				foreach (EnemyData enemy2 in MonoBehaviourSingleton<Progression>.Instance.Enemies)
				{
					InverseProbabilityTotal += Math.Max(1, (int)(1f / (float)enemy2.Value * 100f));
				}
			}
			foreach (EnemyData enemy3 in MonoBehaviourSingleton<Progression>.Instance.Enemies)
			{
				ProbabilityTotal += enemy3.Value;
			}
		}

		public static SosigEnemyID GetNextSosigType()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: 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_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			if (MonoBehaviourSingleton<Progression>.Instance.Enemies.Count == 0)
			{
				Debug.Log((object)"No enemies loaded, make sure that your weaponpool is formatted correctly!");
				return (SosigEnemyID)1200;
			}
			if (MonoBehaviourSingleton<Progression>.Instance.ProgressionType == KillProgressionType.Count)
			{
				if (MonoBehaviourSingleton<Progression>.Instance.ProbabilityTotal == 0)
				{
					Debug.Log((object)"All probabilities set to 0!");
					return MonoBehaviourSingleton<Progression>.Instance.Enemies[Random.Range(0, MonoBehaviourSingleton<Progression>.Instance.Enemies.Count - 1)].EnemyName;
				}
				int num = Random.Range(0, MonoBehaviourSingleton<Progression>.Instance.ProbabilityTotal);
				int num2 = 0;
				foreach (EnemyData enemy in MonoBehaviourSingleton<Progression>.Instance.Enemies)
				{
					num2 += enemy.Value;
					if (num < num2)
					{
						return enemy.EnemyName;
					}
				}
				Debug.Log((object)"Default enemy selected");
				return MonoBehaviourSingleton<Progression>.Instance.Enemies[MonoBehaviourSingleton<Progression>.Instance.Enemies.Count - 1].EnemyName;
			}
			if (MonoBehaviourSingleton<Progression>.Instance.ProgressionType == KillProgressionType.Points)
			{
				if (MonoBehaviourSingleton<Progression>.Instance.ProbabilityTotal == 0)
				{
					Debug.Log((object)"All probabilities set to 0!");
					return MonoBehaviourSingleton<Progression>.Instance.Enemies[Random.Range(0, MonoBehaviourSingleton<Progression>.Instance.Enemies.Count - 1)].EnemyName;
				}
				int num3 = Random.Range(0, MonoBehaviourSingleton<Progression>.Instance.InverseProbabilityTotal);
				int num4 = 0;
				foreach (EnemyData enemy2 in MonoBehaviourSingleton<Progression>.Instance.Enemies)
				{
					num4 += Math.Max(1, (int)(1f / (float)enemy2.Value * 100f));
					if (num3 < num4)
					{
						return enemy2.EnemyName;
					}
				}
				Debug.Log((object)"Default enemy selection");
				return MonoBehaviourSingleton<Progression>.Instance.Enemies[MonoBehaviourSingleton<Progression>.Instance.Enemies.Count - 1].EnemyName;
			}
			if (MonoBehaviourSingleton<Progression>.Instance.ProgressionType == KillProgressionType.Tiers)
			{
				return MonoBehaviourSingleton<Progression>.Instance.Enemies[MonoBehaviourSingleton<Progression>.Instance.CurrentTier].EnemyName;
			}
			Debug.Log((object)"Progression type isn't handled correctly somehow, check that your weaponpool file is formatted correctly!");
			return (SosigEnemyID)1210;
		}

		public UIData GetProgressionTypeUIDefaults()
		{
			UIData result = default(UIData);
			switch (GameSettings.CurrentPool.GetProgressionType())
			{
			case KillProgressionType.Points:
			{
				result.Text = "Points to advance";
				int num = 0;
				foreach (EnemyData enemy in GameSettings.CurrentPool.GetEnemies())
				{
					num += enemy.Value;
				}
				result.Value = num;
				break;
			}
			case KillProgressionType.Tiers:
				result.Text = "Extra kills per tier";
				result.Value = 0;
				break;
			default:
				result.Text = "Kills to advance";
				result.Value = 3;
				break;
			}
			return result;
		}
	}
	public enum KillProgressionType
	{
		Count,
		Points,
		Tiers
	}
	public struct UIData
	{
		public string Text;

		public int Value;
	}
	public class SosigBehavior : MonoBehaviourSingleton<SosigBehavior>
	{
		public int MaxSosigCount = 8;

		[HideInInspector]
		public int RealSosigCount;

		[Header("Don't spawn sosigs too close or too far from the player")]
		public int IgnoredSpawnersCloseToPlayer = 2;

		public int IgnoredSpawnersFarFromPlayer = 0;

		public bool DespawnDistantSosigs = false;

		public float MaxSosigDistanceFromPlayer = 0f;

		public float HearRangeMultiplier = 1f;

		public float SightRangeMultiplier = 1f;

		public List<Transform> Waypoints;

		public List<CustomSosigSpawner> SosigSpawners;

		[HideInInspector]
		public Dictionary<Sosig, SosigEnemyID> Sosigs;

		public override void Awake()
		{
			base.Awake();
			Sosigs = new Dictionary<Sosig, SosigEnemyID>();
			GameManager.GameStartedEvent = (Action)Delegate.Combine(GameManager.GameStartedEvent, new Action(OnGameStarted));
		}

		private void OnGameStarted()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			MonoBehaviourSingleton<Progression>.Instance.InitEnemyProgression();
			RealSosigCount = GameSettings.MaxSosigCount;
			for (int i = 0; i < RealSosigCount; i++)
			{
				SpawnSosigRandomPlace(Progression.GetNextSosigType());
			}
			((MonoBehaviour)this).StartCoroutine(UpdateWaypoints());
		}

		[HarmonyPatch(typeof(Sosig), "Start")]
		[HarmonyPostfix]
		private static void SosigSpawned(Sosig __instance)
		{
			__instance.CanBeKnockedOut = false;
			__instance.m_maxUnconsciousTime = 0f;
			__instance.BleedRateMult = 0.1f;
			for (int i = 0; i < __instance.Links.Count; i++)
			{
				__instance.Links[i].SetIntegrity(__instance.Links[i].m_integrity * 0.65f);
			}
			__instance.Links[0].DamMult = 13.5f;
			__instance.Links[1].DamMult = 6f;
			__instance.Links[2].DamMult = 5f;
			__instance.Links[3].DamMult = 4f;
			__instance.MaxHearingRange *= MonoBehaviourSingleton<SosigBehavior>.Instance.HearRangeMultiplier;
			__instance.MaxSightRange *= MonoBehaviourSingleton<SosigBehavior>.Instance.SightRangeMultiplier;
			if (MonoBehaviourSingleton<SosigBehavior>.Instance.DespawnDistantSosigs)
			{
				((MonoBehaviour)MonoBehaviourSingleton<SosigBehavior>.Instance).StartCoroutine(MonoBehaviourSingleton<SosigBehavior>.Instance.CheckSosigDistance(__instance));
			}
		}

		private IEnumerator UpdateWaypoints()
		{
			while (true)
			{
				for (int i = 0; i < Sosigs.Count; i++)
				{
					if (i >= 0 && i < Sosigs.Count)
					{
						Sosig key = Sosigs.ElementAt(i).Key;
						if (!((Object)(object)key == (Object)null))
						{
							key.SetCurrentOrder((SosigOrder)7);
							key.CommandAssaultPoint(Waypoints[Random.Range(0, Waypoints.Count)].position);
						}
					}
				}
				yield return (object)new WaitForSeconds((float)Random.Range(12, 25));
			}
		}

		private IEnumerator CheckSosigDistance(Sosig sosig)
		{
			WaitForSeconds delay = new WaitForSeconds(6f);
			while ((Object)(object)sosig != (Object)null)
			{
				yield return delay;
				if (Vector3.Distance(((Component)GM.CurrentPlayerBody).transform.position, ((Component)sosig).transform.position) > MaxSosigDistanceFromPlayer)
				{
					if (!Progression.DeadSosigs.Contains(((Object)sosig).GetInstanceID()))
					{
						SosigEnemyID sosigtype = Sosigs[sosig];
						Sosigs.Remove(sosig);
						sosig.DeSpawnSosig();
						MonoBehaviourSingleton<SosigBehavior>.Instance.SpawnSosigRandomPlace(sosigtype);
					}
					break;
				}
			}
		}

		public void SpawnSosigRandomPlace(SosigEnemyID sosigtype)
		{
			//IL_0095: 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)
			List<CustomSosigSpawner> list = SosigSpawners.OrderBy((CustomSosigSpawner spawner) => Vector3.Distance(((Component)spawner).transform.position, ((Component)GM.CurrentPlayerBody).transform.position)).ToList();
			if (IgnoredSpawnersCloseToPlayer > list.Count || IgnoredSpawnersFarFromPlayer > list.Count || IgnoredSpawnersCloseToPlayer + IgnoredSpawnersFarFromPlayer > list.Count)
			{
				Debug.LogError((object)"Ignoring more spawners than available, aborting");
			}
			int index = Random.Range(IgnoredSpawnersCloseToPlayer, list.Count - IgnoredSpawnersFarFromPlayer);
			SpawnedSosigInfo spawnedSosigInfo = list[index].Spawn(sosigtype);
			Sosigs.Add(spawnedSosigInfo.SpawnedSosig, spawnedSosigInfo.SosigType);
		}

		public void OnSosigKilled(Sosig sosig)
		{
			Sosigs.Remove(sosig);
		}

		public IEnumerator ClearSosigs()
		{
			List<Sosig> TempSosigsList = new List<Sosig>();
			foreach (Sosig key in Sosigs.Keys)
			{
				TempSosigsList.Add(key);
			}
			foreach (Sosig sosig in TempSosigsList)
			{
				Sosigs.Remove(sosig);
				sosig.DeSpawnSosig();
				SosigEnemyID sosigType = Progression.GetNextSosigType();
				yield return (object)new WaitForSeconds(1f);
				MonoBehaviourSingleton<SosigBehavior>.Instance.SpawnSosigRandomPlace(sosigType);
			}
		}

		private void OnDestroy()
		{
			GameManager.GameStartedEvent = (Action)Delegate.Remove(GameManager.GameStartedEvent, new Action(OnGameStarted));
		}
	}
}
namespace GunGame.Scripts.Weapons
{
	[Serializable]
	public class EnemyData
	{
		public SosigEnemyID EnemyName = (SosigEnemyID)1;

		public string EnemyNameString = "";

		public int Value = 0;

		public EnemyData(SosigEnemyID InputEnum, int InputValue)
		{
			//IL_0002: 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)
			EnemyName = InputEnum;
			Value = InputValue;
		}

		public EnemyData(string InputNameString, int InputValue)
		{
			//IL_0002: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			EnemyName = StringToSosigID(InputNameString);
			Value = InputValue;
		}

		private SosigEnemyID StringToSosigID(string InputString)
		{
			//IL_0032: 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_0039: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				return (SosigEnemyID)Enum.Parse(typeof(SosigEnemyID), InputString, ignoreCase: true);
			}
			catch (Exception)
			{
				Debug.LogError((object)(InputString + " is not a valid SosigEnemyID, please check your weapon pool format"));
				return (SosigEnemyID)1;
			}
		}
	}
	[Serializable]
	public class GunData
	{
		public string GunName;

		public string MagName;

		public List<string> MagNames;

		public string Extra;

		public int CategoryID;

		public override string ToString()
		{
			return "Name: " + GunName + ", MagName: " + MagName + ", Extra: " + Extra;
		}
	}
	public class PoolChoice : MonoBehaviour
	{
		public Text TitleText;

		public Button Button;

		private WeaponPoolInterface _weaponPool;

		public void Initialize(WeaponPoolInterface weaponPool)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			_weaponPool = weaponPool;
			TitleText.text = _weaponPool.GetName();
			((UnityEvent)Button.onClick).AddListener(new UnityAction(OnClick));
		}

		public void OnClick()
		{
			GameSettings.ChangeCurrentPool(_weaponPool);
		}
	}
	public class WeaponBuffer : MonoBehaviour
	{
		public Transform BufferSpawnPos;

		private FVRPhysicalObject _gun;

		private FVRPhysicalObject _magazineToLoad;

		private FVRPhysicalObject _magazineForQuickbelt;

		private FVRPhysicalObject GetBufferObject(ObjectType type)
		{
			return (FVRPhysicalObject)(type switch
			{
				ObjectType.Gun => _gun, 
				ObjectType.MagazineToLoad => _magazineToLoad, 
				ObjectType.MagazineForQuickbelt => _magazineForQuickbelt, 
				_ => null, 
			});
		}

		public FVRPhysicalObject GetFromBuffer(ObjectType type, int index, bool demoted)
		{
			FVRPhysicalObject bufferObject = GetBufferObject(type);
			if (demoted)
			{
				if (Object.op_Implicit((Object)(object)bufferObject))
				{
					Object.Destroy((Object)(object)((Component)bufferObject).gameObject);
				}
				return SpawnImmediate(type, GameSettings.CurrentPool.GetWeapon(index));
			}
			FVRPhysicalObject val = bufferObject;
			if ((Object)(object)val == (Object)null)
			{
				val = SpawnImmediate(type, GameSettings.CurrentPool.GetWeapon(index));
			}
			return val;
		}

		public void ClearBuffer()
		{
			_gun = null;
			_magazineToLoad = null;
			_magazineForQuickbelt = null;
		}

		public void DestroyMagBuffer()
		{
			if (Object.op_Implicit((Object)(object)_magazineToLoad))
			{
				Object.Destroy((Object)(object)((Component)_magazineToLoad).gameObject);
			}
			if (Object.op_Implicit((Object)(object)_magazineForQuickbelt))
			{
				Object.Destroy((Object)(object)((Component)_magazineForQuickbelt).gameObject);
			}
		}

		public void GenerateBuffer(int currentIndex)
		{
			if (currentIndex + 1 < GameSettings.CurrentPool.GetWeaponCount())
			{
				((MonoBehaviour)this).StartCoroutine(SpawnAsync(ObjectType.Gun, GameSettings.CurrentPool.GetWeapon(currentIndex + 1)));
				((MonoBehaviour)this).StartCoroutine(SpawnAsync(ObjectType.MagazineToLoad, GameSettings.CurrentPool.GetWeapon(currentIndex + 1)));
				((MonoBehaviour)this).StartCoroutine(SpawnAsync(ObjectType.MagazineForQuickbelt, GameSettings.CurrentPool.GetWeapon(currentIndex + 1)));
			}
		}

		private IEnumerator SpawnAsync(ObjectType type, GunData gunData)
		{
			string weaponString = "";
			if (type == ObjectType.Gun)
			{
				weaponString = gunData.GunName;
			}
			if (type == ObjectType.MagazineToLoad || type == ObjectType.MagazineForQuickbelt)
			{
				weaponString = gunData.MagName;
			}
			FVRObject newObj = null;
			if (!IM.OD.TryGetValue(weaponString, out newObj))
			{
				Debug.LogError((object)("No object found with id: " + weaponString));
				yield break;
			}
			AnvilCallback<GameObject> callback = ((AnvilAsset)newObj).GetGameObjectAsync();
			yield return callback;
			Vector3 spawnOffset = Vector3.left * (float)type;
			switch (type)
			{
			case ObjectType.Gun:
				_gun = Object.Instantiate<GameObject>(callback.Result, BufferSpawnPos.position + spawnOffset, BufferSpawnPos.rotation).GetComponent<FVRPhysicalObject>();
				((Component)_gun).gameObject.SetActive(true);
				break;
			case ObjectType.MagazineToLoad:
				_magazineToLoad = Object.Instantiate<GameObject>(callback.Result, BufferSpawnPos.position + spawnOffset, BufferSpawnPos.rotation).GetComponent<FVRPhysicalObject>();
				((Component)_magazineToLoad).gameObject.SetActive(true);
				_magazineToLoad.UsesGravity = false;
				_magazineToLoad.RootRigidbody.isKinematic = true;
				break;
			case ObjectType.MagazineForQuickbelt:
				_magazineForQuickbelt = Object.Instantiate<GameObject>(callback.Result, BufferSpawnPos.position + spawnOffset, BufferSpawnPos.rotation).GetComponent<FVRPhysicalObject>();
				((Component)_magazineForQuickbelt).gameObject.SetActive(true);
				break;
			}
		}

		public FVRPhysicalObject SpawnImmediate(ObjectType objectType, GunData gunData)
		{
			//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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			string text = "";
			if (objectType == ObjectType.Gun)
			{
				text = gunData.GunName;
			}
			if (objectType == ObjectType.MagazineToLoad || objectType == ObjectType.MagazineForQuickbelt)
			{
				text = gunData.MagName;
			}
			if (objectType == ObjectType.Extra)
			{
				text = gunData.Extra;
			}
			FVRObject value = null;
			if (!IM.OD.TryGetValue(text, out value))
			{
				Debug.LogError((object)("No object found with id: " + text));
				return null;
			}
			GameObject gameObject = ((AnvilAsset)value).GetGameObject();
			GameObject val = Object.Instantiate<GameObject>(gameObject, ((Component)this).transform.position + Vector3.up, ((Component)this).transform.rotation);
			val.SetActive(true);
			return val.GetComponent<FVRPhysicalObject>();
		}
	}
	public enum ObjectType
	{
		Gun,
		MagazineToLoad,
		MagazineForQuickbelt,
		Extra
	}
	[Serializable]
	public class WeaponPool : WeaponPoolInterface
	{
		public string Name;

		public string Description;

		public OrderType OrderType;

		public string EnemyType = "M_Swat_Scout";

		public int CurrentIndex;

		public List<GunData> Guns = new List<GunData>();

		[NonSerialized]
		public List<EnemyData> Enemies = new List<EnemyData>();

		[HideInInspector]
		public List<string> GunNames = new List<string>();

		[HideInInspector]
		public List<string> MagNames = new List<string>();

		[HideInInspector]
		public List<int> CategoryIDs = new List<int>();

		public string GetName()
		{
			return Name;
		}

		public string GetDescription()
		{
			return Description;
		}

		public GunData GetNextWeapon()
		{
			if (CurrentIndex + 1 >= GunNames.Count)
			{
				return null;
			}
			return Guns[CurrentIndex + 1];
		}

		public GunData GetWeapon(int index)
		{
			return Guns[index];
		}

		public int GetWeaponCount()
		{
			return Guns.Count;
		}

		public int GetCurrentWeaponIndex()
		{
			return CurrentIndex;
		}

		public GunData GetCurrentWeapon()
		{
			return Guns[CurrentIndex];
		}

		public KillProgressionType GetProgressionType()
		{
			return KillProgressionType.Count;
		}

		public List<EnemyData> GetEnemies()
		{
			return Enemies;
		}

		public bool IncrementProgress()
		{
			CurrentIndex++;
			if (CurrentIndex == Guns.Count)
			{
				return true;
			}
			return false;
		}

		public void DecrementProgress()
		{
			if (CurrentIndex > 0)
			{
				CurrentIndex--;
			}
		}

		public void Initialize()
		{
			SetGunOrder();
			SeedEnemyList();
			CurrentIndex = 0;
		}

		private void SetGunOrder()
		{
			if (OrderType == OrderType.Random)
			{
				IListExtensions.Shuffle<GunData>((IList<GunData>)Guns);
			}
			if (OrderType == OrderType.RandomWithinCategory)
			{
				IListExtensions.Shuffle<GunData>((IList<GunData>)Guns);
				Guns = Guns.OrderBy((GunData x) => x.CategoryID).ToList();
			}
		}

		private void SeedEnemyList()
		{
			Enemies.Add(new EnemyData(EnemyType, 1));
		}

		private void SetSpawners()
		{
		}
	}
	[Serializable]
	public class WeaponPoolAdvanced : WeaponPoolInterface
	{
		public string Name = "";

		public string Description = "";

		public OrderType OrderType = OrderType.Fixed;

		public string EnemyType = "M_Swat_Scout";

		public int CurrentIndex = 0;

		public string WeaponPoolType = "";

		public KillProgressionType EnemyProgressionType = KillProgressionType.Count;

		public List<GunData> Guns = new List<GunData>();

		public List<EnemyData> Enemies = new List<EnemyData>();

		[HideInInspector]
		public List<string> GunNames = new List<string>();

		[HideInInspector]
		public List<string> MagNames = new List<string>();

		[HideInInspector]
		public List<int> CategoryIDs = new List<int>();

		public string GetName()
		{
			return Name;
		}

		public string GetDescription()
		{
			return Description;
		}

		public GunData GetNextWeapon()
		{
			return Guns[CurrentIndex];
		}

		public GunData GetWeapon(int index)
		{
			return Guns[index];
		}

		public int GetWeaponCount()
		{
			return Guns.Count;
		}

		public int GetCurrentWeaponIndex()
		{
			return CurrentIndex;
		}

		public GunData GetCurrentWeapon()
		{
			return Guns[CurrentIndex];
		}

		public KillProgressionType GetProgressionType()
		{
			return EnemyProgressionType;
		}

		public List<EnemyData> GetEnemies()
		{
			return Enemies;
		}

		public bool IncrementProgress()
		{
			CurrentIndex++;
			if (CurrentIndex == Guns.Count)
			{
				return true;
			}
			return false;
		}

		public void DecrementProgress()
		{
			if (CurrentIndex > 0)
			{
				CurrentIndex--;
			}
		}

		public void Initialize()
		{
			SetGunOrder();
			SeedRandomMagazines();
			CurrentIndex = 0;
			AutofillEnemyData();
		}

		private void SetGunOrder()
		{
			if (OrderType == OrderType.Random)
			{
				IListExtensions.Shuffle<GunData>((IList<GunData>)Guns);
			}
			if (OrderType == OrderType.RandomWithinCategory)
			{
				IListExtensions.Shuffle<GunData>((IList<GunData>)Guns);
				Guns = Guns.OrderBy((GunData x) => x.CategoryID).ToList();
			}
		}

		private void AutofillEnemyData()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			foreach (EnemyData enemy in Enemies)
			{
				if (!Utility.IsNullOrWhiteSpace(enemy.EnemyNameString))
				{
					enemy.EnemyName = (SosigEnemyID)Enum.Parse(typeof(SosigEnemyID), enemy.EnemyNameString, ignoreCase: true);
				}
			}
		}

		private void SeedRandomMagazines()
		{
			Random.InitState((int)Convert.ToInt16(Time.time));
			int num = Random.Range(0, 10);
			foreach (GunData gun in Guns)
			{
				if (gun.MagNames.Count > 0)
				{
					gun.MagName = gun.MagNames[num % gun.MagNames.Count];
				}
				num++;
			}
		}
	}
	public interface WeaponPoolInterface
	{
		string GetName();

		string GetDescription();

		int GetWeaponCount();

		int GetCurrentWeaponIndex();

		GunData GetWeapon(int index);

		GunData GetCurrentWeapon();

		GunData GetNextWeapon();

		KillProgressionType GetProgressionType();

		List<EnemyData> GetEnemies();

		bool IncrementProgress();

		void DecrementProgress();

		void Initialize();
	}
	public enum OrderType
	{
		Fixed,
		Random,
		RandomWithinCategory
	}
	public class WeaponPoolLoader : MonoBehaviourSingleton<WeaponPoolLoader>
	{
		public static Action WeaponLoadedEvent;

		public Transform ChoicesListParent;

		public PoolChoice ChoicePrefab;

		public List<WeaponPool> DebugWeaponPools;

		private List<string> _loadedWeaponPoolsLocations = new List<string>();

		private List<WeaponPoolInterface> _weaponPools = new List<WeaponPoolInterface>();

		private List<PoolChoice> _choices = new List<PoolChoice>();

		public void SaveDebugWeaponPools()
		{
			for (int i = 0; i < DebugWeaponPools.Count; i++)
			{
				DebugWeaponPools[i].GunNames.Clear();
				DebugWeaponPools[i].MagNames.Clear();
				DebugWeaponPools[i].CategoryIDs.Clear();
				for (int j = 0; j < DebugWeaponPools[i].Guns.Count; j++)
				{
					DebugWeaponPools[i].GunNames.Add(DebugWeaponPools[i].Guns[j].GunName);
					DebugWeaponPools[i].MagNames.Add(DebugWeaponPools[i].Guns[j].MagName);
					DebugWeaponPools[i].CategoryIDs.Add(DebugWeaponPools[i].Guns[j].CategoryID);
				}
				DebugWeaponPools[i].Guns.Clear();
			}
			foreach (WeaponPool debugWeaponPool in DebugWeaponPools)
			{
				WriteWeaponPool(Application.dataPath + "/GunGame//GunGameWeaponPool_" + debugWeaponPool.Name + ".json", debugWeaponPool);
			}
		}

		public override void Awake()
		{
			base.Awake();
			_loadedWeaponPoolsLocations = GetWeaponPoolLocations();
			_weaponPools = new List<WeaponPoolInterface>();
			if (_loadedWeaponPoolsLocations.Count == 0)
			{
				Debug.LogError((object)"No weapon pools found!");
				return;
			}
			for (int i = 0; i < _loadedWeaponPoolsLocations.Count; i++)
			{
				WeaponPoolInterface weaponPoolInterface = LoadWeaponPool(_loadedWeaponPoolsLocations[i]);
				if (weaponPoolInterface != null)
				{
					_weaponPools.Add(weaponPoolInterface);
					Debug.Log((object)("Weapon pool loaded with name: " + weaponPoolInterface.GetName() + " and count: " + weaponPoolInterface.GetWeaponCount()));
				}
				else
				{
					Debug.Log((object)("Failed to load Weapon pool at location: " + _loadedWeaponPoolsLocations[i]));
				}
			}
			for (int j = 0; j < _weaponPools.Count; j++)
			{
				PoolChoice poolChoice = Object.Instantiate<PoolChoice>(ChoicePrefab, ChoicesListParent);
				poolChoice.Initialize(_weaponPools[j]);
				_choices.Add(poolChoice);
			}
			WeaponPoolInterface newPool = _weaponPools[0];
			GameSettings.ChangeCurrentPool(newPool);
			if (WeaponLoadedEvent != null)
			{
				WeaponLoadedEvent();
			}
		}

		public WeaponPoolInterface LoadWeaponPool(string path)
		{
			using StreamReader streamReader = new StreamReader(path);
			string text = streamReader.ReadToEnd();
			WeaponPoolAdvanced newWeaponPoolAdvanced = null;
			try
			{
				newWeaponPoolAdvanced = JsonUtility.FromJson<WeaponPoolAdvanced>(text);
			}
			catch (Exception ex)
			{
				Debug.Log((object)ex.Message);
				return null;
			}
			if (newWeaponPoolAdvanced.WeaponPoolType == "Advanced")
			{
				if (_weaponPools.FirstOrDefault((WeaponPoolInterface x) => x.GetName() == newWeaponPoolAdvanced.GetName()) != null)
				{
					return null;
				}
				Debug.Log((object)("Loaded advanced weapon pool: " + newWeaponPoolAdvanced.GetName()));
				return newWeaponPoolAdvanced;
			}
			WeaponPool newWeaponPool = JsonUtility.FromJson<WeaponPool>(text);
			if (_weaponPools.FirstOrDefault((WeaponPoolInterface x) => x.GetName() == newWeaponPool.GetName()) != null)
			{
				return null;
			}
			newWeaponPool.Guns.Clear();
			for (int i = 0; i < newWeaponPool.GunNames.Count; i++)
			{
				GunData gunData = new GunData();
				gunData.GunName = newWeaponPool.GunNames[i];
				gunData.MagName = newWeaponPool.MagNames[i];
				gunData.CategoryID = newWeaponPool.CategoryIDs[i];
				GunData item = gunData;
				newWeaponPool.Guns.Add(item);
			}
			Debug.Log((object)("Loaded basic weapon pool: " + newWeaponPoolAdvanced.GetName()));
			return newWeaponPool;
		}

		public void WriteWeaponPool(string path, WeaponPool weaponPool)
		{
			using StreamWriter streamWriter = new StreamWriter(path);
			string value = JsonUtility.ToJson((object)weaponPool, true);
			streamWriter.Write(value);
		}

		private List<string> GetWeaponPoolLocations()
		{
			string pluginPath = Paths.PluginPath;
			List<string> list = Directory.GetFiles(pluginPath, "GunGameWeaponPool*.json", SearchOption.AllDirectories).ToList();
			List<string> collection = Directory.GetFiles(pluginPath, "AdvancedGunGameWeaponPool*.json", SearchOption.AllDirectories).ToList();
			list.AddRange(collection);
			return list;
		}
	}
}
namespace GEnigma.SandpitGunGame
{
	[BepInPlugin("GEnigma.SandpitGunGame", "SandpitGunGame", "1.0.1")]
	[BepInProcess("h3vr.exe")]
	[Description("Built with MeatKit")]
	[BepInDependency("nrgill28.Atlas", "1.0.1")]
	public class SandpitGunGamePlugin : 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(), "GEnigma.SandpitGunGame");
			AtlasPlugin.RegisterScene(Path.Combine(BasePath, "gg_sandpit"));
		}
	}
}
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 i = 0; i < list.Count; i++)
			{
				list2.AddRange(CreatePositionsAround(((Component)list[i]).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 val2 = x - positions[i];
						return ((Vector3)(ref val2)).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 j = 0; j < list2.Count; j++)
				{
					Vector3 center = dictionary[list2[j]].Aggregate(Vector3.zero, (Vector3 result, Vector3 target) => result + target) / (float)dictionary[list2[j]].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 result2;
					if (y != x)
					{
						Vector3 val = y - x;
						result2 = ((((Vector3)(ref val)).magnitude < distance) ? 1 : 0);
					}
					else
					{
						result2 = 0;
					}
					return (byte)result2 != 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 != 0) ? 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 != 0) ? 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 result, Vector3 point) => result + point) / (float)points.Length;
			Bounds result2 = default(Bounds);
			((Bounds)(ref result2))..ctor(val, Vector3.zero);
			for (int i = 0; i < points.Length; i++)
			{
				((Bounds)(ref result2)).Encapsulate(points[i]);
			}
			return result2;
		}

		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 re