2021-11-20 11:48:46 +00:00
|
|
|
|
using QSB.Events;
|
|
|
|
|
using QSB.Messaging;
|
|
|
|
|
|
|
|
|
|
namespace QSB.Player.Events
|
|
|
|
|
{
|
|
|
|
|
internal class LaunchCodesEvent : QSBEvent<PlayerMessage>
|
|
|
|
|
{
|
2021-12-05 11:03:09 +00:00
|
|
|
|
public override bool RequireWorldObjectsReady => true;
|
2021-12-04 16:39:37 +00:00
|
|
|
|
|
2021-11-21 13:52:29 +00:00
|
|
|
|
public override void SetupListener() => GlobalMessenger.AddListener(EventNames.QSBLearnLaunchCodes, Handler);
|
|
|
|
|
public override void CloseListener() => GlobalMessenger.RemoveListener(EventNames.QSBLearnLaunchCodes, Handler);
|
2021-11-20 11:48:46 +00:00
|
|
|
|
|
2021-11-21 15:38:11 +00:00
|
|
|
|
private void Handler() => SendEvent(CreateMessage());
|
2021-11-20 11:48:46 +00:00
|
|
|
|
|
2021-11-21 13:52:29 +00:00
|
|
|
|
private PlayerMessage CreateMessage() => new()
|
2021-11-20 11:48:46 +00:00
|
|
|
|
{
|
|
|
|
|
AboutId = LocalPlayerId
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public override void OnReceiveRemote(bool isHost, PlayerMessage message)
|
|
|
|
|
{
|
|
|
|
|
var flag = false;
|
|
|
|
|
if (!PlayerData._currentGameSave.PersistentConditionExists("LAUNCH_CODES_GIVEN"))
|
|
|
|
|
{
|
|
|
|
|
flag = true;
|
|
|
|
|
}
|
|
|
|
|
else if (PlayerData._currentGameSave.GetPersistentCondition("LAUNCH_CODES_GIVEN"))
|
|
|
|
|
{
|
|
|
|
|
flag = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (flag)
|
|
|
|
|
{
|
2021-11-21 13:52:29 +00:00
|
|
|
|
DialogueConditionManager.SharedInstance.SetConditionState("SCIENTIST_3", true);
|
2021-11-20 11:48:46 +00:00
|
|
|
|
PlayerData._currentGameSave.SetPersistentCondition("LAUNCH_CODES_GIVEN", true);
|
2021-11-21 13:52:29 +00:00
|
|
|
|
GlobalMessenger.FireEvent("LearnLaunchCodes");
|
2021-11-20 11:48:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|