quantum-space-buddies/QSB/OrbSync/OrbManager.cs
2021-04-28 16:32:01 +01:00

34 lines
1.1 KiB
C#

using OWML.Common;
using QSB.OrbSync.TransformSync;
using QSB.OrbSync.WorldObjects;
using QSB.Utility;
using QSB.WorldSync;
using QuantumUNET;
using System.Linq;
using UnityEngine;
namespace QSB.OrbSync
{
public class OrbManager : WorldObjectManager
{
protected override void RebuildWorldObjects(OWScene scene)
{
QSBWorldSync.Init<QSBOrbSlot, NomaiInterfaceSlot>();
DebugLog.DebugWrite($"Finished slot build with {QSBWorldSync.GetWorldObjects<QSBOrbSlot>().Count()} slots.", MessageType.Success);
BuildOrbs();
}
private void BuildOrbs()
{
QSBWorldSync.OldOrbList.Clear();
QSBWorldSync.OldOrbList = Resources.FindObjectsOfTypeAll<NomaiInterfaceOrb>().ToList();
if (QSBCore.IsServer)
{
NomaiOrbTransformSync.OrbTransformSyncs.ForEach(x => QNetworkServer.Destroy(x.gameObject));
NomaiOrbTransformSync.OrbTransformSyncs.Clear();
QSBWorldSync.OldOrbList.ForEach(x => QNetworkServer.Spawn(Instantiate(QSBNetworkManager.Instance.OrbPrefab)));
}
DebugLog.DebugWrite($"Finished orb build with {QSBWorldSync.OldOrbList.Count} orbs.", MessageType.Success);
}
}
}