private static void PerformDamage(GameObject attacker, GameObject inflictor, float damage, bool isCrit, ProcChainMask procChainMask, float procCoefficient, DamageColorIndex damageColorIndex, DamageType damageType, Vector3 forceVector, float pushAwayForce, float upwardsForce, List <ExtendedOverlapAttack.OverlapInfo> hitList)
 {
     for (int i = 0; i < hitList.Count; i++)
     {
         ExtendedOverlapAttack.OverlapInfo overlapInfo = hitList[i];
         if (overlapInfo.hurtBox)
         {
             HealthComponent healthComponent = overlapInfo.hurtBox.healthComponent;
             if (healthComponent)
             {
                 DamageInfo damageInfo = new DamageInfo();
                 damageInfo.attacker         = attacker;
                 damageInfo.inflictor        = inflictor;
                 damageInfo.force            = forceVector + pushAwayForce * overlapInfo.pushDirection;
                 damageInfo.damage           = damage;
                 damageInfo.crit             = isCrit;
                 damageInfo.position         = overlapInfo.hitPosition;
                 damageInfo.procChainMask    = procChainMask;
                 damageInfo.procCoefficient  = procCoefficient;
                 damageInfo.damageColorIndex = damageColorIndex;
                 damageInfo.damageType       = damageType;
                 if (healthComponent.gameObject.GetComponent <CharacterBody>().isFlying)
                 {
                     damageInfo.force += new Vector3(0f, upwardsForce, 0f);
                 }
                 if (NetworkServer.active)
                 {
                     //We're the server, and we can do whatever the fug we want with damage!
                     damageInfo.ModifyDamageInfo(overlapInfo.hurtBox.damageModifier);
                     healthComponent.TakeDamage(damageInfo);
                     GlobalEventManager.instance.OnHitEnemy(damageInfo, healthComponent.gameObject);
                     GlobalEventManager.instance.OnHitAll(damageInfo, healthComponent.gameObject);
                 }
                 else
                 {
                     if (ClientScene.ready)
                     {
                         //It's the hosts world, and we're just livin' in it.
                         ExtendedOverlapAttack.write.StartMessage(7595);
                         //Use our own cool channel, else, the game will not recongize it.
                         ExtendedOverlapAttack.write.Write(healthComponent.gameObject);
                         ExtendedOverlapAttack.WriteDamageInfo(ExtendedOverlapAttack.write, damageInfo);
                         ExtendedOverlapAttack.write.Write(healthComponent != null);
                         ExtendedOverlapAttack.write.FinishMessage();
                         ClientScene.readyConnection.SendWriter(ExtendedOverlapAttack.write, QosChannelIndex.defaultReliable.intVal);
                         //Always write on the default reliable intVal, for obvious reasons.
                     }
                 }
             }
         }
     }
 }
        private void ProcessHits(List <ExtendedOverlapAttack.OverlapInfo> hitList)
        {
            if (hitList.Count == 0)
            {
                return;
            }
            Vector3 vector = Vector3.zero;
            float   d      = 1f / (float)hitList.Count;

            for (int i = 0; i < hitList.Count; i++)
            {
                ExtendedOverlapAttack.OverlapInfo overlapInfo = hitList[i];
                if (this.hitEffectPrefab)
                {
                    Vector3 forward = -hitList[i].pushDirection;
                    EffectManager.SpawnEffect(this.hitEffectPrefab, new EffectData
                    {
                        origin   = overlapInfo.hitPosition,
                        rotation = Util.QuaternionSafeLookRotation(forward),
                    }, true);

                    Util.PlaySound("Play_MULT_shift_hit", this.hitEffectPrefab.gameObject);
                }
                vector += overlapInfo.hitPosition * d;
                SurfaceDefProvider component = hitList[i].hurtBox.GetComponent <SurfaceDefProvider>();
                if (component && component.surfaceDef)
                {
                    SurfaceDef objectSurfaceDef = SurfaceDefProvider.GetObjectSurfaceDef(hitList[i].hurtBox.collider, hitList[i].hitPosition);
                    if (objectSurfaceDef)
                    {
                        if (objectSurfaceDef.impactEffectPrefab)
                        {
                            EffectManager.SpawnEffect(objectSurfaceDef.impactEffectPrefab, new EffectData
                            {
                                origin   = overlapInfo.hitPosition,
                                rotation = ((overlapInfo.pushDirection == Vector3.zero) ? Quaternion.identity : Util.QuaternionSafeLookRotation(overlapInfo.pushDirection)),
                                color    = objectSurfaceDef.approximateColor,
                                scale    = 2f
                            }, true);
                        }
                        if (objectSurfaceDef.impactSoundString != null && objectSurfaceDef.impactSoundString.Length != 0)
                        {
                            Util.PlaySound(objectSurfaceDef.impactSoundString, hitList[i].hurtBox.gameObject);
                        }
                    }
                }
            }
            this.lastFireAverageHitPosition = vector;
            //Since we're the server, we can do damage pretty freely.
            if (NetworkServer.active)
            {
                ExtendedOverlapAttack.PerformDamage(this.attacker, this.inflictor, this.damage, this.isCrit, this.procChainMask, this.procCoefficient, this.damageColorIndex, this.damageType, this.forceVector, this.pushAwayForce, this.upwardsForce, hitList);
                return;
            }
            ExtendedOverlapAttack.outgoingMessage.attacker         = this.attacker;
            ExtendedOverlapAttack.outgoingMessage.inflictor        = this.inflictor;
            ExtendedOverlapAttack.outgoingMessage.damage           = this.damage;
            ExtendedOverlapAttack.outgoingMessage.isCrit           = this.isCrit;
            ExtendedOverlapAttack.outgoingMessage.procChainMask    = this.procChainMask;
            ExtendedOverlapAttack.outgoingMessage.procCoefficient  = this.procCoefficient;
            ExtendedOverlapAttack.outgoingMessage.damageColorIndex = this.damageColorIndex;
            ExtendedOverlapAttack.outgoingMessage.damageType       = this.damageType;
            ExtendedOverlapAttack.outgoingMessage.forceVector      = this.forceVector;
            ExtendedOverlapAttack.outgoingMessage.pushAwayForce    = this.pushAwayForce;
            ExtendedOverlapAttack.outgoingMessage.upwardsForce     = this.upwardsForce;

            Util.CopyList <ExtendedOverlapAttack.OverlapInfo>(hitList, ExtendedOverlapAttack.outgoingMessage.overlapInfoList);
            GameNetworkManager.singleton.client.connection.SendByChannel(7595, ExtendedOverlapAttack.outgoingMessage, QosChannelIndex.defaultReliable.intVal);
        }
 public static void HandleExtendedOverlapAttackHits(NetworkMessage netMsg)
 {
     netMsg.ReadMessage <ExtendedOverlapAttack.ExtendedOverlapAttackMessage>(ExtendedOverlapAttack.incomingMessage);
     ExtendedOverlapAttack.PerformDamage(ExtendedOverlapAttack.incomingMessage.attacker, ExtendedOverlapAttack.incomingMessage.inflictor, ExtendedOverlapAttack.incomingMessage.damage, ExtendedOverlapAttack.incomingMessage.isCrit, ExtendedOverlapAttack.incomingMessage.procChainMask, ExtendedOverlapAttack.incomingMessage.procCoefficient, ExtendedOverlapAttack.incomingMessage.damageColorIndex, ExtendedOverlapAttack.incomingMessage.damageType, ExtendedOverlapAttack.incomingMessage.forceVector, ExtendedOverlapAttack.incomingMessage.pushAwayForce, ExtendedOverlapAttack.incomingMessage.upwardsForce, ExtendedOverlapAttack.incomingMessage.overlapInfoList);
 }