[PathCamDisabler] Fixes for 2023r171

This commit is contained in:
NotAKidoS 2023-07-28 23:13:14 -05:00
parent 0e9f7566da
commit 2d6c4a3fc5
4 changed files with 50 additions and 36 deletions

View file

@ -0,0 +1,26 @@
using ABI_RC.Core.IO;
using ABI_RC.Systems.InputManagement.InputModules;
using HarmonyLib;
namespace NAK.PathCamDisabler.HarmonyPatches;
internal class CVRPathCamControllerPatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(CVRPathCamController), nameof(CVRPathCamController.Update))]
private static void Prefix_CVRPathCamController_Update(ref bool __runOriginal)
{
__runOriginal &= !PathCamDisabler.EntryDisablePathCam.Value;
}
}
internal class CVRInputModule_KeyboardPatches
{
[HarmonyPostfix]
[HarmonyPatch(typeof(CVRInputModule_Keyboard), nameof(CVRInputModule_Keyboard.Update_Binds))]
private static void Postfix_CVRInputModule_Keyboard_Update_Binds(ref CVRInputModule_Keyboard __instance)
{
if (PathCamDisabler.EntryDisableFlightBind.Value)
__instance._inputManager.toggleFlight = false;
}
}

View file

@ -1,7 +1,4 @@
using ABI_RC.Core.IO; using MelonLoader;
using ABI_RC.Core.Player;
using MelonLoader;
using UnityEngine;
namespace NAK.PathCamDisabler; namespace NAK.PathCamDisabler;
@ -11,39 +8,27 @@ public class PathCamDisabler : MelonMod
MelonPreferences.CreateCategory(nameof(PathCamDisabler)); MelonPreferences.CreateCategory(nameof(PathCamDisabler));
public static readonly MelonPreferences_Entry<bool> EntryDisablePathCam = public static readonly MelonPreferences_Entry<bool> EntryDisablePathCam =
Category.CreateEntry("Disable Path Camera Controller.", true, description: "Disable Path Camera Controller."); Category.CreateEntry("Disable Path Camera Controller", true, description: "Disable Path Camera Controller.");
public static readonly MelonPreferences_Entry<bool> EntryDisableFlightBind = public static readonly MelonPreferences_Entry<bool> EntryDisableFlightBind =
Category.CreateEntry("Disable Flight Binding (if controller off).", false, description: "Disable flight bind if Path Camera Controller is also disabled."); Category.CreateEntry("Disable Flight Binding", false, description: "Disable flight bind if Path Camera Controller is also disabled.");
public override void OnInitializeMelon() public override void OnInitializeMelon()
{ {
EntryDisablePathCam.OnEntryValueChangedUntyped.Subscribe(OnUpdateSettings); ApplyPatches(typeof(HarmonyPatches.CVRPathCamControllerPatches));
ApplyPatches(typeof(HarmonyPatches.CVRInputModule_KeyboardPatches));
MelonLoader.MelonCoroutines.Start(WaitForCVRPathCamController());
} }
private System.Collections.IEnumerator WaitForCVRPathCamController() private void ApplyPatches(Type type)
{ {
while (CVRPathCamController.Instance == null) try
yield return null;
UpdateSettings();
}
private void UpdateSettings()
{ {
CVRPathCamController.Instance.enabled = !EntryDisablePathCam.Value; HarmonyInstance.PatchAll(type);
} }
private void OnUpdateSettings(object arg1, object arg2) => UpdateSettings(); catch (Exception e)
public override void OnUpdate()
{ {
if (EntryDisablePathCam.Value && !EntryDisableFlightBind.Value) LoggerInstance.Msg($"Failed while patching {type.Name}!");
{ LoggerInstance.Error(e);
if (Input.GetKeyDown(KeyCode.Keypad5))
{
PlayerSetup.Instance._movementSystem.ToggleFlight();
}
} }
} }
} }

View file

@ -20,10 +20,13 @@ using System.Reflection;
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")] [assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] [assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)] [assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
[assembly: MelonColor(255, 155, 89, 182)]
[assembly: MelonAuthorColor(255, 158, 21, 32)]
[assembly: HarmonyDontPatchAll]
namespace NAK.PathCamDisabler.Properties; namespace NAK.PathCamDisabler.Properties;
internal static class AssemblyInfoParams internal static class AssemblyInfoParams
{ {
public const string Version = "1.0.1"; public const string Version = "1.0.2";
public const string Author = "NotAKidoS"; public const string Author = "NotAKidoS";
} }

View file

@ -1,8 +1,8 @@
{ {
"_id": 110, "_id": 110,
"name": "PathCamDisabler", "name": "PathCamDisabler",
"modversion": "1.0.1", "modversion": "1.0.2",
"gameversion": "2022r170p1", "gameversion": "2023r171",
"loaderversion": "0.6.1", "loaderversion": "0.6.1",
"modtype": "Mod", "modtype": "Mod",
"author": "NotAKidoS", "author": "NotAKidoS",
@ -16,8 +16,8 @@
"requirements": [ "requirements": [
"None" "None"
], ],
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r3/PathCamDisabler.dll", "downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r16/PathCamDisabler.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/PathCamDisabler/", "sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/PathCamDisabler/",
"changelog": "- Organizational changes.\n- No longer using SaveToFile().", "changelog": "- Fixes for 2023r171.",
"embedcolor": "#9b59b6" "embedcolor": "#9b59b6"
} }