当前位置: 首页>>代码示例>>C#>>正文


C# Part.findAttachNode方法代码示例

本文整理汇总了C#中Part.findAttachNode方法的典型用法代码示例。如果您正苦于以下问题:C# Part.findAttachNode方法的具体用法?C# Part.findAttachNode怎么用?C# Part.findAttachNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Part的用法示例。


在下文中一共展示了Part.findAttachNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: addPart

        public void addPart(Part p, Part prevPart)
        {
            if (p==null || hash.Contains(p)) return;
            hash.Add(p);

            if (p.GetComponent<LaunchClamp>()!=null) return;
            if (p==prevPart.parent && prevPart.srfAttachNode.attachedPart==p) return;

            // check for another fairing base
            if (p.GetComponent<ProceduralFairingBase>()!=null
              && p.GetComponent<ProceduralFairingAdapter>()==null)
            {
              AttachNode node=p.findAttachNode("top");
              if (node!=null && node.attachedPart==prevPart)
              {
            // reversed base - potential inline fairing target
            if (nestedBases<=0) { targets.Add(p); return; }
            else --nestedBases;
              }
              else ++nestedBases;
            }

            payload.Add(p);
        }
开发者ID:ItMustBeACamel,项目名称:ProceduralFairings,代码行数:24,代码来源:PayloadScan.cs

示例2: canSwitchTo

 /// <summary>
 /// Determine if the number of parts attached to the part will prevent this mount from being applied;
 /// if any node that has a part attached would be deleted, return false
 /// </summary>
 /// <param name="part"></param>
 /// <param name="nodeNames"></param>
 /// <returns></returns>
 public bool canSwitchTo(Part part, String[] nodeNames)
 {
     AttachNode node;
     int len = nodeNames.Length;
     for (int i = 0; i < len; i++)
     {
         if (i < nodePositions.Count) { continue; }//don't care about those nodes, they will be present
         node = part.findAttachNode(nodeNames[i]);//this is a node that would be disabled
         if (node == null) { continue; }//already disabled, and that is just fine
         else if (node.attachedPart != null) { return false; }//drat, this node is scheduled for deletion, but has a part attached; cannot delete it, so cannot switch to this mount
     }
     return true;//and if all node checks go okay, return true by default...
 }
开发者ID:SixDasher,项目名称:SSTULabs,代码行数:20,代码来源:SSTUModularFuelTank.cs

示例3: updateAttachNodes

        public void updateAttachNodes(Part part, String[] nodeNames, bool userInput)
        {
            Vector3 basePos = new Vector3(0, currentVerticalPosition, 0);
            AttachNode node = null;
            int len = nodeNames.Length;

            Vector3 pos = Vector3.zero;
            Vector3 orient = Vector3.up;
            int size = 2;
            for (int i = 0; i < len; i++)
            {
                node = part.findAttachNode(nodeNames[i]);                
                if (i < mountDefinition.nodePositions.Count)
                {
                    size = nodePositions[i].size;
                    pos = nodePositions[i].position * currentHeightScale;
                    pos.y += currentVerticalPosition;
                    orient = nodePositions[i].orientation;
                    if (node == null)//create it
                    {
                        SSTUUtils.createAttachNode(part, nodeNames[i], pos, orient, size);
                    }
                    else//update its position
                    {
                        SSTUUtils.updateAttachNodePosition(part, node, pos, orient, userInput);
                    }
                }                
                else//extra node, destroy
                {
                    if (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight)
                    {
                        SSTUUtils.destroyAttachNode(part, node);
                    }
                }
            }
        }
开发者ID:SixDasher,项目名称:SSTULabs,代码行数:36,代码来源:SSTUModularFuelTank.cs

