mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-17 19:11:32 +00:00
40 lines
1011 B
C#
40 lines
1011 B
C#
using QSB.Events;
|
|
using QSB.Messaging;
|
|
|
|
namespace QSB.Player.Events
|
|
{
|
|
internal class LaunchCodesEvent : QSBEvent<PlayerMessage>
|
|
{
|
|
public override EventType Type => EventType.PlayerInformation;
|
|
|
|
public override void SetupListener() => GlobalMessenger.AddListener(EventNames.LaunchCodes, Handler);
|
|
public override void CloseListener() => GlobalMessenger.RemoveListener(EventNames.LaunchCodes, Handler);
|
|
|
|
private void Handler() => SendEvent(CreateMessage());
|
|
|
|
private PlayerMessage CreateMessage() => new PlayerMessage
|
|
{
|
|
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)
|
|
{
|
|
PlayerData._currentGameSave.SetPersistentCondition("LAUNCH_CODES_GIVEN", true);
|
|
}
|
|
}
|
|
}
|
|
}
|