mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-21 09:39:56 +00:00
PlayerAttachWatcher
This commit is contained in:
parent
4f3c359946
commit
f301af02f3
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// global messenger events built into outer wilds
|
/// global messenger events built into outer wilds
|
||||||
/// that are also listened to with network messages.
|
/// that are also used by qsb.
|
||||||
/// <para/>
|
/// <para/>
|
||||||
/// don't change unless they change in-game!
|
/// don't change unless they change in-game!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
24
QSB/Player/PlayerAttachWatcher.cs
Normal file
24
QSB/Player/PlayerAttachWatcher.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using UnityEngine;
|
using QSB.Player;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace QSB.ShipSync
|
namespace QSB.ShipSync
|
||||||
{
|
{
|
||||||
@ -38,7 +39,7 @@ namespace QSB.ShipSync
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var attachedToUs = _playerAttachPoint.enabled;
|
var attachedToUs = PlayerAttachWatcher.Current == _playerAttachPoint;
|
||||||
if (!attachedToUs)
|
if (!attachedToUs)
|
||||||
{
|
{
|
||||||
if (PlayerState.IsAttached())
|
if (PlayerState.IsAttached())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user