2022-01-14 07:38:45 +00:00
|
|
|
|
using Mirror;
|
|
|
|
|
using QSB.Messaging;
|
2021-12-25 05:28:41 +00:00
|
|
|
|
using QSB.WorldSync;
|
2020-12-19 10:56:25 +00:00
|
|
|
|
|
2021-12-24 00:26:31 +00:00
|
|
|
|
namespace QSB.LogSync.Messages
|
2020-12-19 10:56:25 +00:00
|
|
|
|
{
|
2021-12-25 05:28:41 +00:00
|
|
|
|
public class RevealFactMessage : QSBMessage
|
2020-12-19 10:56:25 +00:00
|
|
|
|
{
|
2021-12-25 05:28:41 +00:00
|
|
|
|
private string FactId;
|
|
|
|
|
private bool SaveGame;
|
|
|
|
|
private bool ShowNotification;
|
2020-12-19 10:56:25 +00:00
|
|
|
|
|
2021-12-25 05:28:41 +00:00
|
|
|
|
public RevealFactMessage(string id, bool saveGame, bool showNotification)
|
2020-12-19 10:56:25 +00:00
|
|
|
|
{
|
2021-12-25 05:28:41 +00:00
|
|
|
|
FactId = id;
|
|
|
|
|
SaveGame = saveGame;
|
|
|
|
|
ShowNotification = showNotification;
|
2020-12-19 10:56:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-14 07:38:45 +00:00
|
|
|
|
public override void Serialize(NetworkWriter writer)
|
2020-12-19 10:56:25 +00:00
|
|
|
|
{
|
|
|
|
|
base.Serialize(writer);
|
|
|
|
|
writer.Write(FactId);
|
|
|
|
|
writer.Write(SaveGame);
|
|
|
|
|
writer.Write(ShowNotification);
|
|
|
|
|
}
|
2021-12-25 05:28:41 +00:00
|
|
|
|
|
2022-01-14 07:38:45 +00:00
|
|
|
|
public override void Deserialize(NetworkReader reader)
|
2021-12-25 05:28:41 +00:00
|
|
|
|
{
|
|
|
|
|
base.Deserialize(reader);
|
|
|
|
|
FactId = reader.ReadString();
|
2022-01-14 07:38:45 +00:00
|
|
|
|
SaveGame = reader.Read<bool>();
|
|
|
|
|
ShowNotification = reader.Read<bool>();
|
2021-12-25 05:28:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-18 08:27:32 +00:00
|
|
|
|
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
2021-12-25 05:28:41 +00:00
|
|
|
|
|
|
|
|
|
public override void OnReceiveLocal()
|
|
|
|
|
{
|
|
|
|
|
if (QSBCore.IsHost)
|
|
|
|
|
{
|
2021-12-26 08:58:03 +00:00
|
|
|
|
QSBWorldSync.AddFactReveal(FactId, SaveGame);
|
2021-12-25 05:28:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnReceiveRemote()
|
|
|
|
|
{
|
|
|
|
|
if (QSBCore.IsHost)
|
|
|
|
|
{
|
2021-12-26 08:58:03 +00:00
|
|
|
|
QSBWorldSync.AddFactReveal(FactId, SaveGame);
|
2021-12-25 05:28:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-18 08:27:32 +00:00
|
|
|
|
if (!QSBWorldSync.AllObjectsReady)
|
2021-12-25 05:28:41 +00:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Locator.GetShipLogManager().RevealFact(FactId, SaveGame, ShowNotification);
|
|
|
|
|
}
|
2020-12-19 10:56:25 +00:00
|
|
|
|
}
|
2021-12-25 05:28:41 +00:00
|
|
|
|
}
|