Decompiled source of SafehouseProgression v1.1.4

NGA.SafehouseProgression.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using Atlas;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FistVR;
using FistVR.Ugc;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Sodalite.ModPanel;
using UnityEngine;
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("NGA")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Persistent player progression! Raid, stash loot, and deploy with seemless scene/loadout saving.")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1")]
[assembly: AssemblyProduct("NGA.SafehouseProgression")]
[assembly: AssemblyTitle("BepInEx Plugin Title")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace 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 NGA
{
	[BepInPlugin("NGA.SafehouseProgression", "SafehouseProgression", "0.0.1")]
	[BepInDependency("nrgill28.Sodalite", "1.4.1")]
	[BepInDependency("nrgill28.Atlas", "1.0.0")]
	[BepInProcess("h3vr.exe")]
	public class SafehouseProgression : BaseUnityPlugin
	{
		public struct MyWristButton
		{
			public Action<object> onclick;

			public string name;

			public int priority;

			public MyWristButton(string name_, int priority_, Action<object> clickAction = null)
			{
				onclick = clickAction;
				name = name_;
				priority = priority_;
			}
		}

		[HarmonyPatch(typeof(FVRWristMenu2))]
		[HarmonyPatch("Awake")]
		private class WristMenuAwakeHook
		{
			private static void Postfix(FVRWristMenu2 __instance)
			{
				if ((Object)(object)__instance == (Object)null)
				{
					Logger.LogMessage((object)"FVRWristMenu2 is null!?");
				}
				Dictionary<GameObject, MyWristButton> existingButtons = new Dictionary<GameObject, MyWristButton>();
				FVRWristMenuSection_Safehouse fVRWristMenuSection_Safehouse = AddWristMenuSectionAndButton(__instance, null, "Safehouse™", existingButtons, new MyWristButton("Extract-to-Safehouse", 3, ExtractToSafehouse));
				AddWristMenuSectionAndButton(__instance, fVRWristMenuSection_Safehouse, "Safehouse", existingButtons, new MyWristButton("Leave-the-Safehouse", 2, LeaveTheSafehouse));
				AddWristMenuSectionAndButton(__instance, fVRWristMenuSection_Safehouse, "Safehouse", existingButtons, new MyWristButton("Deployment-Loadout", 1, DeploySafehouseLoadout));
				int num = 0;
				foreach (GameObject item in existingButtons.Keys.OrderBy((GameObject x) => existingButtons[x].priority))
				{
					Text componentInChildren = ((Component)item.transform).GetComponentInChildren<Text>();
					if (num == 0)
					{
						fVRWristMenuSection_Safehouse.TXT_Deploy = componentInChildren;
					}
					if (num == 1)
					{
						fVRWristMenuSection_Safehouse.TXT_Leave = componentInChildren;
					}
					if (num == 2)
					{
						fVRWristMenuSection_Safehouse.TXT_Extract = componentInChildren;
					}
					num++;
				}
			}
		}

		[HarmonyPatch(typeof(FVRSceneSettings))]
		[HarmonyPatch("LoadDefaultSceneRoutine")]
		private class FVRSceneSettingsLoadDefaultSceneRoutineHook
		{
			private static void Prefix(FVRSceneSettings __instance)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				Scene activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).name == GetSafehouseName() && extracting_to_safehouse_need_map && Object.op_Implicit((Object)(object)GM.CurrentSceneSettings) && (Object)(object)GM.CurrentSceneSettings.DefaultVaultSceneConfig != (Object)null)
				{
					GM.CurrentSceneSettings.DefaultVaultSceneConfig = null;
				}
			}

			private static void Postfix(FVRSceneSettings __instance)
			{
				//IL_0028: 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_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)__instance == (Object)null)
				{
					Logger.LogMessage((object)"FVRSceneSettings is null!?");
				}
				ManualLogSource logger = Logger;
				Scene activeScene = SceneManager.GetActiveScene();
				logger.LogMessage((object)("Trying to save in scene: " + ((Scene)(ref activeScene)).name));
				activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).name == GetSafehouseName() && extracting_to_safehouse_need_map)
				{
					extracting_to_safehouse_need_map = false;
					string safehouseName = GetSafehouseName();
					string text = default(string);
					if (!TryGetLocalVaultFile((VaultFileType)3, safehouse_persistent_filename, safehouseName, out var vaultFile))
					{
						Logger.LogMessage((object)"WARNING: Didn't find Safehouse file to load :(");
					}
					else if (!VaultSystem.SpawnObjects((VaultFileType)3, vaultFile, ref text, (Transform)null, Vector3.up))
					{
						Logger.LogMessage((object)"ERROR: Loading extracted safehouse scene file failed :(");
						Logger.LogMessage((object)text);
					}
				}
			}
		}

		[HarmonyPatch(typeof(FVRPlayerBody))]
		[HarmonyPatch("Init")]
		private class FvrPlayerBodyInitHook
		{
			private static void Postfix(FVRPlayerBody __instance, FVRSceneSettings SceneSettings)
			{
				//IL_006f: 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_0091: Unknown result type (might be due to invalid IL or missing references)
				Logger.LogMessage((object)"FVRPlayerBody Init HOOKED!");
				if ((Object)(object)__instance == (Object)null)
				{
					Logger.LogMessage((object)"FVRPlayerBody is null!?");
				}
				else
				{
					if (!extracting_to_safehouse_need_loadout)
					{
						return;
					}
					extracting_to_safehouse_need_loadout = false;
					if (!TryGetLocalVaultFile((VaultFileType)2, raid_extracted_loadout_filename, null, out var vaultFile))
					{
						Logger.LogMessage((object)"ERROR: Extraction loadout file not found :(");
						return;
					}
					Transform transform = new GameObject().transform;
					transform.position = ((Component)__instance).transform.position;
					string text = default(string);
					if (VaultSystem.SpawnObjects((VaultFileType)2, vaultFile, ref text, transform, Vector3.zero))
					{
						UgcManager.DeleteItem((IUgcItem)(object)vaultFile);
						return;
					}
					Logger.LogMessage((object)"ERROR: Loading extracted loadout file failed :(");
					Logger.LogMessage((object)text);
				}
			}
		}

		public static string raid_extracted_loadout_filename = "Loadout_Extracted_From_Raid";

		public static string safehouse_persistent_filename = "Safehouse_Persitent_Filename";

		public static string safehouse_save_filename = "BU";

		public static string safehouse_deployment_loadout_filename = "Safehouse_Deployment_Filename";

		public static bool extracting_to_safehouse_need_loadout = false;

		public static bool extracting_to_safehouse_need_map = false;

		private static ConfigEntry<int> config_safehouse_index;

		private static ConfigEntry<string> config_safehouse_scene_name;

		private static ConfigEntry<string> config_safehouse_scene_name_TWO;

		private static ConfigEntry<string> config_safehouse_scene_name_THREE;

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("NGA.SafehouseProgression");
			SetUpConfigFields();
			val.PatchAll();
			Logger.LogMessage((object)"Hello, world! Sent from NGA.SafehouseProgression 0.0.1");
		}

		private void SetUpConfigFields()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			config_safehouse_index = ((BaseUnityPlugin)this).Config.Bind<int>("House", "SceneID INDEX", 1, new ConfigDescription("Swap between 3 safehouse scene IDs you specified below. All your safehouses will be saved.", (AcceptableValueBase)new AcceptableValueIntRangeStep(1, 3, 1), new object[0]));
			config_safehouse_scene_name = ((BaseUnityPlugin)this).Config.Bind<string>("House", "Safehouse Scene ID: 1", "GP_Hangar", "Examples: IndoorRange, ArizonaTargets, Grillhouse_2Story. Find more in Thunderstore. Will CRASH if you get ID wrong.");
			config_safehouse_scene_name_TWO = ((BaseUnityPlugin)this).Config.Bind<string>("House", "Safehouse Scene ID: 2", "IndoorRange_Updated", "Index: 2");
			config_safehouse_scene_name_THREE = ((BaseUnityPlugin)this).Config.Bind<string>("House", "Safehouse Scene ID: 3", "Grillhouse_2Story", "Index: 3");
		}

		private static string GetSafehouseName()
		{
			List<string> list = new List<string> { config_safehouse_scene_name.Value, config_safehouse_scene_name_TWO.Value, config_safehouse_scene_name_THREE.Value };
			return list[config_safehouse_index.Value - 1];
		}

		private static VaultFile FindLocalVaultFile(VaultFileType type, string fileName, string sceneName)
		{
			//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)
			return ((IEnumerable<VaultFile>)UgcManager.GetAllItems<VaultFile>()).FirstOrDefault((Func<VaultFile, bool>)((VaultFile vaultFile) => vaultFile.UgcModule == UgcManager.LocalVaultModule && vaultFile.Type == type && string.Equals(vaultFile.FileName, fileName, StringComparison.OrdinalIgnoreCase) && string.Equals(vaultFile.SceneName ?? string.Empty, sceneName ?? string.Empty, StringComparison.OrdinalIgnoreCase)));
		}

		private static void SaveLocalVaultFile(VaultFile vaultFile, VaultFileType type, string fileName, string sceneName)
		{
			//IL_0001: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			VaultFile val = FindLocalVaultFile(type, fileName, sceneName);
			if (val != null)
			{
				UgcManager.DeleteItem((IUgcItem)(object)val);
			}
			vaultFile.Type = type;
			vaultFile.FileName = fileName;
			vaultFile.SceneName = sceneName;
			if (string.IsNullOrEmpty(vaultFile.Creator))
			{
				vaultFile.Creator = "SafehouseProgression";
			}
			ItemTreeNode rootNode = UgcManager.LocalVaultModule.GetRootNode(typeof(VaultFile));
			UgcManager.CreateItem((IUgcItem)(object)vaultFile, rootNode);
		}

		private static bool TryGetLocalVaultFile(VaultFileType type, string fileName, string sceneName, out VaultFile vaultFile)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			vaultFile = FindLocalVaultFile(type, fileName, sceneName);
			return vaultFile != null;
		}

		private static void DeleteLocalVaultFile(VaultFileType type, string fileName, string sceneName)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			VaultFile val = FindLocalVaultFile(type, fileName, sceneName);
			if (val != null)
			{
				UgcManager.DeleteItem((IUgcItem)(object)val);
			}
		}

		private static void AddWristMenuButton(FVRWristMenuSection shMenuSection, MyWristButton new_button, Transform buttonTransform)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			((Component)buttonTransform).GetComponentInChildren<Text>().text = new_button.name;
			Button component = ((Component)buttonTransform).GetComponent<Button>();
			component.onClick = new ButtonClickedEvent();
			((UnityEvent)component.onClick).AddListener((UnityAction)delegate
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				SM.PlayGlobalUISound((GlobalUISound)0, buttonTransform.position);
				new_button.onclick(component);
			});
		}

		private static void ResizeAndReorderSection(RectTransform background, int oldButtonCount, Dictionary<GameObject, MyWristButton> existingButtons)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_002a: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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)
			Vector2 sizeDelta = background.sizeDelta;
			int childCount = ((Transform)background).childCount;
			RectTransform val = (RectTransform)((Transform)background).GetChild(0);
			float num = val.sizeDelta.y * ((Transform)val).localScale.y;
			float num2 = (sizeDelta.y - num * (float)oldButtonCount) / (float)(oldButtonCount + 2);
			float num3 = num + num2;
			background.sizeDelta = new Vector2(sizeDelta.x, (float)childCount * num3 + num2 * 2f);
			float num4 = num3 / 2f + num2;
			foreach (GameObject item in existingButtons.Keys.OrderBy((GameObject x) => existingButtons[x].priority))
			{
				item.transform.localPosition = new Vector3(0f, num4, 0f);
				num4 += num3;
			}
		}

		private static FVRWristMenuSection_Safehouse AddWristMenuSectionAndButton(FVRWristMenu2 instance2, FVRWristMenuSection_Safehouse menuSection, string sectionText, Dictionary<GameObject, MyWristButton> existingButtons, MyWristButton new_button)
		{
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Expected O, but got Unknown
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Expected O, but got Unknown
			if ((Object)(object)menuSection == (Object)null)
			{
				FVRWristMenuSection val = instance2.Sections.First((FVRWristMenuSection x) => (object)((object)x).GetType() == typeof(FVRWristMenuSection_Spawn));
				Transform transform = ((Component)val).transform;
				FVRWristMenuSection val2 = Object.Instantiate<FVRWristMenuSection>(val, transform.position, transform.rotation, transform.parent);
				GameObject gameObject = ((Component)val2).gameObject;
				Object.Destroy((Object)(object)val2);
				Renderer component = gameObject.GetComponent<Renderer>();
				if ((Object)(object)component != (Object)null)
				{
					Color color = default(Color);
					((Color)(ref color))..ctor(0.3f, 0.67f, 0.3f, 1f);
					component.material.color = color;
				}
				menuSection = gameObject.AddComponent<FVRWristMenuSection_Safehouse>();
				((FVRWristMenuSection)menuSection).ButtonText = sectionText;
				((FVRWristMenuSection)menuSection).Menu = instance2;
				instance2.Sections.Add((FVRWristMenuSection)(object)menuSection);
				instance2.RegenerateButtons();
				RectTransform val3 = (RectTransform)((Component)menuSection).transform;
				RectTransform val4 = (RectTransform)((Transform)val3).GetChild(0);
				int childCount = ((Transform)val3).childCount;
				for (int num = childCount - 1; num >= 0; num--)
				{
					RectTransform val5 = (RectTransform)((Transform)val3).GetChild(num);
					if (!((Object)(object)val5 == (Object)(object)val4))
					{
						Object.DestroyImmediate((Object)(object)((Component)val5).gameObject);
					}
				}
				existingButtons.Add(((Component)val4).gameObject, new_button);
				AddWristMenuButton((FVRWristMenuSection)(object)menuSection, new_button, (Transform)(object)val4);
				ResizeAndReorderSection(val3, childCount, existingButtons);
				return menuSection;
			}
			RectTransform val6 = (RectTransform)((Component)menuSection).transform;
			Transform child = ((Transform)val6).GetChild(0);
			RectTransform val7 = (RectTransform)Object.Instantiate<GameObject>(((Component)child).gameObject, child.position, child.rotation, child.parent).transform;
			existingButtons.Add(((Component)val7).gameObject, new_button);
			AddWristMenuButton((FVRWristMenuSection)(object)menuSection, new_button, (Transform)(object)val7);
			ResizeAndReorderSection(val6, ((Transform)val6).childCount - 1, existingButtons);
			return menuSection;
		}

		private static void ExtractToSafehouse(object sender)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			FVRWristMenuSection_Safehouse fVRWristMenuSection_Safehouse = Object.FindObjectOfType<FVRWristMenuSection_Safehouse>();
			if (!fVRWristMenuSection_Safehouse.confirmedExtractToSafehouse)
			{
				fVRWristMenuSection_Safehouse.ResetConfirm();
				fVRWristMenuSection_Safehouse.confirmedExtractToSafehouse = true;
				fVRWristMenuSection_Safehouse.TXT_Extract.text = "Extract-to-Safehouse ??";
				return;
			}
			fVRWristMenuSection_Safehouse.ResetConfirm();
			VaultFile val = new VaultFile();
			if (VaultSystem.FindAndScanObjectsInQuickbelt(val))
			{
				SaveLocalVaultFile(val, (VaultFileType)2, raid_extracted_loadout_filename, null);
			}
			else
			{
				Logger.LogMessage((object)"ERROR: Extraction quickbelt could not be scanned :(");
			}
			extracting_to_safehouse_need_loadout = true;
			extracting_to_safehouse_need_map = true;
			for (int i = 0; i < GM.CurrentSceneSettings.QuitReceivers.Count; i++)
			{
				GM.CurrentSceneSettings.QuitReceivers[i].BroadcastMessage("QUIT", (SendMessageOptions)1);
			}
			if (((AnvilCallbackBase)GM.LoadingCallback).IsCompleted)
			{
				CustomSceneInfo customScene = AtlasPlugin.GetCustomScene(GetSafehouseName());
				if (customScene != null)
				{
					AtlasPlugin.LoadCustomScene(GetSafehouseName());
					return;
				}
				Logger.LogMessage((object)("WARNING: Map being loaded was determined to NOT be a mod: " + GetSafehouseName()));
				SteamVR_LoadLevel.Begin(GetSafehouseName(), false, 0.5f, 0f, 0f, 0f, 1f);
			}
		}

		private static void LeaveTheSafehouse(object sender)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			FVRWristMenuSection_Safehouse fVRWristMenuSection_Safehouse = Object.FindObjectOfType<FVRWristMenuSection_Safehouse>();
			if (!fVRWristMenuSection_Safehouse.confirmedLeaveTheSafehouse)
			{
				fVRWristMenuSection_Safehouse.ResetConfirm();
				fVRWristMenuSection_Safehouse.confirmedLeaveTheSafehouse = true;
				fVRWristMenuSection_Safehouse.TXT_Leave.text = "Leave-the-Safehouse ??";
				return;
			}
			fVRWristMenuSection_Safehouse.ResetConfirm();
			VaultFile val = new VaultFile();
			if (VaultSystem.FindAndScanObjectsInQuickbelt(val))
			{
				SaveLocalVaultFile(val, (VaultFileType)2, safehouse_deployment_loadout_filename, null);
			}
			else
			{
				Logger.LogMessage((object)"ERROR: Couldn't scan quickbelt to leave safehouse :(");
			}
			VaultFile val2 = new VaultFile();
			bool flag = VaultSystem.FindAndScanObjectsInScene(val2);
			string safehouseName = GetSafehouseName();
			if (flag)
			{
				SaveLocalVaultFile(val2, (VaultFileType)3, safehouse_persistent_filename, safehouseName);
			}
			int num = Random.Range(1, 3);
			Logger.LogMessage((object)("num " + num));
			if (num == 1)
			{
				VaultFile val3 = new VaultFile();
				if (VaultSystem.FindAndScanObjectsInScene(val3))
				{
					string text = DateTime.Now.ToString("yyyyMMdd_HHmmss");
					string fileName = safehouse_save_filename + "_" + text;
					SaveLocalVaultFile(val3, (VaultFileType)3, fileName, safehouseName);
				}
			}
			SteamVR_LoadLevel.Begin("MainMenu3", false, 0.5f, 0f, 0f, 0f, 1f);
		}

		private static void DeploySafehouseLoadout(object sender)
		{
			//IL_0095: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			FVRWristMenuSection_Safehouse fVRWristMenuSection_Safehouse = Object.FindObjectOfType<FVRWristMenuSection_Safehouse>();
			if (!fVRWristMenuSection_Safehouse.confirmedDeploySafehouseLoadout)
			{
				fVRWristMenuSection_Safehouse.ResetConfirm();
				fVRWristMenuSection_Safehouse.confirmedDeploySafehouseLoadout = true;
				fVRWristMenuSection_Safehouse.TXT_Deploy.text = "Deployment-Loadout ??";
				return;
			}
			fVRWristMenuSection_Safehouse.ResetConfirm();
			if (!TryGetLocalVaultFile((VaultFileType)2, safehouse_deployment_loadout_filename, null, out var vaultFile))
			{
				Logger.LogMessage((object)"ERROR: Deployment loadout file not found :(");
				return;
			}
			FVRPlayerBody val = Object.FindObjectOfType<FVRPlayerBody>();
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogMessage((object)"ERROR: FVRPlayerBody not found :(");
				return;
			}
			Transform transform = new GameObject().transform;
			transform.position = ((Component)val).transform.position;
			string text = default(string);
			if (VaultSystem.SpawnObjects((VaultFileType)2, vaultFile, ref text, transform, Vector3.zero))
			{
				UgcManager.DeleteItem((IUgcItem)(object)vaultFile);
				return;
			}
			Logger.LogMessage((object)"ERROR: Deployment loadout failed to spawn :(");
			Logger.LogMessage((object)text);
		}
	}
	public class FVRWristMenuSection_Safehouse : FVRWristMenuSection
	{
		public Text TXT_Deploy;

		public Text TXT_Leave;

		public Text TXT_Extract;

		public bool confirmedDeploySafehouseLoadout = false;

		public bool confirmedLeaveTheSafehouse = false;

		public bool confirmedExtractToSafehouse = false;

		public void ResetConfirm()
		{
			confirmedDeploySafehouseLoadout = false;
			confirmedLeaveTheSafehouse = false;
			confirmedExtractToSafehouse = false;
			TXT_Deploy.text = "Deployment-Loadout";
			TXT_Leave.text = "Leave-the-Safehouse";
			TXT_Extract.text = "Extract-to-Safehouse";
		}

		public override void OnHide()
		{
			ResetConfirm();
		}
	}
}