quantum-space-buddies/QSB/GeyserSync/QSBGeyser.cs
AmazingAlek 321c7db7f7
random fixes (#200)
* usings
* fixed wakeup teleport
* marker bug
* reset ship thing
* cache
* config order
* playerid
* nre sector

Co-authored-by: Mister_Nebula <41904486+misternebula@users.noreply.github.com>
2020-08-23 21:01:09 +02:00

41 lines
1.0 KiB
C#

using QSB.Events;
using QSB.WorldSync;
using UnityEngine.Networking;
namespace QSB.GeyserSync
{
public class QSBGeyser : WorldObject
{
private GeyserController _geyserController;
public void Init(GeyserController geyserController, int id)
{
ObjectId = id;
_geyserController = geyserController;
geyserController.OnGeyserActivateEvent += () => HandleEvent(true);
geyserController.OnGeyserDeactivateEvent += () => HandleEvent(false);
}
private void HandleEvent(bool state)
{
if (NetworkServer.active)
{
GlobalMessenger<int, bool>.FireEvent(EventNames.QSBGeyserState, ObjectId, state);
}
}
public void SetState(bool state)
{
if (state)
{
_geyserController?.ActivateGeyser();
}
else
{
_geyserController?.DeactivateGeyser();
}
}
}
}