mirror of
https://github.com/SDraw/ml_mods_cvr.git
synced 2026-06-23 23:08:26 +00:00
Fix PlayerMovementCopycat
This commit is contained in:
parent
4838b66b6a
commit
bc3cb07ddb
5 changed files with 50 additions and 169 deletions
|
|
@ -14,9 +14,17 @@ namespace ml_pmc
|
|||
public void RemoveListener(Action p_listener) => m_action -= p_listener;
|
||||
public void Invoke() => m_action?.Invoke();
|
||||
}
|
||||
internal class GameEvent<T1>
|
||||
{
|
||||
event Action<T1> m_action;
|
||||
public void AddListener(Action<T1> p_listener) => m_action += p_listener;
|
||||
public void RemoveListener(Action<T1> p_listener) => m_action -= p_listener;
|
||||
public void Invoke(T1 p_obj) => m_action?.Invoke(p_obj);
|
||||
}
|
||||
|
||||
public static readonly GameEvent OnAvatarPreReuse = new GameEvent();
|
||||
public static readonly GameEvent OnAvatarPostReuse = new GameEvent();
|
||||
public static readonly GameEvent<PlayerAvatarMovementData> OnPostLocalPlayerMovementDataUpdate = new GameEvent<PlayerAvatarMovementData>();
|
||||
|
||||
internal static void Init(HarmonyLib.Harmony p_instance)
|
||||
{
|
||||
|
|
@ -27,6 +35,12 @@ namespace ml_pmc
|
|||
new HarmonyLib.HarmonyMethod(typeof(GameEvents).GetMethod(nameof(OnAvatarReinitialize_Prefix), BindingFlags.Static | BindingFlags.NonPublic)),
|
||||
new HarmonyLib.HarmonyMethod(typeof(GameEvents).GetMethod(nameof(OnAvatarReinitialize_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
|
||||
);
|
||||
|
||||
p_instance.Patch(
|
||||
typeof(PlayerSetup).GetMethod("UpdatePlayerAvatarMovementData", BindingFlags.Instance | BindingFlags.NonPublic),
|
||||
null,
|
||||
new HarmonyLib.HarmonyMethod(typeof(GameEvents).GetMethod(nameof(OnPlayerAvatarMovementDataUpdate_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
|
||||
);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
|
@ -57,5 +71,17 @@ namespace ml_pmc
|
|||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
static void OnPlayerAvatarMovementDataUpdate_Postfix(PlayerAvatarMovementData ____playerAvatarMovementData)
|
||||
{
|
||||
try
|
||||
{
|
||||
OnPostLocalPlayerMovementDataUpdate.Invoke(____playerAvatarMovementData);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue