mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-06 01:00:16 +00:00
41 lines
939 B
C#
41 lines
939 B
C#
using OWML.Utils;
|
|
using QSB.Events;
|
|
using QSB.QuantumSync;
|
|
using QSB.WorldSync;
|
|
using UnityEngine;
|
|
|
|
namespace QSB.Player
|
|
{
|
|
internal class PlayerEntanglementWatcher : MonoBehaviour
|
|
{
|
|
private QuantumObject _previousCollidingQuantumObject;
|
|
|
|
private void Update()
|
|
{
|
|
if (!QSBCore.IsInMultiplayer)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var controller = Locator.GetPlayerController();
|
|
if (controller == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var collidingQuantumObject = controller.GetValue<QuantumObject>("_collidingQuantumObject");
|
|
if (_previousCollidingQuantumObject != collidingQuantumObject)
|
|
{
|
|
var objectIndex = (collidingQuantumObject != null)
|
|
? QSBWorldSync.GetIdFromTypeSubset((IQSBQuantumObject)QSBWorldSync.GetWorldFromUnity(collidingQuantumObject))
|
|
: -1;
|
|
|
|
QSBEventManager.FireEvent(
|
|
EventNames.QSBPlayerEntangle,
|
|
objectIndex);
|
|
_previousCollidingQuantumObject = collidingQuantumObject;
|
|
}
|
|
}
|
|
}
|
|
}
|