quantum-space-buddies/QSB/OrbSync/OrbManager.cs

38 lines
1.1 KiB
C#
Raw Normal View History

using OWML.Common;
2021-04-28 09:02:16 +00:00
using QSB.OrbSync.TransformSync;
using QSB.OrbSync.WorldObjects;
using QSB.Utility;
2020-09-29 20:34:46 +00:00
using QSB.WorldSync;
2020-12-04 22:15:41 +00:00
using QuantumUNET;
2020-09-29 20:34:46 +00:00
using System.Linq;
using UnityEngine;
namespace QSB.OrbSync
{
2021-03-23 13:18:29 +00:00
public class OrbManager : WorldObjectManager
2020-12-02 21:29:53 +00:00
{
2021-03-23 13:18:29 +00:00
protected override void RebuildWorldObjects(OWScene scene)
2020-12-02 21:29:53 +00:00
{
2020-12-23 22:43:05 +00:00
QSBWorldSync.Init<QSBOrbSlot, NomaiInterfaceSlot>();
2021-02-28 15:06:11 +00:00
DebugLog.DebugWrite($"Finished slot build with {QSBWorldSync.GetWorldObjects<QSBOrbSlot>().Count()} slots.", MessageType.Success);
2021-03-23 13:18:29 +00:00
BuildOrbs();
2020-12-02 21:29:53 +00:00
}
2020-09-29 20:34:46 +00:00
2021-03-23 13:18:29 +00:00
private void BuildOrbs()
2020-12-02 21:29:53 +00:00
{
2020-12-11 13:14:58 +00:00
QSBWorldSync.OldOrbList.Clear();
QSBWorldSync.OldOrbList = Resources.FindObjectsOfTypeAll<NomaiInterfaceOrb>().ToList();
2021-08-08 18:53:55 +00:00
if (QSBCore.IsHost)
2020-12-02 21:29:53 +00:00
{
2021-04-28 15:32:01 +00:00
NomaiOrbTransformSync.OrbTransformSyncs.ForEach(x => QNetworkServer.Destroy(x.gameObject));
NomaiOrbTransformSync.OrbTransformSyncs.Clear();
2021-08-19 15:37:29 +00:00
foreach (var orb in QSBWorldSync.OldOrbList)
{
Instantiate(QSBNetworkManager.Instance.OrbPrefab).SpawnWithServerAuthority();
}
2020-12-02 21:29:53 +00:00
}
2021-06-18 21:38:32 +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 20:34:46 +00:00
}