quantum-space-buddies/QSB/WorldRegistry.cs
Mister_Nebula 5283982ff8 added it
2020-08-13 14:32:58 +01:00

40 lines
1.2 KiB
C#

using QSB.Events;
using QSB.Utility;
using QSB.WorldSync;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Networking;
namespace QSB
{
public static class WorldRegistry
{
public static List<GeyserController> GeyserControllers = new List<GeyserController>();
public static void GenerateComponentList()
{
GeyserControllers = Resources.FindObjectsOfTypeAll<GeyserController>().ToList();
foreach (var component in GeyserControllers)
{
if (NetworkServer.active)
{
component.OnGeyserActivateEvent += () => GlobalMessenger<GeyserController, bool>.FireEvent(EventNames.QSBGeyserState, component, true);
component.OnGeyserDeactivateEvent += () => GlobalMessenger<GeyserController, bool>.FireEvent(EventNames.QSBGeyserState, component, false);
}
}
}
public static int GetObjectID(SyncObjects type, object component)
{
switch (type)
{
case SyncObjects.Geysers:
return GeyserControllers.FindIndex(x => x == component);
}
return 0;
}
}
}