示例4: CouplePart

        public static void CouplePart(Part srcPart, Part tgtPart, string srcAttachNodeID = null, AttachNode tgtAttachNode = null)
        {
            // Node links
            if (srcAttachNodeID != null)
            {
                if (srcAttachNodeID == "srfAttach")
                {
                    KIS_Shared.DebugLog("Attach type : " + srcPart.srfAttachNode.nodeType + " | ID : " + srcPart.srfAttachNode.id);
                    srcPart.attachMode = AttachModes.SRF_ATTACH;
                    srcPart.srfAttachNode.attachedPart = tgtPart;
                }
                else
                {
                    AttachNode srcAttachNode = srcPart.findAttachNode(srcAttachNodeID);
                    if (srcAttachNode != null)
                    {
                        KIS_Shared.DebugLog("Attach type : " + srcPart.srfAttachNode.nodeType + " | ID : " + srcAttachNode.id);
                        srcPart.attachMode = AttachModes.STACK;
                        srcAttachNode.attachedPart = tgtPart;
                        if (tgtAttachNode != null)
                        {
                            tgtAttachNode.attachedPart = srcPart;
                        }
                    }
                    else
                    {
                        KIS_Shared.DebugError("Source attach node not found !");
                    }
                }
            }
            else
            {
                KIS_Shared.DebugWarning("Missing source attach node !");
            }

            srcPart.Couple(tgtPart);
        }
开发者ID:Amorymeltzer,项目名称:KIS,代码行数:37,代码来源:KIS_Shared.cs

示例5: StartPointer

 public static void StartPointer(Part partToMoveAndAttach, OnPointerClick pClick, OnPointerState pState, Transform from = null)
 {
     if (!running)
     {
         KIS_Shared.DebugLog("StartPointer(pointer)");
         customRot = Vector3.zero;
         aboveDistance = 0;
         partToAttach = partToMoveAndAttach;
         sourceTransform = from;
         running = true;
         SendPointerClick = pClick;
         SendPointerState = pState;
         // Set possible attach nodes
         attachNodes.Clear();
         if (partToAttach.attachRules.srfAttach)
         {
             KIS_Shared.DebugLog("Surface node set to default");
             attachNodes.Add(partToMoveAndAttach.srfAttachNode);
         }
         else if (partToAttach.attachNodes.Count == 0)
         {
             KIS_Shared.DebugLog("No attach nodes found, surface node set to default");
             attachNodes.Add(partToMoveAndAttach.srfAttachNode);
         }
         else if (partToAttach.findAttachNode("bottom") != null)
         {
             KIS_Shared.DebugLog("Bottom node set to default");
             attachNodes.Add(partToAttach.findAttachNode("bottom"));
         }
         else
         {
             KIS_Shared.DebugLog(partToAttach.attachNodes[0].id + " node set to default");
             attachNodes.Add(partToAttach.attachNodes[0]);
         }
         foreach (AttachNode an in partToMoveAndAttach.attachNodes)
         {
             if (!attachNodes.Contains(an))
             {
                 attachNodes.Add(an);
                 KIS_Shared.DebugLog("Node : " + an.id + " added");
             }
         }
         attachNodeIndex = 0;
         InputLockManager.SetControlLock(ControlTypes.ALLBUTCAMERAS, "KISpointer");
     }
 }
开发者ID:khr15714n,项目名称:KIS,代码行数:46,代码来源:KISAddonPointer.cs

