2020-08-13 17:25:12 +00:00
|
|
|
|
using QSB.Events;
|
|
|
|
|
using QSB.WorldSync;
|
|
|
|
|
using UnityEngine.Networking;
|
|
|
|
|
|
|
|
|
|
namespace QSB.GeyserSync
|
|
|
|
|
{
|
|
|
|
|
public class QSBGeyser : WorldObject
|
|
|
|
|
{
|
|
|
|
|
private GeyserController _geyserController;
|
|
|
|
|
|
2020-08-13 18:43:47 +00:00
|
|
|
|
public void Init(GeyserController geyserController, int id)
|
2020-08-13 17:25:12 +00:00
|
|
|
|
{
|
2020-08-13 18:47:23 +00:00
|
|
|
|
ObjectId = id;
|
2020-08-13 17:25:12 +00:00
|
|
|
|
_geyserController = geyserController;
|
|
|
|
|
|
|
|
|
|
geyserController.OnGeyserActivateEvent += () => HandleEvent(true);
|
|
|
|
|
geyserController.OnGeyserDeactivateEvent += () => HandleEvent(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HandleEvent(bool state)
|
|
|
|
|
{
|
|
|
|
|
if (NetworkServer.active)
|
|
|
|
|
{
|
2020-08-13 18:47:23 +00:00
|
|
|
|
GlobalMessenger<int, bool>.FireEvent(EventNames.QSBGeyserState, ObjectId, state);
|
2020-08-13 17:25:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetState(bool state)
|
|
|
|
|
{
|
|
|
|
|
if (state)
|
|
|
|
|
{
|
|
|
|
|
_geyserController.ActivateGeyser();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_geyserController.DeactivateGeyser();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|