mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-07 13:05:41 +00:00
25 lines
771 B
C#
25 lines
771 B
C#
using Mirror;
|
|
using QSB.Messaging;
|
|
using QSB.WorldSync;
|
|
|
|
namespace QSB.Utility.LinkedWorldObject;
|
|
|
|
/// <summary>
|
|
/// sent from the host to a non-host
|
|
/// telling a world object and network behaviour to link
|
|
/// </summary>
|
|
public class LinkMessage : QSBMessage<(int ObjectId, uint NetId)>
|
|
{
|
|
public LinkMessage(IWorldObject worldObject, INetworkBehaviour networkBehaviour) :
|
|
base((worldObject.ObjectId, networkBehaviour.netId)) { }
|
|
|
|
public override void OnReceiveRemote()
|
|
{
|
|
var worldObject = Data.ObjectId.GetWorldObject<ILinkedWorldObject<INetworkBehaviour>>();
|
|
var networkBehaviour = NetworkClient.spawned[Data.NetId].GetComponent<ILinkedNetworkBehaviour<IWorldObject>>();
|
|
|
|
worldObject.LinkTo(networkBehaviour);
|
|
networkBehaviour.LinkTo(worldObject);
|
|
}
|
|
}
|