mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 03:32:38 +00:00
29 lines
760 B
C#
29 lines
760 B
C#
using Mirror;
|
|
using QSB.Messaging;
|
|
using QSB.WorldSync;
|
|
|
|
namespace QSB.Utility.LinkedWorldObject;
|
|
|
|
/// <summary>
|
|
/// sent to the host when all world objects are added.
|
|
/// used in order to link world objects to network behaviours.
|
|
/// </summary>
|
|
public class RequestLinksMessage : QSBMessage
|
|
{
|
|
public RequestLinksMessage() => To = 0;
|
|
|
|
public override void OnReceiveRemote() =>
|
|
Delay.RunWhen(() => QSBWorldSync.AllObjectsAdded,
|
|
() => SendLinks(From));
|
|
|
|
private static void SendLinks(uint to)
|
|
{
|
|
foreach (var worldObject in QSBWorldSync.GetWorldObjects<ILinkedWorldObject<NetworkBehaviour>>())
|
|
{
|
|
new LinkMessage(worldObject, worldObject.NetworkBehaviour) { To = to }.Send();
|
|
}
|
|
|
|
DebugLog.DebugWrite($"sent world object links to {to}");
|
|
}
|
|
}
|