mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 03:32:38 +00:00
36 lines
720 B
C#
36 lines
720 B
C#
using HarmonyLib;
|
|
using QSB.Patches;
|
|
|
|
namespace QSB.Player;
|
|
|
|
[HarmonyPatch(typeof(PlayerAttachPoint))]
|
|
internal class PlayerAttachWatcher : QSBPatch
|
|
{
|
|
public override QSBPatchTypes Type => QSBPatchTypes.OnModStart;
|
|
|
|
public static PlayerAttachPoint Current { get; private set; }
|
|
|
|
[HarmonyPrefix]
|
|
[HarmonyPatch(nameof(PlayerAttachPoint.AttachPlayer))]
|
|
private static void AttachPlayer(PlayerAttachPoint __instance)
|
|
{
|
|
if (Current != null)
|
|
{
|
|
Current.DetachPlayer();
|
|
}
|
|
|
|
Current = __instance;
|
|
}
|
|
|
|
[HarmonyPrefix]
|
|
[HarmonyPatch(nameof(PlayerAttachPoint.DetachPlayer))]
|
|
private static void DetachPlayer(PlayerAttachPoint __instance)
|
|
{
|
|
if (!__instance.enabled)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Current = null;
|
|
}
|
|
} |