mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-03 18:39:23 +00:00
85 lines
2.9 KiB
C#
85 lines
2.9 KiB
C#
using ABI_RC.Core.Player;
|
|
using System.Reflection;
|
|
|
|
namespace ml_amt
|
|
{
|
|
public class AvatarMotionTweaker : MelonLoader.MelonMod
|
|
{
|
|
static AvatarMotionTweaker ms_instance = null;
|
|
|
|
MotionTweaker m_localTweaker = null;
|
|
|
|
public override void OnInitializeMelon()
|
|
{
|
|
if(ms_instance == null)
|
|
ms_instance = this;
|
|
|
|
Settings.Init();
|
|
|
|
HarmonyInstance.Patch(
|
|
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.ClearAvatar)),
|
|
null,
|
|
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnAvatarClear_Postfix), BindingFlags.NonPublic | BindingFlags.Static))
|
|
);
|
|
HarmonyInstance.Patch(
|
|
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.CalibrateAvatar)),
|
|
null,
|
|
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnCalibrateAvatar_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
|
|
);
|
|
|
|
MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer());
|
|
}
|
|
|
|
System.Collections.IEnumerator WaitForLocalPlayer()
|
|
{
|
|
while(PlayerSetup.Instance == null)
|
|
yield return null;
|
|
|
|
m_localTweaker = PlayerSetup.Instance.gameObject.AddComponent<MotionTweaker>();
|
|
m_localTweaker.SetIKOverrideCrouch(Settings.IKOverrideCrouch);
|
|
m_localTweaker.SetCrouchLimit(Settings.CrouchLimit);
|
|
m_localTweaker.SetIKOverrideCrouch(Settings.IKOverrideProne);
|
|
m_localTweaker.SetProneLimit(Settings.ProneLimit);
|
|
m_localTweaker.SetPoseTransitions(Settings.PoseTransitions);
|
|
m_localTweaker.SetAdjustedMovement(Settings.AdjustedMovement);
|
|
m_localTweaker.SetIKOverrideFly(Settings.IKOverrideFly);
|
|
m_localTweaker.SetDetectEmotes(Settings.DetectEmotes);
|
|
}
|
|
|
|
public override void OnDeinitializeMelon()
|
|
{
|
|
if(ms_instance == this)
|
|
ms_instance = null;
|
|
|
|
m_localTweaker = null;
|
|
}
|
|
|
|
static void OnAvatarClear_Postfix() => ms_instance?.OnAvatarClear();
|
|
void OnAvatarClear()
|
|
{
|
|
try
|
|
{
|
|
if(m_localTweaker != null)
|
|
m_localTweaker.OnAvatarClear();
|
|
}
|
|
catch(System.Exception l_exception)
|
|
{
|
|
MelonLoader.MelonLogger.Error(l_exception);
|
|
}
|
|
}
|
|
|
|
static void OnCalibrateAvatar_Postfix() => ms_instance?.OnCalibrateAvatar();
|
|
void OnCalibrateAvatar()
|
|
{
|
|
try
|
|
{
|
|
if(m_localTweaker != null)
|
|
m_localTweaker.OnCalibrateAvatar();
|
|
}
|
|
catch(System.Exception l_exception)
|
|
{
|
|
MelonLoader.MelonLogger.Error(l_exception);
|
|
}
|
|
}
|
|
}
|
|
}
|