示例6: UpdateScale

        //Modifies the size of a part
        private void UpdateScale(Part part, RealChuteModule module)
        {
            if (sizes.Count <= 1 || !moduleNodes.Keys.Contains(this.part.partInfo.name)) { return; }
            SizeNode size = sizes[this.size], lastSize = sizes[this.lastSize];
            part.transform.GetChild(0).localScale = Vector3.Scale(originalSize, size.size);
            module.caseMass = size.caseMass;
            if ((HighLogic.LoadedSceneIsEditor && part == EditorLogic.SortedShipList[0]) || (HighLogic.LoadedSceneIsFlight  && this.vessel.rootPart == part))
            {
                if (part.findAttachNode("top") != null)
                {
                    AttachNode topNode = part.findAttachNode("top");
                    topNode.position = size.topNode;
                    topNode.size = size.topNodeSize;
                    if (topNode.attachedPart != null)
                    {
                        float topDifference = size.topNode.y - lastSize.topNode.y;
                        topNode.attachedPart.transform.Translate(0, topDifference, 0, part.transform);
                        if (part.findAttachNode("top").attachedPart.GetAllChildren().Count > 0)
                        {
                            topNode.attachedPart.GetAllChildren().ForEach(p => p.transform.Translate(0, topDifference, 0, part.transform));
                        }
                    }
                }
                if (part.findAttachNode("bottom") != null)
                {
                    AttachNode bottomNode = part.findAttachNode("bottom");
                    bottomNode.position = size.bottomNode;
                    bottomNode.size = size.bottomNodeSize;
                    if (bottomNode.attachedPart != null)
                    {
                        float bottomDifference = size.bottomNode.y - lastSize.bottomNode.y;
                        bottomNode.attachedPart.transform.Translate(0, bottomDifference, 0, part.transform);
                        if (part.findAttachNode("bottom").attachedPart.GetAllChildren().Count > 0)
                        {
                            bottomNode.attachedPart.GetAllChildren().ForEach(p => p.transform.Translate(0, bottomDifference, 0, part.transform));
                        }
                    }
                }
            }
            else if (part.findAttachNode("bottom") != null && part.findAttachNode("bottom").attachedPart != null && part.parent != null &&  part.findAttachNode("bottom").attachedPart == part.parent)
            {
                AttachNode bottomNode = part.findAttachNode("bottom");
                bottomNode.position = size.bottomNode;
                bottomNode.size = size.bottomNodeSize;
                float bottomDifference = size.bottomNode.y - lastSize.bottomNode.y;
                part.transform.Translate(0, -bottomDifference, 0, part.transform);
                if (part.findAttachNode("top") != null)
                {
                    AttachNode topNode = part.findAttachNode("top");
                    topNode.position = size.topNode;
                    topNode.size = size.topNodeSize;
                    float topDifference = size.topNode.y - lastSize.topNode.y;
                    if (part.GetAllChildren().Count > 0) { part.GetAllChildren().ForEach(p => p.transform.Translate(0, -(bottomDifference - topDifference), 0, part.transform)); }
                }
            }
            else if (part.findAttachNode("top") != null && part.findAttachNode("top").attachedPart != null && part.parent != null && part.findAttachNode("top").attachedPart == part.parent)
            {
                AttachNode topNode = part.findAttachNode("top");
                topNode.position = size.topNode;
                topNode.size = size.topNodeSize;
                float topDifference = size.topNode.y - lastSize.topNode.y;
                part.transform.Translate(0, -topDifference, 0, part.transform);
                if (part.findAttachNode("bottom") != null)
                {
                    AttachNode bottomNode = part.findAttachNode("bottom");
                    bottomNode.position = size.bottomNode;
                    bottomNode.size = size.bottomNodeSize;
                    float bottomDifference = size.bottomNode.y - lastSize.bottomNode.y;
                    if (part.GetAllChildren().Count > 0) { part.GetAllChildren().ForEach(p => p.transform.Translate(0, -(topDifference - bottomDifference), 0, part.transform)); }
                }
            }

            float scaleX = part.transform.GetChild(0).localScale.x / Vector3.Scale(originalSize, lastSize.size).x;
            float scaleZ = part.transform.GetChild(0).localScale.z / Vector3.Scale(originalSize, lastSize.size).z;
            Vector3 chute = main.chute.forcePosition - part.transform.position;
            main.chute.parachute.transform.Translate(chute.x * (scaleX - 1), 0, chute.z * (scaleZ - 1), part.transform);
            if (secondaryChute)
            {
                Vector3 secChute = secondary.chute.forcePosition - part.transform.position;
                secondary.chute.parachute.transform.Translate(secChute.x * (scaleX - 1), 0, secChute.z * (scaleZ - 1), part.transform);
            }

            if (part.children.Count(p => p.attachMode == AttachModes.SRF_ATTACH) > 0)
            {
                List<Part> surfaceAttached = new List<Part>(part.children.Where(p => p.attachMode == AttachModes.SRF_ATTACH));
                surfaceAttached.Where(p => p.GetAllChildren().Count > 0).ToList().ForEach(p => surfaceAttached.AddRange(p.GetAllChildren()));
                foreach (Part p in surfaceAttached)
                {
                    Vector3 v = p.transform.position - part.transform.position;
                    p.transform.Translate(v.x * (scaleX - 1), 0, v.z * (scaleZ - 1), part.transform);
                }
            }
            this.lastSize = this.size;
        }
开发者ID:vosechu,项目名称:RealChute,代码行数:95,代码来源:ProceduralChute.cs

