Decompiled source of VaultGunSharer v0.1.0

NGA.VaultGunSharer.dll

Decompiled 4 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Microsoft.CodeAnalysis;

[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("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NGA.VaultGunSharer")]
[assembly: AssemblyTitle("BepInEx Plugin Title")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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;
		}
	}
}
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.VaultGunSharer", "VaultGunSharer", "1.0.0")]
	[BepInProcess("h3vr.exe")]
	public class VaultGunSharer : BaseUnityPlugin
	{
		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"VaultGunSharer starting work!");
			string pluginPath = Paths.PluginPath;
			((BaseUnityPlugin)this).Logger.LogInfo((object)("pluginsPath: " + pluginPath));
			string[] directories = Directory.GetDirectories(pluginPath);
			string[] array = directories;
			foreach (string text in array)
			{
				string[] files = Directory.GetFiles(text, "gun_shared_*.json");
				if (files.Length != 0)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)("pluginFolder: " + text));
				}
				string[] array2 = files;
				foreach (string text2 in array2)
				{
					string json = File.ReadAllText(text2);
					string jsonValue = GetJsonValue(json, "ReferencePath");
					((BaseUnityPlugin)this).Logger.LogInfo((object)("referencePath: " + jsonValue));
					string[] array3 = jsonValue.Split(new char[1] { '\\' });
					if (array3.Length < 5)
					{
						((BaseUnityPlugin)this).Logger.LogInfo((object)"SKIPPED ERROR on ABOVE");
						continue;
					}
					string text3 = array3[4];
					((BaseUnityPlugin)this).Logger.LogInfo((object)("subfolderName: " + text3));
					string text4 = "\\My Games\\H3VR\\Vault\\Objects\\" + text3;
					((BaseUnityPlugin)this).Logger.LogInfo((object)("ConfigsPath: " + text4));
					string text5 = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + text4;
					((BaseUnityPlugin)this).Logger.LogInfo((object)("fullConfigsPath: " + text5));
					string fileName = Path.GetFileName(text2);
					((BaseUnityPlugin)this).Logger.LogInfo((object)("jsonFileName: " + fileName));
					string text6 = text2;
					((BaseUnityPlugin)this).Logger.LogInfo((object)("jsonFullFilePath: " + text6));
					string text7 = Path.Combine(text5, fileName);
					((BaseUnityPlugin)this).Logger.LogInfo((object)("destinationFilePath: " + text7));
					if (Directory.Exists(text5))
					{
						File.Copy(text6, text7, overwrite: true);
						((BaseUnityPlugin)this).Logger.LogInfo((object)("Copied " + text6 + " to " + text7));
						continue;
					}
					Directory.CreateDirectory(text5);
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Created new directory and file " + text5));
					File.Copy(text6, text7, overwrite: true);
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Then Copied " + text6 + " to " + text7));
				}
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"VaultGunSharer ended work!");
		}

		private string GetJsonValue(string json, string key)
		{
			int num = json.IndexOf("\"" + key + "\": ") + key.Length + 4;
			int num2 = json.IndexOf(',', num);
			if (num2 == -1)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Error, bad file, couldn't find comma.");
				num2 = json.IndexOf('}', num);
			}
			return json.Substring(num, num2 - num - 1).Trim(new char[1] { '"' });
		}
	}
}