Skip to content

Commit

Permalink
Removed Upright
Browse files Browse the repository at this point in the history
Leading hand option
Hands extension with `Q`/`E`
Joints fix
Update to LeapSDK 5.16
  • Loading branch information
SDraw committed Nov 26, 2023
1 parent b6a200d commit aebf6c2
Show file tree
Hide file tree
Showing 22 changed files with 9,130 additions and 6,718 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Merged set of MelonLoader mods for ChilloutVR.
**Table for game build 2023r173:**
| Full name | Short name | Latest version | Available in [CVRMA](https://github.com/knah/CVRMelonAssistant) |
|:---------:|:----------:|:--------------:| :----------------------------------------------------------------|
| [Avatar Motion Tweaker](/ml_amt/README.md) | ml_amt | 1.3.4 [:arrow_down:](../../releases/latest/download/ml_amt.dll)| ✔ Yes |
| [Leap Motion Extension](/ml_lme/README.md)| ml_lme | 1.4.4 [:arrow_down:](../../releases/latest/download/ml_lme.dll)| ✔ Yes |
| [Pickup Arm Movement](/ml_pam/README.md)| ml_pam | 1.0.8 [:arrow_down:](../../releases/latest/download/ml_pam.dll)| ✔ Yes |
| [Avatar Motion Tweaker](/ml_amt/README.md) | ml_amt | 1.3.5 [:arrow_down:](../../releases/latest/download/ml_amt.dll)| ✔ Yes<br>⌛ Update review |
| [Leap Motion Extension](/ml_lme/README.md)| ml_lme | 1.4.5 [:arrow_down:](../../releases/latest/download/ml_lme.dll)| ✔ Yes<br>⌛ Update review |
| [Pickup Arm Movement](/ml_pam/README.md)| ml_pam | 1.0.9 [:arrow_down:](../../releases/latest/download/ml_pam.dll)| ✔ Yes<br>⌛ Update review |
| [Player Movement Copycat](/ml_pmc/README.md)| ml_pmc | 1.0.4 [:arrow_down:](../../releases/latest/download/ml_pmc.dll)| ✔ Yes<br>⌛ Update review |
| [Player Ragdoll Mod](/ml_prm/README.md) | ml_prm | 1.1.1 [:arrow_down:](../../releases/latest/download/ml_prm.dll)| ✔ Yes<br>⌛ Update review |
| [Vive Extended Input](/ml_vei/README.md) | ml_vei | 1.0.0 [:arrow_down:](../../releases/latest/download/ml_vei.dll)| ✔ Yes |
Expand Down
165 changes: 80 additions & 85 deletions ml_amt/AvatarParameter.cs
Original file line number Diff line number Diff line change
@@ -1,85 +1,80 @@
using ABI_RC.Core;
using System.Text.RegularExpressions;
using UnityEngine;

namespace ml_amt
{
class AvatarParameter
{
public enum ParameterType
{
Upright,
GroundedRaw,
Moving
}

readonly ParameterType m_type;
readonly string m_name;
readonly int m_hash = 0;
readonly bool m_sync;
readonly AnimatorControllerParameterType m_innerType;
readonly CVRAnimatorManager m_manager = null;

public AvatarParameter(ParameterType p_type, CVRAnimatorManager p_manager)
{
m_type = p_type;
m_name = p_type.ToString();
m_manager = p_manager;

Regex l_regex = new Regex("^#?" + m_name + '$');
foreach(var l_param in m_manager.animator.parameters)
{
if(l_regex.IsMatch(l_param.name))
{
m_hash = l_param.nameHash;
m_sync = (l_param.name[0] != '#');
m_innerType = l_param.type;
break;
}
}
}

public void Update(MotionTweaker p_tweaker)
{
switch(m_type)
{
case ParameterType.Upright:
SetFloat(p_tweaker.GetUpright());
break;

case ParameterType.GroundedRaw:
SetBoolean(p_tweaker.GetGroundedRaw());
break;

case ParameterType.Moving:
SetBoolean(p_tweaker.GetMoving());
break;
}
}

public bool IsValid() => (m_hash != 0);
public ParameterType GetParameterType() => m_type;

void SetFloat(float p_value)
{
if(m_innerType == AnimatorControllerParameterType.Float)
{
if(m_sync)
m_manager.SetAnimatorParameterFloat(m_name, p_value);
else
m_manager.animator.SetFloat(m_hash, p_value);
}
}

void SetBoolean(bool p_value)
{
if(m_innerType == AnimatorControllerParameterType.Bool)
{
if(m_sync)
m_manager.SetAnimatorParameterBool(m_name, p_value);
else
m_manager.animator.SetBool(m_hash, p_value);
}
}
}
}
using ABI_RC.Core;
using System.Text.RegularExpressions;
using UnityEngine;

namespace ml_amt
{
class AvatarParameter
{
public enum ParameterType
{
GroundedRaw,
Moving
}

readonly ParameterType m_type;
readonly string m_name;
readonly int m_hash = 0;
readonly bool m_sync;
readonly AnimatorControllerParameterType m_innerType;
readonly CVRAnimatorManager m_manager = null;

public AvatarParameter(ParameterType p_type, CVRAnimatorManager p_manager)
{
m_type = p_type;
m_name = p_type.ToString();
m_manager = p_manager;

Regex l_regex = new Regex("^#?" + m_name + '$');
foreach(var l_param in m_manager.animator.parameters)
{
if(l_regex.IsMatch(l_param.name))
{
m_hash = l_param.nameHash;
m_sync = (l_param.name[0] != '#');
m_innerType = l_param.type;
break;
}
}
}

public void Update(MotionTweaker p_tweaker)
{
switch(m_type)
{
case ParameterType.GroundedRaw:
SetBoolean(p_tweaker.GetGroundedRaw());
break;

case ParameterType.Moving:
SetBoolean(p_tweaker.GetMoving());
break;
}
}

public bool IsValid() => (m_hash != 0);
public ParameterType GetParameterType() => m_type;

void SetFloat(float p_value)
{
if(m_innerType == AnimatorControllerParameterType.Float)
{
if(m_sync)
m_manager.SetAnimatorParameterFloat(m_name, p_value);
else
m_manager.animator.SetFloat(m_hash, p_value);
}
}

void SetBoolean(bool p_value)
{
if(m_innerType == AnimatorControllerParameterType.Bool)
{
if(m_sync)
m_manager.SetAnimatorParameterBool(m_name, p_value);
else
m_manager.animator.SetBool(m_hash, p_value);
}
}
}
}
5 changes: 0 additions & 5 deletions ml_amt/MotionTweaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ internal void OnSetupAvatar()
m_avatarScale = Mathf.Abs(PlayerSetup.Instance._avatar.transform.localScale.y);

// Parse animator parameters
m_parameters.Add(new AvatarParameter(AvatarParameter.ParameterType.Upright, PlayerSetup.Instance.animatorManager));
m_parameters.Add(new AvatarParameter(AvatarParameter.ParameterType.GroundedRaw, PlayerSetup.Instance.animatorManager));
m_parameters.Add(new AvatarParameter(AvatarParameter.ParameterType.Moving, PlayerSetup.Instance.animatorManager));
m_parameters.RemoveAll(p => !p.IsValid());
Expand Down Expand Up @@ -246,11 +245,7 @@ void OnIKPreUpdate()
}

