quantum-space-buddies/QSB/LogSync/Messages/RevealFactMessage.cs
2021-12-24 21:28:41 -08:00

63 lines
1.3 KiB
C#

using QSB.Messaging;
using QSB.WorldSync;
using QuantumUNET.Transport;
namespace QSB.LogSync.Messages
{
public class RevealFactMessage : QSBMessage
{
private string FactId;
private bool SaveGame;
private bool ShowNotification;
public RevealFactMessage(string id, bool saveGame, bool showNotification)
{
FactId = id;
SaveGame = saveGame;
ShowNotification = showNotification;
}
public RevealFactMessage() { }
public override void Serialize(QNetworkWriter writer)
{
base.Serialize(writer);
writer.Write(FactId);
writer.Write(SaveGame);
writer.Write(ShowNotification);
}
public override void Deserialize(QNetworkReader reader)
{
base.Deserialize(reader);
FactId = reader.ReadString();
SaveGame = reader.ReadBoolean();
ShowNotification = reader.ReadBoolean();
}
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
public override void OnReceiveLocal()
{
if (QSBCore.IsHost)
{
QSBWorldSync.AddFactReveal(FactId, SaveGame, ShowNotification);
}
}
public override void OnReceiveRemote()
{
if (QSBCore.IsHost)
{
QSBWorldSync.AddFactReveal(FactId, SaveGame, ShowNotification);
}
if (!WorldObjectManager.AllObjectsReady)
{
return;
}
Locator.GetShipLogManager().RevealFact(FactId, SaveGame, ShowNotification);
}
}
}