Features merge from experimental:

Settings rework
Finger tracking networks sync only if hands are tracked
Working fix for animator override controller
Mass center offset calculations
Steps scaling
This commit is contained in:
SDraw 2023-03-16 09:20:45 +03:00
parent 8338fb758a
commit 971466da24
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
13 changed files with 474 additions and 451 deletions

View file

@ -47,6 +47,11 @@ namespace ml_amt
null,
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnCalibrate_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
);
HarmonyInstance.Patch(
typeof(PlayerSetup).GetMethod("SetPlaySpaceScale", BindingFlags.NonPublic | BindingFlags.Instance),
null,
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnPlayspaceScale_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
);
// FBT detour
HarmonyInstance.Patch(
@ -70,16 +75,16 @@ namespace ml_amt
null
);
// AAS overriding "fix"
// AAS overriding fix
HarmonyInstance.Patch(
typeof(CVRAnimatorManager).GetMethod(nameof(CVRAnimatorManager.SetOverrideAnimation), BindingFlags.Instance),
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnAnimationOverride_Prefix), BindingFlags.Static | BindingFlags.NonPublic)),
null
typeof(CVRAnimatorManager).GetMethod(nameof(CVRAnimatorManager.SetOverrideAnimation)),
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnOverride_Prefix), BindingFlags.Static | BindingFlags.NonPublic)),
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnOverride_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
);
HarmonyInstance.Patch(
typeof(CVRAnimatorManager).GetMethod(nameof(CVRAnimatorManager.RestoreOverrideAnimation)),
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnAnimationOverrideRestore_Prefix), BindingFlags.Static | BindingFlags.NonPublic)),
null
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnOverride_Prefix), BindingFlags.Static | BindingFlags.NonPublic)),
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnOverride_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
);
MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer());
@ -93,7 +98,7 @@ namespace ml_amt
m_localTweaker = PlayerSetup.Instance.gameObject.AddComponent<MotionTweaker>();
m_localTweaker.SetIKOverrideCrouch(Settings.IKOverrideCrouch);
m_localTweaker.SetCrouchLimit(Settings.CrouchLimit);
m_localTweaker.SetIKOverrideCrouch(Settings.IKOverrideProne);
m_localTweaker.SetIKOverrideProne(Settings.IKOverrideProne);
m_localTweaker.SetProneLimit(Settings.ProneLimit);
m_localTweaker.SetPoseTransitions(Settings.PoseTransitions);
m_localTweaker.SetAdjustedMovement(Settings.AdjustedMovement);
@ -153,6 +158,20 @@ namespace ml_amt
}
}
static void OnPlayspaceScale_Postfix() => ms_instance?.OnPlayspaceScale();
void OnPlayspaceScale()
{
try
{
if(m_localTweaker != null)
m_localTweaker.OnPlayspaceScale();
}
catch(System.Exception l_exception)
{
MelonLoader.MelonLogger.Error(l_exception);
}
}
// FBT detection override
static void FBTDetour_Prefix()
{
@ -237,14 +256,38 @@ namespace ml_amt
return false;
}
static bool OnAnimationOverride_Prefix()
static void OnOverride_Prefix(ref CVRAnimatorManager __instance, ref bool __state)
{
return !Settings.OverrideFix;
try
{
if(Settings.OverrideFix && (__instance.animator != null))
{
__state = __instance.animator.enabled;
if(__state)
__instance.animator.enabled = false;
__instance.animator.WriteDefaultValues();
}
}
catch(System.Exception l_exception)
{
MelonLoader.MelonLogger.Error(l_exception);
}
}
static bool OnAnimationOverrideRestore_Prefix()
static void OnOverride_Postfix(ref CVRAnimatorManager __instance, bool __state)
{
return !Settings.OverrideFix;
try
{
if(Settings.OverrideFix && (__instance.animator != null))
{
__instance.animator.enabled = __state;
if(__state)
__instance.animator.Update(0f);
}
}
catch(System.Exception l_exception)
{
MelonLoader.MelonLogger.Error(l_exception);
}
}
}
}

