From 16e44f7c35ba6cb577ff05e6ff795147436327d4 Mon Sep 17 00:00:00 2001 From: NotAKidoS <37721153+NotAKidOnSteam@users.noreply.github.com> Date: Wed, 12 Jul 2023 12:09:00 -0500 Subject: [PATCH] [NoDepthOnlyFlat] Initial testing --- NoDepthOnlyFlat/Main.cs | 73 ++++++++++++++++++++++ NoDepthOnlyFlat/NoDepthOnlyFlat.csproj | 2 + NoDepthOnlyFlat/Properties/AssemblyInfo.cs | 29 +++++++++ NoDepthOnlyFlat/README.md | 14 +++++ NoDepthOnlyFlat/format.json | 23 +++++++ 5 files changed, 141 insertions(+) create mode 100644 NoDepthOnlyFlat/Main.cs create mode 100644 NoDepthOnlyFlat/NoDepthOnlyFlat.csproj create mode 100644 NoDepthOnlyFlat/Properties/AssemblyInfo.cs create mode 100644 NoDepthOnlyFlat/README.md create mode 100644 NoDepthOnlyFlat/format.json diff --git a/NoDepthOnlyFlat/Main.cs b/NoDepthOnlyFlat/Main.cs new file mode 100644 index 0000000..66c0927 --- /dev/null +++ b/NoDepthOnlyFlat/Main.cs @@ -0,0 +1,73 @@ +using ABI_RC.Core.Base; +using ABI_RC.Core.Player; +using MelonLoader; +using System.Reflection; +using System.Web.Services.Description; +using ABI_RC.Systems.Camera; +using UnityEngine; +using Valve.VR.InteractionSystem; + +namespace NAK.NoDepthOnlyFlat; + +public class NoDepthOnlyFlat : MelonMod +{ + public static readonly MelonPreferences_Category Category = + MelonPreferences.CreateCategory(nameof(NoDepthOnlyFlat)); + + public static readonly MelonPreferences_Entry EntryUseDepthOnPlayerCamera = + Category.CreateEntry("Use Depth On Player Camera", false, description: "Toggle depth texture on player cameras."); + + public static readonly MelonPreferences_Entry EntryUseDepthOnPortableCamera = + Category.CreateEntry("Use Depth On Portable Camera", false, description: "Toggle depth texture on portable camera."); + + public override void OnInitializeMelon() + { + HarmonyInstance.Patch( + typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.Start)), + postfix: new HarmonyLib.HarmonyMethod(typeof(NoDepthOnlyFlat).GetMethod(nameof(OnPlayerSetupStart_Postfix), BindingFlags.NonPublic | BindingFlags.Static)) + ); + + HarmonyInstance.Patch( + typeof(PortableCamera).GetMethod(nameof(PortableCamera.Start)), + postfix: new HarmonyLib.HarmonyMethod(typeof(NoDepthOnlyFlat).GetMethod(nameof(OnPortableCameraStart_Postfix), BindingFlags.NonPublic | BindingFlags.Static)) + ); + + foreach (MelonPreferences_Entry setting in Category.Entries) + setting.OnEntryValueChangedUntyped.Subscribe(OnSettingsChanged); + } + + public static void OnSettingsChanged(object oldValue = null, object newValue = null) + { + SetPlayerSetupCameraDepthTextureMode(EntryUseDepthOnPlayerCamera.Value); + SetPortableCameraDepthTextureMode(EntryUseDepthOnPortableCamera.Value); + } + + private static void SetPlayerSetupCameraDepthTextureMode(bool useDepth) + { + if (PlayerSetup.Instance != null) + { + PlayerSetup.Instance.desktopCamera.GetComponent().depthTextureMode = useDepth ? DepthTextureMode.Depth : DepthTextureMode.None; + PlayerSetup.Instance.vrCamera.GetComponent().depthTextureMode = useDepth ? DepthTextureMode.Depth : DepthTextureMode.None; + } + } + + private static void SetPortableCameraDepthTextureMode(bool useDepth) + { + if (PortableCamera.Instance != null) + { + PortableCamera.Instance._camera.depthTextureMode = useDepth ? DepthTextureMode.Depth : DepthTextureMode.None; + } + } + + // Lazy way to set settings on start + + private static void OnPlayerSetupStart_Postfix() + { + SetPlayerSetupCameraDepthTextureMode(EntryUseDepthOnPlayerCamera.Value); + } + + private static void OnPortableCameraStart_Postfix() + { + SetPortableCameraDepthTextureMode(EntryUseDepthOnPortableCamera.Value); + } +} \ No newline at end of file diff --git a/NoDepthOnlyFlat/NoDepthOnlyFlat.csproj b/NoDepthOnlyFlat/NoDepthOnlyFlat.csproj new file mode 100644 index 0000000..e94f9dc --- /dev/null +++ b/NoDepthOnlyFlat/NoDepthOnlyFlat.csproj @@ -0,0 +1,2 @@ + + diff --git a/NoDepthOnlyFlat/Properties/AssemblyInfo.cs b/NoDepthOnlyFlat/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..071ec15 --- /dev/null +++ b/NoDepthOnlyFlat/Properties/AssemblyInfo.cs @@ -0,0 +1,29 @@ +using MelonLoader; +using NAK.NoDepthOnlyFlat.Properties; +using System.Reflection; + +[assembly: AssemblyVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyTitle(nameof(NAK.NoDepthOnlyFlat))] +[assembly: AssemblyCompany(AssemblyInfoParams.Author)] +[assembly: AssemblyProduct(nameof(NAK.NoDepthOnlyFlat))] + +[assembly: MelonInfo( + typeof(NAK.NoDepthOnlyFlat.NoDepthOnlyFlat), + nameof(NAK.NoDepthOnlyFlat), + AssemblyInfoParams.Version, + AssemblyInfoParams.Author, + downloadLink: "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/NoDepthOnlyFlat" +)] + +[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")] +[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] +[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)] + +namespace NAK.NoDepthOnlyFlat.Properties; +internal static class AssemblyInfoParams +{ + public const string Version = "1.0.0"; + public const string Author = "NotAKidoS"; +} \ No newline at end of file diff --git a/NoDepthOnlyFlat/README.md b/NoDepthOnlyFlat/README.md new file mode 100644 index 0000000..4a4d1b6 --- /dev/null +++ b/NoDepthOnlyFlat/README.md @@ -0,0 +1,14 @@ +# NoDepthOnlyFlat + +Sets depth texture mode for player and portable cameras or something. Shit together, have not tested, it could explode. + +--- + +Here is the block of text where I tell you this mod is not affiliated or endorsed by ABI. +https://documentation.abinteractive.net/official/legal/tos/#7-modding-our-games + +> This mod is an independent creation and is not affiliated with, supported by or approved by Alpha Blend Interactive. + +> Use of this mod is done so at the user's own risk and the creator cannot be held responsible for any issues arising from its use. + +> To the best of my knowledge, I have adhered to the Modding Guidelines established by Alpha Blend Interactive. diff --git a/NoDepthOnlyFlat/format.json b/NoDepthOnlyFlat/format.json new file mode 100644 index 0000000..b0daad9 --- /dev/null +++ b/NoDepthOnlyFlat/format.json @@ -0,0 +1,23 @@ +{ + "_id": 172, + "name": "NoDepthOnlyFlat", + "modversion": "1.0.0", + "gameversion": "2022r170p1", + "loaderversion": "0.6.1", + "modtype": "Mod", + "author": "Exterrata & NotAKidoS", + "description": "A simple mod to add an audio cue for muting and unmuting.\n\nYou can replace the sfx in 'ChilloutVR\\ChilloutVR_Data\\StreamingAssets\\Cohtml\\UIResources\\GameUI\\mods\\NoDepthOnlyFlat\\audio'.", + "searchtags": [ + "mute", + "unmute", + "audio", + "sound" + ], + "requirements": [ + "None" + ], + "downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r13/NoDepthOnlyFlat.dll", + "sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/NoDepthOnlyFlat/", + "changelog": "- Initial CVRMG release", + "embedcolor": "92e492" +} \ No newline at end of file