quantum-space-buddies/QSB/GeyserSync/WorldObjects/QSBGeyser.cs
2021-12-24 21:23:40 -08:00

35 lines
670 B
C#

using QSB.GeyserSync.Messages;
using QSB.Messaging;
using QSB.WorldSync;
using QuantumUNET;
namespace QSB.GeyserSync.WorldObjects
{
public class QSBGeyser : WorldObject<GeyserController>
{
public override void Init()
{
AttachedObject.OnGeyserActivateEvent += () => HandleEvent(true);
AttachedObject.OnGeyserDeactivateEvent += () => HandleEvent(false);
}
private void HandleEvent(bool state)
{
if (QNetworkServer.active)
{
this.SendMessage(new GeyserMessage(state));
}
}
public void SetState(bool state)
{
if (state)
{
AttachedObject?.ActivateGeyser();
return;
}
AttachedObject?.DeactivateGeyser();
}
}
}