mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
SmartReticle: initial release
This commit is contained in:
parent
cccac75502
commit
0b96d9347f
5 changed files with 176 additions and 0 deletions
101
SmartReticle/Main.cs
Normal file
101
SmartReticle/Main.cs
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
using ABI_RC.Core.InteractionSystem;
|
||||||
|
using ABI_RC.Core.Player;
|
||||||
|
using ABI_RC.Core.UI;
|
||||||
|
using HarmonyLib;
|
||||||
|
using MelonLoader;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace NAK.SmartReticle;
|
||||||
|
|
||||||
|
public class SmartReticleMod : MelonMod
|
||||||
|
{
|
||||||
|
#region Melon Preferences
|
||||||
|
|
||||||
|
private const string SettingsCategory = nameof(SmartReticleMod);
|
||||||
|
|
||||||
|
private static readonly MelonPreferences_Category Category =
|
||||||
|
MelonPreferences.CreateCategory(SettingsCategory);
|
||||||
|
|
||||||
|
private static readonly MelonPreferences_Entry<bool> Entry_Enabled =
|
||||||
|
Category.CreateEntry("enabled", true, display_name: "Enabled",description: "Toggle SmartReticleMod entirely.");
|
||||||
|
|
||||||
|
private static readonly MelonPreferences_Entry<float> Entry_HideTimeout =
|
||||||
|
Category.CreateEntry("hide_timeout", 1f, display_name: "Hide Timeout (s)", description: "Timeout before the reticle hides again. Set to 0 to instantly hide.");
|
||||||
|
|
||||||
|
#endregion Melon Preferences
|
||||||
|
|
||||||
|
public override void OnInitializeMelon()
|
||||||
|
{
|
||||||
|
ApplyPatches(typeof(ControllerRay_Patches));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ApplyPatches(Type type)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HarmonyInstance.PatchAll(type);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LoggerInstance.Msg($"Failed while patching {type.Name}!");
|
||||||
|
LoggerInstance.Error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Patches
|
||||||
|
|
||||||
|
private static class ControllerRay_Patches
|
||||||
|
{
|
||||||
|
private static Transform _mainMenuTransform;
|
||||||
|
private static Transform _quickMenuTransform;
|
||||||
|
private static float _lastDisplayedTime;
|
||||||
|
|
||||||
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch(typeof(ControllerRay), nameof(ControllerRay.Start))]
|
||||||
|
private static void Postfix_ControllerRay_Start()
|
||||||
|
{
|
||||||
|
_mainMenuTransform = ViewManager.Instance.transform;
|
||||||
|
_quickMenuTransform = CVR_MenuManager.Instance.transform;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch(typeof(ControllerRay), nameof(ControllerRay.DisplayAuraHighlight))]
|
||||||
|
private static void Postfix_ControllerRay_DisplayAuraHighlight(ref ControllerRay __instance)
|
||||||
|
{
|
||||||
|
if (!Entry_Enabled.Value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!__instance.isDesktopRay)
|
||||||
|
return;
|
||||||
|
|
||||||
|
GameObject desktopPointer = CohtmlHud.Instance.desktopPointer;
|
||||||
|
|
||||||
|
if (!desktopPointer.activeSelf)
|
||||||
|
{
|
||||||
|
_lastDisplayedTime = 0; // reset time
|
||||||
|
return; // pointing at menu or cursor is active
|
||||||
|
}
|
||||||
|
|
||||||
|
bool shouldDisplayPointer = (__instance._interact // pressing mouse1 or mouse2
|
||||||
|
|| __instance._isTryingToPickup
|
||||||
|
// using some tool/utility
|
||||||
|
|| (PlayerSetup.Instance.GetCurrentPropSelectionMode()
|
||||||
|
!= PlayerSetup.PropSelectionMode.None)
|
||||||
|
// hit something- other than the two menus
|
||||||
|
|| (__instance._objectWasHit
|
||||||
|
&& (__instance.hitTransform != _mainMenuTransform
|
||||||
|
&& __instance.hitTransform != _quickMenuTransform)));
|
||||||
|
|
||||||
|
if (shouldDisplayPointer)
|
||||||
|
{
|
||||||
|
_lastDisplayedTime = Time.time;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Time.time - _lastDisplayedTime > Entry_HideTimeout.Value)
|
||||||
|
desktopPointer.SetActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Patches
|
||||||
|
}
|
32
SmartReticle/Properties/AssemblyInfo.cs
Normal file
32
SmartReticle/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
using NAK.SmartReticle.Properties;
|
||||||
|
using MelonLoader;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
|
||||||
|
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
|
||||||
|
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
|
||||||
|
[assembly: AssemblyTitle(nameof(NAK.SmartReticle))]
|
||||||
|
[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
|
||||||
|
[assembly: AssemblyProduct(nameof(NAK.SmartReticle))]
|
||||||
|
|
||||||
|
[assembly: MelonInfo(
|
||||||
|
typeof(NAK.SmartReticle.SmartReticleMod),
|
||||||
|
nameof(NAK.SmartReticle),
|
||||||
|
AssemblyInfoParams.Version,
|
||||||
|
AssemblyInfoParams.Author,
|
||||||
|
downloadLink: "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/SmartReticle"
|
||||||
|
)]
|
||||||
|
|
||||||
|
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
|
||||||
|
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
||||||
|
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
||||||
|
[assembly: MelonColor(255, 246, 25, 99)] // red-pink
|
||||||
|
[assembly: MelonAuthorColor(255, 158, 21, 32)] // red
|
||||||
|
[assembly: HarmonyDontPatchAll]
|
||||||
|
|
||||||
|
namespace NAK.SmartReticle.Properties;
|
||||||
|
internal static class AssemblyInfoParams
|
||||||
|
{
|
||||||
|
public const string Version = "1.0.0";
|
||||||
|
public const string Author = "NotAKidoS";
|
||||||
|
}
|
14
SmartReticle/README.md
Normal file
14
SmartReticle/README.md
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# SmartReticle
|
||||||
|
|
||||||
|
Simple mod that makes the Desktop reticle only appear when needed.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Here is the block of text where I tell you this mod is not affiliated with or endorsed by ABI.
|
||||||
|
https://documentation.abinteractive.net/official/legal/tos/#7-modding-our-games
|
||||||
|
|
||||||
|
> This mod is an independent creation 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.
|
6
SmartReticle/SmartReticle.csproj
Normal file
6
SmartReticle/SmartReticle.csproj
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net48</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
23
SmartReticle/format.json
Normal file
23
SmartReticle/format.json
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"_id": -1,
|
||||||
|
"name": "SmartReticle",
|
||||||
|
"modversion": "1.0.0",
|
||||||
|
"gameversion": "2024r175",
|
||||||
|
"loaderversion": "0.6.1",
|
||||||
|
"modtype": "Mod",
|
||||||
|
"author": "NotAKidoS",
|
||||||
|
"description": "Simple mod that makes the Desktop reticle only appear when needed.",
|
||||||
|
"searchtags": [
|
||||||
|
"reticle",
|
||||||
|
"hud",
|
||||||
|
"cursor",
|
||||||
|
"dot"
|
||||||
|
],
|
||||||
|
"requirements": [
|
||||||
|
"None"
|
||||||
|
],
|
||||||
|
"downloadlink": "https://github.com/NotAKidoS/NAK_CVR_Mods/releases/download/r39/SmartReticle.dll",
|
||||||
|
"sourcelink": "https://github.com/NotAKidoS/NAK_CVR_Mods/tree/main/SmartReticle/",
|
||||||
|
"changelog": "- Initial Release",
|
||||||
|
"embedcolor": "#f61963"
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue