mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-29 09:32:38 +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()
|
private void Awake()
|
||||||
{
|
{
|
||||||
Harmony.CreateAndPatchAll(typeof(PlayerAttachWatcher));
|
Harmony.CreateAndPatchAll(typeof(PlayerAttachWatcher));
|
||||||
QSBSceneManager.OnSceneLoaded += (_, _, _) => Current = null;
|
|
||||||
Destroy(this);
|
Destroy(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,10 +17,26 @@ namespace QSB.Player
|
|||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(nameof(PlayerAttachPoint.AttachPlayer))]
|
[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]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(nameof(PlayerAttachPoint.DetachPlayer))]
|
[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
|
namespace QSB.ShipSync
|
||||||
{
|
{
|
||||||
@ -39,7 +38,7 @@ namespace QSB.ShipSync
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var attachedToUs = PlayerAttachWatcher.Current == _playerAttachPoint;
|
var attachedToUs = _playerAttachPoint.enabled;
|
||||||
_detachPrompt.SetVisibility(attachedToUs);
|
_detachPrompt.SetVisibility(attachedToUs);
|
||||||
if (attachedToUs && OWInput.IsNewlyPressed(InputLibrary.cancel, InputMode.Character))
|
if (attachedToUs && OWInput.IsNewlyPressed(InputLibrary.cancel, InputMode.Character))
|
||||||
{
|
{
|
||||||
@ -49,12 +48,6 @@ namespace QSB.ShipSync
|
|||||||
|
|
||||||
if (!attachedToUs)
|
if (!attachedToUs)
|
||||||
{
|
{
|
||||||
if (_playerAttachPoint.enabled)
|
|
||||||
{
|
|
||||||
// attached to us, then attached to something else
|
|
||||||
_playerAttachPoint.enabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PlayerState.IsAttached())
|
if (PlayerState.IsAttached())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user