mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-09 03:40:46 +00:00
f434ed027b
* wrapper for sector * using world registry for sectors * using order id as unique sector key * sector manager * not checking closest sector every frame
41 lines
1.0 KiB
C#
41 lines
1.0 KiB
C#
using QSB.Events;
|
|
using QSB.WorldSync;
|
|
using UnityEngine.Networking;
|
|
|
|
namespace QSB.GeyserSync
|
|
{
|
|
public class QSBGeyser : WorldObject
|
|
{
|
|
private GeyserController _geyserController;
|
|
|
|
public void Init(GeyserController geyserController, int id)
|
|
{
|
|
ObjectId = id;
|
|
_geyserController = geyserController;
|
|
|
|
geyserController.OnGeyserActivateEvent += () => HandleEvent(true);
|
|
geyserController.OnGeyserDeactivateEvent += () => HandleEvent(false);
|
|
}
|
|
|
|
private void HandleEvent(bool state)
|
|
{
|
|
if (NetworkServer.active)
|
|
{
|
|
GlobalMessenger<int, bool>.FireEvent(EventNames.QSBGeyserState, ObjectId, state);
|
|
}
|
|
}
|
|
|
|
public void SetState(bool state)
|
|
{
|
|
if (state)
|
|
{
|
|
_geyserController.ActivateGeyser();
|
|
}
|
|
else
|
|
{
|
|
_geyserController.DeactivateGeyser();
|
|
}
|
|
}
|
|
}
|
|
}
|