2022-01-14 14:30:54 -08:00
|
|
|
|
using Mirror;
|
|
|
|
|
using QSB.Messaging;
|
2022-01-08 11:41:55 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
namespace QSB.SaveSync.Messages;
|
|
|
|
|
|
2023-07-28 19:30:57 +01:00
|
|
|
|
public class ShipLogFactSaveMessage : QSBMessage
|
2022-01-08 11:41:55 +00:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
private string _id;
|
|
|
|
|
private int _revealOrder;
|
|
|
|
|
private bool _read;
|
|
|
|
|
private bool _newlyRevealed;
|
|
|
|
|
|
|
|
|
|
public ShipLogFactSaveMessage(ShipLogFactSave save)
|
2022-01-08 11:41:55 +00:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
_id = save.id;
|
|
|
|
|
_revealOrder = save.revealOrder;
|
|
|
|
|
_read = save.read;
|
|
|
|
|
_newlyRevealed = save.newlyRevealed;
|
|
|
|
|
}
|
2022-01-08 11:41:55 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public override void Serialize(NetworkWriter writer)
|
|
|
|
|
{
|
|
|
|
|
base.Serialize(writer);
|
|
|
|
|
writer.Write(_id);
|
|
|
|
|
writer.Write(_revealOrder);
|
|
|
|
|
writer.Write(_read);
|
|
|
|
|
writer.Write(_newlyRevealed);
|
|
|
|
|
}
|
2022-01-08 11:41:55 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public override void Deserialize(NetworkReader reader)
|
|
|
|
|
{
|
|
|
|
|
base.Deserialize(reader);
|
|
|
|
|
_id = reader.ReadString();
|
|
|
|
|
_revealOrder = reader.ReadInt();
|
|
|
|
|
_read = reader.ReadBool();
|
|
|
|
|
_newlyRevealed = reader.ReadBool();
|
|
|
|
|
}
|
2022-01-08 11:41:55 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public override void OnReceiveRemote()
|
|
|
|
|
{
|
|
|
|
|
var save = PlayerData.GetShipLogFactSave(_id);
|
2022-02-24 22:04:54 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
if (save == null)
|
2022-02-27 04:40:44 -08:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
save = new ShipLogFactSave(_id);
|
|
|
|
|
PlayerData.AddShipLogFactSave(save);
|
2022-02-27 04:40:44 -08:00
|
|
|
|
}
|
2022-03-02 19:46:33 -08:00
|
|
|
|
|
|
|
|
|
save.revealOrder = _revealOrder;
|
|
|
|
|
save.read = _read;
|
|
|
|
|
save.newlyRevealed = _newlyRevealed;
|
2022-01-08 11:41:55 +00:00
|
|
|
|
}
|
2022-02-24 22:04:54 -08:00
|
|
|
|
}
|