View file

@ -1,4 +1,5 @@
using ABI_RC.Core.Player;
using ABI_RC.Systems.IK;
using ABI_RC.Systems.IK.SubSystems;
using ABI_RC.Systems.MovementSystem;
using RootMotion.FinalIK;
@ -44,6 +45,7 @@ namespace ml_amt
bool m_grounded = false;
bool m_groundedRaw = false;
bool m_moving = false;
bool m_locomotionOverride = false;
bool m_ikOverrideCrouch = true;
float m_crouchLimit = 0.65f;
@ -64,6 +66,7 @@ namespace ml_amt
bool m_followHips = true;
Vector3 m_hipsToPlayer = Vector3.zero;
Vector2 m_stepDistance = Vector2.zero;
Vector3 m_massCenter = Vector3.zero;
readonly List<AvatarParameter> m_parameters = null;
@ -73,6 +76,7 @@ namespace ml_amt
m_parameters = new List<AvatarParameter>();
}
// Unity events
void Start()
{
m_inVR = Utils.IsInVR();
@ -87,7 +91,8 @@ namespace ml_amt
Settings.IKOverrideJumpChange += this.SetIKOverrideJump;
Settings.DetectEmotesChange += this.SetDetectEmotes;
Settings.FollowHipsChange += this.SetFollowHips;
Settings.MassCenterChange += this.SetMassCenter;
Settings.MassCenterChange += this.OnMassCenterChange;
Settings.ScaledStepsChange += this.OnScaledStepsChange;
}
void OnDestroy()
@ -102,7 +107,7 @@ namespace ml_amt
Settings.IKOverrideJumpChange -= this.SetIKOverrideJump;
Settings.DetectEmotesChange -= this.SetDetectEmotes;
Settings.FollowHipsChange -= this.SetFollowHips;
Settings.MassCenterChange -= this.SetMassCenter;
Settings.MassCenterChange -= this.OnMassCenterChange;
}
void Update()
@ -116,8 +121,7 @@ namespace ml_amt
// Update upright
Matrix4x4 l_hmdMatrix = PlayerSetup.Instance.transform.GetMatrix().inverse * (m_inVR ? PlayerSetup.Instance.vrHeadTracker.transform.GetMatrix() : PlayerSetup.Instance.desktopCameraRig.transform.GetMatrix());
float l_currentHeight = Mathf.Clamp((l_hmdMatrix * ms_pointVector).y, 0f, float.MaxValue);
float l_avatarScale = (m_avatarScale > 0f) ? (PlayerSetup.Instance._avatar.transform.localScale.y / m_avatarScale) : 0f;
float l_avatarViewHeight = Mathf.Clamp(m_viewPointHeight * l_avatarScale, 0f, float.MaxValue);
float l_avatarViewHeight = Mathf.Clamp(m_viewPointHeight * GetRelativeScale(), 0f, float.MaxValue);
m_upright = Mathf.Clamp01((l_avatarViewHeight > 0f) ? (l_currentHeight / l_avatarViewHeight) : 0f);
m_poseState = (m_upright <= Mathf.Min(m_proneLimit, m_crouchLimit)) ? PoseState.Proning : ((m_upright <= Mathf.Max(m_proneLimit, m_crouchLimit)) ? PoseState.Crouching : PoseState.Standing);
@ -163,6 +167,7 @@ namespace ml_amt
}
}
// Game events
internal void OnAvatarClear()
{
m_vrIk = null;
@ -178,10 +183,12 @@ namespace ml_amt
m_locomotionOffset = Vector3.zero;
m_emoteActive = false;
m_moving = false;
m_locomotionOverride = false;
m_hipsToPlayer = Vector3.zero;
m_avatarHips = null;
m_viewPointHeight = 1f;
m_massCenter = Vector3.zero;
m_stepDistance = Vector2.zero;
m_parameters.Clear();
}
@ -252,6 +259,8 @@ namespace ml_amt
m_vrIk.solver.locomotion.offset = (Settings.MassCenter ? m_massCenter : m_locomotionOffset);
m_stepDistance.Set(m_vrIk.solver.locomotion.stepThreshold, m_vrIk.solver.locomotion.footDistance);
m_vrIk.onPreSolverUpdate.AddListener(this.OnIKPreUpdate);
m_vrIk.onPostSolverUpdate.AddListener(this.OnIKPostUpdate);
}
@ -273,9 +282,28 @@ namespace ml_amt
}
}
internal void OnPlayspaceScale()
{
if(m_vrIk != null)
{
if(Settings.MassCenter)
m_vrIk.solver.locomotion.offset = m_massCenter * GetRelativeScale();
if(Settings.ScaledSteps)
{
m_vrIk.solver.locomotion.stepThreshold = m_stepDistance.x * GetRelativeScale();
m_vrIk.solver.locomotion.footDistance = m_stepDistance.y * GetRelativeScale();
m_vrIk.solver.locomotion.stepHeight.keys = Utils.GetSineKeyframes(Mathf.Clamp01(PlayerSetup.Instance.GetAvatarHeight()) * 0.03f);
m_vrIk.solver.locomotion.heelHeight.keys = Utils.GetSineKeyframes(Mathf.Clamp01(PlayerSetup.Instance.GetAvatarHeight()) * 0.03f);
}
}
}
// IK events
void OnIKPreUpdate()
{
bool l_legsOverride = false;
bool l_locomotionOverride = false;
m_ikWeight = m_vrIk.solver.IKPositionWeight;
m_locomotionWeight = m_vrIk.solver.locomotion.weight;
@ -286,35 +314,42 @@ namespace ml_amt
if(m_detectEmotes && m_emoteActive)
m_vrIk.solver.IKPositionWeight = 0f;
if((m_ikOverrideCrouch && (m_poseState != PoseState.Standing)) || (m_ikOverrideProne && (m_poseState == PoseState.Proning)))
if(!BodySystem.isCalibratedAsFullBody)
{
m_vrIk.solver.locomotion.weight = 0f;
l_legsOverride = true;
}
if(m_ikOverrideFly && MovementSystem.Instance.flying)
{
m_vrIk.solver.locomotion.weight = 0f;
m_vrIk.solver.leftLeg.useAnimatedBendNormal = true;
m_vrIk.solver.rightLeg.useAnimatedBendNormal = true;
l_legsOverride = true;
}
if(m_ikOverrideJump && !m_grounded && !MovementSystem.Instance.flying)
{
m_vrIk.solver.locomotion.weight = 0f;
m_vrIk.solver.leftLeg.useAnimatedBendNormal = true;
m_vrIk.solver.rightLeg.useAnimatedBendNormal = true;
l_legsOverride = true;
if((m_ikOverrideCrouch && (m_poseState != PoseState.Standing)) || (m_ikOverrideProne && (m_poseState == PoseState.Proning)))
{
m_vrIk.solver.locomotion.weight = 0f;
m_vrIk.solver.leftLeg.useAnimatedBendNormal = true;
m_vrIk.solver.rightLeg.useAnimatedBendNormal = true;
l_locomotionOverride = true;
}
if(m_ikOverrideFly && MovementSystem.Instance.flying)
{
m_vrIk.solver.locomotion.weight = 0f;
m_vrIk.solver.leftLeg.useAnimatedBendNormal = true;
m_vrIk.solver.rightLeg.useAnimatedBendNormal = true;
l_locomotionOverride = true;
}
if(m_ikOverrideJump && !m_grounded && !MovementSystem.Instance.flying)
{
m_vrIk.solver.locomotion.weight = 0f;
m_vrIk.solver.leftLeg.useAnimatedBendNormal = true;
m_vrIk.solver.rightLeg.useAnimatedBendNormal = true;
l_locomotionOverride = true;
}
}
bool l_solverActive = !Mathf.Approximately(m_vrIk.solver.IKPositionWeight, 0f);
if(l_legsOverride && l_solverActive && m_followHips && (!m_moving || (m_poseState == PoseState.Proning)) && m_inVR && !BodySystem.isCalibratedAsFullBody)
if(l_locomotionOverride && l_solverActive && m_followHips && (!m_moving || (m_poseState == PoseState.Proning)) && m_inVR && !BodySystem.isCalibratedAsFullBody)
{
m_vrIk.solver.plantFeet = false;
ABI_RC.Systems.IK.IKSystem.VrikRootController.enabled = false;
IKSystem.VrikRootController.enabled = false;
PlayerSetup.Instance._avatar.transform.localPosition = m_hipsToPlayer;
}
if(m_locomotionOverride && !l_locomotionOverride)
m_vrIk.solver.Reset();
m_locomotionOverride = l_locomotionOverride;
}
void OnIKPostUpdate()
@ -326,25 +361,26 @@ namespace ml_amt
m_vrIk.solver.rightLeg.useAnimatedBendNormal = m_bendNormalRight;
}
public void SetIKOverrideCrouch(bool p_state)
// Settings
internal void SetIKOverrideCrouch(bool p_state)
{
m_ikOverrideCrouch = p_state;
}
public void SetCrouchLimit(float p_value)
internal void SetCrouchLimit(float p_value)
{
if(!m_customCrouchLimit)
m_crouchLimit = Mathf.Clamp01(p_value);
}
public void SetIKOverrideProne(bool p_state)
internal void SetIKOverrideProne(bool p_state)
{
m_ikOverrideProne = p_state;
}
public void SetProneLimit(float p_value)
internal void SetProneLimit(float p_value)
{
if(!m_customProneLimit)
m_proneLimit = Mathf.Clamp01(p_value);
}
public void SetPoseTransitions(bool p_state)
internal void SetPoseTransitions(bool p_state)
{
m_poseTransitions = p_state;
@ -354,7 +390,7 @@ namespace ml_amt
PlayerSetup.Instance.animatorManager.SetAnimatorParameterBool("Prone", false);
}
}
public void SetAdjustedMovement(bool p_state)
internal void SetAdjustedMovement(bool p_state)
{
m_adjustedMovement = p_state;
@ -364,28 +400,54 @@ namespace ml_amt
MovementSystem.Instance.ChangeProne(false);
}
}
public void SetIKOverrideFly(bool p_state)
internal void SetIKOverrideFly(bool p_state)
{
m_ikOverrideFly = p_state;
}
public void SetIKOverrideJump(bool p_state)
internal void SetIKOverrideJump(bool p_state)
{
m_ikOverrideJump = p_state;
}
public void SetDetectEmotes(bool p_state)
internal void SetDetectEmotes(bool p_state)
{
m_detectEmotes = p_state;
}
public void SetFollowHips(bool p_state)
internal void SetFollowHips(bool p_state)
{
m_followHips = p_state;
}
public void SetMassCenter(bool p_state)
void OnMassCenterChange(bool p_state)
{
if(m_vrIk != null)
m_vrIk.solver.locomotion.offset = (Settings.MassCenter ? m_massCenter : m_locomotionOffset);
m_vrIk.solver.locomotion.offset = (Settings.MassCenter ? (m_massCenter * GetRelativeScale()) : m_locomotionOffset);
}
void OnScaledStepsChange(bool p_state)
{
if(m_vrIk != null)
{
if(p_state)
{
m_vrIk.solver.locomotion.stepThreshold = m_stepDistance.x * GetRelativeScale();
m_vrIk.solver.locomotion.footDistance = m_stepDistance.y * GetRelativeScale();
m_vrIk.solver.locomotion.stepHeight.keys = Utils.GetSineKeyframes(Mathf.Clamp01(PlayerSetup.Instance.GetAvatarHeight()) * 0.03f);
m_vrIk.solver.locomotion.heelHeight.keys = Utils.GetSineKeyframes(Mathf.Clamp01(PlayerSetup.Instance.GetAvatarHeight()) * 0.03f);
}
else
{
IKSystem.Instance.ApplyAvatarScaleToIk(PlayerSetup.Instance.GetAvatarHeight());
m_vrIk.solver.locomotion.stepHeight.keys = Utils.GetSineKeyframes(0.03f);
m_vrIk.solver.locomotion.heelHeight.keys = Utils.GetSineKeyframes(0.03f);
}
}
}
// Arbitrary
float GetRelativeScale()
{
return ((m_avatarScale > 0f) ? (PlayerSetup.Instance._avatar.transform.localScale.y / m_avatarScale) : 0f);
}
// Parameters access
public float GetUpright() => m_upright;
public bool GetGroundedRaw() => m_groundedRaw;
public bool GetMoving() => m_moving;

