Exemplo n.º 1
0
        // Token: 0x060013F9 RID: 5113 RVA: 0x00055808 File Offset: 0x00053A08
        public static SurfaceDef GetObjectSurfaceDef(Collider collider, Vector3 position)
        {
            SurfaceDefProvider component = collider.GetComponent <SurfaceDefProvider>();

            if (!component)
            {
                return(null);
            }
            return(component.surfaceDef);
        }
Exemplo n.º 2
0
 // Token: 0x060018FC RID: 6396 RVA: 0x00077EF8 File Offset: 0x000760F8
 private void ProcessHits(List <OverlapAttack.OverlapInfo> hitList)
 {
     if (hitList.Count == 0)
     {
         return;
     }
     for (int i = 0; i < hitList.Count; i++)
     {
         OverlapAttack.OverlapInfo overlapInfo = hitList[i];
         if (this.hitEffectPrefab)
         {
             EffectManager.instance.SimpleImpactEffect(this.hitEffectPrefab, overlapInfo.hitPosition, -hitList[i].pushDirection, true);
         }
         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.instance.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);
                 }
             }
         }
     }
     if (NetworkServer.active)
     {
         OverlapAttack.PerformDamage(this.attacker, this.inflictor, this.damage, this.isCrit, this.procChainMask, this.procCoefficient, this.damageColorIndex, this.damageType, this.forceVector, this.pushAwayForce, hitList);
         return;
     }
     OverlapAttack.outgoingMessage.attacker         = this.attacker;
     OverlapAttack.outgoingMessage.inflictor        = this.inflictor;
     OverlapAttack.outgoingMessage.damage           = this.damage;
     OverlapAttack.outgoingMessage.isCrit           = this.isCrit;
     OverlapAttack.outgoingMessage.procChainMask    = this.procChainMask;
     OverlapAttack.outgoingMessage.procCoefficient  = this.procCoefficient;
     OverlapAttack.outgoingMessage.damageColorIndex = this.damageColorIndex;
     OverlapAttack.outgoingMessage.damageType       = this.damageType;
     OverlapAttack.outgoingMessage.forceVector      = this.forceVector;
     OverlapAttack.outgoingMessage.pushAwayForce    = this.pushAwayForce;
     Util.CopyList <OverlapAttack.OverlapInfo>(hitList, OverlapAttack.outgoingMessage.overlapInfoList);
     GameNetworkManager.singleton.client.connection.SendByChannel(71, OverlapAttack.outgoingMessage, QosChannelIndex.defaultReliable.intVal);
 }
        // Token: 0x06000F50 RID: 3920 RVA: 0x0004BA88 File Offset: 0x00049C88
        public void Footstep(string childName, GameObject footstepEffect)
        {
            Transform transform = this.childLocator.FindChild(childName);

            if (transform)
            {
                Color      color      = Color.gray;
                RaycastHit raycastHit = default(RaycastHit);
                Vector3    position   = transform.position;
                position.y += 1.5f;
                Debug.DrawRay(position, Vector3.down);
                if (Physics.Raycast(new Ray(position, Vector3.down), out raycastHit, 4f, LayerIndex.world.mask | LayerIndex.water.mask, QueryTriggerInteraction.Collide))
                {
                    if (this.bodyInventory && this.bodyInventory.GetItemCount(ItemIndex.Hoof) > 0 && childName == "FootR")
                    {
                        Util.PlaySound("Play_item_proc_hoof", transform.gameObject);
                    }
                    if (footstepEffect)
                    {
                        EffectManager.instance.SimpleImpactEffect(footstepEffect, raycastHit.point, raycastHit.normal, false);
                    }
                    SurfaceDef objectSurfaceDef = SurfaceDefProvider.GetObjectSurfaceDef(raycastHit.collider, raycastHit.point);
                    bool       flag             = false;
                    if (objectSurfaceDef)
                    {
                        color = objectSurfaceDef.approximateColor;
                        if (objectSurfaceDef.footstepEffectPrefab)
                        {
                            EffectManager.instance.SpawnEffect(objectSurfaceDef.footstepEffectPrefab, new EffectData
                            {
                                origin = raycastHit.point,
                                scale  = this.body.radius
                            }, false);
                            flag = true;
                        }
                        if (!string.IsNullOrEmpty(objectSurfaceDef.materialSwitchString))
                        {
                            AkSoundEngine.SetSwitch("material", objectSurfaceDef.materialSwitchString, transform.gameObject);
                        }
                    }
                    else
                    {
                        Debug.LogFormat("{0} is missing surface def", new object[]
                        {
                            raycastHit.collider.gameObject
                        });
                    }
                    if (this.footstepDustInstanceTransform && !flag)
                    {
                        this.footstepDustInstanceTransform.position             = raycastHit.point;
                        this.footstepDustInstanceParticleSystem.main.startColor = color;
                        this.footstepDustInstanceParticleSystem.Play();
                        if (this.footstepDustInstanceShakeEmitter)
                        {
                            this.footstepDustInstanceShakeEmitter.StartShake();
                        }
                    }
                }
                Util.PlaySound(this.baseFootstepString, transform.gameObject);
                return;
            }
            Debug.LogWarningFormat("Object {0} lacks ChildLocator entry \"{1}\" to handle Footstep event!", new object[]
            {
                base.gameObject.name,
                childName
            });
        }
