quantum-space-buddies/QSB/LogSync/Messages/RevealFactMessage.cs

61 lines
1.3 KiB
C#
Raw Normal View History

2020-12-19 10:56:25 +00:00
using QSB.Messaging;
2021-12-25 05:28:41 +00:00
using QSB.WorldSync;
2020-12-19 10:56:25 +00:00
using QuantumUNET.Transport;
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
}
2020-12-23 12:58:45 +00:00
public override void Serialize(QNetworkWriter 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
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);
2021-12-25 05:28:41 +00:00
}
}
public override void OnReceiveRemote()
{
if (QSBCore.IsHost)
{
QSBWorldSync.AddFactReveal(FactId, SaveGame);
2021-12-25 05:28:41 +00:00
}
if (!WorldObjectManager.AllObjectsReady)
{
return;
}
Locator.GetShipLogManager().RevealFact(FactId, SaveGame, ShowNotification);
}
2020-12-19 10:56:25 +00:00
}
2021-12-25 05:28:41 +00:00
}