2022-01-26 07:40:38 +00:00
|
|
|
|
using QSB.ConversationSync.Messages;
|
|
|
|
|
using QSB.LogSync.Messages;
|
|
|
|
|
using QSB.Messaging;
|
|
|
|
|
using QSB.Utility;
|
|
|
|
|
|
2022-02-27 12:40:44 +00:00
|
|
|
|
namespace QSB.WorldSync
|
2022-01-26 07:40:38 +00:00
|
|
|
|
{
|
2022-02-27 12:40:44 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// sent to the host to get initial object states.
|
|
|
|
|
/// <para/>
|
|
|
|
|
/// world objects will be ready on both sides at this point
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class RequestInitialStatesMessage : QSBMessage
|
|
|
|
|
{
|
|
|
|
|
public RequestInitialStatesMessage() => To = 0;
|
2022-02-16 10:30:01 +00:00
|
|
|
|
|
2022-02-27 12:40:44 +00:00
|
|
|
|
public override void OnReceiveRemote() =>
|
|
|
|
|
Delay.RunWhen(() => QSBWorldSync.AllObjectsReady,
|
|
|
|
|
() => SendInitialStates(From));
|
2022-01-26 07:40:38 +00:00
|
|
|
|
|
2022-02-27 12:40:44 +00:00
|
|
|
|
private static void SendInitialStates(uint to)
|
|
|
|
|
{
|
|
|
|
|
DebugLog.DebugWrite($"sending initial states to {to}");
|
2022-01-26 07:40:38 +00:00
|
|
|
|
|
2022-02-27 12:40:44 +00:00
|
|
|
|
QSBWorldSync.DialogueConditions.ForEach(condition
|
|
|
|
|
=> new DialogueConditionMessage(condition.Key, condition.Value) { To = to }.Send());
|
2022-01-26 07:40:38 +00:00
|
|
|
|
|
2022-02-27 12:40:44 +00:00
|
|
|
|
QSBWorldSync.ShipLogFacts.ForEach(fact
|
|
|
|
|
=> new RevealFactMessage(fact.Id, fact.SaveGame, false) { To = to }.Send());
|
2022-01-26 07:40:38 +00:00
|
|
|
|
|
2022-02-27 12:40:44 +00:00
|
|
|
|
var target = to.GetNetworkConnection();
|
|
|
|
|
foreach (var qsbNetworkBehaviour in QSBWorldSync.GetUnityObjects<QSBNetworkBehaviour>())
|
|
|
|
|
{
|
|
|
|
|
qsbNetworkBehaviour.SendInitialState(target);
|
|
|
|
|
}
|
2022-02-04 22:17:23 +00:00
|
|
|
|
|
2022-02-27 12:40:44 +00:00
|
|
|
|
foreach (var worldObject in QSBWorldSync.GetWorldObjects())
|
|
|
|
|
{
|
|
|
|
|
worldObject.SendInitialState(to);
|
|
|
|
|
}
|
2022-01-26 07:40:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-02-25 06:04:54 +00:00
|
|
|
|
}
|