using QSB.Messaging;
using QSB.Utility;
using System;
namespace QSB.WorldSync;
///
/// sent to the host to get initial object states.
///
/// world objects will be ready on both sides at this point
///
public class RequestInitialStatesMessage : QSBMessage
{
public RequestInitialStatesMessage() => To = 0;
public override void OnReceiveRemote() =>
Delay.RunWhen(() => QSBWorldSync.AllObjectsReady,
() => SendInitialStates(From));
private static void SendInitialStates(uint to)
{
SendInitialState?.SafeInvoke(to);
DebugLog.DebugWrite($"sent initial states to {to}");
}
///
/// called on the host.
/// use this to send initial states to whoever is asking for it.
///
public static event Action SendInitialState;
}