2021-12-25 05:23:40 +00:00
|
|
|
|
using QSB.GeyserSync.Messages;
|
|
|
|
|
using QSB.Messaging;
|
2020-08-13 17:25:12 +00:00
|
|
|
|
using QSB.WorldSync;
|
2020-12-04 22:15:41 +00:00
|
|
|
|
using QuantumUNET;
|
2020-08-13 17:25:12 +00:00
|
|
|
|
|
2020-12-31 12:10:55 +00:00
|
|
|
|
namespace QSB.GeyserSync.WorldObjects
|
2020-08-13 17:25:12 +00:00
|
|
|
|
{
|
2020-12-23 22:43:05 +00:00
|
|
|
|
public class QSBGeyser : WorldObject<GeyserController>
|
2020-12-02 21:29:53 +00:00
|
|
|
|
{
|
2021-12-11 22:38:54 +00:00
|
|
|
|
public override void Init()
|
2020-12-02 21:29:53 +00:00
|
|
|
|
{
|
2020-12-23 23:08:55 +00:00
|
|
|
|
AttachedObject.OnGeyserActivateEvent += () => HandleEvent(true);
|
|
|
|
|
AttachedObject.OnGeyserDeactivateEvent += () => HandleEvent(false);
|
2020-12-02 21:29:53 +00:00
|
|
|
|
}
|
2020-08-13 17:25:12 +00:00
|
|
|
|
|
2020-12-02 21:29:53 +00:00
|
|
|
|
private void HandleEvent(bool state)
|
|
|
|
|
{
|
2020-12-23 12:58:45 +00:00
|
|
|
|
if (QNetworkServer.active)
|
2020-12-02 21:29:53 +00:00
|
|
|
|
{
|
2021-12-25 05:23:40 +00:00
|
|
|
|
this.SendMessage(new GeyserMessage(state));
|
2020-12-02 21:29:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-13 17:25:12 +00:00
|
|
|
|
|
2020-12-02 21:29:53 +00:00
|
|
|
|
public void SetState(bool state)
|
|
|
|
|
{
|
|
|
|
|
if (state)
|
|
|
|
|
{
|
2020-12-23 23:08:55 +00:00
|
|
|
|
AttachedObject?.ActivateGeyser();
|
2020-12-11 23:13:13 +00:00
|
|
|
|
return;
|
2020-12-02 21:29:53 +00:00
|
|
|
|
}
|
2021-06-18 21:38:32 +00:00
|
|
|
|
|
2020-12-23 23:08:55 +00:00
|
|
|
|
AttachedObject?.DeactivateGeyser();
|
2020-12-02 21:29:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-03 08:28:05 +00:00
|
|
|
|
}
|