using QSB.WorldSync; using System.Collections.Generic; using System.Linq; using UnityEngine; namespace QSB.QuantumSync { internal class QuantumManager : MonoBehaviour { public static QuantumManager Instance { get; private set; } private List _socketedQuantumObjects; private List _quantumSockets; public void Awake() { Instance = this; QSBSceneManager.OnSceneLoaded += OnSceneLoaded; } private void OnSceneLoaded(OWScene scene, bool isInUniverse) { _socketedQuantumObjects = Resources.FindObjectsOfTypeAll().ToList(); for (var id = 0; id < _socketedQuantumObjects.Count; id++) { var qsbSocketQuantumObj = QSBWorldSync.GetWorldObject(id) ?? new QSBSocketedQuantumObject(); qsbSocketQuantumObj.Init(_socketedQuantumObjects[id], id); QSBWorldSync.AddWorldObject(qsbSocketQuantumObj); } _quantumSockets = Resources.FindObjectsOfTypeAll().ToList(); for (var id = 0; id < _quantumSockets.Count; id++) { var qsbQuantumSocket = QSBWorldSync.GetWorldObject(id) ?? new QSBQuantumSocket(); qsbQuantumSocket.Init(_quantumSockets[id], id); QSBWorldSync.AddWorldObject(qsbQuantumSocket); } } public int GetId(SocketedQuantumObject obj) => _socketedQuantumObjects.IndexOf(obj); public int GetId(QuantumSocket obj) => _quantumSockets.IndexOf(obj); } }