mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-17 01:13:05 +00:00
custom attach / attach watcher: improve
This commit is contained in:
parent
2154a22624
commit
e6946128ce
@ -10,7 +10,6 @@ namespace QSB.Player
|
||||
private void Awake()
|
||||
{
|
||||
Harmony.CreateAndPatchAll(typeof(PlayerAttachWatcher));
|
||||
QSBSceneManager.OnSceneLoaded += (_, _, _) => Current = null;
|
||||
Destroy(this);
|
||||
}
|
||||
|
||||
@ -18,10 +17,26 @@ namespace QSB.Player
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(PlayerAttachPoint.AttachPlayer))]
|
||||
private static void AttachPlayer(PlayerAttachPoint __instance) => Current = __instance;
|
||||
private static void AttachPlayer(PlayerAttachPoint __instance)
|
||||
{
|
||||
if (Current != null)
|
||||
{
|
||||
Current.DetachPlayer();
|
||||
}
|
||||
|
||||
Current = __instance;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(PlayerAttachPoint.DetachPlayer))]
|
||||
private static void DetachPlayer() => Current = null;
|
||||
private static void DetachPlayer(PlayerAttachPoint __instance)
|
||||
{
|
||||
if (!__instance.enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Current = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using QSB.Player;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.ShipSync
|
||||
{
|
||||
@ -39,7 +38,7 @@ namespace QSB.ShipSync
|
||||
return;
|
||||
}
|
||||
|
||||
var attachedToUs = PlayerAttachWatcher.Current == _playerAttachPoint;
|
||||
var attachedToUs = _playerAttachPoint.enabled;
|
||||
_detachPrompt.SetVisibility(attachedToUs);
|
||||
if (attachedToUs && OWInput.IsNewlyPressed(InputLibrary.cancel, InputMode.Character))
|
||||
{
|
||||
@ -49,12 +48,6 @@ namespace QSB.ShipSync
|
||||
|
||||
if (!attachedToUs)
|
||||
{
|
||||
if (_playerAttachPoint.enabled)
|
||||
{
|
||||
// attached to us, then attached to something else
|
||||
_playerAttachPoint.enabled = false;
|
||||
}
|
||||
|
||||
if (PlayerState.IsAttached())
|
||||
{
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user