2022-03-11 01:57:50 +00:00
|
|
|
|
using QSB.Messaging;
|
2021-12-23 04:45:25 +00:00
|
|
|
|
using QSB.QuantumSync.WorldObjects;
|
|
|
|
|
using QSB.WorldSync;
|
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
namespace QSB.Player.Messages;
|
|
|
|
|
|
|
|
|
|
// almost a world object message, but supports null (-1) as well
|
|
|
|
|
internal class PlayerEntangledMessage : QSBMessage<int>
|
2021-12-23 04:45:25 +00:00
|
|
|
|
{
|
2022-03-11 01:57:50 +00:00
|
|
|
|
public PlayerEntangledMessage(int objectId) : base(objectId) { }
|
2021-12-23 04:45:25 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
2021-12-23 04:45:25 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public override void OnReceiveLocal()
|
|
|
|
|
{
|
|
|
|
|
var player = QSBPlayerManager.LocalPlayer;
|
|
|
|
|
if (Data == -1)
|
2021-12-23 04:45:25 +00:00
|
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
|
player.EntangledObject = null;
|
|
|
|
|
return;
|
2021-12-23 04:45:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
var quantumObject = Data.GetWorldObject<IQSBQuantumObject>();
|
|
|
|
|
player.EntangledObject = quantumObject;
|
|
|
|
|
}
|
2021-12-23 04:45:25 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public override void OnReceiveRemote()
|
|
|
|
|
{
|
|
|
|
|
var player = QSBPlayerManager.GetPlayer(From);
|
|
|
|
|
if (Data == -1)
|
2022-02-27 12:40:44 +00:00
|
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
|
player.EntangledObject = null;
|
|
|
|
|
return;
|
2022-02-27 12:40:44 +00:00
|
|
|
|
}
|
2022-02-25 06:04:54 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
var quantumObject = Data.GetWorldObject<IQSBQuantumObject>();
|
|
|
|
|
player.EntangledObject = quantumObject;
|
|
|
|
|
}
|
2022-02-25 06:04:54 +00:00
|
|
|
|
}
|