mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-03 10:29:22 +00:00
Jump recover option
Preserve late update pose Upcoming mod support
This commit is contained in:
parent
988abd7d53
commit
4e0ddaadd4
7 changed files with 102 additions and 28 deletions
|
@ -150,14 +150,17 @@ namespace ml_lme
|
|||
}
|
||||
}
|
||||
|
||||
if(m_inVR)
|
||||
if(!ModSupporter.SkipFingersOverride())
|
||||
{
|
||||
m_inputManager.individualFingerTracking = !m_steamVrModule.GetIndexGestureToggle();
|
||||
m_inputManager.individualFingerTracking |= (l_data.m_leftHand.m_present || l_data.m_rightHand.m_present);
|
||||
if(m_inVR)
|
||||
{
|
||||
m_inputManager.individualFingerTracking = !m_steamVrModule.GetIndexGestureToggle();
|
||||
m_inputManager.individualFingerTracking |= (l_data.m_leftHand.m_present || l_data.m_rightHand.m_present);
|
||||
}
|
||||
else
|
||||
m_inputManager.individualFingerTracking = (l_data.m_leftHand.m_present || l_data.m_rightHand.m_present);
|
||||
IKSystem.Instance.FingerSystem.controlActive = m_inputManager.individualFingerTracking;
|
||||
}
|
||||
else
|
||||
m_inputManager.individualFingerTracking = (l_data.m_leftHand.m_present || l_data.m_rightHand.m_present);
|
||||
IKSystem.Instance.FingerSystem.controlActive = m_inputManager.individualFingerTracking;
|
||||
}
|
||||
|
||||
m_handRayLeft.enabled = (l_data.m_leftHand.m_present && (!m_inVR || !Utils.IsLeftHandTracked() || !Settings.FingersOnly));
|
||||
|
|
37
ml_lme/ModSupporter.cs
Normal file
37
ml_lme/ModSupporter.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ml_lme
|
||||
{
|
||||
static class ModSupporter
|
||||
{
|
||||
static bool ms_copycatMod = false;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
if(MelonLoader.MelonMod.RegisteredMelons.FirstOrDefault(m => m.Info.Name == "PlayerMovementCopycat") != null)
|
||||
MelonLoader.MelonCoroutines.Start(WaitForCopycatInstance());
|
||||
}
|
||||
|
||||
// PlayerMovementCopycat support
|
||||
static IEnumerator WaitForCopycatInstance()
|
||||
{
|
||||
while(ml_pmc.PoseCopycat.Instance == null)
|
||||
yield return null;
|
||||
|
||||
ms_copycatMod = true;
|
||||
}
|
||||
static bool IsCopycating() => (ml_pmc.PoseCopycat.Instance.IsActive() && ml_pmc.PoseCopycat.Instance.IsFingerTrackingActive());
|
||||
|
||||
public static bool SkipFingersOverride()
|
||||
{
|
||||
bool l_result = false;
|
||||
l_result |= (ms_copycatMod && IsCopycating());
|
||||
return l_result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -55,6 +55,10 @@
|
|||
<HintPath>C:\Games\Steam\steamapps\common\ChilloutVR\MelonLoader\MelonLoader.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="ml_pmc">
|
||||
<HintPath>D:\Games\Steam\steamapps\common\ChilloutVR\Mods\ml_pmc.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
|
@ -89,6 +93,7 @@
|
|||
<Compile Include="LeapTracked.cs" />
|
||||
<Compile Include="LeapTracking.cs" />
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="ModSupporter.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Scripts.cs" />
|
||||
<Compile Include="Settings.cs" />
|
||||
|
|
|
@ -126,12 +126,12 @@ namespace ml_prm
|
|||
}
|
||||
|
||||
static void OnSetupIKScaling_Postfix(ref UnityEngine.Vector3 ___scaleDifference) => ms_instance?.OnSetupIKScaling(___scaleDifference.y);
|
||||
void OnSetupIKScaling(float scaleDifference)
|
||||
void OnSetupIKScaling(float p_scaleDifference)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (m_localController != null)
|
||||
m_localController.OnAvatarScaling(1f + scaleDifference);
|
||||
m_localController.OnAvatarScaling(1f + p_scaleDifference);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace ml_prm
|
|||
Slipperiness,
|
||||
Bounciness,
|
||||
ViewVelocity,
|
||||
JumpRecover,
|
||||
VelocityMultiplier,
|
||||
MovementDrag,
|
||||
AngularDrag,
|
||||
|
@ -77,6 +78,9 @@ namespace ml_prm
|
|||
ms_uiElements.Add(l_modCategory.AddToggle("View direction velocity", "Apply velocity to camera view direction", Settings.ViewVelocity));
|
||||
(ms_uiElements[(int)UiIndex.ViewVelocity] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) => OnToggleUpdate(UiIndex.ViewVelocity, state);
|
||||
|
||||
ms_uiElements.Add(l_modCategory.AddToggle("Jump recover", "Recover from ragdoll state by jumping", Settings.JumpRecover));
|
||||
(ms_uiElements[(int)UiIndex.JumpRecover] as BTKUILib.UIObjects.Components.ToggleButton).OnValueUpdated += (state) => OnToggleUpdate(UiIndex.JumpRecover, state);
|
||||
|
||||
ms_uiElements.Add(l_modRoot.AddSlider("Velocity multiplier", "Velocity multiplier upon entering ragdoll state", Settings.VelocityMultiplier, 1f, 50f));
|
||||
(ms_uiElements[(int)UiIndex.VelocityMultiplier] as BTKUILib.UIObjects.Components.SliderFloat).OnValueUpdated += (value) => OnSliderUpdate(UiIndex.VelocityMultiplier, value);
|
||||
|
||||
|
@ -131,6 +135,10 @@ namespace ml_prm
|
|||
case UiIndex.ViewVelocity:
|
||||
Settings.SetSetting(Settings.ModSetting.ViewVelocity, p_state);
|
||||
break;
|
||||
|
||||
case UiIndex.JumpRecover:
|
||||
Settings.SetSetting(Settings.ModSetting.JumpRecover, p_state);
|
||||
break;
|
||||
}
|
||||
|
||||
if(p_force)
|
||||
|
@ -173,6 +181,7 @@ namespace ml_prm
|
|||
OnToggleUpdate(UiIndex.Slipperiness, false, true);
|
||||
OnToggleUpdate(UiIndex.Bounciness, false, true);
|
||||
OnToggleUpdate(UiIndex.ViewVelocity, false, true);
|
||||
OnToggleUpdate(UiIndex.JumpRecover, false, true);
|
||||
OnSliderUpdate(UiIndex.VelocityMultiplier, 2f, true);
|
||||
OnSliderUpdate(UiIndex.MovementDrag, 2f, true);
|
||||
OnSliderUpdate(UiIndex.AngularDrag, 2f, true);
|
||||
|
|
|
@ -133,25 +133,39 @@ namespace ml_prm
|
|||
}
|
||||
}
|
||||
|
||||
if(Settings.Hotkey && Input.GetKeyDown(KeyCode.R) && !ViewManager.Instance.isGameMenuOpen())
|
||||
SwitchRagdoll();
|
||||
|
||||
if((m_avatarRagdollToggle != null) && m_avatarRagdollToggle.isActiveAndEnabled && m_avatarRagdollToggle.shouldOverride && (m_enabled != m_avatarRagdollToggle.isOn))
|
||||
SwitchRagdoll();
|
||||
|
||||
if((m_customTrigger != null) && m_customTrigger.GetStateWithReset() && m_avatarReady && !m_enabled && Settings.PointersReaction)
|
||||
SwitchRagdoll();
|
||||
|
||||
if(Settings.Hotkey && Input.GetKeyDown(KeyCode.R) && !ViewManager.Instance.isGameMenuOpen())
|
||||
SwitchRagdoll();
|
||||
|
||||
if(m_avatarReady && m_enabled && CVRInputManager.Instance.jump && Settings.JumpRecover)
|
||||
SwitchRagdoll();
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
if(m_avatarReady && m_enabled && !BodySystem.isCalibrating)
|
||||
if(m_avatarReady)
|
||||
{
|
||||
if(BodySystem.isCalibratedAsFullBody)
|
||||
BodySystem.TrackingPositionWeight = 0f;
|
||||
if(m_enabled)
|
||||
{
|
||||
if(!BodySystem.isCalibrating)
|
||||
{
|
||||
if(BodySystem.isCalibratedAsFullBody)
|
||||
BodySystem.TrackingPositionWeight = 0f;
|
||||
|
||||
foreach(var l_link in m_boneLinks)
|
||||
l_link.Item1.CopyGlobal(l_link.Item2);
|
||||
foreach(var l_link in m_boneLinks)
|
||||
l_link.Item1.CopyGlobal(l_link.Item2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach(var l_link in m_boneLinks)
|
||||
l_link.Item2.CopyGlobal(l_link.Item1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,15 +301,13 @@ namespace ml_prm
|
|||
}
|
||||
}
|
||||
|
||||
internal void OnAvatarScaling(float scaleDifference)
|
||||
internal void OnAvatarScaling(float p_scaleDifference)
|
||||
{
|
||||
if(m_avatarReady)
|
||||
{
|
||||
m_puppetRoot.localScale = Vector3.one * scaleDifference;
|
||||
for(int i = 0; i < m_jointAnchors.Count; i++)
|
||||
{
|
||||
m_jointAnchors[i].Item1.connectedAnchor = m_jointAnchors[i].Item2 * scaleDifference;
|
||||
}
|
||||
m_puppetRoot.localScale = Vector3.one * p_scaleDifference;
|
||||
foreach(var l_pair in m_jointAnchors)
|
||||
l_pair.Item1.connectedAnchor = l_pair.Item2 * p_scaleDifference;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -437,10 +449,6 @@ namespace ml_prm
|
|||
if(!Utils.IsWorldSafe())
|
||||
m_reachedGround = false; // Force player to unragdoll and reach ground first
|
||||
|
||||
// Copy before set to non-kinematic to reduce stacked forces
|
||||
foreach(var l_link in m_boneLinks)
|
||||
l_link.Item2.CopyGlobal(l_link.Item1);
|
||||
|
||||
m_puppetRoot.gameObject.SetActive(true);
|
||||
|
||||
foreach(Rigidbody l_body in m_rigidBodies)
|
||||
|
|
|
@ -21,7 +21,8 @@ namespace ml_prm
|
|||
RecoverDelay,
|
||||
Slipperiness,
|
||||
Bounciness,
|
||||
ViewVelocity
|
||||
ViewVelocity,
|
||||
JumpRecover
|
||||
}
|
||||
|
||||
public static bool Hotkey { get; private set; } = true;
|
||||
|
@ -37,6 +38,7 @@ namespace ml_prm
|
|||
public static bool Slipperiness { get; private set; } = false;
|
||||
public static bool Bounciness { get; private set; } = false;
|
||||
public static bool ViewVelocity { get; private set; } = false;
|
||||
public static bool JumpRecover { get; private set; } = false;
|
||||
|
||||
static public event Action<bool> HotkeyChange;
|
||||
static public event Action<float> VelocityMultiplierChange;
|
||||
|
@ -51,6 +53,7 @@ namespace ml_prm
|
|||
static public event Action<bool> SlipperinessChange;
|
||||
static public event Action<bool> BouncinessChange;
|
||||
static public event Action<bool> ViewVelocityChange;
|
||||
static public event Action<bool> JumpRecoverChange;
|
||||
|
||||
static MelonLoader.MelonPreferences_Category ms_category = null;
|
||||
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
|
||||
|
@ -72,7 +75,8 @@ namespace ml_prm
|
|||
ms_category.CreateEntry(ModSetting.RecoverDelay.ToString(), RecoverDelay),
|
||||
ms_category.CreateEntry(ModSetting.Slipperiness.ToString(), Slipperiness),
|
||||
ms_category.CreateEntry(ModSetting.Bounciness.ToString(), Bounciness),
|
||||
ms_category.CreateEntry(ModSetting.ViewVelocity.ToString(), ViewVelocity)
|
||||
ms_category.CreateEntry(ModSetting.ViewVelocity.ToString(), ViewVelocity),
|
||||
ms_category.CreateEntry(ModSetting.JumpRecover.ToString(), JumpRecover)
|
||||
};
|
||||
|
||||
Hotkey = (bool)ms_entries[(int)ModSetting.Hotkey].BoxedValue;
|
||||
|
@ -88,6 +92,7 @@ namespace ml_prm
|
|||
Slipperiness = (bool)ms_entries[(int)ModSetting.Slipperiness].BoxedValue;
|
||||
Bounciness = (bool)ms_entries[(int)ModSetting.Bounciness].BoxedValue;
|
||||
ViewVelocity = (bool)ms_entries[(int)ModSetting.ViewVelocity].BoxedValue;
|
||||
JumpRecover = (bool)ms_entries[(int)ModSetting.JumpRecover].BoxedValue;
|
||||
}
|
||||
|
||||
public static void SetSetting(ModSetting p_settings, object p_value)
|
||||
|
@ -158,6 +163,13 @@ namespace ml_prm
|
|||
}
|
||||
break;
|
||||
|
||||
case ModSetting.JumpRecover:
|
||||
{
|
||||
JumpRecover = (bool)p_value;
|
||||
JumpRecoverChange?.Invoke((bool)p_value);
|
||||
}
|
||||
break;
|
||||
|
||||
// Floats
|
||||
case ModSetting.VelocityMultiplier:
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue