Decompiled source of SupplyRaid v1.2.9

SupplyRaid.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using Atlas;
using Atlas.Loaders;
using Atlas.MappingComponents.TakeAndHold;
using BepInEx;
using BepInEx.Bootstrap;
using FistVR;
using H3MP;
using H3MP.Networking;
using H3MP.Scripts;
using Microsoft.CodeAnalysis;
using Sodalite.Api;
using SupplyRaid;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("Packer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Supply Raid(SR) Gamemode, with native H3MP integration")]
[assembly: AssemblyFileVersion("1.2.9.0")]
[assembly: AssemblyInformationalVersion("1.2.9+2071a8ff3dc91ecd3be0efc0a1708fc7cba99a2d")]
[assembly: AssemblyProduct("SupplyRaid")]
[assembly: AssemblyTitle("SupplyRaid")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.9.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class SR_FVRPhysicalObject : FVRPhysicalObject
{
}
public class SR_FVRPointable : FVRPointable
{
}
public class SR_FVRPointableButton : FVRPointableButton
{
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace H3MP.Networking
{
	public class Networking
	{
		public static bool ServerRunning()
		{
			if (SupplyRaidPlugin.h3mpEnabled)
			{
				return isServerRunning();
			}
			return false;
		}

		private static bool isServerRunning()
		{
			if ((Object)(object)Mod.managerObject == (Object)null)
			{
				return false;
			}
			return true;
		}

		public static bool IsClient()
		{
			if (SupplyRaidPlugin.h3mpEnabled)
			{
				return isClient();
			}
			return false;
		}

		private static bool isClient()
		{
			if ((Object)(object)Mod.managerObject == (Object)null)
			{
				return false;
			}
			if (!ThreadManager.host)
			{
				return true;
			}
			return false;
		}

		public static bool IsHost()
		{
			if (SupplyRaidPlugin.h3mpEnabled)
			{
				return isHosting();
			}
			return false;
		}

		private static bool isHosting()
		{
			if ((Object)(object)Mod.managerObject == (Object)null)
			{
				return false;
			}
			if (ThreadManager.host)
			{
				return true;
			}
			return false;
		}

		public static int GetPlayerCount()
		{
			if (SupplyRaidPlugin.h3mpEnabled)
			{
				return GetNetworkPlayerCount();
			}
			return 1;
		}

		private static int GetNetworkPlayerCount()
		{
			return GameManager.players.Count;
		}

		public static int[] GetPlayerIDs()
		{
			int[] array = new int[GameManager.players.Count];
			int num = 0;
			foreach (KeyValuePair<int, PlayerManager> player in GameManager.players)
			{
				array[num] = player.Key;
				num++;
			}
			return array;
		}

		public static int GetLocalID()
		{
			return GameManager.ID;
		}

		public static int RegisterHostCustomPacket(string identifier)
		{
			if (Mod.registeredCustomPacketIDs.ContainsKey(identifier))
			{
				return Mod.registeredCustomPacketIDs[identifier];
			}
			return Server.RegisterCustomPacketType(identifier, 0);
		}

		public static PlayerData GetPlayer(int i)
		{
			return PlayerData.GetPlayer(i);
		}
	}
	public class PlayerData
	{
		public Transform head;

		public string username;

		public Transform handLeft;

		public Transform handRight;

		public int ID;

		public float health;

		public int iff;

		public static PlayerData GetPlayer(int i)
		{
			return new PlayerData
			{
				head = GameManager.players[i].head,
				username = GameManager.players[i].username,
				handLeft = GameManager.players[i].leftHand,
				handRight = GameManager.players[i].rightHand
			};
		}
	}
}
namespace SupplyRaid
{
	internal static class PluginInfo
	{
		internal const string NAME = "Supply Raid";

		internal const string GUID = "com.Packer.SupplyRaid";

		internal const string VERSION = "1.2.6";
	}
	public class BGM
	{
		public static void SetTakeMusic(int level)
		{
		}

		public static void SetHoldMusic(int level)
		{
		}

		public static void QueueTake(int situation)
		{
		}

		public static void SpawnPanel(Vector3 position, Quaternion rotation)
		{
		}

		public static void InitializeSoundtrackInterface()
		{
		}
	}
	public class SR_TNH : MonoBehaviour
	{
		public TNH_Manager tnhManager;

		public SR_Manager srManager;

		public TNH_ManagerOverride tnHOverideManager;

		public static float maxBoundsSize = 10f;

		public static float spawnHalfExtent = 20f;

		public static float navRange = 30f;

		public void Start()
		{
			if (Object.op_Implicit((Object)(object)tnHOverideManager))
			{
				((MonoBehaviour)this).StartCoroutine(DelaySetup());
			}
			else
			{
				((MonoBehaviour)this).StartCoroutine(SetupSupplyRaid());
			}
		}

		public IEnumerator DelaySetup()
		{
			yield return null;
			tnhManager = Object.FindObjectOfType<TNH_Manager>();
			yield return null;
			if ((Object)(object)tnhManager != (Object)null)
			{
				((MonoBehaviour)this).StartCoroutine(SetupSupplyRaid());
			}
		}

		public IEnumerator SetupSupplyRaid()
		{
			if (Object.op_Implicit((Object)(object)tnhManager))
			{
				tnhManager.FMODController.SwitchTo(0, 0f, true, true);
				tnhManager.ClearMiscEnemies();
				((Component)tnhManager).gameObject.SetActive(false);
				tnhManager.FMODController.SetMasterVolume(0f);
				for (int i = 0; i < tnhManager.HoldPoints.Count; i++)
				{
					tnhManager.HoldPoints[i].ForceClearConfiguration();
					((Component)tnhManager.HoldPoints[i]).gameObject.SetActive(false);
				}
				for (int j = 0; j < tnhManager.SupplyPoints.Count; j++)
				{
					tnhManager.SupplyPoints[j].ClearConfiguration();
					((Component)tnhManager.SupplyPoints[j]).gameObject.SetActive(false);
				}
			}
			if (Object.op_Implicit((Object)(object)tnHOverideManager))
			{
				((Component)tnHOverideManager).gameObject.SetActive(false);
			}
			VaultSystem.ClearExistingSaveableObjects(true);
			Object.Instantiate<GameObject>(new GameObject()).AddComponent<SR_ModLoader>();
			yield return null;
			SetupManager();
			yield return null;
			yield return ((MonoBehaviour)this).StartCoroutine(SetupSupplyPoints());
			yield return null;
			yield return ((MonoBehaviour)this).StartCoroutine(SetupSupplyPointsHold());
			Debug.Log((object)("Supply Raid: SR Supply Points Total: " + SR_Manager.instance.supplyPoints.Count));
			((MonoBehaviour)this).StartCoroutine(SR_ModLoader.LoadSupplyRaidAssets());
		}

		private void SetupManager()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: 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_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(new GameObject());
			srManager = val.AddComponent<SR_Manager>();
			Transform transform = new GameObject().transform;
			Transform transform2 = new GameObject().transform;
			transform2.SetPositionAndRotation(tnhManager.ScoreDisplayPoint.position + Vector3.down * 1.5f, tnhManager.ScoreDisplayPoint.rotation);
			transform.SetPositionAndRotation(transform2.position + -(transform2.forward * 2f), transform2.rotation);
			Transform transform3 = new GameObject().transform;
			transform3.position = tnhManager.ScoreDisplayPoint.position + Vector3.down * 5f;
			srManager.srMenu = transform2;
			srManager.spawnMenu = transform2;
			srManager.resultsMenu = transform2;
			srManager.spawnPoint = transform;
			srManager.spawnStation = transform2;
			srManager.itemSpawner = tnhManager.ItemSpawner.transform;
			((Component)srManager.itemSpawner).transform.SetParent((Transform)null);
			srManager.itemSpawner.SetPositionAndRotation(transform2.position + Vector3.up + -srManager.itemSpawner.forward * 2f, transform2.rotation * Quaternion.Euler(0f, 180f, 0f));
			srManager.buyMenu = transform3;
			srManager.ammoStation = transform3;
			srManager.recycler = transform3;
			srManager.duplicator = transform3;
			srManager.attachmentStation = transform3;
			srManager.itemSpawner = transform3;
			srManager.captureZone = ((Component)transform3).gameObject.AddComponent<SR_CaptureZone>();
			srManager.captureZone.zone = ((Component)this).transform;
			GM.CurrentMovementManager.TeleportToPoint(srManager.spawnPoint.position, true, srManager.spawnPoint.forward);
		}

		public Transform TryGetLocation(List<Transform> safeLocations, int index, List<Transform> tryLocations = null)
		{
			if (tryLocations != null && tryLocations.Count > index)
			{
				return tryLocations[index];
			}
			if (safeLocations.Count > index)
			{
				return safeLocations[index];
			}
			return safeLocations[Random.Range(0, safeLocations.Count)];
		}

		public IEnumerator SetupSupplyPoints()
		{
			yield return null;
			Debug.Log((object)("Supply Raid: Found Supply Points - " + tnhManager.SupplyPoints.Count));
			Random.InitState(tnhManager.m_seed);
			List<Transform> validPanels = new List<Transform>();
			List<Transform> validSosigPoints = new List<Transform>();
			List<Transform> validPatrolPoints = new List<Transform>();
			NavMeshHit hit = default(NavMeshHit);
			for (int x = 0; x < tnhManager.SupplyPoints.Count; x++)
			{
				TNH_SupplyPoint tnhSP = tnhManager.SupplyPoints[x];
				validPanels.Clear();
				validSosigPoints.Clear();
				validPatrolPoints.Clear();
				validPanels.AddRange(tnhSP.SpawnPoints_Panels);
				validPanels.AddRange(tnhSP.SpawnPoint_Tables);
				validPanels.Add(tnhSP.SpawnPoint_PlayerSpawn);
				validPanels.AddRange(tnhSP.SpawnPoints_Boxes);
				validPanels.AddRange(tnhSP.SpawnPoints_Sosigs_Defense);
				validPanels.AddRange(tnhSP.SpawnPoints_Turrets);
				validSosigPoints.Add(tnhSP.SpawnPoint_PlayerSpawn);
				validSosigPoints.AddRange(tnhSP.SpawnPoints_Boxes);
				validSosigPoints.AddRange(tnhSP.SpawnPoints_Sosigs_Defense);
				validSosigPoints.AddRange(tnhSP.SpawnPoints_Turrets);
				validSosigPoints.AddRange(tnhSP.SpawnPoints_Panels);
				for (int k = 0; k < tnhSP.CoverPoints.Count; k++)
				{
					validSosigPoints.Add(((Component)tnhSP.CoverPoints[k]).transform);
				}
				for (int j = validSosigPoints.Count - 1; j >= 0; j--)
				{
					if ((Object)(object)validSosigPoints[j] == (Object)null)
					{
						validSosigPoints.RemoveAt(j);
					}
				}
				SR_SupplyPoint sp = Object.Instantiate<GameObject>(new GameObject()).AddComponent<SR_SupplyPoint>();
				((Object)sp).name = "SupplyPoint_" + x;
				if (Object.op_Implicit((Object)(object)((Component)tnhSP).GetComponent<AtlasSupplyPoint>()))
				{
					Debug.Log((object)"Supply Raid: Found First Spawn Atlas");
					if (((Component)tnhSP).GetComponent<AtlasSupplyPoint>().ForceSpawnHere)
					{
						sp.forceFirstSpawn = true;
					}
				}
				else if (Object.op_Implicit((Object)(object)((Component)tnhSP).GetComponent("WurstMod.MappingComponents.TakeAndHold.ForcedSpawn")))
				{
					Debug.Log((object)"Supply Raid: Found First Spawn Wurst");
					sp.forceFirstSpawn = true;
				}
				sp.respawn = tnhSP.SpawnPoint_PlayerSpawn;
				sp.captureZone = tnhSP.Bounds;
				sp.squadPoint = tnhSP.SpawnPoint_PlayerSpawn;
				float largestSize = Mathf.Max(sp.captureZone.localScale.x, Mathf.Max(sp.captureZone.localScale.y, sp.captureZone.localScale.z)) * 1.5f;
				sp.captureTime = Mathf.CeilToInt(Mathf.Clamp(((float)sp.captureTime < largestSize) ? largestSize : ((float)sp.captureTime), 20f, 45f));
				sp.buyMenu = TryGetLocation(validPanels, 0);
				((Component)sp.buyMenu).transform.Rotate(0f, 90f, 0f);
				sp.ammoStation = TryGetLocation(validPanels, 3);
				((Component)sp.ammoStation).transform.Rotate(0f, 90f, 0f);
				sp.attachmentStation = TryGetLocation(validPanels, 1);
				((Component)sp.attachmentStation).transform.Rotate(0f, 90f, 0f);
				sp.recycler = TryGetLocation(validPanels, 2);
				((Component)sp.recycler).transform.Rotate(0f, 90f, 0f);
				sp.duplicator = TryGetLocation(validPanels, 4);
				((Component)sp.duplicator).transform.Rotate(0f, 90f, 0f);
				sp.sosigSpawns = (Transform[])(object)new Transform[4];
				for (int z2 = 0; z2 < sp.sosigSpawns.Length; z2++)
				{
					sp.sosigSpawns[z2] = TryGetLocation(validSosigPoints, z2);
				}
				sp.sniperPoints.AddRange(validSosigPoints);
				sp.guardPoints.AddRange(validSosigPoints);
				PatrolPath[] patrols = new PatrolPath[2];
				for (int i = 0; i < 8; i++)
				{
					Transform spot = new GameObject().transform;
					validPatrolPoints.Add(spot);
					spot.position = sp.captureZone.position;
					spot.position += new Vector3(Random.Range(0f - spawnHalfExtent, spawnHalfExtent), Random.Range(0f - spawnHalfExtent, spawnHalfExtent), Random.Range(0f - spawnHalfExtent, spawnHalfExtent));
					if (NavMesh.SamplePosition(spot.position, ref hit, navRange, -1))
					{
						spot.position = ((NavMeshHit)(ref hit)).position;
					}
					hit = default(NavMeshHit);
				}
				for (int z = 0; z < patrols.Length; z++)
				{
					patrols[z] = new PatrolPath();
					patrols[z].patrolPoints.AddRange(validPatrolPoints);
					validPatrolPoints.Reverse();
				}
				sp.patrolPaths = patrols;
			}
		}

		public IEnumerator SetupSupplyPointsHold()
		{
			if ((Object)(object)tnhManager == (Object)null || tnhManager.HoldPoints == null)
			{
				yield break;
			}
			Debug.Log((object)("Supply Raid: Found Hold Points - " + tnhManager.HoldPoints.Count));
			List<Transform> validPanels = new List<Transform>();
			List<Transform> validSosigPoints = new List<Transform>();
			List<Transform> validPatrolPoints = new List<Transform>();
			NavMeshHit hit = default(NavMeshHit);
			NavMeshHit hit2 = default(NavMeshHit);
			for (int x = 0; x < tnhManager.HoldPoints.Count; x++)
			{
				TNH_HoldPoint tnhHP = tnhManager.HoldPoints[x];
				if ((Object)(object)tnhHP == (Object)null)
				{
					continue;
				}
				validPanels.Clear();
				validSosigPoints.Clear();
				if ((Object)(object)tnhHP.m_systemNode != (Object)null && (Object)(object)tnhHP.m_systemNode.NodeCenter != (Object)null)
				{
					validPanels.Add(tnhHP.m_systemNode.NodeCenter);
				}
				for (int j = 0; j < tnhHP.CoverPoints.Count; j++)
				{
					if ((Object)(object)tnhHP.CoverPoints[j] != (Object)null && (Object)(object)((Component)tnhHP.CoverPoints[j]).transform != (Object)null)
					{
						validPanels.Add(((Component)tnhHP.CoverPoints[j]).transform);
					}
				}
				validPanels.AddRange(tnhHP.SpawnPoints_Sosigs_Defense);
				validPanels.AddRange(tnhHP.SpawnPoints_Turrets);
				for (int y = 0; y < tnhHP.AttackVectors.Count; y++)
				{
					if (tnhHP.AttackVectors[y] != null)
					{
						if (tnhHP.AttackVectors[y].SpawnPoints_Sosigs_Attack.Count > 0)
						{
							validSosigPoints.AddRange(tnhHP.AttackVectors[y].SpawnPoints_Sosigs_Attack);
						}
						if ((Object)(object)tnhHP.AttackVectors[y].GrenadeVector != (Object)null)
						{
							validSosigPoints.Add(tnhHP.AttackVectors[y].GrenadeVector);
						}
					}
				}
				validSosigPoints.AddRange(tnhHP.SpawnPoints_Sosigs_Defense);
				validSosigPoints.AddRange(tnhHP.SpawnPoints_Turrets);
				for (int k = 0; k < tnhHP.CoverPoints.Count; k++)
				{
					if ((Object)(object)tnhHP.CoverPoints[k] != (Object)null && (Object)(object)((Component)tnhHP.CoverPoints[k]).transform != (Object)null)
					{
						validSosigPoints.Add(((Component)tnhHP.CoverPoints[k]).transform);
					}
				}
				if ((Object)(object)tnhHP.m_systemNode != (Object)null && (Object)(object)tnhHP.m_systemNode.NodeCenter != (Object)null)
				{
					validSosigPoints.Add(tnhHP.m_systemNode.NodeCenter);
				}
				for (int m = validSosigPoints.Count - 1; m >= 0; m--)
				{
					if ((Object)(object)validSosigPoints[m] == (Object)null)
					{
						validSosigPoints.RemoveAt(m);
					}
				}
				SR_SupplyPoint sp = Object.Instantiate<GameObject>(new GameObject()).AddComponent<SR_SupplyPoint>();
				((Object)sp).name = "SupplyPoint_" + x;
				AtlasSupplyPoint ASP = ((Component)tnhHP).GetComponent<AtlasSupplyPoint>();
				if ((Object)(object)ASP != (Object)null)
				{
					Debug.Log((object)"Supply Raid: Found First Spawn Atlas");
					if (ASP.ForceSpawnHere)
					{
						sp.forceFirstSpawn = true;
					}
				}
				else if (Object.op_Implicit((Object)(object)((Component)tnhHP).GetComponent("WurstMod.MappingComponents.TakeAndHold.ForcedSpawn")))
				{
					Debug.Log((object)"Supply Raid: Found First Spawn Wurst");
					sp.forceFirstSpawn = true;
				}
				if ((Object)(object)tnhHP.m_systemNode != (Object)null && (Object)(object)tnhHP.m_systemNode.NodeCenter != (Object)null)
				{
					sp.respawn = tnhHP.m_systemNode.NodeCenter;
				}
				else
				{
					sp.respawn = validSosigPoints[Random.Range(0, validSosigPoints.Count)];
				}
				Transform bounds = null;
				Vector3 boundsScale = Vector3.zero;
				for (int l = 0; l < tnhHP.Bounds.Count; l++)
				{
					if (tnhHP.Bounds[l].localScale.x > boundsScale.x || tnhHP.Bounds[l].localScale.y > boundsScale.y || tnhHP.Bounds[l].localScale.z > boundsScale.z)
					{
						_ = tnhHP.Bounds[l];
						if (tnhHP.Bounds[l].localScale.x <= maxBoundsSize || tnhHP.Bounds[l].localScale.y <= maxBoundsSize || tnhHP.Bounds[l].localScale.z <= maxBoundsSize)
						{
							bounds = tnhHP.Bounds[l];
						}
					}
				}
				if ((Object)(object)bounds == (Object)null)
				{
					bounds = Object.Instantiate<GameObject>(new GameObject()).transform;
					bounds.localScale = Vector3.one * maxBoundsSize;
					if ((Object)(object)tnhHP.m_systemNode != (Object)null && (Object)(object)tnhHP.m_systemNode.NodeCenter != (Object)null)
					{
						bounds.position = tnhHP.m_systemNode.NodeCenter.position;
					}
					else if (tnhHP.Bounds.Count > 0)
					{
						if (NavMesh.SamplePosition(tnhHP.Bounds[0].position, ref hit, navRange, -1))
						{
							bounds.position = ((NavMeshHit)(ref hit)).position;
						}
						hit = default(NavMeshHit);
					}
					else
					{
						bounds.position = ((Component)tnhHP).transform.position;
					}
				}
				sp.captureZone = bounds;
				sp.squadPoint = sp.respawn;
				float largestSize = Mathf.Max(bounds.localScale.x, Mathf.Max(bounds.localScale.y, bounds.localScale.z)) * 1.5f;
				sp.captureTime = Mathf.CeilToInt(Mathf.Clamp(((float)sp.captureTime < largestSize) ? largestSize : ((float)sp.captureTime), 20f, 45f));
				sp.buyMenu = TryGetLocation(validPanels, 0);
				((Component)sp.buyMenu).transform.Rotate(0f, 90f, 0f);
				sp.ammoStation = TryGetLocation(validPanels, 3);
				((Component)sp.ammoStation).transform.Rotate(0f, 90f, 0f);
				sp.attachmentStation = TryGetLocation(validPanels, 1);
				((Component)sp.attachmentStation).transform.Rotate(0f, 90f, 0f);
				sp.recycler = TryGetLocation(validPanels, 2);
				((Component)sp.recycler).transform.Rotate(0f, 90f, 0f);
				sp.duplicator = TryGetLocation(validPanels, 4);
				((Component)sp.duplicator).transform.Rotate(0f, 90f, 0f);
				sp.sosigSpawns = (Transform[])(object)new Transform[4];
				for (int z2 = 0; z2 < sp.sosigSpawns.Length; z2++)
				{
					sp.sosigSpawns[z2] = TryGetLocation(validSosigPoints, z2);
				}
				sp.sniperPoints.AddRange(validSosigPoints);
				sp.guardPoints.AddRange(validSosigPoints);
				PatrolPath[] patrols = new PatrolPath[2];
				for (int i = 0; i < 8; i++)
				{
					Transform spot = new GameObject().transform;
					validPatrolPoints.Add(spot);
					spot.position = sp.captureZone.position;
					spot.position += new Vector3(Random.Range(0f - spawnHalfExtent, spawnHalfExtent), Random.Range(0f - spawnHalfExtent, spawnHalfExtent) * 0.5f, Random.Range(0f - spawnHalfExtent, spawnHalfExtent));
					if (NavMesh.SamplePosition(spot.position, ref hit2, navRange, -1))
					{
						spot.position = ((NavMeshHit)(ref hit2)).position;
					}
					hit2 = default(NavMeshHit);
				}
				for (int z = 0; z < patrols.Length; z++)
				{
					patrols[z] = new PatrolPath();
					patrols[z].patrolPoints.AddRange(validPatrolPoints);
					validPatrolPoints.Reverse();
				}
				sp.patrolPaths = patrols;
				yield return null;
			}
		}
	}
	internal class SR_SosigData
	{
		public static MeshRenderer GetSosigMeshRenderer(string title, Transform geoParent)
		{
			for (int i = 0; i < geoParent.childCount; i++)
			{
				if (((Object)geoParent.GetChild(i)).name == title)
				{
					return ((Component)geoParent.GetChild(i)).GetComponent<MeshRenderer>();
				}
			}
			return null;
		}

		public static void UpdateSosigLink(SosigLink link, Vector3 bodyScale, Vector3 linkScale, Material sosigMaterial, bool stopSever, MeshRenderer geo)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)link == (Object)null)
			{
				return;
			}
			CapsuleCollider val = (CapsuleCollider)link.C;
			val.height *= linkScale.y;
			val.radius *= ((linkScale.x > linkScale.z) ? linkScale.x : linkScale.z);
			CharacterJoint val2 = (((Object)(object)link.J != (Object)null) ? link.J : ((Component)link).GetComponent<CharacterJoint>());
			if (Object.op_Implicit((Object)(object)val2))
			{
				((Joint)val2).autoConfigureConnectedAnchor = false;
				((Joint)val2).anchor = new Vector3(0f, ((Joint)val2).anchor.y * bodyScale.y, 0f);
				((Joint)val2).connectedAnchor = new Vector3(0f, ((Joint)val2).connectedAnchor.y * bodyScale.y, 0f);
			}
			((Renderer)geo).sharedMaterial = sosigMaterial;
			((Component)geo).transform.localScale = linkScale;
			if (stopSever)
			{
				link.m_isJointSevered = true;
			}
			if (link.m_wearables.Count <= 0)
			{
				return;
			}
			foreach (SosigWearable wearable in link.m_wearables)
			{
				((Component)wearable).gameObject.transform.localScale = ((Component)geo).transform.localScale;
			}
		}
	}
	public class SR_Networking : MonoBehaviour
	{
		public static SR_Networking instance;

		public bool isClient = false;

		private int levelUpdate_ID = -1;

		private int gameOptions_ID = -1;

		private int capturedZone_ID = -1;

		private int serverRunning_ID = -1;

		private int updateStats_ID = -1;

		private int requestSync_ID = -1;

		private void Awake()
		{
			instance = this;
		}

		private void StartNetworking()
		{
			if (Networking.ServerRunning())
			{
				if (Networking.IsHost())
				{
				}
				if (Networking.IsHost() || Client.isFullyConnected)
				{
					SetupPacketTypes();
				}
				if (Networking.IsClient())
				{
					SR_Manager.instance.SetLocalAsClient();
				}
			}
		}

		private void Start()
		{
			if (SupplyRaidPlugin.h3mpEnabled)
			{
				StartNetworking();
			}
		}

		private void OnPlayerJoined(int clientID)
		{
			if (clientID != 0)
			{
			}
		}

		private void SetupPacketTypes()
		{
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Expected O, but got Unknown
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Expected O, but got Unknown
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Expected O, but got Unknown
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Expected O, but got Unknown
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Expected O, but got Unknown
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Expected O, but got Unknown
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Expected O, but got Unknown
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Expected O, but got Unknown
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Expected O, but got Unknown
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Expected O, but got Unknown
			//IL_045f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Expected O, but got Unknown
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_0449: Expected O, but got Unknown
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Expected O, but got Unknown
			if (Networking.IsHost())
			{
				if (Mod.registeredCustomPacketIDs.ContainsKey("SR_LevelUpdate"))
				{
					levelUpdate_ID = Mod.registeredCustomPacketIDs["SR_LevelUpdate"];
				}
				else
				{
					levelUpdate_ID = Server.RegisterCustomPacketType("SR_LevelUpdate", 0);
				}
				Mod.customPacketHandlers[levelUpdate_ID] = new CustomPacketHandler(LevelUpdate_Handler);
				if (Mod.registeredCustomPacketIDs.ContainsKey("SR_GameOptions"))
				{
					gameOptions_ID = Mod.registeredCustomPacketIDs["SR_GameOptions"];
				}
				else
				{
					gameOptions_ID = Server.RegisterCustomPacketType("SR_GameOptions", 0);
				}
				Mod.customPacketHandlers[gameOptions_ID] = new CustomPacketHandler(GameOptions_Handler);
				if (Mod.registeredCustomPacketIDs.ContainsKey("SR_CapturedZone"))
				{
					capturedZone_ID = Mod.registeredCustomPacketIDs["SR_CapturedZone"];
				}
				else
				{
					capturedZone_ID = Server.RegisterCustomPacketType("SR_CapturedZone", 0);
				}
				Mod.customPacketHandlers[capturedZone_ID] = new CustomPacketHandler(CapturedZone_Handler);
				if (Mod.registeredCustomPacketIDs.ContainsKey("SR_ServerRunning"))
				{
					serverRunning_ID = Mod.registeredCustomPacketIDs["SR_ServerRunning"];
				}
				else
				{
					serverRunning_ID = Server.RegisterCustomPacketType("SR_ServerRunning", 0);
				}
				Mod.customPacketHandlers[serverRunning_ID] = new CustomPacketHandler(ServerRunning_Handler);
				if (Mod.registeredCustomPacketIDs.ContainsKey("SR_UpdateStats"))
				{
					updateStats_ID = Mod.registeredCustomPacketIDs["SR_UpdateStats"];
				}
				else
				{
					updateStats_ID = Server.RegisterCustomPacketType("SR_UpdateStats", 0);
				}
				Mod.customPacketHandlers[updateStats_ID] = new CustomPacketHandler(UpdateStats_Handler);
				if (Mod.registeredCustomPacketIDs.ContainsKey("SR_RequestSync"))
				{
					requestSync_ID = Mod.registeredCustomPacketIDs["SR_RequestSync"];
				}
				else
				{
					requestSync_ID = Server.RegisterCustomPacketType("SR_RequestSync", 0);
				}
				Mod.customPacketHandlers[requestSync_ID] = new CustomPacketHandler(RequestSync_Handler);
				return;
			}
			if (Mod.registeredCustomPacketIDs.ContainsKey("SR_LevelUpdate"))
			{
				levelUpdate_ID = Mod.registeredCustomPacketIDs["SR_LevelUpdate"];
				Mod.customPacketHandlers[levelUpdate_ID] = new CustomPacketHandler(LevelUpdate_Handler);
			}
			else
			{
				ClientSend.RegisterCustomPacketType("SR_LevelUpdate");
				Mod.CustomPacketHandlerReceived += new CustomPacketHandlerReceivedDelegate(LevelUpdate_Received);
			}
			if (Mod.registeredCustomPacketIDs.ContainsKey("SR_GameOptions"))
			{
				gameOptions_ID = Mod.registeredCustomPacketIDs["SR_GameOptions"];
				Mod.customPacketHandlers[gameOptions_ID] = new CustomPacketHandler(GameOptions_Handler);
			}
			else
			{
				ClientSend.RegisterCustomPacketType("SR_GameOptions");
				Mod.CustomPacketHandlerReceived += new CustomPacketHandlerReceivedDelegate(GameOptions_Received);
			}
			if (Mod.registeredCustomPacketIDs.ContainsKey("SR_CapturedZone"))
			{
				capturedZone_ID = Mod.registeredCustomPacketIDs["SR_CapturedZone"];
				Mod.customPacketHandlers[capturedZone_ID] = new CustomPacketHandler(CapturedZone_Handler);
			}
			else
			{
				ClientSend.RegisterCustomPacketType("SR_CapturedZone");
				Mod.CustomPacketHandlerReceived += new CustomPacketHandlerReceivedDelegate(CapturedZone_Received);
			}
			if (Mod.registeredCustomPacketIDs.ContainsKey("SR_ServerRunning"))
			{
				serverRunning_ID = Mod.registeredCustomPacketIDs["SR_ServerRunning"];
				Mod.customPacketHandlers[serverRunning_ID] = new CustomPacketHandler(ServerRunning_Handler);
			}
			else
			{
				ClientSend.RegisterCustomPacketType("SR_ServerRunning");
				Mod.CustomPacketHandlerReceived += new CustomPacketHandlerReceivedDelegate(ServerRunning_Received);
			}
			if (Mod.registeredCustomPacketIDs.ContainsKey("SR_UpdateStats"))
			{
				updateStats_ID = Mod.registeredCustomPacketIDs["SR_UpdateStats"];
				Mod.customPacketHandlers[updateStats_ID] = new CustomPacketHandler(UpdateStats_Handler);
			}
			else
			{
				ClientSend.RegisterCustomPacketType("SR_UpdateStats");
				Mod.CustomPacketHandlerReceived += new CustomPacketHandlerReceivedDelegate(UpdateStats_Received);
			}
			if (Mod.registeredCustomPacketIDs.ContainsKey("SR_RequestSync"))
			{
				requestSync_ID = Mod.registeredCustomPacketIDs["SR_RequestSync"];
				Mod.customPacketHandlers[requestSync_ID] = new CustomPacketHandler(RequestSync_Handler);
			}
			else
			{
				ClientSend.RegisterCustomPacketType("SR_RequestSync");
				Mod.CustomPacketHandlerReceived += new CustomPacketHandlerReceivedDelegate(RequestSync_Received);
			}
		}

		public void LevelUpdate_Send(bool gameComplete)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			if (Networking.ServerRunning() && !Networking.IsClient())
			{
				Packet val = new Packet(levelUpdate_ID);
				val.Write(SR_Manager.instance.CurrentCaptures);
				val.Write(SR_Manager.instance.attackSupplyID);
				val.Write(SR_Manager.instance.playerSupplyID);
				val.Write(SR_Manager.instance.inEndless);
				val.Write(SR_Manager.instance.stats.ObjectiveComplete);
				val.Write(gameComplete);
				ServerSend.SendTCPDataToAll(val, true);
				Debug.Log((object)("Supply Raid: Host - Level Update: " + SR_Manager.instance.CurrentCaptures));
			}
		}

		private void LevelUpdate_Handler(int clientID, Packet packet)
		{
			int num = packet.ReadInt(true);
			int attackSupply = packet.ReadInt(true);
			int playerSupply = packet.ReadInt(true);
			bool isEndless = packet.ReadBool(true);
			bool objectiveComplete = packet.ReadBool(true);
			bool flag = packet.ReadBool(true);
			if (flag)
			{
				SR_Manager.instance.CurrentCaptures = num;
				SR_Manager.instance.gameCompleted = flag;
				SR_Manager.instance.stats.ObjectiveComplete = objectiveComplete;
				SR_Manager.instance.CompleteGame();
			}
			else
			{
				SR_Manager.instance.SetLevel_Client(num, attackSupply, playerSupply, isEndless);
			}
			Debug.Log((object)("Supply Raid: Client - Level Update: " + num));
		}

		public void GameOptions_Send()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			if (Networking.ServerRunning() && !Networking.IsClient())
			{
				Packet val = new Packet(gameOptions_ID);
				val.Write(SR_Manager.profile.playerCount);
				val.Write(SR_Manager.profile.difficulty);
				val.Write(SR_Manager.profile.freeBuyMenu);
				val.Write(SR_Manager.profile.spawnLocking);
				val.Write(SR_Manager.profile.startLevel);
				val.Write(SR_Manager.profile.playerHealth);
				val.Write(SR_Manager.profile.itemSpawner);
				val.Write(SR_Manager.profile.captureZone);
				val.Write(SR_Manager.profile.captureOrder);
				val.Write(SR_Manager.profile.captures);
				val.Write(SR_Manager.profile.respawn);
				val.Write(SR_Manager.profile.itemsDrop);
				val.Write(SR_Manager.profile.maxEnemies);
				val.Write(SR_Manager.profile.maxSquadEnemies);
				string text = "";
				if (SR_Manager.Faction() != null)
				{
					text = SR_Manager.Faction().name;
				}
				val.Write(text);
				val.Write(SR_Manager.profile.sosigWeapons);
				ServerSend.SendTCPDataToAll(val, true);
			}
		}

		private void GameOptions_Handler(int clientID, Packet packet)
		{
			float playerCount = packet.ReadFloat(true);
			float difficulty = packet.ReadFloat(true);
			bool freeBuyMenu = packet.ReadBool(true);
			bool spawnLocking = packet.ReadBool(true);
			int startLevel = packet.ReadInt(true);
			int playerHealth = packet.ReadInt(true);
			bool itemSpawner = packet.ReadBool(true);
			bool captureZone = packet.ReadBool(true);
			int order = packet.ReadInt(true);
			int captures = packet.ReadInt(true);
			bool respawn = packet.ReadBool(true);
			int itemsDrop = packet.ReadInt(true);
			int maxEnemies = packet.ReadInt(true);
			int maxSquadEnemies = packet.ReadInt(true);
			string factionID = packet.ReadString(true);
			bool sosigWeapons = packet.ReadBool(true);
			SR_Manager.instance.Network_GameOptions(playerCount, difficulty, freeBuyMenu, spawnLocking, startLevel, playerHealth, itemSpawner, captureZone, order, captures, respawn, itemsDrop, maxEnemies, maxSquadEnemies, factionID, sosigWeapons);
		}

		public void CapturedZone_Send()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			if (Networking.ServerRunning() && !Networking.IsHost())
			{
				Debug.Log((object)"Networking: Client Sending Captured Zone");
				Packet val = new Packet(capturedZone_ID);
				ClientSend.SendTCPData(val, true);
			}
		}

		private void CapturedZone_Handler(int clientID, Packet packet)
		{
			Debug.Log((object)"Networking: Received Client Captured zone");
			if (SR_Manager.instance.captureProtection <= 0f)
			{
				SR_Manager.instance.CapturedPoint();
			}
		}

		public void ServerRunning_Send()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if (Networking.ServerRunning() && !Networking.IsClient())
			{
				Packet val = new Packet(serverRunning_ID);
				val.Write(SR_Manager.instance.gameServerRunning);
				ServerSend.SendTCPDataToAll(val, true);
			}
		}

		private void ServerRunning_Handler(int clientID, Packet packet)
		{
			bool flag = packet.ReadBool(true);
			SR_Manager.instance.gameServerRunning = flag;
			SR_Menu.instance.lauchGameButton.SetActive(flag);
		}

		public void UpdateStats_Send()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if (Networking.ServerRunning() && !Networking.IsClient())
			{
				Packet val = new Packet(updateStats_ID);
				val.Write(SR_Manager.instance.CurrentCaptures);
				val.Write(SR_Manager.instance.stats.GameTime);
				val.Write(SR_Manager.instance.stats.Kills);
				ServerSend.SendTCPDataToAll(val, true);
			}
		}

		private void UpdateStats_Handler(int clientID, Packet packet)
		{
			int num = packet.ReadInt(true);
			if (num > SR_Manager.instance.CurrentCaptures)
			{
				SR_Manager.instance.CurrentCaptures = num;
			}
			float num2 = packet.ReadFloat(true);
			if (num2 > SR_Manager.instance.stats.GameTime)
			{
				SR_Manager.instance.stats.GameTime = num2;
			}
			int num3 = packet.ReadInt(true);
			if (SR_Manager.instance.stats.Kills > num3)
			{
				SR_Manager.instance.stats.Kills = num3;
			}
			SR_ResultsMenu.instance.UpdateResults();
		}

		public void RequestSync_Send()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			if (Networking.ServerRunning() && !Networking.IsHost())
			{
				Debug.Log((object)"Networking: Client Sending Request Sync");
				Packet val = new Packet(requestSync_ID);
				ClientSend.SendTCPData(val, true);
			}
		}

		private void RequestSync_Handler(int clientID, Packet packet)
		{
			Debug.Log((object)"Networking: Received Client Request Sync");
			GameOptions_Send();
			LevelUpdate_Send(SR_Manager.instance.gameCompleted);
			UpdateStats_Send();
			ServerRunning_Send();
		}

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

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

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

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

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

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

		public bool NamespaceExists(string desiredNamespace)
		{
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				Type[] types = assembly.GetTypes();
				foreach (Type type in types)
				{
					if (type.Namespace == desiredNamespace)
					{
						return true;
					}
				}
			}
			return false;
		}

		private void OnDestroy()
		{
		}
	}
	public class SR_AmmoSpawner : MonoBehaviour
	{
		public class AmmoRound
		{
			public FireArmRoundType roundType;

			public List<AmmoClass> roundClasses = new List<AmmoClass>();
		}

		public class AmmoClass
		{
			public FireArmRoundClass roundClass;

			public AmmoEnum ammo;

			public bool isOnlyType = false;
		}

		public static SR_AmmoSpawner instance;

		public Transform Spawnpoint_Round;

		public Transform ScanningVolume;

		public LayerMask ScanningLM;

		public Transform selectionIcon;

		[HideInInspector]
		public bool[] purchasedAmmoTypes = new bool[28];

		public GameObject rearmButton;

		public GameObject speedloaderButton;

		public GameObject clipButton;

		public GameObject roundButton;

		public GameObject togglePagesButton;

		[HideInInspector]
		[Tooltip("0 = Rearm \n1 = Speed Loader\n2 = Clip\n3 Round")]
		private bool[] purchaseButtons = new bool[4];

		private SR_GenericButton[] ammoButtons = new SR_GenericButton[28];

		public GameObject[] ammoTypeButtons = (GameObject[])(object)new GameObject[28];

		public AmmoEnum selectedAmmoType = AmmoEnum.Standard;

		public FireArmRoundClass roundClass = (FireArmRoundClass)1;

		private List<FVRFireArmMagazine> m_detectedMags = new List<FVRFireArmMagazine>();

		private List<FVRFireArmClip> m_detectedClips = new List<FVRFireArmClip>();

		private List<Speedloader> m_detectedSLs = new List<Speedloader>();

		private List<SosigWeaponPlayerInterface> m_detectedSweapons = new List<SosigWeaponPlayerInterface>();

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

		private List<FireArmRoundType> m_roundTypes = new List<FireArmRoundType>();

		private Collider[] colbuffer;

		private Dictionary<FireArmRoundType, FireArmRoundClass> m_decidedTypes = new Dictionary<FireArmRoundType, FireArmRoundClass>();

		private float m_scanTick = 1f;

		private List<AmmoRound> ammoList = new List<AmmoRound>();

		private List<FireArmRoundType> allRoundTypes = new List<FireArmRoundType>();

		[Header("Ammo Page")]
		public GameObject ammoPage;

		[Header("Round Page")]
		public GameObject roundPage;

		public GameObject roundButtonPrefab;

		public Transform roundContainer;

		private List<SR_GenericButton> roundButtons = new List<SR_GenericButton>();

		private List<FVRObject> rounds = new List<FVRObject>();

		public static List<FVRObject> GetAllRounds()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Invalid comparison between Unknown and I4
			List<FVRObject> list = new List<FVRObject>();
			foreach (string key in IM.OD.Keys)
			{
				if (IM.OD.TryGetValue(key, out var value) && Object.op_Implicit((Object)(object)value) && (int)value.Category == 4)
				{
					list.Add(value);
				}
			}
			return list;
		}

		private void PopulateRoundPage()
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_040e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < roundButtons.Count; i++)
			{
				if (Object.op_Implicit((Object)(object)roundButtons[i]))
				{
					Object.Destroy((Object)(object)((Component)roundButtons[i]).gameObject);
				}
			}
			List<FireArmRoundType> list = new List<FireArmRoundType>();
			list.AddRange(m_roundTypes);
			for (int j = 0; j < m_detectedMags.Count; j++)
			{
				if (Object.op_Implicit((Object)(object)m_detectedMags[j]) && !list.Contains(m_detectedMags[j].RoundType))
				{
					list.Add(m_detectedMags[j].RoundType);
				}
			}
			for (int k = 0; k < m_detectedClips.Count; k++)
			{
				if (Object.op_Implicit((Object)(object)m_detectedClips[k]) && !list.Contains(m_detectedClips[k].RoundType))
				{
					list.Add(m_detectedClips[k].RoundType);
				}
			}
			for (int l = 0; l < m_detectedSLs.Count; l++)
			{
				if (Object.op_Implicit((Object)(object)m_detectedSLs[l]) && Object.op_Implicit((Object)(object)((FVRPhysicalObject)m_detectedSLs[l]).ObjectWrapper) && !list.Contains(((FVRPhysicalObject)m_detectedSLs[l]).ObjectWrapper.RoundType))
				{
					list.Add(((FVRPhysicalObject)m_detectedSLs[l]).ObjectWrapper.RoundType);
				}
			}
			for (int m = 0; m < m_detectedSweapons.Count; m++)
			{
				if (Object.op_Implicit((Object)(object)m_detectedSweapons[m]) && Object.op_Implicit((Object)(object)((FVRPhysicalObject)m_detectedSweapons[m]).ObjectWrapper) && !list.Contains(((FVRPhysicalObject)m_detectedSweapons[m]).ObjectWrapper.RoundType))
				{
					list.Add(((FVRPhysicalObject)m_detectedSweapons[m]).ObjectWrapper.RoundType);
				}
			}
			for (int n = 0; n < m_detectedFirearms.Count; n++)
			{
				if (Object.op_Implicit((Object)(object)m_detectedFirearms[n]) && !list.Contains(m_detectedFirearms[n].RoundType))
				{
					list.Add(m_detectedFirearms[n].RoundType);
				}
			}
			rounds = GetAllRounds();
			for (int num = rounds.Count - 1; num >= 0; num--)
			{
				if (!list.Contains(rounds[num].RoundType))
				{
					rounds.RemoveAt(num);
				}
			}
			for (int num2 = 0; num2 < rounds.Count; num2++)
			{
				ManagerSingleton<IM>.Instance.SpawnerIDDic.TryGetValue(rounds[num2].SpawnedFromId, out var value);
				if ((Object)(object)value != (Object)null)
				{
					SR_GenericButton component = Object.Instantiate<GameObject>(roundButtonPrefab, roundContainer).GetComponent<SR_GenericButton>();
					((Component)component).gameObject.SetActive(true);
					roundButtons.Add(component);
					component.fvrObject = rounds[num2];
					component.textB.text = rounds[num2].DisplayName;
					FireArmRoundClass firearmRoundClassFromType = GetFirearmRoundClassFromType(rounds[num2].ItemID, rounds[num2].RoundType);
					AmmoEnum ammoEnum = (AmmoEnum)(component.index = (int)SR_Global.GetAmmoEnum(firearmRoundClassFromType));
					component.genericButton = ammoButtons[(int)ammoEnum];
					if (purchasedAmmoTypes[(int)ammoEnum])
					{
						if (SR_Manager.Character().modeRounds == 4)
						{
							int roundPowerCost = SR_Manager.Character().GetRoundPowerCost(rounds[num2].TagFirearmRoundPower, 1);
							component.text.text = roundPowerCost.ToString();
						}
						else
						{
							component.text.text = "";
						}
					}
					else
					{
						component.text.text = SR_Manager.Character().ammoUpgradeCost[(int)ammoEnum].ToString();
					}
					component.thumbnail.sprite = ammoTypeButtons[(int)ammoEnum].GetComponent<Image>().sprite;
				}
				else
				{
					Debug.Log((object)"Supply Raid: No ID found for rounds");
				}
			}
		}

		public void BuySpecificRound(FVRObject fvrObject)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			if (!CanSpawn(SR_Manager.Character().modeRounds, SR_Manager.Character().roundsCost, 3))
			{
				SR_Manager.PlayFailSFX();
				return;
			}
			if ((Object)(object)fvrObject != (Object)null)
			{
				Object.Instantiate<GameObject>(((AnvilAsset)fvrObject).GetGameObject(), Spawnpoint_Round.position, Spawnpoint_Round.rotation);
			}
			SR_Manager.PlayRearmSFX();
		}

		public void TogglePages()
		{
			roundPage.SetActive(ammoPage.activeSelf);
			ammoPage.SetActive(!roundPage.activeSelf);
			((Component)selectionIcon).gameObject.SetActive(!roundPage.activeSelf);
		}

		private void Start()
		{
			instance = this;
			colbuffer = (Collider[])(object)new Collider[50];
		}

		private void Update()
		{
			//IL_002e: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			m_scanTick -= Time.deltaTime;
			if (m_scanTick <= 0f)
			{
				float num = Vector3.Distance(((Component)this).transform.position, ((Component)GM.CurrentPlayerBody).transform.position);
				if (num < 12f)
				{
					Scan();
					m_scanTick = Random.Range(0.8f, 1f);
				}
				else
				{
					m_scanTick = Random.Range(2f, 3f);
				}
			}
			if (((Component)selectionIcon).gameObject.activeSelf && selectedAmmoType != AmmoEnum.None)
			{
				selectionIcon.position = ammoTypeButtons[(int)selectedAmmoType].transform.position;
			}
		}

		public void Setup()
		{
			ammoButtons = new SR_GenericButton[ammoTypeButtons.Length];
			for (int i = 0; i < ammoTypeButtons.Length; i++)
			{
				SR_GenericButton component = ammoTypeButtons[i].GetComponent<SR_GenericButton>();
				ammoButtons[i] = component;
				if (SR_Manager.instance.character.ammoUpgradeCost[i] == 0)
				{
					purchasedAmmoTypes[i] = true;
					component.text.text = "";
				}
				else
				{
					component.text.text = SR_Manager.instance.character.ammoUpgradeCost[i].ToString();
				}
			}
			switch (SR_Manager.instance.character.modeRearming)
			{
			case 0:
				rearmButton.SetActive(false);
				break;
			default:
				rearmButton.SetActive(true);
				rearmButton.GetComponent<FVRPointableButton>().Text.text = "";
				break;
			case 2:
			case 3:
				if (SR_Manager.instance.character.rearmingCost > 0)
				{
					rearmButton.GetComponent<FVRPointableButton>().Text.text = SR_Manager.instance.character.rearmingCost.ToString();
				}
				else
				{
					rearmButton.GetComponent<FVRPointableButton>().Text.text = "";
				}
				break;
			}
			switch (SR_Manager.instance.character.modeSpeedLoaders)
			{
			case 0:
				speedloaderButton.SetActive(false);
				break;
			default:
				speedloaderButton.SetActive(true);
				speedloaderButton.GetComponent<FVRPointableButton>().Text.text = "";
				break;
			case 2:
			case 3:
				if (SR_Manager.instance.character.speedLoadersCost > 0)
				{
					speedloaderButton.GetComponent<FVRPointableButton>().Text.text = SR_Manager.instance.character.speedLoadersCost.ToString();
				}
				else
				{
					speedloaderButton.GetComponent<FVRPointableButton>().Text.text = "";
				}
				break;
			}
			switch (SR_Manager.instance.character.modeClips)
			{
			case 0:
				clipButton.SetActive(false);
				break;
			default:
				clipButton.SetActive(true);
				clipButton.GetComponent<FVRPointableButton>().Text.text = "";
				break;
			case 2:
			case 3:
				if (SR_Manager.instance.character.clipsCost > 0)
				{
					clipButton.GetComponent<FVRPointableButton>().Text.text = SR_Manager.instance.character.clipsCost.ToString();
				}
				else
				{
					clipButton.GetComponent<FVRPointableButton>().Text.text = "";
				}
				break;
			}
			switch (SR_Manager.instance.character.modeRounds)
			{
			case 0:
				roundButton.SetActive(false);
				togglePagesButton.SetActive(false);
				break;
			default:
				roundButton.SetActive(true);
				togglePagesButton.SetActive(true);
				roundButton.GetComponent<FVRPointableButton>().Text.text = "";
				break;
			case 2:
			case 3:
				if (SR_Manager.instance.character.roundsCost > 0)
				{
					roundButton.GetComponent<FVRPointableButton>().Text.text = SR_Manager.instance.character.roundsCost.ToString();
				}
				else
				{
					roundButton.GetComponent<FVRPointableButton>().Text.text = "";
				}
				break;
			}
		}

		public void SetAmmoType(AmmoEnum ammo)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			selectedAmmoType = ammo;
			if (ammoTypeButtons[(int)selectedAmmoType].activeSelf)
			{
				selectionIcon.position = ammoTypeButtons[(int)selectedAmmoType].transform.position;
			}
			else
			{
				((Component)selectionIcon).gameObject.SetActive(false);
			}
		}

		private bool CanSpawn(int mode, int cost, int id)
		{
			if (purchaseButtons[id] || mode <= 1)
			{
				return true;
			}
			if (mode > 1 && cost > 0 && SR_Manager.EnoughPoints(cost) && SR_Manager.SpendPoints(cost))
			{
				if (mode == 2)
				{
					purchaseButtons[id] = true;
					switch (id)
					{
					case 0:
						rearmButton.GetComponent<FVRPointableButton>().Text.text = "";
						break;
					case 1:
						speedloaderButton.GetComponent<FVRPointableButton>().Text.text = "";
						break;
					case 2:
						clipButton.GetComponent<FVRPointableButton>().Text.text = "";
						break;
					case 3:
						roundButton.GetComponent<FVRPointableButton>().Text.text = "";
						break;
					}
				}
				return true;
			}
			return false;
		}

		public void Button_SpawnRound()
		{
			//IL_00c1: 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_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: 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_011b: 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_012b: Unknown result type (might be due to invalid IL or missing references)
			if (m_roundTypes == null || m_roundTypes.Count < 1 || ammoList == null || !CanSpawn(SR_Manager.instance.character.modeRounds, SR_Manager.instance.character.roundsCost, 3))
			{
				SR_Manager.PlayFailSFX();
				return;
			}
			for (int i = 0; i < ammoList.Count; i++)
			{
				if (ammoList[i].roundClasses == null)
				{
					continue;
				}
				for (int j = 0; j < ammoList[i].roundClasses.Count; j++)
				{
					if (ammoList[i].roundClasses[j].ammo == selectedAmmoType)
					{
						FVRObject roundSelfPrefab = AM.GetRoundSelfPrefab(ammoList[i].roundType, ammoList[i].roundClasses[j].roundClass);
						if ((Object)(object)roundSelfPrefab != (Object)null)
						{
							Object.Instantiate<GameObject>(((AnvilAsset)roundSelfPrefab).GetGameObject(), Spawnpoint_Round.position + Vector3.up * (float)i * 0.1f, Spawnpoint_Round.rotation);
							break;
						}
					}
				}
			}
			SR_Manager.PlayRearmSFX();
		}

		public void Button_SpawnSpeedLoader()
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Invalid comparison between Unknown and I4
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			if (!CanSpawn(SR_Manager.instance.character.modeSpeedLoaders, SR_Manager.instance.character.speedLoadersCost, 1))
			{
				SR_Manager.PlayFailSFX();
				return;
			}
			bool flag = false;
			List<FVRObject> list = new List<FVRObject>();
			for (int i = 0; i < m_detectedFirearms.Count; i++)
			{
				if (!IM.OD.ContainsKey(((FVRPhysicalObject)m_detectedFirearms[i]).ObjectWrapper.ItemID))
				{
					continue;
				}
				List<FVRObject> list2 = new List<FVRObject>(ManagerSingleton<IM>.Instance.odicTagCategory[(ObjectCategory)6]);
				for (int num = list2.Count - 1; num >= 0; num--)
				{
					if ((int)list2[num].Category == 6 && list2[num].RoundType == m_detectedFirearms[i].RoundType)
					{
						list.Add(list2[num]);
					}
				}
			}
			for (int j = 0; j < list.Count; j++)
			{
				GameObject gameObject = ((AnvilAsset)list[j]).GetGameObject();
				Speedloader component = gameObject.GetComponent<Speedloader>();
				if (!component.IsPretendingToBeAMagazine)
				{
					flag = true;
					GameObject val = Object.Instantiate<GameObject>(gameObject, Spawnpoint_Round.position + Vector3.up * (float)j * 0.1f, Spawnpoint_Round.rotation);
				}
			}
			if (flag)
			{
				SR_Manager.PlayRearmSFX();
			}
			else
			{
				SR_Manager.PlayFailSFX();
			}
		}

		public void Button_SpawnClip()
		{
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: 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_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			if (!CanSpawn(SR_Manager.instance.character.modeClips, SR_Manager.instance.character.clipsCost, 2))
			{
				SR_Manager.PlayFailSFX();
				return;
			}
			bool flag = false;
			for (int i = 0; i < m_detectedFirearms.Count; i++)
			{
				if (!IM.OD.ContainsKey(((FVRPhysicalObject)m_detectedFirearms[i]).ObjectWrapper.ItemID))
				{
					continue;
				}
				FVRObject val = IM.OD[((FVRPhysicalObject)m_detectedFirearms[i]).ObjectWrapper.ItemID];
				for (int j = 0; j < ammoList.Count; j++)
				{
					if (ammoList[j].roundClasses == null)
					{
						continue;
					}
					for (int k = 0; k < ammoList[j].roundClasses.Count; k++)
					{
						if (ammoList[j].roundClasses[k].ammo != selectedAmmoType)
						{
							continue;
						}
						if (val.CompatibleClips.Count > 0 && ammoList[j].roundType == val.CompatibleClips[0].RoundType)
						{
							flag = true;
							FVRObject val2 = val.CompatibleClips[0];
							GameObject val3 = Object.Instantiate<GameObject>(((AnvilAsset)val2).GetGameObject(), Spawnpoint_Round.position + Vector3.up * (float)i * 0.1f, Spawnpoint_Round.rotation);
							FVRFireArmClip component = val3.GetComponent<FVRFireArmClip>();
							component.ReloadClipWithType(ammoList[j].roundClasses[k].roundClass);
						}
						else if (val.CompatibleMagazines.Count > 0 && ammoList[j].roundType == val.CompatibleMagazines[0].RoundType)
						{
							GameObject gameObject = ((AnvilAsset)val.CompatibleMagazines[0]).GetGameObject();
							FVRFireArmMagazine component2 = gameObject.GetComponent<FVRFireArmMagazine>();
							if (component2.IsEnBloc)
							{
								flag = true;
								GameObject val4 = Object.Instantiate<GameObject>(gameObject, Spawnpoint_Round.position + Vector3.up * (float)i * 0.1f, Spawnpoint_Round.rotation);
								component2 = val4.GetComponent<FVRFireArmMagazine>();
								component2.ReloadMagWithType(ammoList[j].roundClasses[k].roundClass);
							}
						}
					}
				}
			}
			if (flag)
			{
				SR_Manager.PlayRearmSFX();
			}
			else
			{
				SR_Manager.PlayFailSFX();
			}
		}

		public void Button_ReloadGuns()
		{
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			if (!CanSpawn(SR_Manager.instance.character.modeRearming, SR_Manager.instance.character.rearmingCost, 0))
			{
				SR_Manager.PlayFailSFX();
				return;
			}
			if (m_detectedMags.Count < 1 && m_detectedClips.Count < 1 && m_detectedSLs.Count < 1 && m_detectedSweapons.Count < 1)
			{
				SR_Manager.PlayFailSFX();
				return;
			}
			for (int i = 0; i < ammoList.Count; i++)
			{
				if (ammoList[i].roundClasses == null)
				{
					continue;
				}
				for (int j = 0; j < ammoList[i].roundClasses.Count; j++)
				{
					if (ammoList[i].roundClasses[j].ammo != selectedAmmoType)
					{
						continue;
					}
					for (int k = 0; k < m_detectedMags.Count; k++)
					{
						if (ammoList[i].roundType == m_detectedMags[k].RoundType)
						{
							m_detectedMags[k].ReloadMagWithType(ammoList[i].roundClasses[j].roundClass);
						}
					}
					for (int l = 0; l < m_detectedClips.Count; l++)
					{
						if (ammoList[i].roundType == m_detectedClips[l].RoundType)
						{
							m_detectedClips[l].ReloadClipWithType(ammoList[i].roundClasses[j].roundClass);
						}
					}
					for (int m = 0; m < m_detectedSLs.Count; m++)
					{
						if (ammoList[i].roundType == m_detectedSLs[m].Chambers[0].Type)
						{
							m_detectedSLs[m].ReloadClipWithType(ammoList[i].roundClasses[j].roundClass);
						}
					}
					for (int n = 0; n < m_detectedSweapons.Count; n++)
					{
						m_detectedSweapons[n].W.InstaReload();
					}
				}
			}
			SR_Manager.PlayRearmSFX();
		}

		private FireArmRoundClass GetFirearmRoundClassFromType(string itemID, FireArmRoundType t)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < AM.SRoundDisplayDataDic[t].Classes.Length; i++)
			{
				if (AM.SRoundDisplayDataDic[t].Classes[i].ObjectID.ItemID == itemID)
				{
					return AM.SRoundDisplayDataDic[t].Classes[i].Class;
				}
			}
			return AM.SRoundDisplayDataDic[t].Classes[0].Class;
		}

		private void Scan()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Invalid comparison between Unknown and I4
			//IL_0305: 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_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Invalid comparison between Unknown and I4
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Invalid comparison between Unknown and I4
			int num = Physics.OverlapBoxNonAlloc(ScanningVolume.position, ScanningVolume.localScale * 0.5f, colbuffer, ScanningVolume.rotation, LayerMask.op_Implicit(ScanningLM), (QueryTriggerInteraction)2);
			m_roundTypes.Clear();
			m_detectedMags.Clear();
			m_detectedClips.Clear();
			m_detectedSLs.Clear();
			m_detectedSweapons.Clear();
			m_detectedFirearms.Clear();
			for (int i = 0; i < num; i++)
			{
				if (!((Object)(object)colbuffer[i].attachedRigidbody != (Object)null))
				{
					continue;
				}
				FVRFireArm component = ((Component)colbuffer[i].attachedRigidbody).gameObject.GetComponent<FVRFireArm>();
				if ((Object)(object)component != (Object)null && (int)component.RoundType != 993)
				{
					if (!m_detectedFirearms.Contains(component))
					{
						m_detectedFirearms.Add(component);
					}
					if (!m_roundTypes.Contains(component.RoundType))
					{
						m_roundTypes.Add(component.RoundType);
					}
					if ((Object)(object)component.Magazine != (Object)null && !m_detectedMags.Contains(component.Magazine))
					{
						m_detectedMags.Add(component.Magazine);
					}
					if (((FVRPhysicalObject)component).Attachments.Count > 0)
					{
						for (int j = 0; j < ((FVRPhysicalObject)component).Attachments.Count; j++)
						{
							if (((FVRPhysicalObject)component).Attachments[j] is AttachableFirearmPhysicalObject)
							{
								List<FireArmRoundType> roundTypes = m_roundTypes;
								FVRFireArmAttachment obj = ((FVRPhysicalObject)component).Attachments[j];
								if (!roundTypes.Contains(((AttachableFirearmPhysicalObject)((obj is AttachableFirearmPhysicalObject) ? obj : null)).FA.RoundType))
								{
									List<FireArmRoundType> roundTypes2 = m_roundTypes;
									FVRFireArmAttachment obj2 = ((FVRPhysicalObject)component).Attachments[j];
									roundTypes2.Add(((AttachableFirearmPhysicalObject)((obj2 is AttachableFirearmPhysicalObject) ? obj2 : null)).FA.RoundType);
								}
								FVRFireArmAttachment obj3 = ((FVRPhysicalObject)component).Attachments[j];
								if ((Object)(object)((AttachableFirearmPhysicalObject)((obj3 is AttachableFirearmPhysicalObject) ? obj3 : null)).FA.Magazine != (Object)null)
								{
									List<FVRFireArmMagazine> detectedMags = m_detectedMags;
									FVRFireArmAttachment obj4 = ((FVRPhysicalObject)component).Attachments[j];
									detectedMags.Add(((AttachableFirearmPhysicalObject)((obj4 is AttachableFirearmPhysicalObject) ? obj4 : null)).FA.Magazine);
								}
							}
						}
					}
					if ((Object)(object)component.GetIntegratedAttachableFirearm() != (Object)null && !m_roundTypes.Contains(component.GetIntegratedAttachableFirearm().RoundType))
					{
						m_roundTypes.Add(component.GetIntegratedAttachableFirearm().RoundType);
					}
				}
				AttachableFirearmPhysicalObject component2 = ((Component)colbuffer[i].attachedRigidbody).gameObject.GetComponent<AttachableFirearmPhysicalObject>();
				if ((Object)(object)component2 != (Object)null && !m_roundTypes.Contains(component2.FA.RoundType))
				{
					m_roundTypes.Add(component2.FA.RoundType);
				}
				FVRFireArmMagazine component3 = ((Component)colbuffer[i].attachedRigidbody).gameObject.GetComponent<FVRFireArmMagazine>();
				if ((Object)(object)component3 != (Object)null && (Object)(object)component3.FireArm == (Object)null && !m_detectedMags.Contains(component3) && (int)component3.RoundType != 993)
				{
					m_detectedMags.Add(component3);
				}
				FVRFireArmClip component4 = ((Component)colbuffer[i].attachedRigidbody).gameObject.GetComponent<FVRFireArmClip>();
				if ((Object)(object)component4 != (Object)null && (Object)(object)component4.FireArm == (Object)null && !m_detectedClips.Contains(component4))
				{
					m_detectedClips.Add(component4);
				}
				Speedloader component5 = ((Component)colbuffer[i].attachedRigidbody).gameObject.GetComponent<Speedloader>();
				if ((Object)(object)component5 != (Object)null && !m_detectedSLs.Contains(component5))
				{
					m_detectedSLs.Add(component5);
				}
				if ((int)SR_Manager.instance.shakeReloading == 1)
				{
					SosigWeaponPlayerInterface component6 = ((Component)colbuffer[i].attachedRigidbody).gameObject.GetComponent<SosigWeaponPlayerInterface>();
					if ((Object)(object)component6 != (Object)null && !m_detectedSweapons.Contains(component6))
					{
						m_detectedSweapons.Add(component6);
					}
				}
			}
			UpdateAmmoTypeDisplay();
		}

		private void UpdateAmmoTypeDisplay()
		{
			//IL_002b: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			allRoundTypes.Clear();
			ammoList.Clear();
			for (int i = 0; i < m_roundTypes.Count; i++)
			{
				if (!allRoundTypes.Contains(m_roundTypes[i]))
				{
					allRoundTypes.Add(m_roundTypes[i]);
				}
			}
			for (int j = 0; j < m_detectedMags.Count; j++)
			{
				if (!allRoundTypes.Contains(m_detectedMags[j].RoundType))
				{
					allRoundTypes.Add(m_detectedMags[j].RoundType);
				}
			}
			for (int k = 0; k < m_detectedClips.Count; k++)
			{
				if (!allRoundTypes.Contains(m_detectedClips[k].RoundType))
				{
					allRoundTypes.Add(m_detectedClips[k].RoundType);
				}
			}
			for (int l = 0; l < m_detectedSLs.Count; l++)
			{
				if (!allRoundTypes.Contains(m_detectedSLs[l].Chambers[0].Type))
				{
					allRoundTypes.Add(m_detectedSLs[l].Chambers[0].Type);
				}
			}
			for (int m = 0; m < allRoundTypes.Count; m++)
			{
				AmmoRound ammoRound = new AmmoRound();
				ammoRound.roundType = allRoundTypes[m];
				ammoRound.roundClasses = new List<AmmoClass>();
				ammoList.Add(ammoRound);
			}
			ClearAmmoButtons();
			if (ammoList.Count == 0)
			{
				((Component)selectionIcon).gameObject.SetActive(false);
				SetAmmoType(AmmoEnum.Standard);
				UpdateDisplayButtons();
				return;
			}
			if (roundPage.activeSelf)
			{
				PopulateRoundPage();
			}
			SetAmmoType(selectedAmmoType);
			UpdateAmmoList();
		}

		private void UpdateAmmoList()
		{
			//IL_0032: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < ammoList.Count; i++)
			{
				if (ammoList[i] == null)
				{
					continue;
				}
				AM.STypeClassLists.TryGetValue(ammoList[i].roundType, out var value);
				if (value != null)
				{
					int count = value.Count;
					ammoList[i].roundClasses.Clear();
					for (int j = 0; j < count; j++)
					{
						FireArmRoundClass round = value[j];
						AmmoClass item = new AmmoClass
						{
							roundClass = round,
							ammo = SR_Global.GetAmmoEnum(round),
							isOnlyType = true
						};
						ammoList[i].roundClasses.Add(item);
					}
				}
			}
			UpdateDisplayButtons();
		}

		private void ClearAmmoButtons()
		{
			for (int i = 0; i < roundButtons.Count; i++)
			{
				if (Object.op_Implicit((Object)(object)roundButtons[i]))
				{
					Object.Destroy((Object)(object)((Component)roundButtons[i]).gameObject);
				}
			}
		}

		private void UpdateDisplayButtons()
		{
			((Component)selectionIcon).gameObject.SetActive(false);
			for (int i = 0; i < ammoTypeButtons.Length; i++)
			{
				if ((Object)(object)ammoTypeButtons[i] != (Object)null)
				{
					ammoTypeButtons[i].SetActive(false);
				}
			}
			for (int j = 0; j < ammoList.Count; j++)
			{
				if (ammoList[j].roundClasses == null)
				{
					continue;
				}
				for (int k = 0; k < ammoList[j].roundClasses.Count; k++)
				{
					if (!((Object)(object)ammoTypeButtons[(int)ammoList[j].roundClasses[k].ammo] == (Object)null) && SR_Manager.instance.character.ammoUpgradeCost[(int)ammoList[j].roundClasses[k].ammo] > -1 && SR_Manager.instance.character.ammoUpgradeCost[(int)ammoList[j].roundClasses[k].ammo] >= 0 && ammoPage.activeSelf)
					{
						ammoTypeButtons[(int)ammoList[j].roundClasses[k].ammo].SetActive(true);
						if (purchasedAmmoTypes[(int)ammoList[j].roundClasses[k].ammo])
						{
							SetSelectionIcon((int)selectedAmmoType);
						}
					}
				}
			}
			if (ammoList.Count > 0 && ammoPage.activeSelf)
			{
				SetSelectionIcon((int)selectedAmmoType);
			}
		}

		private void SetSelectionIcon(int i)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			((Component)selectionIcon).gameObject.SetActive(true);
			selectionIcon.position = ammoTypeButtons[i].transform.position;
		}

		private void OnDrawGizmos()
		{
			//IL_0001: 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_001d: 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)
			Gizmos.color = Color.yellow;
			Gizmos.DrawWireCube(ScanningVolume.position, ScanningVolume.localScale * 0.5f);
		}
	}
	[CreateAssetMenu(fileName = "SR Assets", menuName = "Supply Raid/SR Assets", order = 1)]
	public class SR_Assets : ScriptableObject
	{
		[Header("Gameplay")]
		public SR_Compass srCompass;

		public SR_CaptureZone srCaptureZone;

		public SR_Manager srManager;

		[Header("Menus")]
		public SR_Menu srMenu;

		public SR_BuyMenu srBuyMenu;

		public SR_AmmoSpawner srAmmoSpawner;

		public SR_MagazineDuplicator srMagazineDuplicator;

		public SR_ModTable srModTable;

		public SR_Recycler srRecycler;

		public SR_ResultsMenu srResultsMenu;

		public SR_SpawnMenu srSpawnMenu;

		public SR_SpawnStation srSpawnStation;
	}
	public class SR_BuyMenu : MonoBehaviour
	{
		public class CategoryButton
		{
			public GameObject categoryButton;

			public SR_ItemCategory itemCategory;
		}

		public static SR_BuyMenu instance;

		public List<CategoryButton> categoryItems = new List<CategoryButton>();

		[Header("Spawn Points")]
		[SerializeField]
		private Transform[] spawnPoints;

		[Header("Loot Tables")]
		private List<SR_PurchaseCategory> purchaseCategories = new List<SR_PurchaseCategory>();

		private LootTable[] lootTables;

		[Header("Prefabs")]
		[SerializeField]
		private GameObject buttonTabPrefab;

		[SerializeField]
		private GameObject buttonContainerPrefab;

		[SerializeField]
		private GameObject buyButtonPrefab;

		[Header("Tabs")]
		[SerializeField]
		private Transform tabContainer;

		[SerializeField]
		private BuyMenuContainer[] tabContainers;

		public Text pointDisplay;

		private void Awake()
		{
			instance = this;
		}

		public void Setup()
		{
			if ((Object)(object)SR_Manager.instance != (Object)null)
			{
				SR_Manager.PointEvent += UpdatePoints;
				SR_Manager.LaunchedEvent += StartGame;
				pointDisplay.text = SR_Manager.instance.Points.ToString();
			}
		}

		private void OnDestroy()
		{
			SR_Manager.PointEvent -= UpdatePoints;
			SR_Manager.LaunchedEvent -= StartGame;
		}

		private void Update()
		{
		}

		private void StartGame()
		{
			purchaseCategories = SR_Manager.instance.character.purchaseCategories;
			GenerateLootTables();
			GenerateButtons();
		}

		public void OpenMenu(int index)
		{
			for (int i = 0; i < tabContainers.Length; i++)
			{
				if (Object.op_Implicit((Object)(object)tabContainers[i].container))
				{
					tabContainers[i].container.SetActive(false);
				}
			}
			tabContainers[index].container.SetActive(true);
			SR_Manager.PlayConfirmSFX();
		}

		private void UpdatePoints(int i)
		{
			if ((Object)(object)SR_Manager.instance != (Object)null)
			{
				pointDisplay.text = SR_Manager.instance.Points.ToString();
			}
		}

		private void GenerateButtons()
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected I4, but got Unknown
			List<string> list = new List<string>();
			for (int i = 0; i < purchaseCategories.Count; i++)
			{
				if (list.Contains(purchaseCategories[i].ItemCategory().category))
				{
					continue;
				}
				if (purchaseCategories[i].ItemCategory().category == "")
				{
					LootTableType type = purchaseCategories[i].ItemCategory().type;
					LootTableType val = type;
					string text = (int)val switch
					{
						1 => "Standard_Powerup", 
						2 => "Standard_Thrown", 
						3 => "Standard_Attachments", 
						4 => "Standard_Melee", 
						_ => "Standard_Firearm", 
					};
					if (!list.Contains(text))
					{
						list.Add(text);
					}
					purchaseCategories[i].ItemCategory().category = text;
				}
				else
				{
					list.Add(purchaseCategories[i].ItemCategory().category);
				}
			}
			tabContainers = new BuyMenuContainer[list.Count];
			for (int j = 0; j < tabContainers.Length; j++)
			{
				tabContainers[j] = new BuyMenuContainer();
				tabContainers[j].name = list[j];
				tabContainers[j].container = Object.Instantiate<GameObject>(buttonContainerPrefab, buttonContainerPrefab.transform.parent);
				tabContainers[j].container.SetActive(false);
				tabContainers[j].tabButton = Object.Instantiate<GameObject>(buttonTabPrefab, tabContainer).GetComponent<SR_GenericButton>();
				((Component)tabContainers[j].tabButton).gameObject.SetActive(true);
				tabContainers[j].tabButton.index = j;
				if (tabContainers[j].name != "")
				{
					string[] files = Directory.GetFiles(Paths.PluginPath, "*" + tabContainers[j].name + ".png", SearchOption.AllDirectories);
					if (files.Length != 0 && files[0] != "")
					{
						Sprite sprite = SR_Global.LoadSprite(files[0]);
						tabContainers[j].tabButton.thumbnail.sprite = sprite;
					}
				}
				else
				{
					Debug.LogError((object)("Supply Raid: No Icon found for category " + tabContainers[j].name));
				}
			}
			for (int k = 0; k < purchaseCategories.Count; k++)
			{
				if (purchaseCategories[k].ItemCategory().objectGroups.Count == 0 && lootTables[k].Loot.Count == 0)
				{
					continue;
				}
				for (int l = 0; l < tabContainers.Length; l++)
				{
					if (purchaseCategories[k].ItemCategory().category == tabContainers[l].name)
					{
						SR_GenericButton component = Object.Instantiate<GameObject>(buyButtonPrefab, tabContainers[l].container.transform).GetComponent<SR_GenericButton>();
						((Component)component).gameObject.SetActive(true);
						component.index = k;
						component.thumbnail.sprite = purchaseCategories[k].ItemCategory().Thumbnail();
						component.text.text = purchaseCategories[k].cost.ToString();
						((Object)component).name = purchaseCategories[k].ItemCategory().name;
						CategoryButton categoryButton = new CategoryButton();
						categoryButton.itemCategory = purchaseCategories[k].ItemCategory();
						categoryButton.categoryButton = ((Component)component).gameObject;
						categoryItems.Add(categoryButton);
						break;
					}
				}
			}
			UpdateBuyItems();
		}

		public void UpdateBuyItems()
		{
			for (int i = 0; i < categoryItems.Count; i++)
			{
				if (categoryItems[i] != null)
				{
					if ((categoryItems[i].itemCategory.minLevel == -1 || categoryItems[i].itemCategory.minLevel <= SR_Manager.instance.CurrentCaptures) && (categoryItems[i].itemCategory.maxLevel == -1 || categoryItems[i].itemCategory.maxLevel >= SR_Manager.instance.CurrentCaptures))
					{
						categoryItems[i].categoryButton.SetActive(true);
					}
					else
					{
						categoryItems[i].categoryButton.SetActive(false);
					}
				}
			}
		}

		public void SpawnLootButton(int i)
		{
			if (i > lootTables.Length || i > purchaseCategories.Count)
			{
				SR_Manager.PlayFailSFX();
			}
			else if (SR_Manager.EnoughPoints(purchaseCategories[i].cost))
			{
				if (SR_Global.SpawnLoot(lootTables[i], purchaseCategories[i].ItemCategory(), spawnPoints))
				{
					SR_Manager.PlayConfirmSFX();
					SR_Manager.SpendPoints(purchaseCategories[i].cost);
				}
				else
				{
					SR_Manager.PlayFailSFX();
				}
			}
			else
			{
				SR_Manager.PlayFailSFX();
			}
		}

		private void GenerateLootTables()
		{
			Debug.Log((object)("Supply Raid: Purchase Items: " + purchaseCategories.Count));
			lootTables = (LootTable[])(object)new LootTable[purchaseCategories.Count];
			for (int i = 0; i < purchaseCategories.Count; i++)
			{
				if (purchaseCategories[i] != null)
				{
					lootTables[i] = purchaseCategories[i].ItemCategory().InitializeLootTable();
				}
				else
				{
					Debug.Log((object)"Supply Raid: Missing Purchase Category");
				}
			}
		}

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

		public void SpawnAmmoAtPlaceForGun(FVRObject gun, Vector3 pos, Quaternion rotation)
		{
			//IL_0033: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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_011c: Unknown result type (might be due to invalid IL or missing references)
			if (gun.CompatibleMagazines.Count > 0)
			{
				SpawnObjectAtPlace(gun.CompatibleMagazines[Random.Range(0, gun.CompatibleMagazines.Count - 1)], pos, rotation);
			}
			else if (gun.CompatibleClips.Count > 0)
			{
				SpawnObjectAtPlace(gun.CompatibleClips[Random.Range(0, gun.CompatibleClips.Count - 1)], pos, rotation);
			}
			else if (gun.CompatibleSpeedLoaders.Count > 0)
			{
				SpawnObjectAtPlace(gun.CompatibleSpeedLoaders[Random.Range(0, gun.CompatibleSpeedLoaders.Count - 1)], pos, rotation);
			}
			else if (gun.CompatibleSingleRounds.Count > 0)
			{
				int num = Random.Range(2, 5);
				for (int i = 0; i < num; i++)
				{
					Vector3 pos2 = pos + Vector3.up * (0.05f * (float)i);
					SpawnObjectAtPlace(gun.CompatibleSingleRounds[Random.Range(0, gun.CompatibleSingleRounds.Count - 1)], pos2, rotation);
				}
			}
		}
	}
	[Serializable]
	public class BuyMenuContainer
	{
		public string name;

		public SR_GenericButton tabButton;

		public SR_GenericButton[] buttons;

		public GameObject container;
	}
	public class SR_CaptureZone : MonoBehaviour
	{
		public bool replaced = false;

		public Transform zone;

		[HideInInspector]
		public float captureRemain = 15f;

		private float captureTick = 1f;

		[Header("Audio")]
		private Bounds bounds;

		private float guardCaptureTime = 0f;

		private void Start()
		{
			((Component)this).gameObject.SetActive(false);
			if ((Object)(object)SR_Manager.instance.captureZone != (Object)(object)this)
			{
				((Component)this).gameObject.SetActive(false);
			}
		}

		private void Update()
		{
			if (Object.op_Implicit((Object)(object)SR_Compass.instance))
			{
				if (SR_Manager.instance.gameRunning && SR_Manager.profile.captureZone)
				{
					CaptureZoneScan();
				}
				else
				{
					((Component)this).gameObject.SetActive(false);
				}
			}
		}

		private void CaptureZoneScan()
		{
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			captureTick -= Time.deltaTime;
			if (!(captureTick <= 0f))
			{
				return;
			}
			if (WithinCaptureZone())
			{
				captureRemain -= 1f;
				if (captureRemain < 0f)
				{
					captureRemain = 0f;
				}
				captureTick = 1f;
				if (guardCaptureTime < Time.time)
				{
					guardCaptureTime = Time.time + (float)Random.Range(2, 10);
					for (int i = 0; i < SR_Manager.instance.defenderSosigs.Count; i++)
					{
						Sosig val = SR_Manager.instance.defenderSosigs[i];
						Transform captureZone = SR_Manager.AttackSupplyPoint().captureZone;
						float num = captureZone.localScale.x / 2f;
						float num2 = captureZone.localScale.z / 2f;
						Vector3 val2 = captureZone.position + new Vector3(Random.Range(0f - num, num), 0f, Random.Range(0f - num2, num2));
						val.CommandGuardPoint(val2, false);
					}
				}
				if (captureRemain > 5f)
				{
					SR_Manager.PlayTickSFX();
				}
				else
				{
					SR_Manager.PlayTickAlmostSFX();
				}
				if (Object.op_Implicit((Object)(object)SR_Compass.instance) && !((Component)SR_Compass.instance.captureText).gameObject.activeSelf)
				{
					((Component)SR_Compass.instance.captureText).gameObject.SetActive(true);
				}
				if (Object.op_Implicit((Object)(object)SR_Compass.instance))
				{
					SR_Compass.instance.captureText.text = Mathf.RoundToInt(captureRemain).ToString();
				}
				if (captureRemain <= 0f)
				{
					if (Networking.IsClient())
					{
						Transform obj = zone;
						obj.position -= Vector3.up * 100f;
						SR_Networking.instance.CapturedZone_Send();
					}
					else if (SR_Manager.instance.captureProtection <= 0f)
					{
						SR_Manager.instance.CapturedPoint();
					}
					captureRemain = SR_Manager.AttackSupplyPoint().captureTime;
					captureTick = Random.Range(0, 3);
					if (Object.op_Implicit((Object)(object)SR_Compass.instance))
					{
						((Component)SR_Compass.instance.captureText).gameObject.SetActive(false);
					}
				}
				return;
			}
			if (Object.op_Implicit((Object)(object)SR_Compass.instance) && ((Component)SR_Compass.instance.captureText).gameObject.activeSelf)
			{
				if (SR_Manager.instance.captureProtection <= 0f)
				{
					SR_Manager.PlayFailSFX();
				}
				if (Object.op_Implicit((Object)(object)SR_Compass.instance))
				{
					((Component)SR_Compass.instance.captureText).gameObject.SetActive(false);
				}
			}
			captureRemain = SR_Manager.AttackSupplyPoint().captureTime;
			captureTick = Random.Range(0, 2);
		}

		public void MoveCaptureZone(Transform point)
		{
			//IL_0008: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			zone.position = point.position;
			zone.localScale = point.localScale;
			zone.rotation = point.rotation;
			((Bounds)(ref bounds)).center = zone.position;
			((Bounds)(ref bounds)).size = zone.localScale;
			captureRemain = SR_Manager.AttackSupplyPoint().captureTime;
		}

		private bool WithinCaptureZone()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_0047: 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_006a: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Quaternion.Inverse(zone.rotation) * (GM.CurrentPlayerBody.Head.position - zone.position);
			return Mathf.Abs(val.x) <= zone.localScale.x / 2f && Mathf.Abs(val.y) <= zone.localScale.y / 2f && Mathf.Abs(val.z) <= zone.localScale.z / 2f;
		}
	}
	[Serializable]
	public class SR_CharacterPreset
	{
		[Tooltip("(REQUIRED) Name of this character")]
		public string name = "Character Name";

		[Tooltip("Short explanation of this character")]
		[Multiline(6)]
		public string description = "Put a brief explination of the character here";

		[Tooltip("(REQUIRED) The menu category this character will go in, Recommend mod creator names etc")]
		public string category = "Mod";

		public string factionName = "";

		[Tooltip("Points player receives per capture, endless reuses the last array position")]
		public int[] pointsLevel = new int[1];

		public bool pointsCatchup = true;

		[Tooltip("Cost of a new Magazine - if -1 disable")]
		public float newMagazineCost = 1f;

		[Tooltip("Cost of upgrading a magazine - if -1 disable")]
		public float upgradeMagazineCost = 2f;

		[Tooltip("Cost of Duplicating a magazine - if -1 disable")]
		public float duplicateMagazineCost = 1f;

		public float[] powerMultiplier = new float[10];

		public bool perRound = false;

		[Tooltip("Custom Mod Cost")]
		public int modCost = 1;

		[Tooltip("How many points the players get for recycling weapons")]
		public int recyclerPoints = 1;

		[Tooltip("How many points the players get for recycling the golden token")]
		public int recyclerTokens = 1;

		[Tooltip("0 = False\n1 = True\n3 = Buy Once\n 4 = Pay Every Time")]
		public int modeRearming = 1;

		public int rearmingCost = 0;

		[Tooltip("0 = False\n1 = True\n3 = Buy Once\n 4 = Pay Every Time")]
		public int modeSpeedLoaders = 1;

		public int speedLoadersCost = 0;

		[Tooltip("0 = False\n1 = True\n3 = Buy Once\n 4 = Pay Every Time")]
		public int modeClips = 1;

		public int clipsCost = 0;

		[Tooltip("0 = False\n1 = True\n3 = Buy Once\n 4 = Pay Every Time")]
		public int modeRounds = 1;

		public int roundsCost = 0;

		public bool disableAmmoTable = false;

		public bool disableModtable = false;

		public bool disableBuyMenu = false;

		public bool disableDuplicator = false;

		public bool disableRecycler = false;

		[Tooltip("Cost of each ammo upgrade, 0 is normally free as its the standard - 28 Ammo Types - if set to -1 disable")]
		public int[] ammoUpgradeCost = new int[28];

		[Tooltip("Cost of each attachment - 17 Attachment Types, if set to -1 disable")]
		public int[] attachmentsCost = new int[17];

		public List<string> startGearCategories = new List<string>();

		[Tooltip("(REQUIRED) What buy categories are available to this character")]
		public List<SR_PurchaseCategory> purchaseCategories = new List<SR_PurchaseCategory>();

		public List<SR_LootCategory> lootCategories = new List<SR_LootCategory>();

		[Tooltip("Globally Removes these ObjectIDs from ALL system including Attachments and Ammo types")]
		public List<string> subtractionObjectIDs = new List<string>();

		[Tooltip("These objectIDs won't drop off the player")]
		public List<string> dropProtectionObjectIDs = new List<string>();

		[Tooltip("Preview image of the character when selected")]
		private Sprite thumbnail;

		private int[] startGearIndex = new int[0];

		private string thumbnailPath = "";

		public void SetupCharacterPreset(List<SR_ItemCategory> items)
		{
			startGearIndex = new int[startGearCategories.Count];
			for (int i = 0; i < startGearCategories.Count; i++)
			{
				startGearIndex[i] = -1;
				for (int j = 0; j < items.Count; j++)
				{
					if (items[j] != null && startGearCategories[i] == items[j].name)
					{
						startGearIndex[i] = j;
						break;
					}
				}
				if (startGearIndex[i] == -1)
				{
					Debug.LogError((object)("Supply Raid: Missing character start gear index: " + i));
				}
			}
			List<SR_PurchaseCategory> list = new List<SR_PurchaseCategory>();
			for (int k = 0; k < purchaseCategories.Count; k++)
			{
				for (int l = 0; l < items.Count; l++)
				{
					if (purchaseCategories[k].itemCategory == items[l].name)
					{
						purchaseCategories[k].SetIndex(l);
						break;
					}
				}
				if (purchaseCategories[k].GetIndex() == -1)
				{
					Debug.Log((object)("Supply Raid: Purchase Category " + purchaseCategories[k].itemCategory + " could not set item Category"));
					list.Add(purchaseCategories[k]);
				}
			}
			for (int m = 0; m < list.Count; m++)
			{
				purchaseCategories.Remove(list[m]);
			}
			List<SR_LootCategory> list2 = new List<SR_LootCategory>();
			for (int n = 0; n < lootCategories.Count; n++)
			{
				if (lootCategories[n].GetIndex() != -1)
				{
					continue;
				}
				for (int num = 0; num < items.Count; num++)
				{