using OWML.Common; using QSB.ShipSync.TransformSync; using QSB.Utility; using QSB.WorldSync; using QuantumUNET; using System; using System.Linq; using UnityEngine; namespace QSB.ShipSync { internal class ShipManager : WorldObjectManager { public static ShipManager Instance; public InteractZone HatchInteractZone; public HatchController HatchController; public ShipTractorBeamSwitch ShipTractorBeam; public ShipCockpitController CockpitController; public bool HasAuthority => ShipTransformSync.LocalInstance.HasAuthority; public uint CurrentFlyer { get => _currentFlyer; set { if (_currentFlyer != uint.MaxValue && value != uint.MaxValue) { DebugLog.ToConsole($"Warning - Trying to set current flyer while someone is still flying? Current:{_currentFlyer}, New:{value}", MessageType.Warning); } _currentFlyer = value; } } private uint _currentFlyer = uint.MaxValue; public void Start() => Instance = this; protected override void RebuildWorldObjects(OWScene scene) { var shipTransform = GameObject.Find("Ship_Body"); HatchController = shipTransform.GetComponentInChildren(); HatchInteractZone = HatchController.GetComponent(); ShipTractorBeam = Resources.FindObjectsOfTypeAll().First(); CockpitController = Resources.FindObjectsOfTypeAll().First(); var sphereShape = HatchController.GetComponent(); sphereShape.radius = 2.5f; sphereShape.center = new Vector3(0, 0, 1); if (QSBCore.IsServer) { if (ShipTransformSync.LocalInstance != null) { QNetworkServer.Destroy(ShipTransformSync.LocalInstance.gameObject); } QNetworkServer.Spawn(Instantiate(QSBNetworkManager.Instance.ShipPrefab)); } var shipComponents = Resources.FindObjectsOfTypeAll(); var electricalComponents = Resources.FindObjectsOfTypeAll(); var electricalSystems = Resources.FindObjectsOfTypeAll(); var shipModules = Resources.FindObjectsOfTypeAll(); var shipHulls = Resources.FindObjectsOfTypeAll(); DebugLog.DebugWrite("ShipComponents : "); PrintAll(shipComponents); DebugLog.DebugWrite("Electrical Components : "); PrintAll(electricalComponents); DebugLog.DebugWrite("Electrical Systems : "); PrintAll(electricalSystems); DebugLog.DebugWrite("Ship Modules : "); PrintAll(shipModules); DebugLog.DebugWrite("Ship Hulls : "); PrintAll(shipHulls); } private void PrintAll(Array array) { foreach (var item in array) { DebugLog.DebugWrite($" - {(item as MonoBehaviour).name}"); } } } }