示例7: DockingPortExplode

 private void DockingPortExplode(VesselElementViewOptions ol, VesselElementViewOption o, Part part)
 {
     MonoBehaviour.print("Exploding Docking Port: " + part.ToString());
     var module = part.Module<ModuleDockingNode>();
     if (string.IsNullOrEmpty(module.referenceAttachNode)) return;
     var an = part.findAttachNode(module.referenceAttachNode);
     if (!an.attachedPart) return;
     var distance = o.valueParam;
     Part partToBeMoved;
     if (an.attachedPart == part.parent)
     {
         distance *= -1;
         partToBeMoved = part;
     }
     else
     {
         partToBeMoved = an.attachedPart;
     }
     partToBeMoved.transform.Translate(module.nodeTransform.forward * distance, Space.World);
 }
开发者ID:EdwardWongHau,项目名称:ksp-kronalutils,代码行数:20,代码来源:VesselViewConfig.cs

示例8: AssignDecoupledInStage

        // Determine when this part will be decoupled given when its parent will be decoupled.
        // Then recurse to all of this part's children.
        public void AssignDecoupledInStage(Part p, Dictionary<Part, FuelNode> nodeLookup, int parentDecoupledInStage)
        {
            // Already processed
            if (decoupledInStage != int.MinValue)
                return;

            bool isDecoupler = false;
            decoupledInStage = parentDecoupledInStage;

            for (int i = 0; i < p.Modules.Count; i++)
            {
                PartModule m = p.Modules[i];
                
                ModuleDecouple mDecouple = m as ModuleDecouple;
                if (mDecouple != null)
                {
                    if (!mDecouple.isDecoupled && mDecouple.stagingEnabled && p.stagingOn)
                    {
                        if (mDecouple.isOmniDecoupler)
                        {
                            isDecoupler = true;
                            // We are decoupling our parent
                            // The part and its children are not part of the ship when we decouple
                            decoupledInStage = p.inverseStage;

                            // The parent should already have its info assigned at this point
                            //nodeLookup[p.parent].AssignDecoupledInStage(p.parent, nodeLookup, p.inverseStage);

                            // The part children are decoupled when we decouple
                            foreach (Part child in p.children)
                            {
                                nodeLookup[child].AssignDecoupledInStage(child, nodeLookup, p.inverseStage);
                            }
                        }
                        else
                        {
                            AttachNode attach;
                            if (mDecouple.explosiveNodeID != "srf")
                            {
                                attach = p.findAttachNode(mDecouple.explosiveNodeID);
                            }
                            else
                            {
                                attach = p.srfAttachNode;
                            }

                            if (attach != null && attach.attachedPart != null)
                            {
                                if (attach.attachedPart == p.parent)
                                {
                                    isDecoupler = true;
                                    // We are decoupling our parent
                                    // The part and its children are not part of the ship when we decouple
                                    decoupledInStage = p.inverseStage;
                                    //print("AssignDecoupledInStage ModuleDecouple          " + p.partInfo.name + "(" + p.inverseStage + ") decoupling " + attach.attachedPart + "(" + attach.attachedPart.inverseStage + "). parent " + decoupledInStage);

                                    // The parent should already have its info assigned at this point
                                    //nodeLookup[p.parent].AssignDecoupledInStage(p.parent, nodeLookup, p.inverseStage);
                                }
                                else
                                {
                                    isDecoupler = true;
                                    // We are still attached to our parent
                                    // The part and it's children are dropped when the parent is
                                    decoupledInStage = parentDecoupledInStage;

                                    //print("AssignDecoupledInStage ModuleDecouple          " + p.partInfo.name + "(" + p.inverseStage + ") decoupling " + attach.attachedPart + "(" + attach.attachedPart.inverseStage + "). not the parent " + decoupledInStage);
                                    // The part we decouple is dropped when we decouple
                                    nodeLookup[attach.attachedPart].AssignDecoupledInStage(attach.attachedPart, nodeLookup, p.inverseStage);
                                    
                                }
                            }
                        }
                        break; // Hopefully no one made part with multiple decoupler modules ?
                    }
                }
                
                ModuleAnchoredDecoupler mAnchoredDecoupler = m as ModuleAnchoredDecoupler;
                if (mAnchoredDecoupler != null)
                {
                    if (!mAnchoredDecoupler.isDecoupled && mAnchoredDecoupler.stagingEnabled && p.stagingOn)
                    {
                        AttachNode attach;
                        if (mAnchoredDecoupler.explosiveNodeID != "srf")
                        {
                            attach = p.findAttachNode(mAnchoredDecoupler.explosiveNodeID);
                        }
                        else
                        {
                            attach = p.srfAttachNode;
                        }
                        
                        if (attach != null && attach.attachedPart != null)
                        {
                            if (attach.attachedPart == p.parent)
                            {
                                isDecoupler = true;
                                // We are decoupling our parent
//.........这里部分代码省略.........
开发者ID:Kerbas-ad-astra,项目名称:MechJeb2,代码行数:101,代码来源:FuelFlowSimulation.cs

示例9: updateAttachNodes

        public void updateAttachNodes(Part part, String[] nodeNames, bool userInput, ModelOrientation orientation)
        {
            Vector3 basePos = new Vector3(0, currentVerticalPosition, 0);
            AttachNode node = null;
            AttachNodeBaseData data;

            int nodeCount = modelDefinition.attachNodeData.Length;
            int len = nodeNames.Length;

            Vector3 pos = Vector3.zero;
            Vector3 orient = Vector3.up;
            int size = 2;

            bool invert = (orientation == ModelOrientation.BOTTOM && modelDefinition.invertForBottom) || (orientation == ModelOrientation.TOP && modelDefinition.invertForTop);
            for (int i = 0; i < len; i++)
            {
                node = part.findAttachNode(nodeNames[i]);
                if (i < nodeCount)
                {
                    data = modelDefinition.attachNodeData[i];
                    size = data.size;
                    pos = data.position * currentHeightScale;
                    if (invert)
                    {
                        pos.y = -pos.y;
                        pos.x = -pos.x;
                    }
                    pos.y += currentVerticalPosition;
                    orient = data.orientation;
                    if (invert) { orient = -orient; }
                    if (node == null)//create it
                    {
                        SSTUAttachNodeUtils.createAttachNode(part, nodeNames[i], pos, orient, size);
                    }
                    else//update its position
                    {
                        SSTUAttachNodeUtils.updateAttachNodePosition(part, node, pos, orient, userInput);
                    }
                }
                else//extra node, destroy
                {
                    if (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight)
                    {
                        SSTUAttachNodeUtils.destroyAttachNode(part, node);
                    }
                }
            }
        }
开发者ID:Joshg213,项目名称:SSTULabs,代码行数:48,代码来源:ModelData.cs

示例10: RadialDecouplerExplode

 private void RadialDecouplerExplode(VesselElementViewOptions ol, VesselElementViewOption o, Part part)
 {
     MonoBehaviour.print("Exploding Radial Decoupler: " + part.ToString());
     var module = part.Module<ModuleAnchoredDecoupler>();
     if (module.isDecoupled) return;
     if (string.IsNullOrEmpty(module.explosiveNodeID)) return;
     var an = module.explosiveNodeID == "srf" ? part.srfAttachNode : part.findAttachNode(module.explosiveNodeID);
     if (an == null || an.attachedPart == null) return;
     var distance = o.valueParam;
     Part partToBeMoved;
     if (an.attachedPart == part.parent)
     {
         distance *= -1;
         partToBeMoved = part;
     }
     else
     {
         partToBeMoved = an.attachedPart;
     }
     partToBeMoved.transform.Translate(part.transform.right * distance, Space.World);
 }
开发者ID:EdwardWongHau,项目名称:ksp-kronalutils,代码行数:21,代码来源:VesselViewConfig.cs

示例11: UpdatePartJoint


//.........这里部分代码省略.........
            if (jointList == null)
                return;

            StringBuilder debugString = new StringBuilder();

            bool addAdditionalJointToParent = KJRJointUtils.multiPartAttachNodeReinforcement;
            //addAdditionalJointToParent &= !(p.Modules.Contains("LaunchClamp") || (p.parent.Modules.Contains("ModuleDecouple") || p.parent.Modules.Contains("ModuleAnchoredDecoupler")));
            addAdditionalJointToParent &= !(p is StrutConnector || p.Modules.Contains("CModuleStrut"));

            float partMass = p.mass + p.GetResourceMass();
            for (int i = 0; i < jointList.Count; i++)
            {
                ConfigurableJoint j = jointList[i];
                if (j == null)
                    continue;

                String jointType = j.GetType().Name;
                Rigidbody connectedBody = j.connectedBody;

                Part connectedPart = connectedBody.GetComponent<Part>() ?? p.parent;
                float parentMass = connectedPart.mass + connectedPart.GetResourceMass();

                if (partMass < KJRJointUtils.massForAdjustment || parentMass < KJRJointUtils.massForAdjustment)
                {
                    if (KJRJointUtils.debug)
                    {
                        Debug.Log("KJR: Part mass too low, skipping: " + p.partInfo.name + " (" + p.flightID + ")");
                    }

                    continue;
                }                
                
                // Check attachment nodes for better orientation data
                AttachNode attach = p.findAttachNodeByPart(p.parent);
                AttachNode p_attach = p.parent.findAttachNodeByPart(p);
                AttachNode node = attach ?? p_attach;

                if (node == null)
                {
                    // Check if it's a pair of coupled docking ports
                    var dock1 = p.Modules["ModuleDockingNode"] as ModuleDockingNode;
                    var dock2 = p.parent.Modules["ModuleDockingNode"] as ModuleDockingNode;

                    //Debug.Log(dock1 + " " + (dock1 ? ""+dock1.dockedPartUId : "?") + " " + dock2 + " " + (dock2 ? ""+dock2.dockedPartUId : "?"));

                    if (dock1 && dock2 && (dock1.dockedPartUId == p.parent.flightID || dock2.dockedPartUId == p.flightID))
                    {
                        attach = p.findAttachNode(dock1.referenceAttachNode);
                        p_attach = p.parent.findAttachNode(dock2.referenceAttachNode);
                        node = attach ?? p_attach;
                    }
                }

                // If still no node and apparently surface attached, use the normal one if it's there
                if (node == null && p.attachMode == AttachModes.SRF_ATTACH)
                    node = attach = p.srfAttachNode;

                if (KJRJointUtils.debug)
                {
                    debugString.AppendLine("Original joint from " + p.partInfo.title + " to " + p.parent.partInfo.title);
                    debugString.AppendLine("  " + p.partInfo.name + " (" + p.flightID + ") -> " + p.parent.partInfo.name + " (" + p.parent.flightID + ")");
                    debugString.AppendLine("");
                    debugString.AppendLine(p.partInfo.title + " Inertia Tensor: " + p.rigidbody.inertiaTensor + " " + p.parent.partInfo.name + " Inertia Tensor: " + connectedBody.inertiaTensor);
                    debugString.AppendLine("");

开发者ID:Boris-Barboris,项目名称:Kerbal-Joint-Reinforcement,代码行数:65,代码来源:KJRManager.cs

示例12: KASConnectorPortExplode

 private void KASConnectorPortExplode(VesselElementViewOptions ol, VesselElementViewOption o, Part part)
 {
     if (hasMod("KAS"))
     {
         var module = part.Module<KAS.KASModulePort>();//this creates KAS Dependancy.  
         if (string.IsNullOrEmpty(module.attachNode)) return;
         var an = part.findAttachNode(module.attachNode);
         if (!an.attachedPart) return;
         var distance = o.valueParam;
         Part partToBeMoved;
         if (an.attachedPart == part.parent)
         {
             distance *= -1;
             partToBeMoved = part;
         }
         else
         {
             partToBeMoved = an.attachedPart;
         }
         partToBeMoved.transform.Translate(module.portNode.forward * distance, Space.World);
     }
 }
开发者ID:bigorangemachine,项目名称:ksp-kronalutils,代码行数:22,代码来源:VesselViewConfig.cs

示例13: RadialDecouplerExplode

 private void RadialDecouplerExplode(VesselElementViewOptions ol, VesselElementViewOption o, Part part)
 {
     var module = part.Module<ModuleAnchoredDecoupler>();
     if (module.isDecoupled) return;
     if (!module.staged) return;
     if (string.IsNullOrEmpty(module.explosiveNodeID)) return;
     var an = module.explosiveNodeID == "srf" ? part.srfAttachNode : part.findAttachNode(module.explosiveNodeID);
     if (an == null || an.attachedPart == null) return;
     var distance = o.valueParam;
     if (part.name.Contains("FairingCone"))
     {
         distance *= -1;
     }
     Part partToBeMoved;
     if (an.attachedPart == part.parent)
     {
         distance *= -1;
         partToBeMoved = part;
     }
     else
     {
         partToBeMoved = an.attachedPart;
     }
     partToBeMoved.transform.Translate(part.transform.right * distance, Space.World);
 }
开发者ID:bigorangemachine,项目名称:ksp-kronalutils,代码行数:25,代码来源:VesselViewConfig.cs

示例14: FuelStackSearcher

        /// <summary>
        /// This is the combined FuelStackSearch and FuelStackReSearch. It should be a bit more reliable as well as preventing me from updating one segment of code and not the other (which would likley lead to autonomus explosions)
        /// So this sub basically finds all the valid fuel sources for the booster segment, it should work fine.
        /// </summary>
        /// <param name="pl"></param>
        public void FuelStackSearcher(System.Collections.Generic.List<Part> pl)
        {
            fullStackFuelMass = 0;

            pl.Clear();
            i = 0;
            bEndofFuelSearch = false;

            p = this.part;
            AttachNode n = new AttachNode();

            AdvSRBSegment SRB = new AdvSRBSegment();

            p = this.part;
            n = p.findAttachNode(topNode);

            if (p.Modules.Contains("AdvSRBSegment"))
            {
                if (pl.Contains(p) != true)
                {
                    pl.Add(p);

                    p.GetComponent<AdvSRBSegment>().startLoadedFuelMass = p.GetComponent<AdvSRBSegment>().calcStartFuelLoadMass(resourceName);

                    fullStackFuelMass += p.GetComponent<AdvSRBSegment>().startLoadedFuelMass;
                }

                SRB = p.GetComponent<AdvSRBSegment>();

                if (SRB.endOfStack)
                    goto Leave;
            }

            do
            {
                if (n.attachedPart.Modules.Contains("AdvSRBSegment"))
                {
                    p = n.attachedPart;

                    if (pl.Contains(p) != true)
                    {
                        pl.Add(p);

                        p.GetComponent<AdvSRBSegment>().startLoadedFuelMass = p.GetComponent<AdvSRBSegment>().calcStartFuelLoadMass(resourceName);

                        fullStackFuelMass += p.GetComponent<AdvSRBSegment>().startLoadedFuelMass;
                    }

                    SRB = p.GetComponent<AdvSRBSegment>();

                    if (SRB.endOfStack != true)
                    {
                        foreach (AttachNode k in p.attachNodes)
                        {
                            if (k.id == SRB.topNode)
                            {
                                n = k;
                                goto Finish;
                            }
                        }

                    Finish:

                        if (n.attachedPart == null)
                        {
                            bEndofFuelSearch = true;
                        }
                    }
                    else
                    {
                        bEndofFuelSearch = true;
                    }
                }
                else
                    bEndofFuelSearch = true;

                i += 1;

            } while (bEndofFuelSearch == false && i < 250);

            if (i == 250) //I hope to hell no one builds a rocket such that 250 iterations is restricting an otherwise valid design. Because damn.
            {
                print("SolidBoosterNozzle: Forced out of loop");
                print("SolidBoosterNozzle: Loop executed 250 times");
            }

            Leave:
            ;
        }
开发者ID:kujuman,项目名称:ksp-ksf-advSRB,代码行数:94,代码来源:AdvSRBNozzle.cs

示例15: UpdatePartJoint

        private void UpdatePartJoint(Part p)
        {
            if (!JointUtils.JointAdjustmentValid(p) || p.rb == null)
                return;

            if (p.attachJoint.Joint is ConfigurableJoint &&
                p.attachMethod == AttachNodeMethod.LOCKED_JOINT)
            {
                if (JointUtils.debug)
                {
                    Debug.Log("KJR: Already processed part before: " + p.partInfo.name + " (" + p.uid + ") -> " +
                              p.parent.partInfo.name + " (" + p.parent.uid + ")");
                }

                return;
            }

            if (p is StrutConnector)
            {
                StrutConnector s = p as StrutConnector;
                JointDrive strutDrive = s.strutJoint.Joint.angularXDrive;
                strutDrive.positionSpring = JointUtils.decouplerAndClampJointStrength;
                strutDrive.maximumForce = JointUtils.decouplerAndClampJointStrength;
                s.strutJoint.Joint.xDrive = s.strutJoint.Joint.yDrive = s.strutJoint.Joint.zDrive = s.strutJoint.Joint.angularXDrive = s.strutJoint.Joint.angularYZDrive = strutDrive;

                float scalingFactor = (s.jointTarget.mass + s.jointTarget.GetResourceMass() + s.jointRoot.mass + s.jointRoot.GetResourceMass()) * 0.01f;

                s.strutJoint.SetBreakingForces(s.strutJoint.Joint.breakForce * scalingFactor, s.strutJoint.Joint.breakTorque * scalingFactor);

                p.attachMethod = AttachNodeMethod.LOCKED_JOINT;

                return;
            }

            StringBuilder debugString = new StringBuilder();

            String jointType = p.attachJoint.Joint.GetType().Name;
            Rigidbody connectedBody = p.attachJoint.Joint.connectedBody;

            Part connectedPart = connectedBody.GetComponent<Part>() ?? p.parent;
            float partMass = p.mass + p.GetResourceMass();
            float parentMass = connectedPart.mass + connectedPart.GetResourceMass();

            if (partMass < JointUtils.massForAdjustment || parentMass < JointUtils.massForAdjustment)
            {
                if (JointUtils.debug)
                {
                    Debug.Log("KJR: Part mass too low, skipping: " + p.partInfo.name + " (" + p.uid + ")");
                }

                return;
            }

            // Check attachment nodes for better orientation data
            AttachNode attach = p.findAttachNodeByPart(p.parent);
            AttachNode p_attach = p.parent.findAttachNodeByPart(p);
            AttachNode node = attach ?? p_attach;

            if (node == null)
            {
                // Check if it's a pair of coupled docking ports
                var dock1 = p.Modules["ModuleDockingNode"] as ModuleDockingNode;
                var dock2 = p.parent.Modules["ModuleDockingNode"] as ModuleDockingNode;

                //Debug.Log(dock1 + " " + (dock1 ? ""+dock1.dockedPartUId : "?") + " " + dock2 + " " + (dock2 ? ""+dock2.dockedPartUId : "?"));

                if (dock1 && dock2 && (dock1.dockedPartUId == p.parent.flightID || dock2.dockedPartUId == p.flightID))
                {
                    attach = p.findAttachNode(dock1.referenceAttachNode);
                    p_attach = p.parent.findAttachNode(dock2.referenceAttachNode);
                    node = attach ?? p_attach;
                }
            }

            // If still no node and apparently surface attached, use the normal one if it's there
            if (node == null && p.attachMode == AttachModes.SRF_ATTACH)
                node = attach = p.srfAttachNode;

            if (JointUtils.debug)
            {
                debugString.AppendLine("Original joint from " + p.partInfo.title + " to " + p.parent.partInfo.title);
                debugString.AppendLine("  " + p.partInfo.name + " (" + p.uid + ") -> " + p.parent.partInfo.name + " (" + p.parent.uid + ")");
                debugString.AppendLine("");
                debugString.AppendLine(p.partInfo.title + " Inertia Tensor: " + p.rigidbody.inertiaTensor + " " + p.parent.partInfo.name + " Inertia Tensor: " + connectedBody.inertiaTensor);
                debugString.AppendLine("");

                debugString.AppendLine("Std. Joint Parameters");
                debugString.AppendLine("Connected Body: " + p.attachJoint.Joint.connectedBody);
                debugString.AppendLine("Attach mode: " + p.attachMode + " (was " + jointType + ")");
                if (attach != null)
                    debugString.AppendLine("Attach node: " + attach.id + " - " + attach.nodeType + " " + attach.size);
                if (p_attach != null)
                    debugString.AppendLine("Parent node: " + p_attach.id + " - " + p_attach.nodeType + " " + p_attach.size);
                debugString.AppendLine("Anchor: " + p.attachJoint.Joint.anchor);
                debugString.AppendLine("Axis: " + p.attachJoint.Joint.axis);
                debugString.AppendLine("Sec Axis: " + p.attachJoint.Joint.secondaryAxis);
                debugString.AppendLine("Break Force: " + p.attachJoint.Joint.breakForce);
                debugString.AppendLine("Break Torque: " + p.attachJoint.Joint.breakTorque);
                debugString.AppendLine("");

//.........这里部分代码省略.........
开发者ID:vosechu,项目名称:Kerbal-Joint-Reinforcement,代码行数:101,代码来源:KerbalJointReinforcement.cs


注:本文中的Part.findAttachNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。