quantum-space-buddies/QSB/ConversationSync/Messages/PersistentConditionMessage.cs

50 lines
1.1 KiB
C#
Raw Normal View History

using QSB.Messaging;
2022-01-08 11:41:55 +00:00
using QSB.WorldSync;
namespace QSB.ConversationSync.Messages
2022-01-08 11:41:55 +00:00
{
internal class PersistentConditionMessage : QSBMessage<(string Condition, bool State)>
2022-01-08 11:41:55 +00:00
{
public PersistentConditionMessage(string condition, bool state)
2022-01-08 11:41:55 +00:00
{
Data.Condition = condition;
Data.State = state;
2022-01-08 11:41:55 +00:00
}
public override void OnReceiveRemote()
2022-01-08 11:41:55 +00:00
{
if (QSBCore.IsHost)
{
QSBWorldSync.SetPersistentCondition(Data.Condition, Data.State);
}
var gameSave = PlayerData._currentGameSave;
if (gameSave.dictConditions.ContainsKey(Data.Condition))
{
gameSave.dictConditions[Data.Condition] = Data.State;
}
else
{
gameSave.dictConditions.Add(Data.Condition, Data.State);
}
if (Data.Condition
is not "LAUNCH_CODES_GIVEN"
and not "PLAYER_ENTERED_TIMELOOPCORE"
and not "PROBE_ENTERED_TIMELOOPCORE"
and not "PLAYER_ENTERED_TIMELOOPCORE_MULTIPLE")
{
PlayerData.SaveCurrentGame();
}
2022-01-08 11:41:55 +00:00
}
public override void OnReceiveLocal()
2022-01-08 11:41:55 +00:00
{
if (QSBCore.IsHost)
{
QSBWorldSync.SetPersistentCondition(Data.Condition, Data.State);
}
2022-01-08 11:41:55 +00:00
}
}
}