View file

@ -20,23 +20,25 @@ namespace ml_amt
DetectEmotes,
FollowHips,
CollisionScale,
ScaledSteps,
MassCenter,
OverrideFix
};
static bool ms_ikOverrideCrouch = true;
static float ms_crouchLimit = 0.65f;
static bool ms_ikOverrideProne = true;
static float ms_proneLimit = 0.3f;
static bool ms_poseTransitions = true;
static bool ms_adjustedMovement = true;
static bool ms_ikOverrideFly = true;
static bool ms_ikOverrideJump = true;
static bool ms_detectEmotes = true;
static bool ms_followHips = true;
static bool ms_collisionScale = true;
static bool ms_massCenter = true;
static bool ms_overrideFix = false;
public static bool IKOverrideCrouch { get; private set; } = true;
public static float CrouchLimit { get; private set; } = 0.65f;
public static bool IKOverrideProne { get; private set; } = true;
public static float ProneLimit { get; private set; } = 0.3f;
public static bool PoseTransitions { get; private set; } = true;
public static bool AdjustedMovement { get; private set; } = true;
public static bool IKOverrideFly { get; private set; } = true;
public static bool IKOverrideJump { get; private set; } = true;
public static bool DetectEmotes { get; private set; } = true;
public static bool FollowHips { get; private set; } = true;
public static bool MassCenter { get; private set; } = true;
public static bool ScaledSteps { get; private set; } = true;
public static bool CollisionScale { get; private set; } = true;
public static bool OverrideFix { get; private set; } = true;
static MelonLoader.MelonPreferences_Category ms_category = null;
static List<MelonLoader.MelonPreferences_Entry> ms_entries = null;
@ -51,8 +53,9 @@ namespace ml_amt
static public event Action<bool> IKOverrideJumpChange;
static public event Action<bool> DetectEmotesChange;
static public event Action<bool> FollowHipsChange;
static public event Action<bool> CollisionScaleChange;
static public event Action<bool> MassCenterChange;
static public event Action<bool> ScaledStepsChange;
static public event Action<bool> CollisionScaleChange;
static public event Action<bool> OverrideFixChange;
internal static void Init()
@ -61,19 +64,20 @@ namespace ml_amt
ms_entries = new List<MelonLoader.MelonPreferences_Entry>()
{
ms_category.CreateEntry(ModSetting.IKOverrideCrouch.ToString(), true),
ms_category.CreateEntry(ModSetting.CrouchLimit.ToString(), 65),
ms_category.CreateEntry(ModSetting.IKOverrideProne.ToString(), true),
ms_category.CreateEntry(ModSetting.ProneLimit.ToString(), 30),
ms_category.CreateEntry(ModSetting.PoseTransitions.ToString(), true),
ms_category.CreateEntry(ModSetting.AdjustedMovement.ToString(), true),
ms_category.CreateEntry(ModSetting.IKOverrideFly.ToString(), true),
ms_category.CreateEntry(ModSetting.IKOverrideJump.ToString(), true),
ms_category.CreateEntry(ModSetting.DetectEmotes.ToString(), true),
ms_category.CreateEntry(ModSetting.FollowHips.ToString(), true),
ms_category.CreateEntry(ModSetting.CollisionScale.ToString(), true),
ms_category.CreateEntry(ModSetting.MassCenter.ToString(), true),
ms_category.CreateEntry(ModSetting.OverrideFix.ToString(), false)
ms_category.CreateEntry(ModSetting.IKOverrideCrouch.ToString(), IKOverrideCrouch),
ms_category.CreateEntry(ModSetting.CrouchLimit.ToString(), (int)(CrouchLimit * 100f)),
ms_category.CreateEntry(ModSetting.IKOverrideProne.ToString(), IKOverrideProne),
ms_category.CreateEntry(ModSetting.ProneLimit.ToString(), (int)(ProneLimit * 100f)),
ms_category.CreateEntry(ModSetting.PoseTransitions.ToString(), PoseTransitions),
ms_category.CreateEntry(ModSetting.AdjustedMovement.ToString(), AdjustedMovement),
ms_category.CreateEntry(ModSetting.IKOverrideFly.ToString(), IKOverrideFly),
ms_category.CreateEntry(ModSetting.IKOverrideJump.ToString(), IKOverrideJump),
ms_category.CreateEntry(ModSetting.DetectEmotes.ToString(), DetectEmotes),
ms_category.CreateEntry(ModSetting.FollowHips.ToString(), FollowHips),
ms_category.CreateEntry(ModSetting.MassCenter.ToString(), MassCenter),
ms_category.CreateEntry(ModSetting.ScaledSteps.ToString(), ScaledSteps),
ms_category.CreateEntry(ModSetting.CollisionScale.ToString(), CollisionScale),
ms_category.CreateEntry(ModSetting.OverrideFix.ToString(), OverrideFix)
};
Load();
@ -105,19 +109,20 @@ namespace ml_amt
static void Load()
{
ms_ikOverrideCrouch = (bool)ms_entries[(int)ModSetting.IKOverrideCrouch].BoxedValue;
ms_crouchLimit = ((int)ms_entries[(int)ModSetting.CrouchLimit].BoxedValue) * 0.01f;
ms_ikOverrideProne = (bool)ms_entries[(int)ModSetting.IKOverrideProne].BoxedValue;
ms_proneLimit = ((int)ms_entries[(int)ModSetting.ProneLimit].BoxedValue) * 0.01f;
ms_poseTransitions = (bool)ms_entries[(int)ModSetting.PoseTransitions].BoxedValue;
ms_adjustedMovement = (bool)ms_entries[(int)ModSetting.AdjustedMovement].BoxedValue;
ms_ikOverrideFly = (bool)ms_entries[(int)ModSetting.IKOverrideFly].BoxedValue;
ms_ikOverrideJump = (bool)ms_entries[(int)ModSetting.IKOverrideJump].BoxedValue;
ms_detectEmotes = (bool)ms_entries[(int)ModSetting.DetectEmotes].BoxedValue;
ms_followHips = (bool)ms_entries[(int)ModSetting.FollowHips].BoxedValue;
ms_collisionScale = (bool)ms_entries[(int)ModSetting.CollisionScale].BoxedValue;
ms_massCenter = (bool)ms_entries[(int)ModSetting.MassCenter].BoxedValue;
ms_overrideFix = (bool)ms_entries[(int)ModSetting.OverrideFix].BoxedValue;
IKOverrideCrouch = (bool)ms_entries[(int)ModSetting.IKOverrideCrouch].BoxedValue;
CrouchLimit = ((int)ms_entries[(int)ModSetting.CrouchLimit].BoxedValue) * 0.01f;
IKOverrideProne = (bool)ms_entries[(int)ModSetting.IKOverrideProne].BoxedValue;
ProneLimit = ((int)ms_entries[(int)ModSetting.ProneLimit].BoxedValue) * 0.01f;
PoseTransitions = (bool)ms_entries[(int)ModSetting.PoseTransitions].BoxedValue;
AdjustedMovement = (bool)ms_entries[(int)ModSetting.AdjustedMovement].BoxedValue;
IKOverrideFly = (bool)ms_entries[(int)ModSetting.IKOverrideFly].BoxedValue;
IKOverrideJump = (bool)ms_entries[(int)ModSetting.IKOverrideJump].BoxedValue;
DetectEmotes = (bool)ms_entries[(int)ModSetting.DetectEmotes].BoxedValue;
FollowHips = (bool)ms_entries[(int)ModSetting.FollowHips].BoxedValue;
MassCenter = (bool)ms_entries[(int)ModSetting.MassCenter].BoxedValue;
ScaledSteps = (bool)ms_entries[(int)ModSetting.ScaledSteps].BoxedValue;
CollisionScale = (bool)ms_entries[(int)ModSetting.CollisionScale].BoxedValue;
OverrideFix = (bool)ms_entries[(int)ModSetting.OverrideFix].BoxedValue;
}
static void OnSliderUpdate(string p_name, string p_value)
@ -128,15 +133,15 @@ namespace ml_amt
{
case ModSetting.CrouchLimit:
{
ms_crouchLimit = int.Parse(p_value) * 0.01f;
CrouchLimitChange?.Invoke(ms_crouchLimit);
CrouchLimit = int.Parse(p_value) * 0.01f;
CrouchLimitChange?.Invoke(CrouchLimit);
}
break;
case ModSetting.ProneLimit:
{
ms_proneLimit = int.Parse(p_value) * 0.01f;
ProneLimitChange?.Invoke(ms_proneLimit);
ProneLimit = int.Parse(p_value) * 0.01f;
ProneLimitChange?.Invoke(ProneLimit);
}
break;
}
@ -153,78 +158,85 @@ namespace ml_amt
{
case ModSetting.IKOverrideCrouch:
{
ms_ikOverrideCrouch = bool.Parse(p_value);
IKOverrideCrouchChange?.Invoke(ms_ikOverrideCrouch);
IKOverrideCrouch = bool.Parse(p_value);
IKOverrideCrouchChange?.Invoke(IKOverrideCrouch);
}
break;
case ModSetting.IKOverrideProne:
{
ms_ikOverrideProne = bool.Parse(p_value);
IKOverrideProneChange?.Invoke(ms_ikOverrideProne);
IKOverrideProne = bool.Parse(p_value);
IKOverrideProneChange?.Invoke(IKOverrideProne);
}
break;
case ModSetting.PoseTransitions:
{
ms_poseTransitions = bool.Parse(p_value);
PoseTransitionsChange?.Invoke(ms_poseTransitions);
PoseTransitions = bool.Parse(p_value);
PoseTransitionsChange?.Invoke(PoseTransitions);
}
break;
case ModSetting.AdjustedMovement:
{
ms_adjustedMovement = bool.Parse(p_value);
AdjustedMovementChange?.Invoke(ms_adjustedMovement);
AdjustedMovement = bool.Parse(p_value);
AdjustedMovementChange?.Invoke(AdjustedMovement);
}
break;
case ModSetting.IKOverrideFly:
{
ms_ikOverrideFly = bool.Parse(p_value);
IKOverrideFlyChange?.Invoke(ms_ikOverrideFly);
IKOverrideFly = bool.Parse(p_value);
IKOverrideFlyChange?.Invoke(IKOverrideFly);
}
break;
case ModSetting.IKOverrideJump:
{
ms_ikOverrideJump = bool.Parse(p_value);
IKOverrideJumpChange?.Invoke(ms_ikOverrideJump);
IKOverrideJump = bool.Parse(p_value);
IKOverrideJumpChange?.Invoke(IKOverrideJump);
}
break;
case ModSetting.DetectEmotes:
{
ms_detectEmotes = bool.Parse(p_value);
DetectEmotesChange?.Invoke(ms_detectEmotes);
DetectEmotes = bool.Parse(p_value);
DetectEmotesChange?.Invoke(DetectEmotes);
}
break;
case ModSetting.FollowHips:
{
ms_followHips = bool.Parse(p_value);
FollowHipsChange?.Invoke(ms_followHips);
}
break;
case ModSetting.CollisionScale:
{
ms_collisionScale = bool.Parse(p_value);
CollisionScaleChange?.Invoke(ms_collisionScale);
FollowHips = bool.Parse(p_value);
FollowHipsChange?.Invoke(FollowHips);
}
break;
case ModSetting.MassCenter:
{
ms_massCenter = bool.Parse(p_value);
MassCenterChange?.Invoke(ms_massCenter);
MassCenter = bool.Parse(p_value);
MassCenterChange?.Invoke(MassCenter);
}
break;
case ModSetting.ScaledSteps:
{
ScaledSteps = bool.Parse(p_value);
ScaledStepsChange?.Invoke(ScaledSteps);
}
break;
case ModSetting.CollisionScale:
{
CollisionScale = bool.Parse(p_value);
CollisionScaleChange?.Invoke(CollisionScale);
}
break;
case ModSetting.OverrideFix:
{
ms_overrideFix = bool.Parse(p_value);
OverrideFixChange?.Invoke(ms_overrideFix);
OverrideFix = bool.Parse(p_value);
OverrideFixChange?.Invoke(OverrideFix);
}
break;
}
@ -232,58 +244,5 @@ namespace ml_amt
ms_entries[(int)l_setting].BoxedValue = bool.Parse(p_value);
}
}
public static bool IKOverrideCrouch
{
get => ms_ikOverrideCrouch;
}
public static float CrouchLimit
{
get => ms_crouchLimit;
}
public static bool IKOverrideProne
{
get => ms_ikOverrideProne;
}
public static float ProneLimit
{
get => ms_proneLimit;
}
public static bool PoseTransitions
{
get => ms_poseTransitions;
}
public static bool AdjustedMovement
{
get => ms_adjustedMovement;
}
public static bool IKOverrideFly
{
get => ms_ikOverrideFly;
}
public static bool IKOverrideJump
{
get => ms_ikOverrideJump;
}
public static bool DetectEmotes
{
get => ms_detectEmotes;
}
public static bool FollowHips
{
get => ms_followHips;
}
public static bool CollisionScale
{
get => ms_collisionScale;
}
public static bool MassCenter
{
get => ms_massCenter;
}
public static bool OverrideFix
{
get => ms_overrideFix;
}
}
}

