示例#1
0
        // Not called on parts where physicalSignificance = false. Check the parent part instead.
        public void OnCollisionEnter(Collision c)
        {
            if (_paused)
            {
                return;
            }
            if (c.relativeVelocity.magnitude > 3)
            {
                if (c.contacts.Length == 0)
                {
                    return;
                }

                foreach (ContactPoint contactPoint in c.contacts)
                {
                    Part collidingPart = GetCollidingPart(contactPoint);
                    if (collidingPart != null)
                    {
                        CollisionFX cfx = collidingPart.GetComponent <CollisionFX>();
                        if (cfx != null)
                        {
                            DustImpact(c.relativeVelocity.magnitude, contactPoint.point, c.collider.name);

                            bool isUsableWheel = true;
                            if (cfx.moduleWheel != null)
                            {
                                if (cfx.moduleWheelDamage != null && cfx.moduleWheelDamage.isDamaged)
                                {
                                    isUsableWheel = false;
                                }
                                if (cfx.moduleWheelDeployment != null && cfx.moduleWheelDeployment.Position == 0)
                                {
                                    isUsableWheel = false;
                                }
                            }
                            else
                            {
                                isUsableWheel = false;
                            }

                            cfx.ImpactSounds(isUsableWheel);
                        }
                    }
                }
            }
        }