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

45 lines
1.2 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;
2021-10-21 16:21:54 +00:00
using System.Collections.Generic;
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-10-21 16:21:54 +00:00
private List<GameObject> _orbs = new List<GameObject>();
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();
2021-10-25 15:31:15 +00:00
NomaiOrbTransformSync.OrbTransformSyncs.Clear();
QSBWorldSync.OldOrbList = QSBWorldSync.GetUnityObjects<NomaiInterfaceOrb>().ToList();
2021-08-08 18:53:55 +00:00
if (QSBCore.IsHost)
2020-12-02 21:29:53 +00:00
{
2021-10-21 16:21:54 +00:00
_orbs.ForEach(x => QNetworkServer.Destroy(x));
_orbs.Clear();
2021-08-19 15:37:29 +00:00
foreach (var orb in QSBWorldSync.OldOrbList)
{
2021-10-21 16:21:54 +00:00
var newOrb = Instantiate(QSBNetworkManager.Instance.OrbPrefab);
newOrb.SpawnWithServerAuthority();
2021-10-25 09:42:25 +00:00
_orbs.Add(newOrb);
2021-08-19 15:37:29 +00:00
}
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
}
}
}