using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using Microsoft.CodeAnalysis; using Mono.Cecil; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("HowToFishVR.Preload")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("HowToFishXR - Preloader (stages OpenXR runtime)")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+e3cc92a1988e2680296bae95a521b7a361bab8be")] [assembly: AssemblyProduct("HowToFishVR.Preload")] [assembly: AssemblyTitle("HowToFishVR.Preload")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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 HowToFishVR.Preload { public static class Preload { private const string DATA_DIR = "How to Fish_Data"; private const string VR_MANIFEST = "{\n \"name\": \"OpenXR XR Plugin\",\n \"version\": \"1.14.3\",\n \"libraryName\": \"UnityOpenXR\",\n \"displays\": [ { \"id\": \"OpenXR Display\" } ],\n \"inputs\": [ { \"id\": \"OpenXR Input\" } ]\n}"; private static readonly ManualLogSource Logger = Logger.CreateLogSource("HowToFishVR.Preload"); public static IEnumerable TargetDLLs { get; } = new string[0]; public static void Initialize() { try { SetupRuntimeAssets(); } catch (Exception arg) { Logger.LogError((object)$"Failed to stage VR runtime assets: {arg}"); } } private static void SetupRuntimeAssets() { string path = Path.Combine(Paths.GameRootPath, "How to Fish_Data"); string text = Path.Combine(Path.Combine(path, "UnitySubsystems"), "UnityOpenXR"); Directory.CreateDirectory(text); File.WriteAllText(Path.Combine(text, "UnitySubsystemsManifest.json"), "{\n \"name\": \"OpenXR XR Plugin\",\n \"version\": \"1.14.3\",\n \"libraryName\": \"UnityOpenXR\",\n \"displays\": [ { \"id\": \"OpenXR Display\" } ],\n \"inputs\": [ { \"id\": \"OpenXR Input\" } ]\n}"); string text2 = Path.Combine(path, "Plugins"); Directory.CreateDirectory(text2); string path2 = FindRuntimeDeps(); CopyIfNewer(Path.Combine(path2, "UnityOpenXR.dll"), Path.Combine(text2, "UnityOpenXR.dll")); CopyIfNewer(Path.Combine(path2, "openxr_loader.dll"), Path.Combine(text2, "openxr_loader.dll")); } private static string FindRuntimeDeps() { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "RuntimeDeps"); if (Directory.Exists(text)) { return text; } string[] directories = Directory.GetDirectories(Paths.BepInExRootPath, "RuntimeDeps", SearchOption.AllDirectories); foreach (string text2 in directories) { if (File.Exists(Path.Combine(text2, "UnityOpenXR.dll"))) { return text2; } } return text; } private static void CopyIfNewer(string src, string dst) { if (!File.Exists(src)) { Logger.LogError((object)("Required VR runtime dependency is missing: " + src)); } else if (!File.Exists(dst) || new FileInfo(dst).Length != new FileInfo(src).Length) { File.Copy(src, dst, overwrite: true); } } public static void Patch(AssemblyDefinition assembly) { } } }