Exemple #1
0
        // Token: 0x06001739 RID: 5945 RVA: 0x0006E498 File Offset: 0x0006C698
        public void OnCollisionEnter(Collision collision)
        {
            Debug.LogFormat("Hit {0}", new object[]
            {
                collision.gameObject
            });
            Rigidbody component = collision.collider.GetComponent <Rigidbody>();

            if (component)
            {
                Debug.Log("Hit?");
                HealthComponent component2 = component.GetComponent <HealthComponent>();
                if (component2)
                {
                    Vector3 point  = collision.contacts[0].point;
                    Vector3 normal = collision.contacts[0].normal;
                    this.vehicleRigidbody.GetPointVelocity(point);
                    Vector3 impulse = collision.impulse;
                    float   num     = 0f;
                    this.vehicleRigidbody.AddForceAtPosition(impulse * num, point);
                    Debug.LogFormat("Impulse: {0}, Ratio: {1}", new object[]
                    {
                        impulse,
                        num
                    });
                    component2.TakeDamageForce(new DamageInfo
                    {
                        attacker = base.gameObject,
                        force    = -impulse * (1f - num),
                        position = point
                    }, true);
                }
            }
        }
Exemple #2
0
        // Token: 0x06001738 RID: 5944 RVA: 0x0006E370 File Offset: 0x0006C570
        public void OnTriggerEnter(Collider other)
        {
            CharacterMotor  component  = other.GetComponent <CharacterMotor>();
            HealthComponent component2 = other.GetComponent <HealthComponent>();

            if (component && component2)
            {
                Vector3 position      = base.transform.position;
                Vector3 normalized    = this.vehicleRigidbody.velocity.normalized;
                Vector3 pointVelocity = this.vehicleRigidbody.GetPointVelocity(position);
                Vector3 vector        = pointVelocity * this.vehicleRigidbody.mass * this.impactMultiplier;
                float   mass          = this.vehicleRigidbody.mass;
                Mathf.Pow(pointVelocity.magnitude, 2f);
                float num = component.mass / (component.mass + this.vehicleRigidbody.mass);
                this.vehicleRigidbody.AddForceAtPosition(-vector * num, position);
                Debug.LogFormat("Impulse: {0}, Ratio: {1}", new object[]
                {
                    vector.magnitude,
                    num
                });
                component2.TakeDamageForce(new DamageInfo
                {
                    attacker = base.gameObject,
                    force    = vector,
                    position = position
                }, true);
            }
        }
Exemple #3
0
 // Token: 0x060010CD RID: 4301 RVA: 0x0004987C File Offset: 0x00047A7C
 private void FixedUpdate()
 {
     Collider[] array = Physics.OverlapSphere(base.transform.position, this.radius, LayerIndex.defaultLayer.mask);
     for (int i = 0; i < array.Length; i++)
     {
         HealthComponent component  = array[i].GetComponent <HealthComponent>();
         CharacterMotor  component2 = array[i].GetComponent <CharacterMotor>();
         if (component)
         {
             TeamComponent component3 = component.GetComponent <TeamComponent>();
             bool          flag       = false;
             if (component3 && this.teamFilter)
             {
                 flag = (component3.teamIndex == this.teamFilter.teamIndex);
             }
             if (!flag)
             {
                 this.AddToList(component.gameObject);
                 if (NetworkServer.active)
                 {
                     Vector3 a   = array[i].transform.position - this._transform.position;
                     float   num = 1f - Mathf.Clamp(a.magnitude / this.radius, 0f, 1f - this.forceCoefficientAtEdge);
                     a = a.normalized * this.forceMagnitude * (1f - num);
                     Vector3 velocity;
                     float   mass;
                     if (component2)
                     {
                         velocity = component2.velocity;
                         mass     = component2.mass;
                     }
                     else
                     {
                         Rigidbody component4 = component.GetComponent <Rigidbody>();
                         velocity = component4.velocity;
                         mass     = component4.mass;
                     }
                     velocity.y += Physics.gravity.y * Time.fixedDeltaTime;
                     component.TakeDamageForce(a - velocity * (this.damping * mass * num), true, false);
                 }
             }
         }
     }
 }