2020-10-23 19:06:11 +01:00
|
|
|
|
using OWML.Common;
|
|
|
|
|
using QSB.Utility;
|
2020-09-29 21:34:46 +01:00
|
|
|
|
using QSB.WorldSync;
|
2020-12-04 22:15:41 +00:00
|
|
|
|
using QuantumUNET;
|
2020-09-29 21:34:46 +01:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace QSB.OrbSync
|
|
|
|
|
{
|
2020-12-02 21:29:53 +00:00
|
|
|
|
public class OrbManager : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public static OrbManager Instance { get; private set; }
|
2020-09-29 21:34:46 +01:00
|
|
|
|
|
2020-12-18 20:28:22 +00:00
|
|
|
|
private void Awake() => Instance = this;
|
2020-09-29 21:34:46 +01:00
|
|
|
|
|
2020-12-02 21:29:53 +00:00
|
|
|
|
private void BuildOrbSlots()
|
|
|
|
|
{
|
2020-12-23 22:43:05 +00:00
|
|
|
|
QSBWorldSync.RemoveWorldObjects<QSBOrbSlot, NomaiInterfaceSlot>();
|
|
|
|
|
QSBWorldSync.Init<QSBOrbSlot, NomaiInterfaceSlot>();
|
2020-12-02 21:29:53 +00:00
|
|
|
|
}
|
2020-09-29 21:34:46 +01:00
|
|
|
|
|
2020-12-02 21:29:53 +00:00
|
|
|
|
public void BuildOrbs()
|
|
|
|
|
{
|
2020-12-11 13:14:58 +00:00
|
|
|
|
QSBWorldSync.OldOrbList.Clear();
|
|
|
|
|
QSBWorldSync.OldOrbList = Resources.FindObjectsOfTypeAll<NomaiInterfaceOrb>().ToList();
|
2020-12-23 12:58:45 +00:00
|
|
|
|
if (QNetworkServer.active)
|
2020-12-02 21:29:53 +00:00
|
|
|
|
{
|
2020-12-23 12:58:45 +00:00
|
|
|
|
QSBWorldSync.OrbSyncList.ForEach(x => QNetworkServer.Destroy(x.gameObject));
|
2020-12-11 13:14:58 +00:00
|
|
|
|
QSBWorldSync.OrbSyncList.Clear();
|
2020-12-23 12:58:45 +00:00
|
|
|
|
QSBWorldSync.OldOrbList.ForEach(x => QNetworkServer.Spawn(Instantiate(QSBNetworkManager.Instance.OrbPrefab)));
|
2020-12-02 21:29:53 +00:00
|
|
|
|
}
|
2020-12-11 13:14:58 +00:00
|
|
|
|
DebugLog.DebugWrite($"Finished orb build with {QSBWorldSync.OldOrbList.Count} orbs.", MessageType.Success);
|
2020-12-02 21:29:53 +00:00
|
|
|
|
}
|
2020-09-29 21:34:46 +01:00
|
|
|
|
|
2020-12-14 16:24:52 +00:00
|
|
|
|
public void QueueBuildSlots() => QSBCore.Helper.Events.Unity.RunWhen(() => QSBCore.HasWokenUp, BuildOrbSlots);
|
2020-12-23 12:58:45 +00:00
|
|
|
|
public void QueueBuildOrbs() => QSBCore.Helper.Events.Unity.RunWhen(() => QNetworkServer.active, BuildOrbs);
|
2020-12-02 21:29:53 +00:00
|
|
|
|
}
|
2020-09-29 21:34:46 +01:00
|
|
|
|
}
|