Example #1
0
        public void OnEquippedPartCoupled(Part createdPart, Part tgtPart = null,
                                          AttachNode tgtAttachNode       = null)
        {
            if (equipMode == EquipMode.Part)
            {
                //Disable colliders
                foreach (var col in equippedPart.gameObject.GetComponentsInChildren <Collider>())
                {
                    col.isTrigger = true;
                }

                //Destroy joint to avoid buggy eva move
                if (equippedPart.attachJoint)
                {
                    equippedPart.attachJoint.DestroyJoint();
                }

                //Destroy rigidbody
                equippedPart.physicalSignificance = Part.PhysicalSignificance.NONE;
                if (equippedPart.collisionEnhancer)
                {
                    UnityEngine.Object.DestroyImmediate(equippedPart.collisionEnhancer);
                }
                UnityEngine.Object.Destroy(equippedPart.Rigidbody);
            }

            if (equipMode == EquipMode.Physic)
            {
                equippedPart.mass = 0.001f;
                //Disable colliders
                foreach (Collider col in equippedPart.gameObject.GetComponentsInChildren <Collider>())
                {
                    col.isTrigger = true;
                }

                //Destroy joint to avoid buggy eva move
                if (equippedPart.attachJoint)
                {
                    equippedPart.attachJoint.DestroyJoint();
                }

                //Create physic join
                FixedJoint evaJoint = equippedPart.gameObject.AddComponent <FixedJoint>();
                evaJoint.connectedBody = inventory.part.Rigidbody;//evaCollider.attachedRigidbody;
                evaJoint.breakForce    = EqippedPartJointBreakForce;
                evaJoint.breakTorque   = EqippedPartJointBreakForce;
                KIS_Shared.ResetCollisionEnhancer(equippedPart);
            }
        }