示例#1
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);
            }
        }
示例#2
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";
        }