diff --git a/DropPropTweak/DropPropTweak.csproj b/DropPropTweak/DropPropTweak.csproj new file mode 100644 index 0000000..4e44ed3 --- /dev/null +++ b/DropPropTweak/DropPropTweak.csproj @@ -0,0 +1,11 @@ + + + + net48 + + + + ..\.ManagedLibs\TheClapper.dll + + + diff --git a/DropPropTweak/Main.cs b/DropPropTweak/Main.cs new file mode 100644 index 0000000..1d71dbc --- /dev/null +++ b/DropPropTweak/Main.cs @@ -0,0 +1,49 @@ +using System.Reflection; +using ABI_RC.Core.Player; +using ABI_RC.Core.Util; +using HarmonyLib; +using MelonLoader; +using UnityEngine; + +namespace NAK.DropPropTweak; + +public class DropPropTweakMod : MelonMod +{ + public override void OnInitializeMelon() + { + HarmonyInstance.Patch( // make drop prop actually usable + typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.DropProp), + BindingFlags.Public | BindingFlags.Instance), + new HarmonyMethod(typeof(DropPropTweakMod).GetMethod(nameof(OnDropProp), + BindingFlags.NonPublic | BindingFlags.Static)) + ); + } + + private static bool OnDropProp(string propGuid, ref PlayerSetup __instance) + { + Vector3 position = __instance.activeCam.transform.position + __instance.GetPlayerForward() * 1.5f; // 1f -> 1.5f + + if (Physics.Raycast(position, + __instance.CharacterController.GetGravityDirection(), // align with gravity, not player up + out RaycastHit raycastHit, 4f, __instance.dropPlacementMask)) + { + // native method passes false, so DropProp doesn't align with gravity :) + CVRSyncHelper.SpawnProp(propGuid, raycastHit.point.x, raycastHit.point.y, raycastHit.point.z, true); + return false; + } + + // unlike original, we will still spawn prop even if raycast fails, giving the method actual utility :3 + + // hack- we want to align with *our* rotation, not affecting gravity + Vector3 ogGravity = __instance.CharacterController.GetGravityDirection(); + __instance.CharacterController.gravity = -__instance.transform.up; // align with our rotation + + // spawn prop with useTargetLocationGravity false, so it pulls our gravity dir we've modified + CVRSyncHelper.SpawnProp(propGuid, position.x, position.y, position.z, false); + + __instance.CharacterController.gravity = ogGravity; // restore gravity + return false; + } + + +} \ No newline at end of file diff --git a/DropPropTweak/Properties/AssemblyInfo.cs b/DropPropTweak/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..3fd0e7a --- /dev/null +++ b/DropPropTweak/Properties/AssemblyInfo.cs @@ -0,0 +1,32 @@ +using NAK.DropPropTweak.Properties; +using MelonLoader; +using System.Reflection; + +[assembly: AssemblyVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyTitle(nameof(NAK.DropPropTweak))] +[assembly: AssemblyCompany(AssemblyInfoParams.Author)] +[assembly: AssemblyProduct(nameof(NAK.DropPropTweak))] + +[assembly: MelonInfo( + typeof(NAK.DropPropTweak.DropPropTweakMod), + nameof(NAK.DropPropTweak), + AssemblyInfoParams.Version, + AssemblyInfoParams.Author, + downloadLink: "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/DropPropTweak" +)] + +[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.DropPropTweak.Properties; +internal static class AssemblyInfoParams +{ + public const string Version = "1.0.0"; + public const string Author = "Exterrata & NotAKidoS"; +} \ No newline at end of file diff --git a/DropPropTweak/README.md b/DropPropTweak/README.md new file mode 100644 index 0000000..33bd3fd --- /dev/null +++ b/DropPropTweak/README.md @@ -0,0 +1,14 @@ +# DropPropTweak + +Gives the Drop Prop button more utility by allowing you to drop props in the air. + +--- + +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. diff --git a/DropPropTweak/format.json b/DropPropTweak/format.json new file mode 100644 index 0000000..8b8a474 --- /dev/null +++ b/DropPropTweak/format.json @@ -0,0 +1,23 @@ +{ + "_id": -1, + "name": "DropPropTweak", + "modversion": "1.0.0", + "gameversion": "2024r175", + "loaderversion": "0.6.1", + "modtype": "Mod", + "author": "NotAKidoS", + "description": "Gives the Drop Prop button more utility by allowing you to drop props in the air.", + "searchtags": [ + "prop", + "spawn", + "indicator", + "loading" + ], + "requirements": [ + "None" + ], + "downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r34/DropPropTweak.dll", + "sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/DropPropTweak/", + "changelog": "- Initial Release", + "embedcolor": "#f61963" +} \ No newline at end of file