mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
rerelase
rawr
This commit is contained in:
parent
4183ecaa19
commit
4ed64d0f17
7 changed files with 581 additions and 0 deletions
191
PickupPushPull/Main.cs
Normal file
191
PickupPushPull/Main.cs
Normal file
|
@ -0,0 +1,191 @@
|
|||
using ABI.CCK.Components;
|
||||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.Savior;
|
||||
using HarmonyLib;
|
||||
using MelonLoader;
|
||||
using UnityEngine;
|
||||
using Valve.VR;
|
||||
|
||||
namespace PickupPushPull;
|
||||
|
||||
public class PickupPushPull : MelonMod
|
||||
{
|
||||
private static MelonPreferences_Category m_categoryPickupPushPull;
|
||||
private static MelonPreferences_Entry<float> m_entryPushPullSpeed;
|
||||
private static MelonPreferences_Entry<float> m_entryRotateSpeed;
|
||||
private static MelonPreferences_Entry<bool> m_entryEnableRotation;
|
||||
|
||||
//not sure if im gonna implement that switch hell for gamepad or mouse yet...
|
||||
private static MelonPreferences_Entry<BindingOptionsVR> m_entryRotateBindsVR;
|
||||
private static MelonPreferences_Entry<BindHandVR> m_entryRotateBindHandVR;
|
||||
|
||||
private enum BindHandVR
|
||||
{
|
||||
LeftHand,
|
||||
RightHand
|
||||
}
|
||||
private enum BindingOptionsVR
|
||||
{
|
||||
ButtonATouch,
|
||||
ButtonBTouch,
|
||||
StickTouch,
|
||||
TriggerTouch
|
||||
}
|
||||
|
||||
public override void OnApplicationStart()
|
||||
{
|
||||
m_categoryPickupPushPull = MelonPreferences.CreateCategory(nameof(PickupPushPull));
|
||||
m_entryPushPullSpeed = m_categoryPickupPushPull.CreateEntry("PushPullSpeed", 1f, description: "Up/down on right joystick for VR. Left bumper + Up/down on right joystick for Gamepad.");
|
||||
m_entryRotateSpeed = m_categoryPickupPushPull.CreateEntry<float>("RotateSpeed", 1f);
|
||||
m_entryEnableRotation = m_categoryPickupPushPull.CreateEntry<bool>("EnableRotation", false, description: "Hold left trigger in VR or right bumper on Gamepad.");
|
||||
m_entryRotateBindHandVR = m_categoryPickupPushPull.CreateEntry("VR Hand", BindHandVR.LeftHand);
|
||||
m_entryRotateBindsVR = m_categoryPickupPushPull.CreateEntry("VR Binding", BindingOptionsVR.ButtonATouch);
|
||||
|
||||
m_categoryPickupPushPull.SaveToFile(false);
|
||||
m_entryPushPullSpeed.OnValueChangedUntyped += UpdateSettings;
|
||||
m_entryRotateSpeed.OnValueChangedUntyped += UpdateSettings;
|
||||
m_entryEnableRotation.OnValueChangedUntyped += UpdateSettings;
|
||||
|
||||
UpdateSettings();
|
||||
}
|
||||
private static void UpdateSettings()
|
||||
{
|
||||
HarmonyPatches.ppSpeed = m_entryPushPullSpeed.Value;
|
||||
HarmonyPatches.rotSpeed = m_entryRotateSpeed.Value;
|
||||
HarmonyPatches.enableRot = m_entryEnableRotation.Value;
|
||||
HarmonyPatches.rotBindVR = m_entryRotateBindsVR.Value;
|
||||
HarmonyPatches.rotHandVR = (SteamVR_Input_Sources)m_entryRotateBindHandVR.Value + 1;
|
||||
}
|
||||
|
||||
[HarmonyPatch]
|
||||
private class HarmonyPatches
|
||||
{
|
||||
//UpdateSettings() on app start immediatly overrides these :shrug:
|
||||
public static float ppSpeed = m_entryPushPullSpeed.Value;
|
||||
public static float rotSpeed = m_entryRotateSpeed.Value;
|
||||
public static bool enableRot = m_entryEnableRotation.Value;
|
||||
public static BindingOptionsVR rotBindVR = m_entryRotateBindsVR.Value;
|
||||
public static SteamVR_Input_Sources rotHandVR = (SteamVR_Input_Sources)m_entryRotateBindHandVR.Value + 1;
|
||||
|
||||
private static float objectPitch = 0f;
|
||||
private static float objectYaw = 0f;
|
||||
|
||||
private static bool lockedVRInput = false;
|
||||
private static bool lockedFSInput = false;
|
||||
private static CursorLockMode savedCursorLockState;
|
||||
|
||||
//uses code from https://github.com/ljoonal/CVR-Plugins/tree/main/RotateIt
|
||||
//GPL-3.0 license - Thank you ljoonal for being smart brain :plead:
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CVRPickupObject), "Update")]
|
||||
public static void GrabbedObjectPatch(ref CVRPickupObject __instance)
|
||||
{
|
||||
// Need to only run when the object is grabbed by the local player
|
||||
if (!__instance.IsGrabbedByMe()) return;
|
||||
|
||||
Quaternion originalRotation = __instance.transform.rotation;
|
||||
Transform referenceTransform = __instance._controllerRay.transform;
|
||||
|
||||
__instance.transform.RotateAround(__instance.transform.position, referenceTransform.right, objectPitch * Time.deltaTime);
|
||||
__instance.transform.RotateAround(__instance.transform.position, referenceTransform.up, objectYaw * Time.deltaTime);
|
||||
|
||||
// Add the new difference between the og rotation and our newly added rotation the the stored offset.
|
||||
__instance.initialRotationalOffset *= Quaternion.Inverse(__instance.transform.rotation) * originalRotation;
|
||||
}
|
||||
|
||||
//Reset object rotation input each frame
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(CVRInputManager), "Update")]
|
||||
private static void BeforeUpdate()
|
||||
{
|
||||
objectPitch = 0f;
|
||||
objectYaw = 0f;
|
||||
}
|
||||
|
||||
//Gamepad & Desktop Input Patch
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(InputModuleGamepad), "UpdateInput")]
|
||||
private static void AfterUpdateInput(ref bool ___enableGamepadInput)
|
||||
{
|
||||
|
||||
bool button1 = Input.GetButton("Controller Left Button") || Input.GetKey(KeyCode.Mouse4) || Input.GetKey(KeyCode.Mouse3);
|
||||
bool button2 = Input.GetButton("Controller Right Button") || Input.GetKey(KeyCode.Mouse3);
|
||||
|
||||
if (button1)
|
||||
{
|
||||
if (!lockedFSInput)
|
||||
{
|
||||
lockedFSInput = true;
|
||||
savedCursorLockState = Cursor.lockState;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
PlayerSetup.Instance._movementSystem.disableCameraControl = true;
|
||||
}
|
||||
if (button2 && enableRot)
|
||||
{
|
||||
objectPitch += rotSpeed * CVRInputManager.Instance.rawLookVector.y * -1;
|
||||
objectYaw += rotSpeed * CVRInputManager.Instance.rawLookVector.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
CVRInputManager.Instance.objectPushPull += CVRInputManager.Instance.rawLookVector.y * ppSpeed * Time.deltaTime;
|
||||
}
|
||||
}
|
||||
else if (lockedFSInput)
|
||||
{
|
||||
lockedFSInput = false;
|
||||
Cursor.lockState = savedCursorLockState;
|
||||
PlayerSetup.Instance._movementSystem.disableCameraControl = false;
|
||||
}
|
||||
}
|
||||
|
||||
//VR Input Patch
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(InputModuleSteamVR), "UpdateInput")]
|
||||
private static void AfterUpdateInputprivate(ref SteamVR_Action_Boolean ___steamVrButtonATouch, ref SteamVR_Action_Boolean ___steamVrButtonBTouch, ref SteamVR_Action_Boolean ___steamVrStickTouch, ref SteamVR_Action_Boolean ___steamVrTriggerTouch)
|
||||
{
|
||||
if (!MetaPort.Instance.isUsingVr) return;
|
||||
|
||||
bool button = false;
|
||||
|
||||
//not really sure this is optimal, i dont know all the cool c# tricks yet
|
||||
switch (rotBindVR)
|
||||
{
|
||||
case BindingOptionsVR.ButtonATouch:
|
||||
button = ___steamVrButtonATouch.GetState(rotHandVR);
|
||||
return;
|
||||
case BindingOptionsVR.ButtonBTouch:
|
||||
button = ___steamVrButtonBTouch.GetState(rotHandVR);
|
||||
return;
|
||||
case BindingOptionsVR.StickTouch:
|
||||
button = ___steamVrStickTouch.GetState(rotHandVR);
|
||||
return;
|
||||
case BindingOptionsVR.TriggerTouch:
|
||||
button = ___steamVrTriggerTouch.GetState(rotHandVR);
|
||||
return;
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (button && enableRot)
|
||||
{
|
||||
if (!lockedVRInput)
|
||||
{
|
||||
lockedVRInput = true;
|
||||
PlayerSetup.Instance._movementSystem.canRot = false;
|
||||
PlayerSetup.Instance._movementSystem.disableCameraControl = true;
|
||||
}
|
||||
objectPitch += rotSpeed * (CVRInputManager.Instance.floatDirection / 2f * -1);
|
||||
objectYaw += rotSpeed * CVRInputManager.Instance.rawLookVector.x;
|
||||
return;
|
||||
}
|
||||
else if (lockedVRInput)
|
||||
{
|
||||
lockedVRInput = false;
|
||||
PlayerSetup.Instance._movementSystem.canRot = true;
|
||||
PlayerSetup.Instance._movementSystem.disableCameraControl = false;
|
||||
}
|
||||
|
||||
CVRInputManager.Instance.objectPushPull += CVRInputManager.Instance.floatDirection * ppSpeed * Time.deltaTime;
|
||||
}
|
||||
}
|
||||
}
|
37
PickupPushPull/PickupPushPull.csproj
Normal file
37
PickupPushPull/PickupPushPull.csproj
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="0Harmony">
|
||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\0Harmony.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MelonLoader">
|
||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\MelonLoader.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SteamVR">
|
||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\SteamVR.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.CoreModule">
|
||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.InputLegacyModule">
|
||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.InputLegacyModule.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="Deploy" AfterTargets="Build">
|
||||
<Copy SourceFiles="$(TargetPath)" DestinationFolder="C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\Mods\" />
|
||||
<Message Text="Copied $(TargetPath) to C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\Mods\" Importance="high" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
25
PickupPushPull/PickupPushPull.sln
Normal file
25
PickupPushPull/PickupPushPull.sln
Normal file
|
@ -0,0 +1,25 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.2.32630.192
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GestureLock", "GestureLock.csproj", "{B318B038-DA12-4960-A35E-613BE26B7965}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{B318B038-DA12-4960-A35E-613BE26B7965}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B318B038-DA12-4960-A35E-613BE26B7965}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B318B038-DA12-4960-A35E-613BE26B7965}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B318B038-DA12-4960-A35E-613BE26B7965}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {0ABE9CFE-D4F5-4B5B-9D1A-5D0B1DA7E2CD}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
30
PickupPushPull/Properties/AssemblyInfo.cs
Normal file
30
PickupPushPull/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using PickupPushPull.Properties;
|
||||
using MelonLoader;
|
||||
using System.Reflection;
|
||||
|
||||
|
||||
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
|
||||
[assembly: AssemblyTitle(nameof(PickupPushPull))]
|
||||
[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
|
||||
[assembly: AssemblyProduct(nameof(PickupPushPull))]
|
||||
|
||||
[assembly: MelonInfo(
|
||||
typeof(PickupPushPull.PickupPushPull),
|
||||
nameof(PickupPushPull),
|
||||
AssemblyInfoParams.Version,
|
||||
AssemblyInfoParams.Author,
|
||||
downloadLink: "https://github.com/NotAKidOnSteam/PickupPushPull"
|
||||
)]
|
||||
|
||||
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
|
||||
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
||||
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
||||
|
||||
namespace PickupPushPull.Properties;
|
||||
internal static class AssemblyInfoParams
|
||||
{
|
||||
public const string Version = "2.0.0";
|
||||
public const string Author = "NotAKidoS";
|
||||
}
|
23
PickupPushPull/format.json
Normal file
23
PickupPushPull/format.json
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"_id": 91,
|
||||
"name": "PickupPushPull",
|
||||
"modversion": "1.1.0",
|
||||
"gameversion": "2022r168",
|
||||
"loaderversion": "0.5.4",
|
||||
"modtype": "Mod",
|
||||
"author": "NotAKidoS",
|
||||
"description": "Allows you to push & pull pickups with Gamepad or VR using the right joystick.",
|
||||
"searchtags": [
|
||||
"pull",
|
||||
"push",
|
||||
"pickup",
|
||||
"prop"
|
||||
],
|
||||
"requirements": [
|
||||
"None"
|
||||
],
|
||||
"downloadlink": "https://github.com/NotAKidOnSteam/PickupPP/releases/download/r3/PickupPushPull.dll",
|
||||
"sourcelink": "https://github.com/NotAKidOnSteam/PickupPP/",
|
||||
"changelog": "Switched to using Harmony Patches.",
|
||||
"embedcolor": "804221"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue