From cf151b25734f9679635a1899cc265aed55808d49 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Sat, 5 Feb 2022 03:48:06 -0800 Subject: [PATCH] ShipCustomAttach: disable custom attach point if we attach to something else --- QSB/Player/PlayerAttachWatcher.cs | 2 ++ QSB/ShipSync/ShipCustomAttach.cs | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/QSB/Player/PlayerAttachWatcher.cs b/QSB/Player/PlayerAttachWatcher.cs index 7d8bd38f..2a44e1bc 100644 --- a/QSB/Player/PlayerAttachWatcher.cs +++ b/QSB/Player/PlayerAttachWatcher.cs @@ -15,9 +15,11 @@ namespace QSB.Player 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; } diff --git a/QSB/ShipSync/ShipCustomAttach.cs b/QSB/ShipSync/ShipCustomAttach.cs index 36d7866f..2a51028c 100644 --- a/QSB/ShipSync/ShipCustomAttach.cs +++ b/QSB/ShipSync/ShipCustomAttach.cs @@ -42,6 +42,12 @@ namespace QSB.ShipSync var attachedToUs = PlayerAttachWatcher.Current == _playerAttachPoint; if (!attachedToUs) { + if (_playerAttachPoint.enabled) + { + // attached to us, then attached to something else + _playerAttachPoint.enabled = false; + } + if (PlayerState.IsAttached()) { return;