コード例 #1
0
        /// <summary>
        /// Refresh docking node data, including selecting the "reference"
        /// docking node (for docking node control).
        /// </summary>
        private void FetchDockingNodeData()
        {
            mainDockingNode      = null;
            mainDockingNodeState = DockingNodeState.UNKNOWN;

            Part referencePart = vessel.GetReferenceTransformPart();

            if (referencePart != null)
            {
                ModuleDockingNode node = referencePart.FindModuleImplementing <ModuleDockingNode>();
                if (node != null)
                {
                    // The current reference part is a docking node, so we
                    // choose it.
                    mainDockingNode = node;
                }
            }

            if (mainDockingNode == null)
            {
                uint launchId;
                Part currentPart = JUtil.DeduceCurrentPart(vessel);
                if (currentPart == null)
                {
                    launchId = 0u;
                }
                else
                {
                    launchId = currentPart.launchID;
                }

                for (int i = 0; i < vessel.parts.Count; ++i)
                {
                    if (vessel.parts[i].launchID == launchId)
                    {
                        ModuleDockingNode node = vessel.parts[i].FindModuleImplementing <ModuleDockingNode>();
                        if (node != null)
                        {
                            // We found a docking node that has the same launch
                            // ID as the current IVA part, so we consider it our
                            // main docking node.
                            mainDockingNode = node;
                            break;
                        }
                    }
                }
            }

            mainDockingNodeState = GetNodeState(mainDockingNode);
        }