Ejemplo n.º 1
0
 public void tellEffectPoint(CSteamID steamID, ushort id, Vector3 point)
 {
     if (base.channel.checkServer(steamID))
     {
         EffectManager.effect(id, point, Vector3.up);
     }
 }
Ejemplo n.º 2
0
 private void OnTriggerEnter(Collider other)
 {
     if (this.isExploded)
     {
         return;
     }
     if (other.isTrigger)
     {
         return;
     }
     if (other.transform.CompareTag("Agent"))
     {
         return;
     }
     this.isExploded = true;
     if (Provider.isServer)
     {
         if (Dedicator.isDedicated)
         {
             EffectManager.effect(121, this.lastPos, Vector3.up);
         }
         EffectManager.sendEffectReliable(121, EffectManager.LARGE, this.lastPos);
     }
     Object.Destroy(base.transform.parent.gameObject);
 }
 // Token: 0x06002174 RID: 8564 RVA: 0x000B6D78 File Offset: 0x000B5178
 public override void use()
 {
     if (base.objectAsset.interactabilityEffect != 0 && Time.realtimeSinceStartup - this.lastEffect > 1f)
     {
         this.lastEffect = Time.realtimeSinceStartup;
         Transform transform = base.transform.FindChild("Effect");
         if (transform != null)
         {
             EffectManager.effect(base.objectAsset.interactabilityEffect, transform.position, transform.forward);
         }
         else
         {
             EffectManager.effect(base.objectAsset.interactabilityEffect, base.transform.position, base.transform.forward);
         }
     }
     ObjectManager.useObjectQuest(base.transform);
     if (!Provider.isServer)
     {
         base.objectAsset.applyInteractabilityConditions(Player.player, false);
         base.objectAsset.grantInteractabilityRewards(Player.player, false);
     }
 }
