private void UpdateShipConstruct()
        {
            if (null != _vessel)
            {
                _vessel.Clear();
                _vessel = null;
            }

            if (EditorLogic.RootPart == null)
            {
                return;
            }

            try
            {
                // Build new vessel information
                _vessel = new CLSVessel();
                _vessel.Populate(EditorLogic.RootPart);

                // Recoupler support
                for (int i = requestedConnections.Count - 1; i >= 0; i--)
                {
                    ConnectPair connectPair = requestedConnections[i];
                    if (connectPair.part1.vessel != connectPair.part2.vessel)
                    {
                        requestedConnections.Remove(connectPair);
                    }
                    _vessel.MergeSpaces(connectPair.part1, connectPair.part2);
                }
            }
            catch (Exception ex)
            {
                Log.error(ex, "rebuild Vessel Error");
            }
        }
Ejemplo n.º 2
0
        private void RebuildCLSVessel()
        {
            dirty = false;

            if (null != _clsVessel)
            {
                _clsVessel.Clear();
                _clsVessel = null;
            }

            if (vessel.rootPart == null)
            {
                return;
            }

            try
            {
                // Build new vessel information
                _clsVessel = new CLSVessel();
                _clsVessel.Populate(vessel.rootPart);

                // Recoupler support
                for (int i = CLSAddon.Instance.requestedConnections.Count - 1; i >= 0; i--)
                {
                    CLSAddon.ConnectPair connectPair = CLSAddon.Instance.requestedConnections[i];
                    if (connectPair.part1.vessel != connectPair.part2.vessel)
                    {
                        CLSAddon.Instance.requestedConnections.Remove(connectPair);
                    }
                    _clsVessel.MergeSpaces(connectPair.part1, connectPair.part2);
                }
            }
            catch (Exception ex)
            {
                Debug.Log($"CLS rebuild Vessel Error:  { ex}");
            }
        }