37 lines
737 B
C#
Raw Normal View History

2022-01-21 21:54:46 -08:00
using QSB.GeyserSync.Messages;
2021-12-24 21:23:40 -08:00
using QSB.Messaging;
2020-08-13 19:25:12 +02:00
using QSB.WorldSync;
namespace QSB.GeyserSync.WorldObjects
2020-08-13 19:25:12 +02:00
{
2020-12-23 22:43:05 +00:00
public class QSBGeyser : WorldObject<GeyserController>
2020-12-02 21:29:53 +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 19:25:12 +02:00
2022-01-21 21:54:46 -08:00
public override void SendResyncInfo(uint to) =>
HandleEvent(AttachedObject._isActive);
2020-12-02 21:29:53 +00:00
private void HandleEvent(bool state)
{
if (QSBCore.IsHost)
2020-12-02 21:29:53 +00:00
{
2021-12-24 21:23:40 -08:00
this.SendMessage(new GeyserMessage(state));
2020-12-02 21:29:53 +00:00
}
}
2020-08-13 19:25:12 +02: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 22:38:32 +01: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
}