Minor changes and fixes

This commit is contained in:
SDraw 2023-04-19 15:00:37 +03:00
parent 1ef839af3f
commit ac5820d188
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
6 changed files with 28 additions and 21 deletions

View file

@ -5,7 +5,6 @@ using ABI_RC.Systems.IK.SubSystems;
using ABI_RC.Systems.MovementSystem;
using RootMotion.FinalIK;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
namespace ml_amt
@ -14,9 +13,6 @@ namespace ml_amt
class MotionTweaker : MonoBehaviour
{
static readonly Vector4 ms_pointVector = new Vector4(0f, 0f, 0f, 1f);
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 int ms_emoteHash = Animator.StringToHash("Emote");
enum PoseState
@ -121,8 +117,8 @@ namespace ml_amt
{
if(m_avatarReady)
{
m_grounded = (bool)ms_grounded.GetValue(MovementSystem.Instance);
m_groundedRaw = (bool)ms_groundedRaw.GetValue(MovementSystem.Instance);
m_grounded = MovementSystem.Instance.IsGrounded();
m_groundedRaw = MovementSystem.Instance.IsGroundedRaw();
m_moving = !Mathf.Approximately(MovementSystem.Instance.movementVector.magnitude, 0f);
// Update upright
@ -230,7 +226,7 @@ namespace ml_amt
m_locomotionOffset = m_vrIk.solver.locomotion.offset;
m_massCenter = m_locomotionOffset;
if((bool)ms_hasToes.GetValue(m_vrIk.solver))
if(m_vrIk.solver.HasToes())
{
Transform l_foot = PlayerSetup.Instance._animator.GetBoneTransform(HumanBodyBones.LeftFoot);
if(l_foot == null)

View file

@ -1,23 +1,32 @@
using System.Reflection;
using ABI_RC.Systems.MovementSystem;
using RootMotion.FinalIK;
using System.Reflection;
using UnityEngine;
namespace ml_amt
{
static class Utils
{
static MethodInfo ms_getSineKeyframes = typeof(RootMotion.FinalIK.IKSolverVR).GetMethod("GetSineKeyframes", BindingFlags.NonPublic | BindingFlags.Static);
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 MethodInfo ms_getSineKeyframes = typeof(IKSolverVR).GetMethod("GetSineKeyframes", BindingFlags.NonPublic | BindingFlags.Static);
public static bool IsInVR() => ((ABI_RC.Core.Savior.CheckVR.Instance != null) && ABI_RC.Core.Savior.CheckVR.Instance.hasVrDeviceLoaded);
// 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);
}
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 Keyframe[] GetSineKeyframes(float p_mag)
{
return (Keyframe[])ms_getSineKeyframes.Invoke(null, new object[] { p_mag });
}
// 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);
}
}
}