2020-12-14 16:24:52 +00:00
|
|
|
|
using QSB.Events;
|
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
|
|
|
|
{
|
2020-12-23 22:43:05 +00:00
|
|
|
|
public override void Init(GeyserController geyserController, int id)
|
2020-12-02 21:29:53 +00:00
|
|
|
|
{
|
|
|
|
|
ObjectId = id;
|
2020-12-23 23:08:55 +00:00
|
|
|
|
AttachedObject = geyserController;
|
|
|
|
|
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-02-10 19:34:41 +00:00
|
|
|
|
QSBEventManager.FireEvent(EventNames.QSBGeyserState, ObjectId, 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
|
|
|
|
}
|