mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-05 03:19:23 +00:00
Additional nightly fixes
This commit is contained in:
parent
40b683d33c
commit
5261203833
16 changed files with 570 additions and 750 deletions
|
@ -15,8 +15,6 @@ namespace ml_pmc
|
|||
public void Invoke() => m_action?.Invoke();
|
||||
}
|
||||
|
||||
public static readonly GameEvent OnAvatarSetup = new GameEvent();
|
||||
public static readonly GameEvent OnAvatarClear = new GameEvent();
|
||||
public static readonly GameEvent OnAvatarPreReuse = new GameEvent();
|
||||
public static readonly GameEvent OnAvatarPostReuse = new GameEvent();
|
||||
|
||||
|
@ -24,18 +22,6 @@ namespace ml_pmc
|
|||
{
|
||||
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),
|
||||
new HarmonyLib.HarmonyMethod(typeof(GameEvents).GetMethod(nameof(OnAvatarReinitialize_Prefix), BindingFlags.Static | BindingFlags.NonPublic)),
|
||||
|
@ -48,30 +34,6 @@ namespace ml_pmc
|
|||
}
|
||||
}
|
||||
|
||||
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_Prefix()
|
||||
{
|
||||
try
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
using ABI_RC.Core.Networking.IO.Social;
|
||||
using ABI.CCK.Components;
|
||||
using ABI_RC.Core.Networking.IO.Social;
|
||||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Systems.GameEventSystem;
|
||||
using ABI_RC.Systems.IK;
|
||||
using ABI_RC.Systems.IK.SubSystems;
|
||||
using ABI_RC.Systems.InputManagement;
|
||||
|
@ -55,8 +57,8 @@ namespace ml_pmc
|
|||
|
||||
void Start()
|
||||
{
|
||||
GameEvents.OnAvatarClear.AddListener(this.OnAvatarClear);
|
||||
GameEvents.OnAvatarSetup.AddListener(this.OnAvatarSetup);
|
||||
CVRGameEventSystem.Avatar.OnLocalAvatarClear.AddListener(this.OnAvatarClear);
|
||||
CVRGameEventSystem.Avatar.OnLocalAvatarLoad.AddListener(this.OnAvatarSetup);
|
||||
GameEvents.OnAvatarPreReuse.AddListener(this.OnAvatarPreReuse);
|
||||
GameEvents.OnAvatarPostReuse.AddListener(this.OnAvatarPostReuse);
|
||||
|
||||
|
@ -78,8 +80,8 @@ namespace ml_pmc
|
|||
m_vrIk = null;
|
||||
m_lookAtIk = null;
|
||||
|
||||
GameEvents.OnAvatarClear.RemoveListener(this.OnAvatarClear);
|
||||
GameEvents.OnAvatarSetup.RemoveListener(this.OnAvatarSetup);
|
||||
CVRGameEventSystem.Avatar.OnLocalAvatarClear.RemoveListener(this.OnAvatarClear);
|
||||
CVRGameEventSystem.Avatar.OnLocalAvatarLoad.RemoveListener(this.OnAvatarSetup);
|
||||
GameEvents.OnAvatarPreReuse.RemoveListener(this.OnAvatarPreReuse);
|
||||
GameEvents.OnAvatarPostReuse.RemoveListener(this.OnAvatarPostReuse);
|
||||
|
||||
|
@ -229,58 +231,72 @@ namespace ml_pmc
|
|||
}
|
||||
|
||||
// Game events
|
||||
void OnAvatarClear()
|
||||
void OnAvatarClear(CVRAvatar p_avatar)
|
||||
{
|
||||
if(m_active)
|
||||
try
|
||||
{
|
||||
RestoreIK();
|
||||
RestoreFingerTracking();
|
||||
OnCopycatChanged.Invoke(false);
|
||||
if(m_active)
|
||||
{
|
||||
RestoreIK();
|
||||
RestoreFingerTracking();
|
||||
OnCopycatChanged.Invoke(false);
|
||||
}
|
||||
m_active = false;
|
||||
|
||||
if(m_puppetParser != null)
|
||||
Object.Destroy(m_puppetParser);
|
||||
m_puppetParser = null;
|
||||
|
||||
m_animator = null;
|
||||
m_vrIk = null;
|
||||
m_lookAtIk = null;
|
||||
|
||||
m_poseHandler?.Dispose();
|
||||
m_poseHandler = null;
|
||||
|
||||
m_distanceLimit = float.MaxValue;
|
||||
m_fingerTracking = false;
|
||||
m_pose = new HumanPose();
|
||||
}
|
||||
catch(System.Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
m_active = false;
|
||||
|
||||
if(m_puppetParser != null)
|
||||
Object.Destroy(m_puppetParser);
|
||||
m_puppetParser = null;
|
||||
|
||||
m_animator = null;
|
||||
m_vrIk = null;
|
||||
m_lookAtIk = null;
|
||||
|
||||
m_poseHandler?.Dispose();
|
||||
m_poseHandler = null;
|
||||
|
||||
m_distanceLimit = float.MaxValue;
|
||||
m_fingerTracking = false;
|
||||
m_pose = new HumanPose();
|
||||
}
|
||||
|
||||
void OnAvatarSetup()
|
||||
void OnAvatarSetup(CVRAvatar p_avatar)
|
||||
{
|
||||
m_inVr = Utils.IsInVR();
|
||||
m_animator = PlayerSetup.Instance.Animator;
|
||||
m_vrIk = PlayerSetup.Instance.AvatarObject.GetComponent<VRIK>();
|
||||
m_lookAtIk = PlayerSetup.Instance.AvatarObject.GetComponent<LookAtIK>();
|
||||
|
||||
if((m_animator != null) && m_animator.isHuman)
|
||||
try
|
||||
{
|
||||
m_poseHandler = new HumanPoseHandler(m_animator.avatar, m_animator.transform);
|
||||
m_poseHandler.GetHumanPose(ref m_pose);
|
||||
m_inVr = Utils.IsInVR();
|
||||
m_animator = PlayerSetup.Instance.Animator;
|
||||
m_vrIk = PlayerSetup.Instance.AvatarObject.GetComponent<VRIK>();
|
||||
m_lookAtIk = PlayerSetup.Instance.AvatarObject.GetComponent<LookAtIK>();
|
||||
|
||||
if(m_vrIk != null)
|
||||
if((m_animator != null) && m_animator.isHuman)
|
||||
{
|
||||
m_vrIk.onPreSolverUpdate.AddListener(this.OnVRIKPreUpdate);
|
||||
m_vrIk.onPostSolverUpdate.AddListener(this.OnVRIKPostUpdate);
|
||||
}
|
||||
m_poseHandler = new HumanPoseHandler(m_animator.avatar, m_animator.transform);
|
||||
m_poseHandler.GetHumanPose(ref m_pose);
|
||||
|
||||
if(m_lookAtIk != null)
|
||||
{
|
||||
m_lookAtIk.onPreSolverUpdate.AddListener(this.OnLookAtIKPreUpdate);
|
||||
m_lookAtIk.onPostSolverUpdate.AddListener(this.OnLookAtIKPostUpdate);
|
||||
if(m_vrIk != null)
|
||||
{
|
||||
m_vrIk.onPreSolverUpdate.AddListener(this.OnVRIKPreUpdate);
|
||||
m_vrIk.onPostSolverUpdate.AddListener(this.OnVRIKPostUpdate);
|
||||
}
|
||||
|
||||
if(m_lookAtIk != null)
|
||||
{
|
||||
m_lookAtIk.onPreSolverUpdate.AddListener(this.OnLookAtIKPreUpdate);
|
||||
m_lookAtIk.onPostSolverUpdate.AddListener(this.OnLookAtIKPostUpdate);
|
||||
}
|
||||
}
|
||||
else
|
||||
m_animator = null;
|
||||
}
|
||||
catch(System.Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
else
|
||||
m_animator = null;
|
||||
}
|
||||
|
||||
void OnAvatarPreReuse()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue