-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Leading hand option Hands extension with `Q`/`E` Joints fix Update to LeapSDK 5.16
- Loading branch information
Showing
22 changed files
with
9,130 additions
and
6,718 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.