public void OnPartUnpack()
        {
            if (part.parent == null)
            {
                return;
            }

            neighbours.Add(part.parent);

            StringBuilder debugString = null;

            if (Log.debuglevel > 3)
            {
                debugString = new StringBuilder();
                debugString.AppendLine("The following joints added by " + part.partInfo.title + " to increase stiffness:");
            }

            if (part.parent.Rigidbody != null)
            {
                joints.Add(KJRJointUtils.BuildJoint(part, part.parent));
            }

            if (Log.debuglevel > 3)
            {
                debugString.AppendLine(part.parent.partInfo.title + " connected to part " + part.partInfo.title);
                Log.dbg("{0}", debugString);
            }

            if (joints.Count > 0)
            {
                GameEvents.onVesselWasModified.Add(OnVesselWasModified);
            }
        }
        private void MultiPartJointBuildJoint(Part p, Part linkPart)
        {
            if (multiJointManager.CheckMultiJointBetweenParts(p, linkPart) || !multiJointManager.TrySetValidLinkedSet(p, linkPart))
            {
                return;
            }

            multiJointManager.RegisterMultiJointBetweenParts(p, linkPart, KJRJointUtils.BuildJoint(p, linkPart));
        }
        private void MultiPartJointBuildJoint(Part part, Part linkPart, KJRMultiJointManager.Reason jointReason)
        {
            if (multiJointManager.CheckDirectJointBetweenParts(part, linkPart) ||
                !multiJointManager.TrySetValidLinkedSet(part, linkPart))
            {
                return;
            }

            ConfigurableJoint joint = KJRJointUtils.BuildJoint(part, linkPart);

            multiJointManager.RegisterMultiJoint(part, joint, true, jointReason);
            multiJointManager.RegisterMultiJoint(linkPart, joint, true, jointReason);

            foreach (Part p in multiJointManager.linkedSet)
            {
                multiJointManager.RegisterMultiJoint(p, joint, false, jointReason);
            }
        }
Пример #4
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);
        }