Exemplo n.º 4
0
        // Token: 0x06000426 RID: 1062 RVA: 0x00010B54 File Offset: 0x0000ED54
        public bool DefaultHitCallback(ref BulletAttack.BulletHit hitInfo)
        {
            bool result = false;

            if (hitInfo.collider)
            {
                result = ((1 << hitInfo.collider.gameObject.layer & this.stopperMask) == 0);
            }
            if (this.hitEffectPrefab)
            {
                EffectManager.SimpleImpactEffect(this.hitEffectPrefab, hitInfo.point, this.HitEffectNormal ? hitInfo.surfaceNormal : (-hitInfo.direction), true);
            }
            if (hitInfo.collider)
            {
                SurfaceDef objectSurfaceDef = SurfaceDefProvider.GetObjectSurfaceDef(hitInfo.collider, hitInfo.point);
                if (objectSurfaceDef && objectSurfaceDef.impactEffectPrefab)
                {
                    EffectData effectData = new EffectData
                    {
                        origin          = hitInfo.point,
                        rotation        = Quaternion.LookRotation(hitInfo.surfaceNormal),
                        color           = objectSurfaceDef.approximateColor,
                        surfaceDefIndex = objectSurfaceDef.surfaceDefIndex
                    };
                    EffectManager.SpawnEffect(objectSurfaceDef.impactEffectPrefab, effectData, true);
                }
            }
            if (this.isCrit)
            {
                EffectManager.SimpleImpactEffect(Resources.Load <GameObject>("Prefabs/Effects/ImpactEffects/Critspark"), hitInfo.point, this.HitEffectNormal ? hitInfo.surfaceNormal : (-hitInfo.direction), true);
            }
            GameObject entityObject = hitInfo.entityObject;

            if (entityObject)
            {
                float num = 1f;
                switch (this.falloffModel)
                {
                case BulletAttack.FalloffModel.None:
                    num = 1f;
                    break;

                case BulletAttack.FalloffModel.DefaultBullet:
                    num = 0.5f + Mathf.Clamp01(Mathf.InverseLerp(60f, 25f, hitInfo.distance)) * 0.5f;
                    break;

                case BulletAttack.FalloffModel.Buckshot:
                    num = 0.25f + Mathf.Clamp01(Mathf.InverseLerp(25f, 7f, hitInfo.distance)) * 0.75f;
                    break;
                }
                DamageInfo damageInfo = new DamageInfo();
                damageInfo.damage           = this.damage * num;
                damageInfo.crit             = this.isCrit;
                damageInfo.attacker         = this.owner;
                damageInfo.inflictor        = this.weapon;
                damageInfo.position         = hitInfo.point;
                damageInfo.force            = hitInfo.direction * (this.force * num);
                damageInfo.procChainMask    = this.procChainMask;
                damageInfo.procCoefficient  = this.procCoefficient;
                damageInfo.damageType       = this.damageType;
                damageInfo.damageColorIndex = this.damageColorIndex;
                damageInfo.ModifyDamageInfo(hitInfo.damageModifier);
                TeamIndex teamIndex = TeamIndex.Neutral;
                if (this.owner)
                {
                    TeamComponent component = this.owner.GetComponent <TeamComponent>();
                    if (component)
                    {
                        teamIndex = component.teamIndex;
                    }
                }
                TeamIndex     teamIndex2 = TeamIndex.Neutral;
                TeamComponent component2 = hitInfo.entityObject.GetComponent <TeamComponent>();
                if (component2)
                {
                    teamIndex2 = component2.teamIndex;
                }
                bool            flag            = teamIndex == teamIndex2;
                HealthComponent healthComponent = null;
                if (!flag)
                {
                    healthComponent = entityObject.GetComponent <HealthComponent>();
                }
                if (NetworkServer.active)
                {
                    if (healthComponent)
                    {
                        healthComponent.TakeDamage(damageInfo);
                        GlobalEventManager.instance.OnHitEnemy(damageInfo, hitInfo.entityObject);
                    }
                    GlobalEventManager.instance.OnHitAll(damageInfo, hitInfo.entityObject);
                }
                else if (ClientScene.ready)
                {
                    BulletAttack.messageWriter.StartMessage(53);
                    BulletAttack.messageWriter.Write(entityObject);
                    BulletAttack.messageWriter.Write(damageInfo);
                    BulletAttack.messageWriter.Write(healthComponent != null);
                    BulletAttack.messageWriter.FinishMessage();
                    ClientScene.readyConnection.SendWriter(BulletAttack.messageWriter, QosChannelIndex.defaultReliable.intVal);
                }
            }
            return(result);
        }