Ejemplo n.º 4
0
        // Token: 0x0600280E RID: 10254 RVA: 0x000F2934 File Offset: 0x000F0D34
        public static Transform effect(ushort id, Vector3 point, Vector3 normal)
        {
            EffectAsset effectAsset = (EffectAsset)Assets.find(EAssetType.EFFECT, id);

            if (effectAsset == null)
            {
                return(null);
            }
            if (effectAsset.splatterTemperature != EPlayerTemperature.NONE)
            {
                Transform transform = new GameObject().transform;
                transform.name       = "Temperature";
                transform.parent     = Level.effects;
                transform.position   = point + Vector3.down * -2f;
                transform.localScale = Vector3.one * 6f;
                transform.gameObject.SetActive(false);
                transform.gameObject.AddComponent <TemperatureTrigger>().temperature = effectAsset.splatterTemperature;
                transform.gameObject.SetActive(true);
                UnityEngine.Object.Destroy(transform.gameObject, effectAsset.splatterLifetime - effectAsset.splatterLifetimeSpread);
            }
            if (Dedicator.isDedicated)
            {
                if (!effectAsset.spawnOnDedicatedServer)
                {
                    return(null);
                }
            }
            else if (GraphicsSettings.effectQuality == EGraphicQuality.OFF && !effectAsset.splatterLiquid)
            {
                return(null);
            }
            Quaternion quaternion = Quaternion.LookRotation(normal);

            if (effectAsset.randomizeRotation)
            {
                quaternion *= Quaternion.Euler(0f, 0f, (float)UnityEngine.Random.Range(0, 360));
            }
            Transform transform2 = EffectManager.pool.Instantiate(effectAsset.effect, point, quaternion).transform;

            transform2.name   = id.ToString();
            transform2.parent = Level.effects;
            if (effectAsset.splatter > 0 && (!effectAsset.gore || OptionsSettings.gore))
            {
                for (int i = 0; i < (int)(effectAsset.splatter * ((effectAsset.splatterLiquid || !(Player.player != null) || Player.player.skills.boost != EPlayerBoost.SPLATTERIFIC) ? 1 : 8)); i++)
                {
                    RaycastHit raycastHit;
                    if (effectAsset.splatterLiquid)
                    {
                        float f        = UnityEngine.Random.Range(0f, 6.28318548f);
                        float num      = UnityEngine.Random.Range(1f, 6f);
                        Ray   ray      = new Ray(point + new Vector3(Mathf.Cos(f) * num, 0f, Mathf.Sin(f) * num), Vector3.down);
                        int   splatter = RayMasks.SPLATTER;
                        LandscapeHoleUtility.raycastIgnoreLandscapeIfNecessary(ray, 8f, ref splatter);
                        Physics.Raycast(ray, out raycastHit, 8f, splatter);
                    }
                    else
                    {
                        Ray ray2      = new Ray(point, -2f * normal + new Vector3(UnityEngine.Random.Range(-1f, 1f), UnityEngine.Random.Range(-1f, 1f), UnityEngine.Random.Range(-1f, 1f)));
                        int splatter2 = RayMasks.SPLATTER;
                        LandscapeHoleUtility.raycastIgnoreLandscapeIfNecessary(ray2, 8f, ref splatter2);
                        Physics.Raycast(ray2, out raycastHit, 8f, splatter2);
                    }
                    if (raycastHit.transform != null)
                    {
                        EPhysicsMaterial material = DamageTool.getMaterial(raycastHit.point, raycastHit.transform, raycastHit.collider);
                        if (!PhysicsTool.isMaterialDynamic(material))
                        {
                            float     num2       = UnityEngine.Random.Range(1f, 2f);
                            Transform transform3 = EffectManager.pool.Instantiate(effectAsset.splatters[UnityEngine.Random.Range(0, effectAsset.splatters.Length)], raycastHit.point + raycastHit.normal * UnityEngine.Random.Range(0.04f, 0.06f), Quaternion.LookRotation(raycastHit.normal) * Quaternion.Euler(0f, 0f, (float)UnityEngine.Random.Range(0, 360))).transform;
                            transform3.name       = "Splatter";
                            transform3.parent     = Level.effects;
                            transform3.localScale = new Vector3(num2, num2, num2);
                            transform3.gameObject.SetActive(true);
                            if (effectAsset.splatterLifetime > 1.401298E-45f)
                            {
                                EffectManager.pool.Destroy(transform3.gameObject, effectAsset.splatterLifetime + UnityEngine.Random.Range(-effectAsset.splatterLifetimeSpread, effectAsset.splatterLifetimeSpread));
                            }
                            else
                            {
                                EffectManager.pool.Destroy(transform3.gameObject, GraphicsSettings.effect);
                            }
                        }
                    }
                }
            }
            if (effectAsset.gore)
            {
                transform2.GetComponent <ParticleSystem>().emission.enabled = OptionsSettings.gore;
            }
            if (!effectAsset.isStatic && transform2.GetComponent <AudioSource>() != null)
            {
                transform2.GetComponent <AudioSource>().pitch = UnityEngine.Random.Range(0.9f, 1.1f);
            }
            if (effectAsset.lifetime > 1.401298E-45f)
            {
                EffectManager.pool.Destroy(transform2.gameObject, effectAsset.lifetime + UnityEngine.Random.Range(-effectAsset.lifetimeSpread, effectAsset.lifetimeSpread));
            }
            else
            {
                float        num3      = 0f;
                MeshRenderer component = transform2.GetComponent <MeshRenderer>();
                if (component == null)
                {
                    ParticleSystem component2 = transform2.GetComponent <ParticleSystem>();
                    if (component2 != null)
                    {
                        if (component2.main.loop)
                        {
                            num3 = component2.main.startLifetime.constantMax;
                        }
                        else
                        {
                            num3 = component2.main.duration + component2.main.startLifetime.constantMax;
                        }
                    }
                    AudioSource component3 = transform2.GetComponent <AudioSource>();
                    if (component3 != null && component3.clip != null && component3.clip.length > num3)
                    {
                        num3 = component3.clip.length;
                    }
                }
                if (num3 < 1.401298E-45f)
                {
                    num3 = GraphicsSettings.effect;
                }
                EffectManager.pool.Destroy(transform2.gameObject, num3);
            }
            if (effectAsset.blast > 0 && GraphicsSettings.blast && GraphicsSettings.renderMode == ERenderMode.DEFERRED)
            {
                EffectManager.effect(effectAsset.blast, point, new Vector3(UnityEngine.Random.Range(-0.1f, 0.1f), 1f, UnityEngine.Random.Range(-0.1f, 0.1f)));
            }
            return(transform2);
        }
        public void updateRubble(byte section, bool isAlive, bool playEffect, Vector3 ragdoll)
        {
            RubbleInfo rubbleInfo = this.rubbleInfos[(int)section];

            if (isAlive)
            {
                rubbleInfo.health = this.asset.rubbleHealth;
            }
            else
            {
                rubbleInfo.lastDead = Time.realtimeSinceStartup;
                rubbleInfo.health   = 0;
            }
            bool flag = this.isAllDead();

            if (rubbleInfo.aliveGameObject != null)
            {
                rubbleInfo.aliveGameObject.SetActive(!rubbleInfo.isDead);
            }
            if (rubbleInfo.deadGameObject != null)
            {
                rubbleInfo.deadGameObject.SetActive(rubbleInfo.isDead && (!flag || this.asset.rubbleFinale == 0));
            }
            if (this.aliveGameObject != null)
            {
                this.aliveGameObject.SetActive(!flag);
            }
            if (this.deadGameObject != null)
            {
                this.deadGameObject.SetActive(flag);
            }
            if (!Dedicator.isDedicated && playEffect)
            {
                if (rubbleInfo.ragdolls != null && GraphicsSettings.debris && rubbleInfo.isDead)
                {
                    for (int i = 0; i < rubbleInfo.ragdolls.Length; i++)
                    {
                        RubbleRagdollInfo rubbleRagdollInfo = rubbleInfo.ragdolls[i];
                        if (rubbleRagdollInfo != null)
                        {
                            Vector3 vector = ragdoll;
                            if (rubbleRagdollInfo.forceTransform != null)
                            {
                                vector  = rubbleRagdollInfo.forceTransform.forward * vector.magnitude * rubbleRagdollInfo.forceTransform.localScale.z;
                                vector += rubbleRagdollInfo.forceTransform.right * Random.Range(-16f, 16f) * rubbleRagdollInfo.forceTransform.localScale.x;
                                vector += rubbleRagdollInfo.forceTransform.up * Random.Range(-16f, 16f) * rubbleRagdollInfo.forceTransform.localScale.y;
                            }
                            else
                            {
                                vector.y += 8f;
                                vector.x += Random.Range(-16f, 16f);
                                vector.z += Random.Range(-16f, 16f);
                            }
                            vector *= (float)((!(Player.player != null) || Player.player.skills.boost != EPlayerBoost.FLIGHT) ? 2 : 4);
                            GameObject gameObject = Object.Instantiate <GameObject>(rubbleRagdollInfo.ragdollGameObject, rubbleRagdollInfo.ragdollGameObject.transform.position, rubbleRagdollInfo.ragdollGameObject.transform.rotation);
                            gameObject.name                 = "Ragdoll";
                            gameObject.transform.parent     = Level.effects;
                            gameObject.transform.localScale = base.transform.localScale;
                            gameObject.SetActive(true);
                            gameObject.gameObject.AddComponent <Rigidbody>();
                            gameObject.GetComponent <Rigidbody>().interpolation          = 1;
                            gameObject.GetComponent <Rigidbody>().collisionDetectionMode = 0;
                            gameObject.GetComponent <Rigidbody>().AddForce(vector);
                            gameObject.GetComponent <Rigidbody>().drag        = 0.5f;
                            gameObject.GetComponent <Rigidbody>().angularDrag = 0.1f;
                            Object.Destroy(gameObject, 8f);
                        }
                    }
                }
                if (this.asset.rubbleEffect != 0 && rubbleInfo.isDead)
                {
                    if (rubbleInfo.effectTransform != null)
                    {
                        EffectManager.effect(this.asset.rubbleEffect, rubbleInfo.effectTransform.position, rubbleInfo.effectTransform.forward);
                    }
                    else
                    {
                        EffectManager.effect(this.asset.rubbleEffect, rubbleInfo.section.position, Vector3.up);
                    }
                }
                if (this.asset.rubbleFinale != 0 && flag)
                {
                    if (this.finaleTransform != null)
                    {
                        EffectManager.effect(this.asset.rubbleFinale, this.finaleTransform.position, this.finaleTransform.forward);
                    }
                    else
                    {
                        EffectManager.effect(this.asset.rubbleFinale, base.transform.position, Vector3.up);
                    }
                }
            }
        }
