Пример #1
0
 public void UpdateFairingNodes()
 {
     ROLLog.log($"UpdateFairingNodes()");
     foreach (ROLNodeFairingData data in fairingParts)
     {
         ROLLog.log($"fairingName: {fairingName}");
         // Update the Nose Interstage Node
         if (fairingName == "Top Fairing")
         {
             Vector3 pos = new Vector3(0, data.topY, 0);
             ROLLog.log($"data.topY: {data.topY}");
             ROLSelectableNodes.updateNodePosition(part, noseFairingNode, pos);
             if (part.FindAttachNode(noseFairingNode) is AttachNode noseInterstage)
             {
                 ROLAttachNodeUtils.updateAttachNodePosition(part, noseInterstage, pos, Vector3.up, true, 2);
             }
         }
         // Update the Mount Interstage Node
         if (fairingName == "Bottom Fairing")
         {
             Vector3 pos = new Vector3(0, data.bottomY, 0);
             ROLSelectableNodes.updateNodePosition(part, data.mountNode, pos);
             if (part.FindAttachNode(mountFairingNode) is AttachNode mountInterstage)
             {
                 ROLAttachNodeUtils.updateAttachNodePosition(part, mountInterstage, pos, Vector3.down, true, 2);
             }
         }
     }
 }
Пример #2
0
        public void toggleNode()
        {
            AttachNode node = part.FindAttachNode(nodeName);

            ROLLog.debug("toggleNode() node: " + node);
            if (node == null)
            {
                currentlyEnabled = true;
                ROLAttachNodeUtils.createAttachNode(part, nodeName, nodeDefaultPosition, nodeDefaultOrientation, 2);
            }
            else if (node.attachedPart == null)
            {
                currentlyEnabled = false;
                ROLAttachNodeUtils.destroyAttachNode(part, node);
            }
        }
Пример #3
0
        /// <summary>
        /// Update the attach nodes for the current model-module configuration.
        /// The 'nose' module is responsible for updating of upper attach nodes, while the 'mount' module is responsible for lower attach nodes.
        /// Also includes updating of 'interstage' nose/mount attach nodes.
        /// Also includes updating of surface-attach node position.
        /// Also includes updating of any parts that are surface attached to this part.
        /// </summary>
        /// <param name="userInput"></param>
        public void updateAttachNodes(bool userInput)
        {
            //update the standard top and bottom attach nodes, using the node position(s) defined in the nose and mount modules
            noseModule.updateAttachNodeTop("top", userInput);
            mountModule.updateAttachNodeBottom("bottom", userInput);

            //update the model-module specific attach nodes, using the per-module node definitions from the part
            noseModule.updateAttachNodeBody(noseNodeNames, userInput);
            coreModule.updateAttachNodeBody(coreNodeNames, userInput);
            mountModule.updateAttachNodeBody(mountNodeNames, userInput);

            // Update the Nose Interstage Node
            float   y        = noseModule.modulePosition + noseModule.moduleVerticalScale;
            int     nodeSize = Mathf.RoundToInt(coreModule.moduleDiameter) + 1;
            Vector3 pos      = new Vector3(0, y, 0);

            ROLSelectableNodes.updateNodePosition(part, noseInterstageNode, pos);
            AttachNode noseInterstage = part.FindAttachNode(noseInterstageNode);

            if (noseInterstage != null)
            {
                ROLAttachNodeUtils.updateAttachNodePosition(part, noseInterstage, pos, Vector3.up, userInput, nodeSize);
            }

            // Update the Mount Interstage Node
            y        = mountModule.modulePosition + mountModule.moduleVerticalScale;
            nodeSize = Mathf.RoundToInt(coreModule.moduleDiameter) + 1;
            pos      = new Vector3(0, y, 0);
            ROLSelectableNodes.updateNodePosition(part, mountInterstageNode, pos);
            AttachNode mountInterstage = part.FindAttachNode(mountInterstageNode);

            if (mountInterstage != null)
            {
                ROLAttachNodeUtils.updateAttachNodePosition(part, mountInterstage, pos, Vector3.down, userInput, nodeSize);
            }


            //update surface attach node position, part position, and any surface attached children
            AttachNode surfaceNode = part.srfAttachNode;

            if (surfaceNode != null)
            {
                coreModule.updateSurfaceAttachNode(surfaceNode, prevDiameter, userInput);
            }
        }
Пример #4
0
        public override void OnStart(PartModule.StartState state)
        {
            base.OnStart(state);

            tEvent = Events["toggleNodeEvent"];

            if (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight)
            {
                if (!initialized)
                {
                    currentlyEnabled = startsEnabled;
                    initialized      = true;
                    AttachNode node = part.FindAttachNode(nodeName);
                    if (currentlyEnabled && node == null)
                    {
                        ROLAttachNodeUtils.createAttachNode(part, nodeName, nodeDefaultPosition, nodeDefaultOrientation, 2);
                    }
                    else if (!currentlyEnabled && node != null && node.attachedPart == null)
                    {
                        ROLAttachNodeUtils.destroyAttachNode(part, node);
                    }
                    else if (!currentlyEnabled && node != null && node.attachedPart != null)//error, should never occur if things were handled properly
                    {
                        currentlyEnabled = true;
                    }
                }
                else
                {
                    AttachNode node = part.FindAttachNode(nodeName);
                    if (currentlyEnabled && node == null)
                    {
                        currentlyEnabled = true;
                        ROLAttachNodeUtils.createAttachNode(part, nodeName, nodeDefaultPosition, nodeDefaultOrientation, 2);
                    }
                    else if (!currentlyEnabled && node != null && node.attachedPart == null)
                    {
                        currentlyEnabled = false;
                        ROLAttachNodeUtils.destroyAttachNode(part, node);
                    }
                }
            }

            tEvent.guiName = currentlyEnabled ? nodeName + ": Enabled" : nodeName + ": Disabled";
        }