if(m_locomotionOverride && !l_locomotionOverride)
{
m_vrIk.solver.Reset();
if((IKSystem.VrikRootController != null) && !MovementSystem.Instance.sitting)
IKSystem.VrikRootController.enabled = true;
}
m_locomotionOverride = l_locomotionOverride;
}

Expand Down
2 changes: 1 addition & 1 deletion ml_amt/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[assembly: MelonLoader.MelonInfo(typeof(ml_amt.AvatarMotionTweaker), "AvatarMotionTweaker", "1.3.4", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
[assembly: MelonLoader.MelonInfo(typeof(ml_amt.AvatarMotionTweaker), "AvatarMotionTweaker", "1.3.5", "SDraw", "https://github.com/SDraw/ml_mods_cvr")]
[assembly: MelonLoader.MelonGame(null, "ChilloutVR")]
[assembly: MelonLoader.MelonPlatform(MelonLoader.MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
[assembly: MelonLoader.MelonPlatformDomain(MelonLoader.MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
93 changes: 47 additions & 46 deletions ml_amt/Utils.cs
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
using ABI.CCK.Components;
using ABI_RC.Core.UI;
using ABI_RC.Systems.MovementSystem;
using RootMotion.FinalIK;
using System.Reflection;
using UnityEngine;

namespace ml_amt
{
static class Utils
{
static readonly FieldInfo ms_grounded = typeof(MovementSystem).GetField("_isGrounded", BindingFlags.NonPublic | BindingFlags.Instance);
static readonly FieldInfo ms_groundedRaw = typeof(MovementSystem).GetField("_isGroundedRaw", BindingFlags.NonPublic | BindingFlags.Instance);
static readonly FieldInfo ms_hasToes = typeof(IKSolverVR).GetField("hasToes", BindingFlags.NonPublic | BindingFlags.Instance);
static readonly FieldInfo ms_view = typeof(CohtmlControlledViewWrapper).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance);

public static bool IsInVR() => ((ABI_RC.Core.Savior.CheckVR.Instance != null) && ABI_RC.Core.Savior.CheckVR.Instance.hasVrDeviceLoaded);

public static bool IsGrounded(this MovementSystem p_instance) => (bool)ms_grounded.GetValue(MovementSystem.Instance);
public static bool IsGroundedRaw(this MovementSystem p_instance) => (bool)ms_groundedRaw.GetValue(MovementSystem.Instance);

public static bool HasToes(this IKSolverVR p_instance) => (bool)ms_hasToes.GetValue(p_instance);

public static bool IsWorldSafe() => ((CVRWorld.Instance != null) && CVRWorld.Instance.allowFlying);
public static float GetWorldMovementLimit()
{
float l_result = 1f;
if(CVRWorld.Instance != null)
{
l_result = CVRWorld.Instance.baseMovementSpeed;
l_result *= CVRWorld.Instance.sprintMultiplier;
l_result *= CVRWorld.Instance.inAirMovementMultiplier;
l_result *= CVRWorld.Instance.flyMultiplier;
}
return l_result;
}

static public void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script);

// Engine extensions
public static Matrix4x4 GetMatrix(this Transform p_transform, bool p_pos = true, bool p_rot = true, bool p_scl = false)
{
return Matrix4x4.TRS(p_pos ? p_transform.position : Vector3.zero, p_rot ? p_transform.rotation : Quaternion.identity, p_scl ? p_transform.localScale : Vector3.one);
}
}
}
using ABI.CCK.Components;
using ABI_RC.Core.UI;
using ABI_RC.Systems.MovementSystem;
using RootMotion.FinalIK;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;

namespace ml_amt
{
static class Utils
{
static readonly FieldInfo ms_grounded = typeof(MovementSystem).GetField("_isGrounded", BindingFlags.NonPublic | BindingFlags.Instance);
static readonly FieldInfo ms_groundedRaw = typeof(MovementSystem).GetField("_isGroundedRaw", BindingFlags.NonPublic | BindingFlags.Instance);
static readonly FieldInfo ms_hasToes = typeof(IKSolverVR).GetField("hasToes", BindingFlags.NonPublic | BindingFlags.Instance);
static readonly FieldInfo ms_view = typeof(CohtmlControlledViewWrapper).GetField("_view", BindingFlags.NonPublic | BindingFlags.Instance);

public static bool IsInVR() => ((ABI_RC.Core.Savior.CheckVR.Instance != null) && ABI_RC.Core.Savior.CheckVR.Instance.hasVrDeviceLoaded);

public static bool IsGrounded(this MovementSystem p_instance) => (bool)ms_grounded.GetValue(MovementSystem.Instance);
public static bool IsGroundedRaw(this MovementSystem p_instance) => (bool)ms_groundedRaw.GetValue(MovementSystem.Instance);

public static bool HasToes(this IKSolverVR p_instance) => (bool)ms_hasToes.GetValue(p_instance);

public static bool IsWorldSafe() => ((CVRWorld.Instance != null) && CVRWorld.Instance.allowFlying);
public static float GetWorldMovementLimit()
{
float l_result = 1f;
if(CVRWorld.Instance != null)
{
l_result = CVRWorld.Instance.baseMovementSpeed;
l_result *= CVRWorld.Instance.sprintMultiplier;
l_result *= CVRWorld.Instance.inAirMovementMultiplier;
l_result *= CVRWorld.Instance.flyMultiplier;
}
return l_result;
}

static public void ExecuteScript(this CohtmlControlledViewWrapper p_instance, string p_script) => ((cohtml.Net.View)ms_view.GetValue(p_instance)).ExecuteScript(p_script);

// Engine extensions
public static Matrix4x4 GetMatrix(this Transform p_transform, bool p_pos = true, bool p_rot = true, bool p_scl = false)
{
return Matrix4x4.TRS(p_pos ? p_transform.position : Vector3.zero, p_rot ? p_transform.rotation : Quaternion.identity, p_scl ? p_transform.localScale : Vector3.one);
}
}
}
2 changes: 1 addition & 1 deletion ml_amt/ml_amt.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Company>None</Company>
<Product>AvatarMotionTweaker</Product>
<PackageId>AvatarMotionTweaker</PackageId>
<Version>1.3.4</Version>
<Version>1.3.5</Version>
<Platforms>x64</Platforms>
<AssemblyName>ml_amt</AssemblyName>
</PropertyGroup>
Expand Down
Loading

0 comments on commit aebf6c2

Please sign in to comment.