mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-04 10:59:22 +00:00
60 lines
2.1 KiB
C#
60 lines
2.1 KiB
C#
using ABI_RC.Core.Player;
|
|
|
|
namespace ml_amt
|
|
{
|
|
public class AvatarMotionTweaker : MelonLoader.MelonMod
|
|
{
|
|
static AvatarMotionTweaker ms_instance = null;
|
|
|
|
MotionTweaker m_localTweaker = null;
|
|
|
|
public override void OnApplicationStart()
|
|
{
|
|
ms_instance = this;
|
|
|
|
Settings.Init();
|
|
Settings.CrouchLimitChange += this.OnCrouchLimitChange;
|
|
|
|
HarmonyInstance.Patch(
|
|
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.ClearAvatar)),
|
|
null,
|
|
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnAvatarClear_Postfix), System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static))
|
|
);
|
|
HarmonyInstance.Patch(
|
|
typeof(PlayerSetup).GetMethod("SetupAvatarGeneral", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic),
|
|
null,
|
|
new HarmonyLib.HarmonyMethod(typeof(AvatarMotionTweaker).GetMethod(nameof(OnSetupAvatarGeneral_Postfix), System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic))
|
|
);
|
|
|
|
MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer());
|
|
}
|
|
|
|
System.Collections.IEnumerator WaitForLocalPlayer()
|
|
{
|
|
while(PlayerSetup.Instance == null)
|
|
yield return null;
|
|
|
|
m_localTweaker = PlayerSetup.Instance.gameObject.AddComponent<MotionTweaker>();
|
|
}
|
|
|
|
void OnCrouchLimitChange(float p_value)
|
|
{
|
|
if(m_localTweaker != null)
|
|
m_localTweaker.SetCrouchLimit(p_value);
|
|
}
|
|
|
|
static void OnAvatarClear_Postfix() => ms_instance?.OnAvatarClear();
|
|
void OnAvatarClear()
|
|
{
|
|
if(m_localTweaker != null)
|
|
m_localTweaker.OnAvatarClear();
|
|
}
|
|
|
|
static void OnSetupAvatarGeneral_Postfix() => ms_instance?.OnSetupAvatarGeneral();
|
|
void OnSetupAvatarGeneral()
|
|
{
|
|
if(m_localTweaker != null)
|
|
m_localTweaker.OnSetupAvatarGeneral();
|
|
}
|
|
}
|
|
}
|