mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-03 18:39:23 +00:00
Additional nightly fixes
This commit is contained in:
parent
40b683d33c
commit
5261203833
16 changed files with 570 additions and 750 deletions
|
@ -23,8 +23,6 @@ namespace ml_lme
|
|||
public void Invoke(T1 p_obj) => m_action?.Invoke(p_obj);
|
||||
}
|
||||
|
||||
public static readonly GameEvent OnAvatarSetup = new GameEvent();
|
||||
public static readonly GameEvent OnAvatarClear = new GameEvent();
|
||||
public static readonly GameEvent OnAvatarReuse = new GameEvent();
|
||||
public static readonly GameEvent<float> OnRayScale = new GameEvent<float>();
|
||||
public static readonly GameEvent<float> OnPlayspaceScale = new GameEvent<float>();
|
||||
|
@ -34,18 +32,6 @@ namespace ml_lme
|
|||
{
|
||||
try
|
||||
{
|
||||
p_instance.Patch(
|
||||
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.ClearAvatar), BindingFlags.Instance | BindingFlags.Public),
|
||||
null,
|
||||
new HarmonyLib.HarmonyMethod(typeof(GameEvents).GetMethod(nameof(OnAvatarClear_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
|
||||
);
|
||||
|
||||
p_instance.Patch(
|
||||
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.SetupAvatar), BindingFlags.Instance | BindingFlags.Public),
|
||||
null,
|
||||
new HarmonyLib.HarmonyMethod(typeof(GameEvents).GetMethod(nameof(OnSetupAvatar_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
|
||||
);
|
||||
|
||||
p_instance.Patch(
|
||||
typeof(IKSystem).GetMethod(nameof(IKSystem.ReinitializeAvatar), BindingFlags.Instance | BindingFlags.Public),
|
||||
null,
|
||||
|
@ -76,30 +62,6 @@ namespace ml_lme
|
|||
}
|
||||
}
|
||||
|
||||
static void OnAvatarClear_Postfix()
|
||||
{
|
||||
try
|
||||
{
|
||||
OnAvatarClear.Invoke();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
static void OnSetupAvatar_Postfix()
|
||||
{
|
||||
try
|
||||
{
|
||||
OnAvatarSetup.Invoke();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
static void OnAvatarReinitialize_Postfix()
|
||||
{
|
||||
try
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using ABI.CCK.Components;
|
||||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Systems.GameEventSystem;
|
||||
using ABI_RC.Systems.IK;
|
||||
using RootMotion.FinalIK;
|
||||
using System.Collections.Generic;
|
||||
|
@ -148,8 +150,8 @@ namespace ml_lme
|
|||
Settings.OnFingersOnlyChanged.AddListener(this.OnEnabledOrFingersOnlyChanged);
|
||||
Settings.OnTrackElbowsChanged.AddListener(this.OnTrackElbowsChanged);
|
||||
|
||||
GameEvents.OnAvatarClear.AddListener(this.OnAvatarClear);
|
||||
GameEvents.OnAvatarSetup.AddListener(this.OnAvatarSetup);
|
||||
CVRGameEventSystem.Avatar.OnLocalAvatarLoad.AddListener(this.OnAvatarSetup);
|
||||
CVRGameEventSystem.Avatar.OnLocalAvatarClear.AddListener(this.OnAvatarClear);
|
||||
GameEvents.OnAvatarReuse.AddListener(this.OnAvatarReuse);
|
||||
}
|
||||
|
||||
|
@ -174,8 +176,8 @@ namespace ml_lme
|
|||
Settings.OnFingersOnlyChanged.RemoveListener(this.OnEnabledOrFingersOnlyChanged);
|
||||
Settings.OnTrackElbowsChanged.RemoveListener(this.OnTrackElbowsChanged);
|
||||
|
||||
GameEvents.OnAvatarClear.RemoveListener(this.OnAvatarClear);
|
||||
GameEvents.OnAvatarSetup.RemoveListener(this.OnAvatarSetup);
|
||||
CVRGameEventSystem.Avatar.OnLocalAvatarLoad.RemoveListener(this.OnAvatarSetup);
|
||||
CVRGameEventSystem.Avatar.OnLocalAvatarClear.RemoveListener(this.OnAvatarClear);
|
||||
GameEvents.OnAvatarReuse.RemoveListener(this.OnAvatarReuse);
|
||||
}
|
||||
|
||||
|
@ -255,58 +257,72 @@ namespace ml_lme
|
|||
}
|
||||
|
||||
// Game events
|
||||
void OnAvatarClear()
|
||||
void OnAvatarClear(CVRAvatar p_avatar)
|
||||
{
|
||||
m_vrIK = null;
|
||||
m_hips = null;
|
||||
m_leftArmIK = null;
|
||||
m_rightArmIK = null;
|
||||
m_leftTargetActive = false;
|
||||
m_rightTargetActive = false;
|
||||
try
|
||||
{
|
||||
m_vrIK = null;
|
||||
m_hips = null;
|
||||
m_leftArmIK = null;
|
||||
m_rightArmIK = null;
|
||||
m_leftTargetActive = false;
|
||||
m_rightTargetActive = false;
|
||||
|
||||
m_poseHandler?.Dispose();
|
||||
m_poseHandler = null;
|
||||
m_poseHandler?.Dispose();
|
||||
m_poseHandler = null;
|
||||
|
||||
m_leftHandTarget.localPosition = Vector3.zero;
|
||||
m_leftHandTarget.localRotation = Quaternion.identity;
|
||||
m_rightHandTarget.localPosition = Vector3.zero;
|
||||
m_rightHandTarget.localRotation = Quaternion.identity;
|
||||
m_leftHandTarget.localPosition = Vector3.zero;
|
||||
m_leftHandTarget.localRotation = Quaternion.identity;
|
||||
m_rightHandTarget.localPosition = Vector3.zero;
|
||||
m_rightHandTarget.localRotation = Quaternion.identity;
|
||||
|
||||
m_leftHandOffset.Reset();
|
||||
m_rightHandOffset.Reset();
|
||||
m_leftHandOffset.Reset();
|
||||
m_rightHandOffset.Reset();
|
||||
|
||||
m_leftFingerOffsets.Clear();
|
||||
m_rightFingerOffsets.Clear();
|
||||
m_leftFingerOffsets.Clear();
|
||||
m_rightFingerOffsets.Clear();
|
||||
}
|
||||
catch(System.Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
void OnAvatarSetup()
|
||||
void OnAvatarSetup(CVRAvatar p_avatar)
|
||||
{
|
||||
Animator l_animator = PlayerSetup.Instance.Animator;
|
||||
if(l_animator.isHuman)
|
||||
try
|
||||
{
|
||||
Utils.SetAvatarTPose();
|
||||
|
||||
m_poseHandler = new HumanPoseHandler(l_animator.avatar, l_animator.transform);
|
||||
m_poseHandler.GetHumanPose(ref m_pose);
|
||||
|
||||
m_hips = l_animator.GetBoneTransform(HumanBodyBones.Hips);
|
||||
|
||||
m_leftHandOffset.m_source = l_animator.GetBoneTransform(HumanBodyBones.LeftHand);
|
||||
m_leftHandTarget.localRotation = ms_offsetLeft * (Quaternion.Inverse(l_animator.transform.rotation) * m_leftHandOffset.m_source.rotation);
|
||||
|
||||
m_rightHandOffset.m_source = l_animator.GetBoneTransform(HumanBodyBones.RightHand);
|
||||
m_rightHandTarget.localRotation = ms_offsetRight * (Quaternion.Inverse(l_animator.transform.rotation) * m_rightHandOffset.m_source.rotation);
|
||||
|
||||
ParseFingersBones();
|
||||
|
||||
m_vrIK = l_animator.GetComponent<VRIK>();
|
||||
if(m_vrIK != null)
|
||||
Animator l_animator = PlayerSetup.Instance.Animator;
|
||||
if(l_animator.isHuman)
|
||||
{
|
||||
m_vrIK.onPreSolverUpdate.AddListener(this.OnIKPreSolverUpdate);
|
||||
m_vrIK.onPostSolverUpdate.AddListener(this.OnIKPostSolverUpdate);
|
||||
Utils.SetAvatarTPose();
|
||||
|
||||
m_poseHandler = new HumanPoseHandler(l_animator.avatar, l_animator.transform);
|
||||
m_poseHandler.GetHumanPose(ref m_pose);
|
||||
|
||||
m_hips = l_animator.GetBoneTransform(HumanBodyBones.Hips);
|
||||
|
||||
m_leftHandOffset.m_source = l_animator.GetBoneTransform(HumanBodyBones.LeftHand);
|
||||
m_leftHandTarget.localRotation = ms_offsetLeft * (Quaternion.Inverse(l_animator.transform.rotation) * m_leftHandOffset.m_source.rotation);
|
||||
|
||||
m_rightHandOffset.m_source = l_animator.GetBoneTransform(HumanBodyBones.RightHand);
|
||||
m_rightHandTarget.localRotation = ms_offsetRight * (Quaternion.Inverse(l_animator.transform.rotation) * m_rightHandOffset.m_source.rotation);
|
||||
|
||||
ParseFingersBones();
|
||||
|
||||
m_vrIK = l_animator.GetComponent<VRIK>();
|
||||
if(m_vrIK != null)
|
||||
{
|
||||
m_vrIK.onPreSolverUpdate.AddListener(this.OnIKPreSolverUpdate);
|
||||
m_vrIK.onPostSolverUpdate.AddListener(this.OnIKPostSolverUpdate);
|
||||
}
|
||||
else
|
||||
SetupArmIK();
|
||||
}
|
||||
else
|
||||
SetupArmIK();
|
||||
}
|
||||
catch(System.Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue