mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-08 09:41:07 +00:00
28 lines
744 B
C#
28 lines
744 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));
|
|
QSBSceneManager.OnSceneLoaded += (_, _, _) => Current = null;
|
|
Destroy(this);
|
|
}
|
|
|
|
public static PlayerAttachPoint Current { get; private set; }
|
|
|
|
[HarmonyPrefix]
|
|
[HarmonyPatch(nameof(PlayerAttachPoint.AttachPlayer))]
|
|
private static void AttachPlayer(PlayerAttachPoint __instance) => Current = __instance;
|
|
|
|
[HarmonyPrefix]
|
|
[HarmonyPatch(nameof(PlayerAttachPoint.DetachPlayer))]
|
|
private static void DetachPlayer() => Current = null;
|
|
}
|
|
}
|