2022-01-08 15:04:52 +00:00
|
|
|
|
using QSB.ConversationSync.Messages;
|
|
|
|
|
using QSB.Messaging;
|
2022-02-19 04:16:57 -08:00
|
|
|
|
using QSB.Player;
|
2022-11-07 20:14:03 +00:00
|
|
|
|
using QSB.ServerSettings;
|
2022-02-19 04:16:57 -08:00
|
|
|
|
using QSB.Utility;
|
2021-12-22 22:44:31 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
namespace QSB.SaveSync.Messages;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// always sent to host
|
|
|
|
|
/// </summary>
|
2023-07-28 19:30:57 +01:00
|
|
|
|
public class RequestGameStateMessage : QSBMessage
|
2021-12-22 22:44:31 -08:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public RequestGameStateMessage() => To = 0;
|
2022-02-27 04:40:44 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public override void OnReceiveRemote() => Delay.RunFramesLater(100, () =>
|
2022-04-05 18:02:00 -07:00
|
|
|
|
{
|
|
|
|
|
if (!QSBPlayerManager.PlayerExists(From))
|
2022-01-08 11:41:55 +00:00
|
|
|
|
{
|
2022-04-05 18:02:00 -07:00
|
|
|
|
// player was kicked
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-02-19 04:16:57 -08:00
|
|
|
|
|
2022-04-05 18:02:00 -07:00
|
|
|
|
new GameStateMessage(From).Send();
|
2022-11-07 20:14:03 +00:00
|
|
|
|
new ServerSettingsMessage().Send();
|
2022-01-08 11:41:55 +00:00
|
|
|
|
|
2022-04-05 18:02:00 -07:00
|
|
|
|
var gameSave = PlayerData._currentGameSave;
|
2022-01-08 11:41:55 +00:00
|
|
|
|
|
2022-04-05 18:02:00 -07:00
|
|
|
|
var factSaves = gameSave.shipLogFactSaves;
|
|
|
|
|
foreach (var item in factSaves)
|
|
|
|
|
{
|
|
|
|
|
new ShipLogFactSaveMessage(item.Value).Send();
|
|
|
|
|
}
|
2022-01-08 15:04:52 +00:00
|
|
|
|
|
2022-04-05 18:02:00 -07:00
|
|
|
|
var dictConditions = gameSave.dictConditions;
|
|
|
|
|
foreach (var item in dictConditions)
|
|
|
|
|
{
|
|
|
|
|
new PersistentConditionMessage(item.Key, item.Value).Send();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|