quantum-space-buddies/QSB/Player/PlayerAttachWatcher.cs
2022-02-05 03:15:54 -08:00

25 lines
643 B
C#

using HarmonyLib;
using QSB.Utility;
using UnityEngine;
namespace QSB.Player
{
[HarmonyPatch(typeof(PlayerAttachPoint))]
internal class PlayerAttachWatcher : MonoBehaviour, IAddComponentOnStart
{
private void Awake()
{
Harmony.CreateAndPatchAll(typeof(PlayerAttachWatcher));
Destroy(this);
}
public static PlayerAttachPoint Current { get; private set; }
[HarmonyPatch(nameof(PlayerAttachPoint.AttachPlayer))]
private static void AttachPlayer(PlayerAttachPoint __instance) => Current = __instance;
[HarmonyPatch(nameof(PlayerAttachPoint.DetachPlayer))]
private static void DetachPlayer() => Current = null;
}
}