View file

@ -1,10 +1,12 @@
using UnityEngine;
using ABI_RC.Systems.IK;
using System.Reflection;
namespace ml_amt
{
static class Utils
{
static MethodInfo ms_getSineKeyframes = typeof(RootMotion.FinalIK.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
@ -12,5 +14,10 @@ namespace ml_amt
{
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 Keyframe[] GetSineKeyframes(float p_mag)
{
return (Keyframe[])ms_getSineKeyframes.Invoke(null, new object[] { p_mag });
}
}
}

View file

@ -256,6 +256,13 @@ function inp_toggle_mod_amt(_obj, _callbackName) {
<div id="MassCenter" class ="inp_toggle no-scroll" data-current="true"></div>
</div>
</div>
<div class ="row-wrapper">
<div class ="option-caption">Scaled locomotion steps: </div>
<div class ="option-input">
<div id="ScaledSteps" class ="inp_toggle no-scroll" data-current="true"></div>
</div>
</div>
<div class ="row-wrapper">
<div class ="option-caption">Alternative avatar collider scale: </div>
@ -265,9 +272,9 @@ function inp_toggle_mod_amt(_obj, _callbackName) {
</div>
<div class ="row-wrapper">
<div class ="option-caption">Prevent Unity animation override (chairs, etc.): </div>
<div class ="option-caption">Fix animation overrides (chairs, etc.): </div>
<div class ="option-input">
<div id="OverrideFix" class ="inp_toggle no-scroll" data-current="false"></div>
<div id="OverrideFix" class ="inp_toggle no-scroll" data-current="true"></div>
</div>
</div>
`;