Add workaround for bad dream man, and DESTROY bepinex

This commit is contained in:
Raicuparta 2022-10-28 22:27:20 +02:00
parent a59f5c759e
commit 5b23c68937
13 changed files with 39 additions and 261 deletions

View File

@ -9,10 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NomaiVRPatcher", "NomaiVRPa
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
DebugOWML|Any CPU = DebugOWML|Any CPU
OWML|Any CPU = OWML|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CE7F4F71-F74E-4BA2-9AE1-930905B4B883}.Debug|Any CPU.ActiveCfg = Debug|Any CPU

View File

@ -1,63 +0,0 @@
#if !OWML
extern alias BepInEx;
using BepInEx::HarmonyLib;
using System;
using System.Reflection;
namespace NomaiVR.Loaders
{
public class BIEHarmonyInstance : IHarmonyInstance
{
private BepInEx::HarmonyLib.Harmony harmonyInstance;
public BIEHarmonyInstance(BepInEx::HarmonyLib.Harmony harmonyInstance)
{
this.harmonyInstance = harmonyInstance;
}
public void AddPrefix(MethodBase original, Type patchType, string patchMethodName)
{
var prefix = TypeExtensions.GetAnyMethod(patchType, patchMethodName);
if (prefix == null)
{
Logs.WriteError($"Error in {nameof(AddPrefix)}: {patchType.Name}.{patchMethodName} is null.");
return;
}
Patch(original, prefix, null, null);
}
public void AddPostfix(MethodBase original, Type patchType, string patchMethodName)
{
var postfix = TypeExtensions.GetAnyMethod(patchType, patchMethodName);
if (postfix == null)
{
Logs.WriteError($"Error in {nameof(AddPostfix)}: {patchType.Name}.{patchMethodName} is null.");
return;
}
Patch(original, null, postfix, null);
}
private void Patch(MethodBase original, MethodInfo prefix, MethodInfo postfix, MethodInfo transpiler)
{
if (original == null)
{
Logs.WriteError($"Error in {nameof(Patch)}: original MethodInfo is null.");
return;
}
var prefixMethod = prefix == null ? null : new HarmonyMethod(prefix);
var postfixMethod = postfix == null ? null : new HarmonyMethod(postfix);
var transpilerMethod = transpiler == null ? null : new HarmonyMethod(transpiler);
var fullName = $"{original.DeclaringType}.{original.Name}";
try
{
harmonyInstance.Patch(original, prefixMethod, postfixMethod, transpilerMethod);
Logs.Write($"Patched {fullName}!");
}
catch (Exception ex)
{
Logs.WriteError($"Exception while patching {fullName}: {ex}");
}
}
}
}
#endif

View File

@ -1,11 +0,0 @@
using System;
using System.Reflection;
namespace NomaiVR.Loaders.Harmony
{
public interface IHarmonyInstance
{
void AddPrefix(MethodBase original, Type patchType, string patchMethodName);
void AddPostfix(MethodBase original, Type patchType, string patchMethodName);
}
}

View File

@ -1,21 +0,0 @@
using System;
using System.Reflection;
using OWML.Common;
namespace NomaiVR.Loaders.Harmony
{
public class OwmlHarmonyInstance : IHarmonyInstance
{
private readonly IModHelper modHelper;
public OwmlHarmonyInstance(IModHelper modHelper)
{
this.modHelper = modHelper;
}
public void AddPostfix(MethodBase original, Type patchType, string patchMethodName) =>
modHelper.HarmonyHelper.AddPostfix(original, patchType, patchMethodName);
public void AddPrefix(MethodBase original, Type patchType, string patchMethodName) =>
modHelper.HarmonyHelper.AddPrefix(original, patchType, patchMethodName);
}
}

View File

@ -1,27 +0,0 @@
#if !OWML
extern alias BepInEx;
using BepInEx;
using System.IO;
namespace NomaiVR.Loaders.BepInEx
{
[BepInPlugin("raicuparta.nomaivr", "NomaiVR", "2.0.0")]
public class NomaiVRLoaderBIE : BaseUnityPlugin
{
internal void Awake()
{
var harmony = new BepInEx::HarmonyLib.Harmony("raicuparta.nomaivr");
NomaiVR.HarmonyInstance = new BIEHarmonyInstance(harmony);
NomaiVR.ModFolderPath = $"{Directory.GetCurrentDirectory()}/BepInEx/plugins/NomaiVR/";
NomaiVR.GameDataPath = $"{Paths.ManagedPath}/../";
var settingsProvider = new ModConfig.BepInExSettingsProvider(Config);
ModSettings.SetProvider(settingsProvider);
}
internal void Start()
{
NomaiVR.ApplyMod();
}
}
}
#endif

View File