Ejemplo n.º 6
0
        // Token: 0x0600339D RID: 13213 RVA: 0x0014ECF0 File Offset: 0x0014D0F0
        private void OnTriggerEnter(Collider other)
        {
            if (this.isExploded)
            {
                return;
            }
            if (other.isTrigger)
            {
                return;
            }
            if (other.transform.CompareTag("Agent"))
            {
                return;
            }
            this.isExploded = true;
            Vector3 normalized = (base.transform.position - this.lastPos).normalized;

            if (Provider.isServer)
            {
                float num = Mathf.Clamp(base.transform.parent.GetComponent <Rigidbody>().velocity.magnitude, 0f, 20f);
                if (num < 3f)
                {
                    return;
                }
                if (other.transform.CompareTag("Player"))
                {
                    Player player = DamageTool.getPlayer(other.transform);
                    if (player != null)
                    {
                        EPlayerKill eplayerKill;
                        DamageTool.damage(player, EDeathCause.BOULDER, ELimb.SPINE, CSteamID.Nil, normalized, Boulder.DAMAGE_PLAYER, num, out eplayerKill);
                    }
                }
                else if (other.transform.CompareTag("Vehicle"))
                {
                    InteractableVehicle component = other.transform.GetComponent <InteractableVehicle>();
                    if (component != null && component.asset != null && component.asset.isVulnerableToEnvironment)
                    {
                        VehicleManager.damage(component, Boulder.DAMAGE_VEHICLE, num, true);
                    }
                }
                else if (other.transform.CompareTag("Barricade"))
                {
                    Transform             transform  = other.transform;
                    InteractableDoorHinge component2 = transform.GetComponent <InteractableDoorHinge>();
                    if (component2 != null)
                    {
                        transform = component2.transform.parent.parent;
                    }
                    BarricadeManager.damage(transform, Boulder.DAMAGE_BARRICADE, num, true);
                }
                else if (other.transform.CompareTag("Structure"))
                {
                    StructureManager.damage(other.transform, normalized, Boulder.DAMAGE_STRUCTURE, num, true);
                }
                else if (other.transform.CompareTag("Resource"))
                {
                    EPlayerKill eplayerKill2;
                    uint        num2;
                    ResourceManager.damage(other.transform, normalized, Boulder.DAMAGE_RESOURCE, num, 1f, out eplayerKill2, out num2);
                }
                else
                {
                    InteractableObjectRubble componentInParent = other.transform.GetComponentInParent <InteractableObjectRubble>();
                    if (componentInParent != null)
                    {
                        EPlayerKill eplayerKill3;
                        uint        num3;
                        DamageTool.damage(componentInParent.transform, normalized, componentInParent.getSection(other.transform), Boulder.DAMAGE_OBJECT, num, out eplayerKill3, out num3);
                    }
                }
            }
            if (!Dedicator.isDedicated)
            {
                EffectManager.effect(52, base.transform.position, -normalized);
            }
        }
