protected internal bool RequestRemoveConnection(Part part1, Part part2, bool rebuildVessel = true)
        {
            bool        modified   = false;
            ConnectPair CPtoRemove = new ConnectPair(part1, part2);

            if (requestedConnections.Contains(CPtoRemove))
            {
                requestedConnections.Remove(CPtoRemove);
                modified = true;
            }
            else if (requestedConnections.Contains(CPtoRemove.Other()))
            {
                requestedConnections.Remove(CPtoRemove.Other());
                modified = true;
            }
            if (modified && rebuildVessel)
            {
                if (HighLogic.LoadedSceneIsEditor)
                {
                    UpdateShipConstruct();
                }
                else
                {
                    part1.vessel.GetComponent <CLSVesselModule>().MarkDirty();
                }
            }
            return(modified);
        }
        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");
            }
        }
        protected internal bool RequestAddConnection(Part part1, Part part2, bool rebuildVessel = true)
        {
            ConnectPair connectPair = new ConnectPair(part1, part2);

            if (requestedConnections.Contains(connectPair) || requestedConnections.Contains(connectPair.Other()))
            {
                return(false);
            }
            requestedConnections.Add(connectPair);
            if (rebuildVessel)
            {
                if (HighLogic.LoadedSceneIsEditor)
                {
                    UpdateShipConstruct();
                }
                else
                {
                    part1.vessel.GetComponent <CLSVesselModule>().MarkDirty();
                }
            }
            return(true);
        }
 public static ConnectPair Other(ConnectPair connectPair)
 {
     return(new ConnectPair(connectPair.part2, connectPair.part1));
 }