Decompiled source of EFT SCAV And PMC Sosigs v1.0.0

EFT_SCAV_And_PMC_Sosigs.dll

Decompiled 3 weeks ago
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using FistVR;
using H3MP.Networking;
using HarmonyLib;
using NGA;
using OtherLoader;
using UnityEngine;

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace JerryAr.EFT_SCAV_And_PMC_Sosigs;

[BepInPlugin("JerryAr.EFT_SCAV_And_PMC_Sosigs", "EFT_SCAV_And_PMC_Sosigs", "1.0.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class EFT_SCAV_And_PMC_SosigsPlugin : BaseUnityPlugin
{
	private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

	internal static ManualLogSource Logger;

	private void Awake()
	{
		Logger = ((BaseUnityPlugin)this).Logger;
		LoadAssets();
	}

	private void LoadAssets()
	{
		Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "JerryAr.EFT_SCAV_And_PMC_Sosigs");
		OtherLoader.RegisterDirectLoad(BasePath, "JerryAr.EFT_SCAV_And_PMC_Sosigs", "", "", "eft_sosig_outfits", "");
	}
}
public class AutoLoadAndSave : MonoBehaviour
{
	public bool saved = false;

	public bool isH3MPInstalled;

	public float countdown = 2f;

	public bool isNGAInstalled;

	public float timer = 1f;

	public bool sceneSpawned = false;

	public bool loadouted = false;

	private void Start()
	{
		isH3MPInstalled = Chainloader.PluginInfos.ContainsKey("VIP.TommySoucy.H3MP");
		isNGAInstalled = Chainloader.PluginInfos.ContainsKey("NGA.SafehouseMP");
	}

	private void EnterWithLoadOut()
	{
		//IL_0048: 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_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Expected O, but got Unknown
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Expected O, but got Unknown
		if (countdown >= 0f)
		{
			countdown -= Time.deltaTime;
		}
		if (!loadouted && countdown < 0f)
		{
			loadouted = true;
			Transform transform = new GameObject().transform;
			transform.position = ((Component)GM.CurrentPlayerBody).transform.position;
			VaultFile val = new VaultFile();
			if (!VaultSystem.LoadVaultFile(SafehouseMP.raid_extracted_loadout_filename, (VaultFileDisplayMode)1, ref val))
			{
				Debug.Log((object)"ERROR: Loading saved loadout failed.");
				return;
			}
			string text = default(string);
			if (!VaultSystem.SpawnObjects((VaultFileDisplayMode)1, val, ref text, transform, Vector3.zero))
			{
				Debug.Log((object)"ERROR: Spawning saved loadout failed.");
				return;
			}
			VaultFile val2 = new VaultFile();
			VaultSystem.SaveVaultFile(SafehouseMP.raid_extracted_loadout_filename, (VaultFileDisplayMode)1, val2);
		}
	}

	private void FixedUpdate()
	{
		//IL_02de: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0342: Unknown result type (might be due to invalid IL or missing references)
		//IL_0349: Expected O, but got Unknown
		//IL_036e: Unknown result type (might be due to invalid IL or missing references)
		//IL_026c: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0203: Expected O, but got Unknown
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Expected O, but got Unknown
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		if (isH3MPInstalled)
		{
			if (Client.isFullyConnected)
			{
				if (!ThreadManager.host || !isNGAInstalled)
				{
					return;
				}
				if ((Object)(object)GM.CurrentPlayerBody != (Object)null)
				{
					((Component)this).gameObject.transform.position = GM.CurrentPlayerBody.Head.position;
					((Component)this).gameObject.transform.eulerAngles = GM.CurrentPlayerBody.Head.eulerAngles;
				}
				timer -= Time.deltaTime;
				if (!(timer <= 0f))
				{
					return;
				}
				timer = 0f;
				if (!sceneSpawned)
				{
					VaultFile val = new VaultFile();
					if (VaultSystem.DoesVaultFileExist((VaultFileDisplayMode)2, "EFTHideOut_Standard_Edition_SaveFile"))
					{
						VaultSystem.LoadVaultFile("EFTHideOut_Standard_Edition_SaveFile", (VaultFileDisplayMode)2, ref val);
						string text = default(string);
						VaultSystem.SpawnObjects((VaultFileDisplayMode)2, val, ref text, (Transform)null, Vector3.zero);
						Debug.Log((object)"SceneLoaded");
					}
					else if (!VaultSystem.DoesVaultFileExist((VaultFileDisplayMode)2, "EFTHideOut_Standard_Edition_SaveFile"))
					{
						Debug.Log((object)"Can't find scene save");
					}
					sceneSpawned = true;
				}
				if (Vector3.Distance(((Component)this).transform.position, GM.CurrentMovementManager.Head.position) < 0.25f)
				{
					EnterWithLoadOut();
				}
			}
			else
			{
				if (Client.isFullyConnected || !isNGAInstalled)
				{
					return;
				}
				if ((Object)(object)GM.CurrentPlayerBody != (Object)null)
				{
					((Component)this).gameObject.transform.position = GM.CurrentPlayerBody.Head.position;
					((Component)this).gameObject.transform.eulerAngles = GM.CurrentPlayerBody.Head.eulerAngles;
				}
				timer -= Time.deltaTime;
				if (!(timer <= 0f))
				{
					return;
				}
				timer = 0f;
				if (!sceneSpawned)
				{
					VaultFile val2 = new VaultFile();
					if (VaultSystem.DoesVaultFileExist((VaultFileDisplayMode)2, "EFTHideOut_Standard_Edition_SaveFile"))
					{
						VaultSystem.LoadVaultFile("EFTHideOut_Standard_Edition_SaveFile", (VaultFileDisplayMode)2, ref val2);
						string text2 = default(string);
						VaultSystem.SpawnObjects((VaultFileDisplayMode)2, val2, ref text2, (Transform)null, Vector3.zero);
						Debug.Log((object)"SceneLoaded");
					}
					else if (!VaultSystem.DoesVaultFileExist((VaultFileDisplayMode)2, "EFTHideOut_Standard_Edition_SaveFile"))
					{
						Debug.Log((object)"Can't find scene save");
					}
					sceneSpawned = true;
				}
				if (Vector3.Distance(((Component)this).transform.position, GM.CurrentMovementManager.Head.position) < 0.25f)
				{
					EnterWithLoadOut();
				}
			}
		}
		else
		{
			if (isH3MPInstalled || !isNGAInstalled)
			{
				return;
			}
			if ((Object)(object)GM.CurrentPlayerBody != (Object)null)
			{
				((Component)this).gameObject.transform.position = GM.CurrentPlayerBody.Head.position;
				((Component)this).gameObject.transform.eulerAngles = GM.CurrentPlayerBody.Head.eulerAngles;
			}
			timer -= Time.deltaTime;
			if (!(timer <= 0f))
			{
				return;
			}
			timer = 0f;
			if (!sceneSpawned)
			{
				VaultFile val3 = new VaultFile();
				if (VaultSystem.DoesVaultFileExist((VaultFileDisplayMode)2, "EFTHideOut_Standard_Edition_SaveFile"))
				{
					VaultSystem.LoadVaultFile("EFTHideOut_Standard_Edition_SaveFile", (VaultFileDisplayMode)2, ref val3);
					string text3 = default(string);
					VaultSystem.SpawnObjects((VaultFileDisplayMode)2, val3, ref text3, (Transform)null, Vector3.zero);
					Debug.Log((object)"SceneLoaded");
				}
				else if (!VaultSystem.DoesVaultFileExist((VaultFileDisplayMode)2, "EFTHideOut_Standard_Edition_SaveFile"))
				{
					Debug.Log((object)"Can't find scene save");
				}
				sceneSpawned = true;
			}
			if (Vector3.Distance(((Component)this).transform.position, GM.CurrentMovementManager.Head.position) < 0.25f)
			{
				EnterWithLoadOut();
			}
		}
	}
}
public class AutoLoadSceneOnStart : MonoBehaviour
{
	public bool isH3MPInstalled;

	private VaultFile FileToSpawn = new VaultFile();

	public bool saved = false;

	public string FileName;

	public string SceneVaultFileName;

	public string PluginDictionaryString;

	public float countdown = 2f;

	public float timer = 1f;

	public bool sceneSpawned = false;

	public bool loadouted = false;

	public bool loadonlyonce = false;

	public string newlySavedFileName;

	public bool isPMCStandard;

	private void Awake()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		PluginInfo value = new PluginInfo();
		Chainloader.PluginInfos.TryGetValue(PluginDictionaryString, out value);
		string directoryName = Path.GetDirectoryName(value.Location);
		Load<VaultFile>(Path.Combine(directoryName, FileName), FileToSpawn);
	}

	private void Start()
	{
		isH3MPInstalled = Chainloader.PluginInfos.ContainsKey("VIP.TommySoucy.H3MP");
		isPMCStandard = Chainloader.PluginInfos.ContainsKey("JerryAr.EFT_PMC_ModPack");
	}

	public void Load<T>(string path, T objectToOverwrite)
	{
		string empty = string.Empty;
		Debug.Log((object)path);
		JsonUtility.FromJsonOverwrite(File.ReadAllText(path), (object)objectToOverwrite);
	}

	public void LoadSavedScene()
	{
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		timer -= Time.deltaTime;
		if (timer <= 0f)
		{
			timer = 0f;
			if (!sceneSpawned)
			{
				string text = default(string);
				VaultSystem.SpawnObjects((VaultFileDisplayMode)2, FileToSpawn, ref text, (Transform)null, Vector3.zero);
				Debug.Log((object)"SceneLoaded");
				sceneSpawned = true;
			}
		}
	}

	private void Update()
	{
		if (!isPMCStandard || sceneSpawned)
		{
			return;
		}
		if (VaultSystem.DoesVaultFileExist((VaultFileDisplayMode)2, newlySavedFileName))
		{
			if (!loadonlyonce)
			{
				if (isH3MPInstalled && ThreadManager.host)
				{
					LoadSavedScene();
				}
				if (!isH3MPInstalled)
				{
					LoadSavedScene();
				}
			}
		}
		else
		{
			if (VaultSystem.DoesVaultFileExist((VaultFileDisplayMode)2, newlySavedFileName))
			{
				return;
			}
			if (isH3MPInstalled)
			{
				if (Client.isFullyConnected)
				{
					if (ThreadManager.host)
					{
						LoadSavedScene();
					}
				}
				else if (!Client.isFullyConnected)
				{
					LoadSavedScene();
				}
			}
			if (!isH3MPInstalled)
			{
				LoadSavedScene();
			}
		}
	}
}