@ -1,26 +0,0 @@
using OWML.Common;
using OWML.ModHelper;
using NomaiVR.Loaders.Harmony;
using NomaiVR.ModConfig;
namespace NomaiVR.Loaders
{
public class NomaiVRLoaderOwml : ModBehaviour
{
public static IModHelper Helper { get; private set; }
internal void Start()
{
NomaiVR.HarmonyInstance = new OwmlHarmonyInstance(ModHelper);
NomaiVR.ModFolderPath = Helper.Manifest.ModFolderPath;
NomaiVR.GameDataPath = Helper.OwmlConfig.DataPath;
NomaiVR.ApplyMod();
}
public override void Configure(IModConfig config)
{
Helper = ModHelper;
var settingsProvider = new OwmlSettingsProvider(config);
ModSettings.SetProvider(settingsProvider);
}
}
}

View File

@ -1,5 +1,4 @@
using NomaiVR.Loaders;
using NomaiVR.ModConfig;
using NomaiVR.ModConfig;
namespace NomaiVR
{
@ -20,15 +19,15 @@ namespace NomaiVR
switch (messageType)
{
case MessageType.Error:
NomaiVRLoaderOwml.Helper.Console.WriteLine(message, OWML.Common.MessageType.Error);
NomaiVR.Helper.Console.WriteLine(message, OWML.Common.MessageType.Error);
break;
case MessageType.Warning:
NomaiVRLoaderOwml.Helper.Console.WriteLine(message, OWML.Common.MessageType.Warning);
NomaiVR.Helper.Console.WriteLine(message, OWML.Common.MessageType.Warning);
break;
default:
NomaiVRLoaderOwml.Helper.Console.WriteLine(message, OWML.Common.MessageType.Info);
NomaiVR.Helper.Console.WriteLine(message, OWML.Common.MessageType.Info);
break;
}
}

View File

@ -1,90 +0,0 @@
#if !OWML
using BepInEx.Configuration;
using System;
namespace NomaiVR.ModConfig
{
public class BepInExSettingsProvider : IModSettingProvider
{
public event Action OnConfigChange;
private ConfigEntry<bool> leftHandDominant;
public bool LeftHandDominant => leftHandDominant.Value;
private ConfigEntry<bool> debugMode;
public bool DebugMode => debugMode.Value;
private ConfigEntry<bool> preventCursorLock;
public bool PreventCursorLock => preventCursorLock.Value;
private ConfigEntry<bool> showHelmet;
public bool ShowHelmet => showHelmet.Value;
private ConfigEntry<float> vibrationStrength;
public float VibrationStrength => vibrationStrength.Value;
private ConfigEntry<bool> enableGesturePrompts;
public bool EnableGesturePrompts => enableGesturePrompts.Value;
private ConfigEntry<bool> enableHandLaser;
public bool EnableHandLaser => enableHandLaser.Value;
private ConfigEntry<bool> enableFeetMarker;
public bool EnableFeetMarker => enableFeetMarker.Value;
private ConfigEntry<bool> controllerOrientedMovement;
public bool ControllerOrientedMovement => controllerOrientedMovement.Value;
private ConfigEntry<bool> autoHideToolbelt;
public bool AutoHideToolbelt => autoHideToolbelt.Value;
private ConfigEntry<float> toolbeltHeight;
public float ToolbeltHeight => toolbeltHeight.Value;
private ConfigEntry<float> hudScale;
public float HudScale => hudScale.Value;
private ConfigEntry<float> hudOpacity;
public float HudOpacity => hudOpacity.Value;
private ConfigEntry<float> markersOpacity;
public float MarkersOpacity => markersOpacity.Value;
private ConfigEntry<float> lookArrowOpacity;
public float LookArrowOpacity => lookArrowOpacity.Value;
private ConfigEntry<bool> hudSmoothFollow;
public bool HudSmoothFollow => hudSmoothFollow.value;
private ConfigFile config;
public BepInExSettingsProvider(ConfigFile config)
{
this.config = config;
}
public void Configure()
{
// TODO: setting descriptions.
const string section = "NomaiVRSettings";
leftHandDominant = config.Bind(section, "leftHandDominant", false, "");
vibrationStrength = config.Bind(section, "vibrationIntensity", 1f, new ConfigDescription("", new AcceptableValueRange<float>(0f, 3f)));
toolbeltHeight = config.Bind(section, "toolbeltHeight", -0.55f, new ConfigDescription("", new AcceptableValueRange<float>(-0.8f, -0.2f)));
showHelmet = config.Bind(section, "helmetVisibility", true, "");
hudScale = config.Bind(section, "hudScale", 1f, new ConfigDescription("", new AcceptableValueRange<float>(0.2f, 1.8f)));
hudOpacity = config.Bind(section, "hudOpacity", 1f, new ConfigDescription("", new AcceptableValueRange<float>(0f, 1f)));
markersOpacity = config.Bind(section, "markersOpacity", 1f, new ConfigDescription("", new AcceptableValueRange<float>(0f, 1f)));
lookArrowOpacity = config.Bind(section, "lookArrowOpacity", 1f, new ConfigDescription("", new AcceptableValueRange<float>(0f, 1f)));
hudSmoothFollow = config.Bind(section, "hudSmoothFollow", true, "");
controllerOrientedMovement = config.Bind(section, "movementControllerOriented", false, "");
enableGesturePrompts = config.Bind(section, "showGesturePrompts", true, "");
enableHandLaser = config.Bind(section, "showHandLaser", true, "");
enableFeetMarker = config.Bind(section, "showFeetMarker", true, "");
preventCursorLock = config.Bind(section, "disableCursorLock", true, "");
debugMode = config.Bind(section, "debug", false, "");
autoHideToolbelt = config.Bind(section, "autoHideToolbelt", false, "");
OnConfigChange?.Invoke();
}
}
}
#endif

