2022-01-22 05:54:46 +00:00
|
|
|
|
using QSB.GeyserSync.Messages;
|
2021-12-25 05:23:40 +00:00
|
|
|
|
using QSB.Messaging;
|
2020-08-13 17:25:12 +00:00
|
|
|
|
using QSB.WorldSync;
|
|
|
|
|
|
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
|
|
|
|
{
|
2022-01-26 04:20:16 +00:00
|
|
|
|
if (QSBCore.IsHost)
|
|
|
|
|
{
|
|
|
|
|
AttachedObject.OnGeyserActivateEvent += OnActivate;
|
|
|
|
|
AttachedObject.OnGeyserDeactivateEvent += OnDeactivate;
|
|
|
|
|
}
|
2020-12-02 21:29:53 +00:00
|
|
|
|
}
|
2020-08-13 17:25:12 +00:00
|
|
|
|
|
2022-01-26 04:20:16 +00:00
|
|
|
|
public override void OnRemoval()
|
|
|
|
|
{
|
|
|
|
|
if (QSBCore.IsHost)
|
|
|
|
|
{
|
|
|
|
|
AttachedObject.OnGeyserActivateEvent -= OnActivate;
|
|
|
|
|
AttachedObject.OnGeyserDeactivateEvent -= OnDeactivate;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-22 05:54:46 +00:00
|
|
|
|
|
2022-01-26 07:40:38 +00:00
|
|
|
|
public override void SendInitialState(uint to)
|
2020-12-02 21:29:53 +00:00
|
|
|
|
{
|
2022-01-15 06:54:18 +00:00
|
|
|
|
if (QSBCore.IsHost)
|
2020-12-02 21:29:53 +00:00
|
|
|
|
{
|
2022-01-26 04:20:16 +00:00
|
|
|
|
this.SendMessage(new GeyserMessage(AttachedObject._isActive));
|
2020-12-02 21:29:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-08-13 17:25:12 +00:00
|
|
|
|
|
2022-01-26 04:20:16 +00:00
|
|
|
|
private void OnActivate() => this.SendMessage(new GeyserMessage(true));
|
|
|
|
|
private void OnDeactivate() => this.SendMessage(new GeyserMessage(false));
|
|
|
|
|
|
2020-12-02 21:29:53 +00:00
|
|
|
|
public void SetState(bool state)
|
|
|
|
|
{
|
2022-01-26 04:16:53 +00:00
|
|
|
|
if (AttachedObject._isActive == state)
|
2020-12-02 21:29:53 +00:00
|
|
|
|
{
|
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
|
|
|
|
|
2022-01-26 04:16:53 +00:00
|
|
|
|
if (state)
|
|
|
|
|
{
|
|
|
|
|
AttachedObject.ActivateGeyser();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
AttachedObject.DeactivateGeyser();
|
|
|
|
|
}
|
2020-12-02 21:29:53 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-26 04:20:16 +00:00
|
|
|
|
}
|