quantum-space-buddies/QSB/Player/Events/LaunchCodesEvent.cs

41 lines
1.1 KiB
C#
Raw Normal View History

using QSB.Events;
using QSB.Messaging;
namespace QSB.Player.Events
{
internal class LaunchCodesEvent : QSBEvent<PlayerMessage>
{
public override bool RequireWorldObjectsReady => true;
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-21 15:38:11 +00:00
private void Handler() => SendEvent(CreateMessage());
2021-11-21 13:52:29 +00:00
private PlayerMessage CreateMessage() => new()
{
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);
PlayerData._currentGameSave.SetPersistentCondition("LAUNCH_CODES_GIVEN", true);
2021-11-21 13:52:29 +00:00
GlobalMessenger.FireEvent("LearnLaunchCodes");
}
}
}
}