2022-03-03 03:41:33 +00:00
|
|
|
|
using QSB.Messaging;
|
2022-01-08 11:41:55 +00:00
|
|
|
|
using QSB.WorldSync;
|
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
namespace QSB.ConversationSync.Messages;
|
|
|
|
|
|
|
|
|
|
internal class PersistentConditionMessage : QSBMessage<(string Condition, bool State)>
|
2022-01-08 11:41:55 +00:00
|
|
|
|
{
|
2022-03-11 01:57:50 +00:00
|
|
|
|
public PersistentConditionMessage(string condition, bool state) : base((condition, state)) { }
|
2022-03-03 03:46:33 +00:00
|
|
|
|
|
|
|
|
|
public override void OnReceiveRemote()
|
2022-01-08 11:41:55 +00:00
|
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
|
if (QSBCore.IsHost)
|
2022-01-08 11:41:55 +00:00
|
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
|
QSBWorldSync.SetPersistentCondition(Data.Condition, Data.State);
|
2022-01-08 11:41:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
var gameSave = PlayerData._currentGameSave;
|
|
|
|
|
if (gameSave.dictConditions.ContainsKey(Data.Condition))
|
2022-01-08 11:41:55 +00:00
|
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
|
gameSave.dictConditions[Data.Condition] = Data.State;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gameSave.dictConditions.Add(Data.Condition, Data.State);
|
|
|
|
|
}
|
2022-02-27 12:40:44 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
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
|
|
|
|
}
|
2022-03-03 03:46:33 +00:00
|
|
|
|
}
|
2022-01-08 11:41:55 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public override void OnReceiveLocal()
|
|
|
|
|
{
|
|
|
|
|
if (QSBCore.IsHost)
|
2022-01-08 11:41:55 +00:00
|
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
|
QSBWorldSync.SetPersistentCondition(Data.Condition, Data.State);
|
2022-01-08 11:41:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-03-03 03:46:33 +00:00
|
|
|
|
}
|