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