Exemplo n.º 1
0
        // Token: 0x060003D0 RID: 976 RVA: 0x0000EB60 File Offset: 0x0000CD60
        private BlastAttack.HitPoint[] CollectHits()
        {
            Vector3 vector = this.position;

            Collider[] array = Physics.OverlapSphere(vector, this.radius, LayerIndex.entityPrecise.mask);
            int        num   = array.Length;
            int        num2  = 0;

            BlastAttack.< > c__DisplayClass27_0 CS$ < > 8__locals1;
            CS$ < > 8__locals1.encounteredHealthComponentsLength = 0;
            CS$ < > 8__locals1.hitOrderBufferLength = 0;
            HGArrayUtilities.EnsureCapacity <BlastAttack.HitPoint>(ref BlastAttack.hitPointsBuffer, num);
            HGArrayUtilities.EnsureCapacity <int>(ref BlastAttack.hitOrderBuffer, num);
            HGArrayUtilities.EnsureCapacity <HealthComponent>(ref BlastAttack.encounteredHealthComponentsBuffer, num);
            for (int i = 0; i < num; i++)
            {
                Collider collider  = array[i];
                HurtBox  component = collider.GetComponent <HurtBox>();
                if (component)
                {
                    HealthComponent healthComponent = component.healthComponent;
                    if (healthComponent && ((this.canHurtAttacker && healthComponent.gameObject == this.attacker) || healthComponent.GetComponent <TeamComponent>().teamIndex != this.teamIndex))
                    {
                        Vector3 vector2      = collider.transform.position;
                        Vector3 hitNormal    = vector2 - vector;
                        float   sqrMagnitude = hitNormal.sqrMagnitude;
                        BlastAttack.hitPointsBuffer[num2++] = new BlastAttack.HitPoint
                        {
                            hurtBox     = component,
                            hitPosition = vector2,
                            hitNormal   = hitNormal,
                            distanceSqr = sqrMagnitude
                        };
                    }
                }
            }
            if (true)
            {
                for (int j = 0; j < num2; j++)
                {
                    ref BlastAttack.HitPoint ptr = ref BlastAttack.hitPointsBuffer[j];
                    RaycastHit raycastHit;
                    if (ptr.hurtBox != null && ptr.distanceSqr > 0f && ptr.hurtBox.collider.Raycast(new Ray(vector, -ptr.hitNormal), out raycastHit, this.radius))
                    {
                        ptr.hitPosition = raycastHit.point;
                        ptr.hitNormal   = raycastHit.normal;
                    }
                }
            }
Exemplo n.º 2
0
 // Token: 0x06000A11 RID: 2577 RVA: 0x00008219 File Offset: 0x00006419
 public static int DistanceSort(BlastAttack.HitPoint a, BlastAttack.HitPoint b)
 {
     return(a.distanceSqr.CompareTo(b.distanceSqr));
 }
Exemplo n.º 3
0
        // Token: 0x06000A0E RID: 2574 RVA: 0x00046974 File Offset: 0x00044B74
        public void Fire()
        {
            Collider[] array = Physics.OverlapSphere(this.position, this.radius, LayerIndex.entityPrecise.mask);
            int        num   = array.Length;

            for (int i = 0; i < num; i++)
            {
                Collider collider  = array[i];
                HurtBox  component = collider.GetComponent <HurtBox>();
                if (component)
                {
                    HealthComponent healthComponent = component.healthComponent;
                    if (healthComponent && ((this.canHurtAttacker && healthComponent.gameObject == this.attacker) || healthComponent.GetComponent <TeamComponent>().teamIndex != this.teamIndex))
                    {
                        BlastAttack.HitPoint hitPoint   = default(BlastAttack.HitPoint);
                        RaycastHit           raycastHit = default(RaycastHit);
                        hitPoint.hurtBox = component;
                        Vector3 direction = collider.transform.position - this.position;
                        if (direction.sqrMagnitude > 0f && collider.Raycast(new Ray(this.position, direction), out raycastHit, this.radius))
                        {
                            hitPoint.hitPosition = raycastHit.point;
                            hitPoint.hitNormal   = raycastHit.normal;
                        }
                        else
                        {
                            hitPoint.hitPosition = collider.transform.position;
                            hitPoint.hitNormal   = this.position - hitPoint.hitPosition;
                        }
                        hitPoint.distanceSqr = (hitPoint.hitPosition - this.position).sqrMagnitude;
                        if (!BlastAttack.bestHitPoints.ContainsKey(healthComponent) || BlastAttack.bestHitPoints[healthComponent].distanceSqr > hitPoint.distanceSqr)
                        {
                            BlastAttack.bestHitPoints[healthComponent] = hitPoint;
                        }
                    }
                }
            }
            BlastAttack.HitPoint[] array2 = new BlastAttack.HitPoint[BlastAttack.bestHitPoints.Count];
            int num2 = 0;

            foreach (KeyValuePair <HealthComponent, BlastAttack.HitPoint> keyValuePair in BlastAttack.bestHitPoints)
            {
                array2[num2++] = keyValuePair.Value;
            }
            BlastAttack.bestHitPoints.Clear();
            Array.Sort <BlastAttack.HitPoint>(array2, new Comparison <BlastAttack.HitPoint>(BlastAttack.HitPoint.DistanceSort));
            foreach (BlastAttack.HitPoint hitPoint2 in array2)
            {
                float num3 = Mathf.Sqrt(hitPoint2.distanceSqr);
                float num4 = 0f;
                switch (this.falloffModel)
                {
                case BlastAttack.FalloffModel.None:
                    num4 = 1f;
                    break;

                case BlastAttack.FalloffModel.Linear:
                    num4 = 1f - Mathf.Clamp01(num3 / this.radius);
                    break;

                case BlastAttack.FalloffModel.SweetSpot:
                    num4 = 1f - ((num3 > this.radius / 2f) ? 0.75f : 0f);
                    break;
                }
                DamageInfo damageInfo = new DamageInfo();
                damageInfo.attacker         = this.attacker;
                damageInfo.inflictor        = this.inflictor;
                damageInfo.damage           = this.baseDamage * num4;
                damageInfo.crit             = this.crit;
                damageInfo.force            = this.bonusForce * num4 + this.baseForce * num4 * (hitPoint2.hitPosition - this.position).normalized;
                damageInfo.procChainMask    = this.procChainMask;
                damageInfo.procCoefficient  = this.procCoefficient;
                damageInfo.damageType       = this.damageType;
                damageInfo.damageColorIndex = this.damageColorIndex;
                damageInfo.position         = hitPoint2.hitPosition;
                damageInfo.ModifyDamageInfo(hitPoint2.hurtBox.damageModifier);
                hitPoint2.hurtBox.healthComponent.TakeDamage(damageInfo);
                GlobalEventManager.instance.OnHitEnemy(damageInfo, hitPoint2.hurtBox.healthComponent.gameObject);
                GlobalEventManager.instance.OnHitAll(damageInfo, hitPoint2.hurtBox.healthComponent.gameObject);
            }
        }