quantum-space-buddies/QSB/QuantumSync/QuantumManager.cs

35 lines
1.2 KiB
C#
Raw Normal View History

using QSB.QuantumSync.WorldObjects;
using QSB.WorldSync;
2020-12-22 21:39:53 +00:00
using System.Collections.Generic;
using UnityEngine;
namespace QSB.QuantumSync
{
internal class QuantumManager : MonoBehaviour
{
public static QuantumManager Instance { get; private set; }
private List<SocketedQuantumObject> _socketedQuantumObjects;
2020-12-23 22:43:05 +00:00
private List<MultiStateQuantumObject> _multiStateQuantumObjects;
2020-12-22 21:39:53 +00:00
private List<QuantumSocket> _quantumSockets;
public void Awake()
{
Instance = this;
QSBSceneManager.OnSceneLoaded += OnSceneLoaded;
}
2020-12-23 22:43:05 +00:00
public void OnDestroy() => QSBSceneManager.OnSceneLoaded -= OnSceneLoaded;
2020-12-22 21:39:53 +00:00
private void OnSceneLoaded(OWScene scene, bool isInUniverse)
{
_socketedQuantumObjects = QSBWorldSync.Init<QSBSocketedQuantumObject, SocketedQuantumObject>();
_multiStateQuantumObjects = QSBWorldSync.Init<QSBMultiStateQuantumObject, MultiStateQuantumObject>();
2020-12-24 15:57:25 +00:00
_quantumSockets = QSBWorldSync.Init<QSBQuantumSocket, QuantumSocket>();
2020-12-22 21:39:53 +00:00
}
public int GetId(SocketedQuantumObject obj) => _socketedQuantumObjects.IndexOf(obj);
2020-12-23 22:43:05 +00:00
public int GetId(MultiStateQuantumObject obj) => _multiStateQuantumObjects.IndexOf(obj);
2020-12-22 21:39:53 +00:00
public int GetId(QuantumSocket obj) => _quantumSockets.IndexOf(obj);
}
2020-12-23 10:43:13 +00:00
}