Ejemplo n.º 7
0
        private void Update()
        {
            if (Provider.isServer && this.power != null && this.power.isWired)
            {
                Vector3 vector = base.transform.position + new Vector3(0f, 0.65f, 0f);
                if (Time.realtimeSinceStartup - this.lastScan > 0.1f)
                {
                    this.lastScan = Time.realtimeSinceStartup;
                    float num = 48f;
                    if (this.hasWeapon)
                    {
                        num = Mathf.Min(num, ((ItemWeaponAsset)this.displayAsset).range);
                    }
                    float  num2   = num * num;
                    float  num3   = num2;
                    Player player = null;
                    Zombie zombie = null;
                    if (Provider.isPvP)
                    {
                        InteractableSentry.playersInRadius.Clear();
                        PlayerTool.getPlayersInRadius(vector, num2, InteractableSentry.playersInRadius);
                        for (int i = 0; i < InteractableSentry.playersInRadius.Count; i++)
                        {
                            Player player2 = InteractableSentry.playersInRadius[i];
                            if (!(player2.channel.owner.playerID.steamID == base.owner) && !player2.quests.isMemberOfGroup(base.group))
                            {
                                if (!player2.life.isDead && player2.animator.gesture != EPlayerGesture.ARREST_START)
                                {
                                    if ((!player2.movement.isSafe || !player2.movement.isSafeInfo.noWeapons) && player2.movement.canAddSimulationResultsToUpdates)
                                    {
                                        if (!(player != null) || player2.animator.gesture != EPlayerGesture.SURRENDER_START)
                                        {
                                            if (this.sentryMode != ESentryMode.FRIENDLY || Time.realtimeSinceStartup - player2.equipment.lastPunching <= 2f || (player2.equipment.isSelected && player2.equipment.asset != null && player2.equipment.asset.isDangerous))
                                            {
                                                float sqrMagnitude = (player2.look.aim.position - vector).sqrMagnitude;
                                                if (sqrMagnitude <= num3)
                                                {
                                                    Vector3 vector2   = player2.look.aim.position - vector;
                                                    float   magnitude = vector2.magnitude;
                                                    Vector3 vector3   = vector2 / magnitude;
                                                    if (!(player2 != this.targetPlayer) || Vector3.Dot(vector3, this.aimTransform.forward) >= 0.5f)
                                                    {
                                                        if (magnitude > 0.025f)
                                                        {
                                                            RaycastHit raycastHit;
                                                            PhysicsUtility.raycast(new Ray(vector, vector3), out raycastHit, magnitude - 0.025f, RayMasks.BLOCK_SENTRY, 0);
                                                            if (raycastHit.transform != null && raycastHit.transform != base.transform)
                                                            {
                                                                goto IL_35F;
                                                            }
                                                            PhysicsUtility.raycast(new Ray(vector + vector3 * (magnitude - 0.025f), -vector3), out raycastHit, magnitude - 0.025f, RayMasks.DAMAGE_SERVER, 0);
                                                            if (raycastHit.transform != null && raycastHit.transform != base.transform)
                                                            {
                                                                goto IL_35F;
                                                            }
                                                        }
                                                        num3   = sqrMagnitude;
                                                        player = player2;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            IL_35F :;
                        }
                    }
                    InteractableSentry.zombiesInRadius.Clear();
                    ZombieManager.getZombiesInRadius(vector, num2, InteractableSentry.zombiesInRadius);
                    for (int j = 0; j < InteractableSentry.zombiesInRadius.Count; j++)
                    {
                        Zombie zombie2 = InteractableSentry.zombiesInRadius[j];
                        if (!zombie2.isDead && zombie2.isHunting)
                        {
                            Vector3 vector4 = zombie2.transform.position;
                            switch (zombie2.speciality)
                            {
                            case EZombieSpeciality.NORMAL:
                                vector4 += new Vector3(0f, 1.75f, 0f);
                                break;

                            case EZombieSpeciality.MEGA:
                                vector4 += new Vector3(0f, 2.625f, 0f);
                                break;

                            case EZombieSpeciality.CRAWLER:
                                vector4 += new Vector3(0f, 0.25f, 0f);
                                break;

                            case EZombieSpeciality.SPRINTER:
                                vector4 += new Vector3(0f, 1f, 0f);
                                break;
                            }
                            float sqrMagnitude2 = (vector4 - vector).sqrMagnitude;
                            if (sqrMagnitude2 <= num3)
                            {
                                Vector3 vector5    = vector4 - vector;
                                float   magnitude2 = vector5.magnitude;
                                Vector3 vector6    = vector5 / magnitude2;
                                if (!(zombie2 != this.targetZombie) || Vector3.Dot(vector6, this.aimTransform.forward) >= 0.5f)
                                {
                                    if (magnitude2 > 0.025f)
                                    {
                                        RaycastHit raycastHit2;
                                        PhysicsUtility.raycast(new Ray(vector, vector6), out raycastHit2, magnitude2 - 0.025f, RayMasks.BLOCK_SENTRY, 0);
                                        if (raycastHit2.transform != null && raycastHit2.transform != base.transform)
                                        {
                                            goto IL_5B4;
                                        }
                                        PhysicsUtility.raycast(new Ray(vector + vector6 * (magnitude2 - 0.025f), -vector6), out raycastHit2, magnitude2 - 0.025f, RayMasks.DAMAGE_SERVER, 0);
                                        if (raycastHit2.transform != null && raycastHit2.transform != base.transform)
                                        {
                                            goto IL_5B4;
                                        }
                                    }
                                    num3   = sqrMagnitude2;
                                    player = null;
                                    zombie = zombie2;
                                }
                            }
                        }
                        IL_5B4 :;
                    }
                    if (player != this.targetPlayer || zombie != this.targetZombie)
                    {
                        this.targetPlayer = player;
                        this.targetZombie = zombie;
                        this.lastFire     = Time.realtimeSinceStartup + 0.1f;
                    }
                }
                if (this.targetPlayer != null)
                {
                    ESentryMode esentryMode = this.sentryMode;
                    if (esentryMode != ESentryMode.FRIENDLY && esentryMode != ESentryMode.NEUTRAL)
                    {
                        if (esentryMode == ESentryMode.HOSTILE)
                        {
                            this.isFiring = true;
                        }
                    }
                    else
                    {
                        this.isFiring = (this.targetPlayer.animator.gesture != EPlayerGesture.SURRENDER_START);
                    }
                    this.isAiming = true;
                }
                else if (this.targetZombie != null)
                {
                    this.isFiring = true;
                    this.isAiming = true;
                }
                else
                {
                    this.isFiring = false;
                    this.isAiming = false;
                }
                if (this.isAiming && Time.realtimeSinceStartup - this.lastAim > Provider.UPDATE_TIME)
                {
                    this.lastAim = Time.realtimeSinceStartup;
                    Transform transform = null;
                    Vector3   vector7   = Vector3.zero;
                    if (this.targetPlayer != null)
                    {
                        transform = this.targetPlayer.transform;
                        vector7   = this.targetPlayer.look.aim.position;
                    }
                    else if (this.targetZombie != null)
                    {
                        transform = this.targetZombie.transform;
                        vector7   = this.targetZombie.transform.position;
                        switch (this.targetZombie.speciality)
                        {
                        case EZombieSpeciality.NORMAL:
                            vector7 += new Vector3(0f, 1.75f, 0f);
                            break;

                        case EZombieSpeciality.MEGA:
                            vector7 += new Vector3(0f, 2.625f, 0f);
                            break;

                        case EZombieSpeciality.CRAWLER:
                            vector7 += new Vector3(0f, 0.25f, 0f);
                            break;

                        case EZombieSpeciality.SPRINTER:
                            vector7 += new Vector3(0f, 1f, 0f);
                            break;
                        }
                    }
                    if (transform != null)
                    {
                        float num4 = Mathf.Atan2(vector7.x - vector.x, vector7.z - vector.z) * 57.29578f;
                        float num5 = Mathf.Sin((vector7.y - vector.y) / (vector7 - vector).magnitude) * 57.29578f;
                        BarricadeManager.sendAlertSentry(base.transform, num4, num5);
                    }
                }
                if (this.isFiring && this.hasWeapon && this.displayItem.state[10] > 0 && !this.isOpen && Time.realtimeSinceStartup - this.lastFire > this.fireTime)
                {
                    this.lastFire += this.fireTime;
                    if (Time.realtimeSinceStartup - this.lastFire > this.fireTime)
                    {
                        this.lastFire = Time.realtimeSinceStartup;
                    }
                    float num6 = (float)this.displayItem.quality / 100f;
                    if (this.attachments.magazineAsset == null)
                    {
                        return;
                    }
                    byte[] state = this.displayItem.state;
                    int    num7  = 10;
                    state[num7] -= 1;
                    if (this.attachments.barrelAsset == null || !this.attachments.barrelAsset.isSilenced || this.displayItem.state[16] == 0)
                    {
                        AlertTool.alert(base.transform.position, 48f);
                    }
                    if (Provider.modeConfigData.Items.Has_Durability && this.displayItem.quality > 0 && Random.value < ((ItemWeaponAsset)this.displayAsset).durability)
                    {
                        if (this.displayItem.quality > ((ItemWeaponAsset)this.displayAsset).wear)
                        {
                            Item displayItem = this.displayItem;
                            displayItem.quality -= ((ItemWeaponAsset)this.displayAsset).wear;
                        }
                        else
                        {
                            this.displayItem.quality = 0;
                        }
                    }
                    float num8 = ((ItemGunAsset)this.displayAsset).spreadAim * ((num6 >= 0.5f) ? 1f : (1f + (1f - num6 * 2f)));
                    if (this.attachments.tacticalAsset != null && this.interact)
                    {
                        num8 *= this.attachments.tacticalAsset.spread;
                    }
                    if (this.attachments.gripAsset != null)
                    {
                        num8 *= this.attachments.gripAsset.spread;
                    }
                    if (this.attachments.barrelAsset != null)
                    {
                        num8 *= this.attachments.barrelAsset.spread;
                    }
                    if (this.attachments.magazineAsset != null)
                    {
                        num8 *= this.attachments.magazineAsset.spread;
                    }
                    if (((ItemGunAsset)this.displayAsset).projectile == null)
                    {
                        BarricadeManager.sendShootSentry(base.transform);
                        byte pellets = this.attachments.magazineAsset.pellets;
                        for (byte b = 0; b < pellets; b += 1)
                        {
                            EPlayerKill eplayerKill = EPlayerKill.NONE;
                            uint        num9        = 0u;
                            float       num10       = 1f;
                            num10 *= ((num6 >= 0.5f) ? 1f : (0.5f + num6));
                            Transform transform2;
                            float     magnitude3;
                            if (this.targetPlayer != null)
                            {
                                transform2 = this.targetPlayer.transform;
                                magnitude3 = (transform2.position - base.transform.position).magnitude;
                            }
                            else
                            {
                                transform2 = this.targetZombie.transform;
                                magnitude3 = (transform2.position - base.transform.position).magnitude;
                            }
                            float num11 = magnitude3 / ((ItemWeaponAsset)this.displayAsset).range;
                            num11  = 1f - num11;
                            num11 *= 1f - ((ItemGunAsset)this.displayAsset).spreadHip;
                            num11 *= 0.75f;
                            if (transform2 == null || Random.value > num11)
                            {
                                Vector3 vector8 = this.aimTransform.forward;
                                vector8 += this.aimTransform.right * Random.Range(-((ItemGunAsset)this.displayAsset).spreadHip, ((ItemGunAsset)this.displayAsset).spreadHip) * num8;
                                vector8 += this.aimTransform.up * Random.Range(-((ItemGunAsset)this.displayAsset).spreadHip, ((ItemGunAsset)this.displayAsset).spreadHip) * num8;
                                vector8.Normalize();
                                Ray ray;
                                ray..ctor(this.aimTransform.position, vector8);
                                RaycastInfo raycastInfo = DamageTool.raycast(ray, ((ItemWeaponAsset)this.displayAsset).range, RayMasks.DAMAGE_SERVER);
                                if (!(raycastInfo.transform == null))
                                {
                                    DamageTool.impact(raycastInfo.point, raycastInfo.normal, raycastInfo.material, raycastInfo.vehicle != null || raycastInfo.transform.CompareTag("Barricade") || raycastInfo.transform.CompareTag("Structure") || raycastInfo.transform.CompareTag("Resource"));
                                    if (raycastInfo.vehicle != null)
                                    {
                                        DamageTool.damage(raycastInfo.vehicle, false, Vector3.zero, false, ((ItemGunAsset)this.displayAsset).vehicleDamage, num10, true, out eplayerKill);
                                    }
                                    else if (raycastInfo.transform != null)
                                    {
                                        if (raycastInfo.transform.CompareTag("Barricade"))
                                        {
                                            ushort id;
                                            if (ushort.TryParse(raycastInfo.transform.name, out id))
                                            {
                                                ItemBarricadeAsset itemBarricadeAsset = (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, id);
                                                if (itemBarricadeAsset != null && (itemBarricadeAsset.isVulnerable || ((ItemWeaponAsset)this.displayAsset).isInvulnerable))
                                                {
                                                    DamageTool.damage(raycastInfo.transform, false, ((ItemGunAsset)this.displayAsset).barricadeDamage, num10, out eplayerKill);
                                                }
                                            }
                                        }
                                        else if (raycastInfo.transform.CompareTag("Structure"))
                                        {
                                            ushort id2;
                                            if (ushort.TryParse(raycastInfo.transform.name, out id2))
                                            {
                                                ItemStructureAsset itemStructureAsset = (ItemStructureAsset)Assets.find(EAssetType.ITEM, id2);
                                                if (itemStructureAsset != null && (itemStructureAsset.isVulnerable || ((ItemWeaponAsset)this.displayAsset).isInvulnerable))
                                                {
                                                    DamageTool.damage(raycastInfo.transform, false, raycastInfo.direction * Mathf.Ceil((float)this.attachments.magazineAsset.pellets / 2f), ((ItemGunAsset)this.displayAsset).structureDamage, num10, out eplayerKill);
                                                }
                                            }
                                        }
                                        else if (raycastInfo.transform.CompareTag("Resource"))
                                        {
                                            byte   x;
                                            byte   y;
                                            ushort index;
                                            if (ResourceManager.tryGetRegion(raycastInfo.transform, out x, out y, out index))
                                            {
                                                ResourceSpawnpoint resourceSpawnpoint = ResourceManager.getResourceSpawnpoint(x, y, index);
                                                if (resourceSpawnpoint != null && !resourceSpawnpoint.isDead && resourceSpawnpoint.asset.bladeID == ((ItemWeaponAsset)this.displayAsset).bladeID)
                                                {
                                                    DamageTool.damage(raycastInfo.transform, raycastInfo.direction * Mathf.Ceil((float)this.attachments.magazineAsset.pellets / 2f), ((ItemGunAsset)this.displayAsset).resourceDamage, num10, 1f, out eplayerKill, out num9);
                                                }
                                            }
                                        }
                                        else if (raycastInfo.section < 255)
                                        {
                                            InteractableObjectRubble component = raycastInfo.transform.GetComponent <InteractableObjectRubble>();
                                            if (component != null && !component.isSectionDead(raycastInfo.section) && (component.asset.rubbleIsVulnerable || ((ItemWeaponAsset)this.displayAsset).isInvulnerable))
                                            {
                                                DamageTool.damage(raycastInfo.transform, raycastInfo.direction, raycastInfo.section, ((ItemGunAsset)this.displayAsset).objectDamage, num10, out eplayerKill, out num9);
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                Vector3 vector9 = Vector3.zero;
                                if (this.targetPlayer != null)
                                {
                                    vector9 = this.targetPlayer.look.aim.position;
                                }
                                else if (this.targetZombie != null)
                                {
                                    vector9 = this.targetZombie.transform.position;
                                    switch (this.targetZombie.speciality)
                                    {
                                    case EZombieSpeciality.NORMAL:
                                        vector9 += new Vector3(0f, 1.75f, 0f);
                                        break;

                                    case EZombieSpeciality.MEGA:
                                        vector9 += new Vector3(0f, 2.625f, 0f);
                                        break;

                                    case EZombieSpeciality.CRAWLER:
                                        vector9 += new Vector3(0f, 0.25f, 0f);
                                        break;

                                    case EZombieSpeciality.SPRINTER:
                                        vector9 += new Vector3(0f, 1f, 0f);
                                        break;
                                    }
                                }
                                DamageTool.impact(vector9, -this.aimTransform.forward, EPhysicsMaterial.FLESH_DYNAMIC, true);
                                if (this.targetPlayer != null)
                                {
                                    DamageTool.damage(this.targetPlayer, EDeathCause.SENTRY, ELimb.SPINE, base.owner, this.aimTransform.forward * Mathf.Ceil((float)this.attachments.magazineAsset.pellets / 2f), ((ItemGunAsset)this.displayAsset).playerDamageMultiplier, num10, true, out eplayerKill);
                                }
                                else if (this.targetZombie != null)
                                {
                                    DamageTool.damage(this.targetZombie, ELimb.SPINE, this.aimTransform.forward * Mathf.Ceil((float)this.attachments.magazineAsset.pellets / 2f), ((ItemGunAsset)this.displayAsset).zombieDamageMultiplier, num10, true, out eplayerKill, out num9);
                                }
                            }
                        }
                    }
                    base.rebuildState();
                }
            }
            bool flag = Time.realtimeSinceStartup - this.lastAlert < 1f;

            if (flag != this.isAlert)
            {
                this.isAlert = flag;
                if (!Dedicator.isDedicated)
                {
                    if (this.isAlert)
                    {
                        EffectManager.effect(92, base.transform.position, Vector3.up);
                    }
                    else
                    {
                        EffectManager.effect(93, base.transform.position, Vector3.up);
                    }
                }
                if (!this.isAlert)
                {
                    this.targetYaw = base.transform.localRotation.eulerAngles.y;
                }
            }
            if (this.power != null)
            {
                if (this.power.isWired)
                {
                    if (this.isAlert)
                    {
                        this.lastDrift = Time.realtimeSinceStartup;
                        this.yaw       = Mathf.LerpAngle(this.yaw, this.targetYaw, 4f * Time.deltaTime);
                    }
                    else
                    {
                        this.yaw = Mathf.LerpAngle(this.yaw, this.targetYaw + Mathf.Sin(Time.realtimeSinceStartup - this.lastDrift) * 60f, 4f * Time.deltaTime);
                    }
                    this.pitch = Mathf.LerpAngle(this.pitch, this.targetPitch, 4f * Time.deltaTime);
                    this.yawTransform.rotation        = Quaternion.Euler(-90f, 0f, this.yaw);
                    this.pitchTransform.localRotation = Quaternion.Euler(0f, -90f, this.pitch);
                }
                if (!Dedicator.isDedicated)
                {
                    if (this.onGameObject != null)
                    {
                        this.onGameObject.SetActive(this.isAlert && this.power.isWired);
                    }
                    if (this.onModelGameObject != null)
                    {
                        this.onModelGameObject.SetActive(this.isAlert);
                        if (this.onMaterial != null)
                        {
                            this.onMaterial.SetColor("_EmissionColor", (!this.isAlert || !this.power.isWired) ? Color.black : this.onMaterial.color);
                        }
                    }
                    if (this.offGameObject != null)
                    {
                        this.offGameObject.SetActive(!this.isAlert && this.power.isWired);
                    }
                    if (this.offModelGameObject != null)
                    {
                        this.offModelGameObject.SetActive(!this.isAlert);
                        if (this.offMaterial != null)
                        {
                            this.offMaterial.SetColor("_EmissionColor", (this.isAlert || !this.power.isWired) ? Color.black : this.offMaterial.color);
                        }
                    }
                    if ((double)(Time.realtimeSinceStartup - this.lastShot) > 0.05 && this.muzzleEmitter != null)
                    {
                        this.muzzleEmitter.GetComponent <Light>().enabled = false;
                    }
                }
            }
        }