private void HandleCollision(Collision collision, bool enter) { if (collision.contacts.Length == 0) { return; } Vector3 impulse = collision.GetImpulse(); float magnitude = impulse.magnitude; if (magnitude < impulseTreshold) { return; } float num = 1f; Transform transform = collision.transform; if (transform.name.StartsWith("Lock")) { return; } while (transform != null) { if (showDebug) { Debug.Log(base.name + " T != Null "); } if ((bool)transform.GetComponent <Human>()) { num = humanHardness; break; } ShatterHardness component = transform.GetComponent <ShatterHardness>(); if (component != null) { num = component.hardness; break; } transform = transform.parent; } adjustedImpulse += impulse * num; if (showDebug) { Debug.Log(base.name + " adjustedImpulse " + adjustedImpulse); } if (showDebug) { Debug.Log(base.name + " impulse " + impulse); } if (showDebug) { Debug.Log(base.name + " hardnessValue " + num); } }
private void HandleCollision(Collision collision, bool enter) { if (collision.contacts.Length == 0 || ReplayRecorder.isPlaying || NetGame.isClient) { return; } Vector3 a = -collision.GetImpulse(); float magnitude = a.magnitude; if (magnitude < impulseTreshold) { return; } float num = 1f; Transform transform = collision.transform; while (transform != null) { if ((bool)transform.GetComponent <Human>()) { num = humanHardness; break; } ShatterHardness component = transform.GetComponent <ShatterHardness>(); if (component != null) { num = component.hardness; break; } transform = transform.parent; } if (magnitude * num > maxImpact) { maxImpact = magnitude * num; maxImpactPoint = collision.contacts[0].point; } adjustedImpulse += a * num; }