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