2022-01-14 07:38:45 +00:00
|
|
|
using QSB.Messaging;
|
2021-12-24 00:20:17 +00:00
|
|
|
using QSB.WorldSync;
|
2020-12-11 12:54:19 +00:00
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
namespace QSB.ConversationSync.Messages;
|
|
|
|
|
|
|
|
public class DialogueConditionMessage : QSBMessage<(string Name, bool State)>
|
2020-12-11 12:54:19 +00:00
|
|
|
{
|
2022-03-11 01:57:50 +00:00
|
|
|
public DialogueConditionMessage(string name, bool state) : base((name, state)) { }
|
2022-03-03 03:46:33 +00:00
|
|
|
|
|
|
|
public override void OnReceiveRemote()
|
2020-12-11 12:54:19 +00:00
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
if (QSBCore.IsHost)
|
2022-02-27 12:40:44 +00:00
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
QSBWorldSync.SetDialogueCondition(Data.Name, Data.State);
|
2022-02-27 12:40:44 +00:00
|
|
|
}
|
2022-02-25 06:04:54 +00:00
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
var sharedInstance = DialogueConditionManager.SharedInstance;
|
|
|
|
|
|
|
|
var flag = true;
|
|
|
|
if (sharedInstance.ConditionExists(Data.Name))
|
2021-12-24 00:20:17 +00:00
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
if (sharedInstance._dictConditions[Data.Name] == Data.State)
|
2021-12-24 00:20:17 +00:00
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
flag = false;
|
2021-12-24 00:20:17 +00:00
|
|
|
}
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
sharedInstance._dictConditions[Data.Name] = Data.State;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sharedInstance.AddCondition(Data.Name, Data.State);
|
|
|
|
}
|
2022-02-27 12:40:44 +00:00
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
if (flag)
|
|
|
|
{
|
|
|
|
GlobalMessenger<string, bool>.FireEvent("DialogueConditionChanged", Data.Name, Data.State);
|
|
|
|
}
|
2022-02-27 12:40:44 +00:00
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
if (Data.Name == "LAUNCH_CODES_GIVEN")
|
|
|
|
{
|
|
|
|
PlayerData.LearnLaunchCodes();
|
2021-12-24 00:20:17 +00:00
|
|
|
}
|
2022-03-03 03:46:33 +00:00
|
|
|
}
|
2021-12-24 00:20:17 +00:00
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
public override void OnReceiveLocal()
|
|
|
|
{
|
|
|
|
if (QSBCore.IsHost)
|
2021-12-24 00:20:17 +00:00
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
QSBWorldSync.SetDialogueCondition(Data.Name, Data.State);
|
2021-12-24 00:20:17 +00:00
|
|
|
}
|
2020-12-11 12:54:19 +00:00
|
|
|
}
|
2022-03-03 03:46:33 +00:00
|
|
|
}
|