예제 #1
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, using the node position as specified by the nose module's fairing offset parameter
            // ModelModule<ModuleROTank> nodeModule = getUpperFairingModelModule();
            // Vector3 pos = new Vector3(0, nodeModule.fairingBottom, 0);
            float theCoreNode = 0.0f;

            theCoreNode = coreModule.moduleHeight * 0.5f;
            Vector3 pos = new Vector3(0, theCoreNode, 0);

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

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

            //update the nose interstage node, using the node position as specified by the nose module's fairing offset parameter
            // nodeModule = getLowerFairingModelModule();
            theCoreNode = -theCoreNode;
            pos         = new Vector3(0, theCoreNode, 0);
            ModuleROTSelectableNodes.updateNodePosition(part, mountInterstageNode, pos);
            AttachNode mountInterstage = part.FindAttachNode(mountInterstageNode);

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

            //update surface attach node position, part position, and any surface attached children
            //TODO -- how to determine how far to offset/move surface attached children?
            AttachNode surfaceNode = part.srfAttachNode;

            if (surfaceNode != null)
            {
                coreModule.updateSurfaceAttachNode(surfaceNode, prevDiameter, userInput);
            }
        }
예제 #2
0
        public void toggleNode()
        {
            AttachNode node = part.FindAttachNode(nodeName);

            ROTLog.debug("toggleNode() node: " + node);
            if (node == null)
            {
                currentlyEnabled = true;
                ROTAttachNodeUtils.createAttachNode(part, nodeName, nodeDefaultPosition, nodeDefaultOrientation, 2);
            }
            else if (node.attachedPart == null)
            {
                currentlyEnabled = false;
                ROTAttachNodeUtils.destroyAttachNode(part, node);
            }
        }
예제 #3
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)
                    {
                        ROTAttachNodeUtils.createAttachNode(part, nodeName, nodeDefaultPosition, nodeDefaultOrientation, 2);
                    }
                    else if (!currentlyEnabled && node != null && node.attachedPart == null)
                    {
                        ROTAttachNodeUtils.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;
                        ROTAttachNodeUtils.createAttachNode(part, nodeName, nodeDefaultPosition, nodeDefaultOrientation, 2);
                    }
                    else if (!currentlyEnabled && node != null && node.attachedPart == null)
                    {
                        currentlyEnabled = false;
                        ROTAttachNodeUtils.destroyAttachNode(part, node);
                    }
                }
            }

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