2022-01-26 07:40:38 +00:00
|
|
|
|
using QSB.ConversationSync.Messages;
|
|
|
|
|
using QSB.LogSync.Messages;
|
|
|
|
|
using QSB.Messaging;
|
|
|
|
|
using QSB.Utility;
|
|
|
|
|
|
|
|
|
|
namespace QSB.WorldSync
|
|
|
|
|
{
|
2022-01-26 07:46:41 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// sent by non-host clients to get object states
|
|
|
|
|
/// </summary>
|
2022-01-26 07:40:38 +00:00
|
|
|
|
public class RequestInitialStatesMessage : QSBMessage
|
|
|
|
|
{
|
2022-01-31 19:38:53 +00:00
|
|
|
|
public override void OnReceiveRemote() =>
|
2022-01-31 19:31:23 +00:00
|
|
|
|
Delay.RunWhen(() => QSBWorldSync.AllObjectsReady,
|
2022-01-26 07:40:38 +00:00
|
|
|
|
() => SendInitialStates(From));
|
|
|
|
|
|
|
|
|
|
private static void SendInitialStates(uint to)
|
|
|
|
|
{
|
|
|
|
|
DebugLog.DebugWrite($"sending initial states to {to}");
|
|
|
|
|
|
|
|
|
|
if (QSBCore.IsHost)
|
|
|
|
|
{
|
|
|
|
|
QSBWorldSync.DialogueConditions.ForEach(condition
|
|
|
|
|
=> new DialogueConditionMessage(condition.Key, condition.Value) { To = to }.Send());
|
|
|
|
|
|
|
|
|
|
QSBWorldSync.ShipLogFacts.ForEach(fact
|
|
|
|
|
=> new RevealFactMessage(fact.Id, fact.SaveGame, false) { To = to }.Send());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var worldObject in QSBWorldSync.GetWorldObjects())
|
|
|
|
|
{
|
|
|
|
|
worldObject.SendInitialState(to);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|