// FEHLER, überarbeiten... ist das nicht etwas sehr viel was wir hier aufbauen???
        private void ReinforceDecouplers(Part part)
        {
            List <Part> childParts  = new List <Part>();
            List <Part> parentParts = new List <Part>();

            parentParts = KJRJointUtils.DecouplerPartStiffeningListParents(part.parent);

            foreach (Part p in part.children)
            {
                if (KJRJointUtils.IsJointAdjustmentAllowed(p))
                {
                    childParts.AddRange(KJRJointUtils.DecouplerPartStiffeningListChildren(p));
                    if (!childParts.Contains(p))
                    {
                        childParts.Add(p);
                    }
                }
            }

            parentParts.Add(part);

            StringBuilder debugString = null;

            if (KJRJointUtils.debug)
            {
                debugString = new StringBuilder();
                debugString.AppendLine(parentParts.Count + " parts above decoupler to be connected to " + childParts.Count + " below decoupler.");
                debugString.AppendLine("The following joints added by " + part.partInfo.title + " to increase stiffness:");
            }

            foreach (Part p in parentParts)
            {
                if (p == null || p.rb == null || p.Modules.Contains("ProceduralFairingDecoupler"))
                {
                    continue;
                }

                foreach (Part q in childParts)
                {
                    if (q == null || q.rb == null || p == q || q.Modules.Contains("ProceduralFairingDecoupler"))
                    {
                        continue;
                    }

                    if (p.vessel != q.vessel)
                    {
                        continue;
                    }

                    MultiPartJointBuildJoint(p, q, KJRMultiJointManager.Reason.ReinforceDecoupler);

                    if (KJRJointUtils.debug)
                    {
                        debugString.AppendLine(p.partInfo.title + " connected to part " + q.partInfo.title);
                    }
                }
            }


            if (KJRJointUtils.debug)
            {
                Debug.Log(debugString.ToString());
            }
        }
示例#2
0
        private void AddExtraJoints()
        {
            List <Part> childParts  = new List <Part>();
            List <Part> parentParts = new List <Part>();

            parentParts = KJRJointUtils.DecouplerPartStiffeningListParents(part.parent);

            foreach (Part p in part.children)
            {
                if (KJRJointUtils.IsJointAdjustmentAllowed(p))
                {
                    childParts.AddRange(KJRJointUtils.DecouplerPartStiffeningListChildren(p));
                    if (!childParts.Contains(p))
                    {
                        childParts.Add(p);
                    }
                }
            }

            neighbours.Clear();
            neighbours.AddRange(parentParts);
            neighbours.AddRange(childParts);
            neighbours.Remove(part);

            parentParts.Add(part);

            StringBuilder debugString = null;

            if (Log.debuglevel > 3)
            {
                debugString = new StringBuilder();
                debugString.AppendLine(parentParts.Count + " parts above decoupler to be connected to " + childParts.Count + " below decoupler.");
                debugString.AppendLine("The following joints added by " + part.partInfo.title + " to increase stiffness:");
            }

            foreach (Part p in parentParts)
            {
                if (p == null || p.rb == null || p.Modules.Contains("ProceduralFairingDecoupler"))
                {
                    continue;
                }

                foreach (Part q in childParts)
                {
                    if (q == null || q.rb == null || p == q || q.Modules.Contains("ProceduralFairingDecoupler"))
                    {
                        continue;
                    }

                    if (p.vessel != q.vessel)
                    {
                        continue;
                    }

                    joints.Add(KJRJointUtils.BuildJoint(p, q));

                    if (Log.debuglevel > 3)
                    {
                        debugString.AppendLine(p.partInfo.title + " connected to part " + q.partInfo.title);
                    }
                }
            }

            if (joints.Count > 0)
            {
                GameEvents.onVesselCreate.Add(OnVesselWasModified);
                GameEvents.onVesselWasModified.Add(OnVesselWasModified);
            }

            Log.dbg("{0}", debugString);
        }