View File

@ -4,23 +4,39 @@ using NomaiVR.EffectFixes;
using NomaiVR.Hands;
using NomaiVR.Helpers;
using NomaiVR.Input;
using NomaiVR.ModConfig;
using NomaiVR.Tools;
using NomaiVR.UI;
using NomaiVR.Loaders.Harmony;
using NomaiVR.Player;
using NomaiVR.Saves;
using NomaiVR.Ship;
using OWML.Common;
using OWML.ModHelper;
namespace NomaiVR
{
public class NomaiVR
public class NomaiVR : ModBehaviour
{
public static IHarmonyInstance HarmonyInstance;
public static ModSaveFile Save;
public static string ModFolderPath;
public static string GameDataPath;
public static IModHelper Helper;
internal static void ApplyMod()
internal void Start()
{
ModFolderPath = ModHelper.Manifest.ModFolderPath;
GameDataPath = ModHelper.OwmlConfig.DataPath;
Helper = ModHelper;
ApplyMod();
}
public override void Configure(IModConfig config)
{
var settingsProvider = new OwmlSettingsProvider(config);
ModSettings.SetProvider(settingsProvider);
}
internal void ApplyMod()
{
Save = ModSaveFile.LoadSaveFile();
new AssetLoader();
@ -40,7 +56,12 @@ namespace NomaiVR
new DreamFix();
new ProjectionStoneCameraFix();
new PeepholeCameraFix();
new CameraMaskFix();
// Camera mask patches fuck up the dreamstalker mod, so we're just disabling them and hoping for the best.
if (!ModHelper.Interaction.ModExists("xen.Dreamstalker"))
{
new CameraMaskFix();
}
new MapFix();
new PlayerBodyPosition();
new VRToolSwapper();

View File

@ -34,13 +34,13 @@ namespace NomaiVR
AddPrefix(GetMethod<T>(methodName), patchType, patchMethodName);
public void AddPrefix(MethodBase original, Type patchType, string patchMethodName) =>
NomaiVR.HarmonyInstance.AddPrefix(original, patchType, patchMethodName);
NomaiVR.Helper.HarmonyHelper.AddPrefix(original, patchType, patchMethodName);
public void AddPostfix<T>(string methodName, Type patchType, string patchMethodName) =>
AddPostfix(GetMethod<T>(methodName), patchType, patchMethodName);
public void AddPostfix(MethodBase original, Type patchType, string patchMethodName) =>
NomaiVR.HarmonyInstance.AddPostfix(original, patchType, patchMethodName);
NomaiVR.Helper.HarmonyHelper.AddPostfix(original, patchType, patchMethodName);
public void EmptyMethod<T>(string methodName) =>
EmptyMethod(GetMethod<T>(methodName));

View File

@ -36,9 +36,7 @@ The project references should now be working. When you build the solution, the d
The available build configurations are:
- `Debug` which compiles only the mod and patcher binaries for BepInEx
- `DebugOWML` which compiles only the mod and patcher binaries for OWML
- `Release` which compiles both the unity project and the mod + patcher for BepInEx
- `OWML` which compiles both the unity project and the mod + patcher for OWML
If for some reason none of this is working, you might have to set everything manually:

View File

@ -1,20 +1,20 @@
ManifestFileVersion: 0
CRC: 3565622252
CRC: 2287794281
AssetBundleManifest:
AssetBundleInfos:
Info_0:
Name: vrbindings-textures
Dependencies: {}
Info_1:
Name: cockpit-buttons
Name: steamvr-shaders
Dependencies: {}
Info_2:
Name: autopilot-button
Dependencies: {}
Info_3:
Name: handheld-buttons
Dependencies:
Dependency_0: cockpit-buttons
Info_4:
Name: steamvr-shaders
Info_3:
Name: autopilot-button
Dependencies: {}
Info_4:
Name: cockpit-buttons
Dependencies: {}