예제 #1
0
 public void Hurt(float percent, GameObject attacker)
 {
     if (percent >= 0.05f)
     {
         this.lastTakeDamageTime = Time.time;
         if (CameraMount.current != null)
         {
             HeadBob component = CameraMount.current.GetComponent <HeadBob>();
             if (component == null)
             {
                 Debug.Log("no camera headbob");
             }
             if (component != null)
             {
                 bool flag;
                 if (attacker != null)
                 {
                     Controllable controllable = attacker.GetComponent <Controllable>();
                     flag = (controllable != null) && (controllable.npcName == "zombie");
                     if (!flag)
                     {
                         flag = attacker.GetComponent <BasicWildLifeAI>() != null;
                     }
                 }
                 else
                 {
                     flag = false;
                 }
                 component.AddEffect(!flag ? this.takeDamageBob : this.meleeBob);
             }
         }
     }
 }
예제 #2
0
    public override void Local_FireWeapon(ViewModel vm, ItemRepresentation itemRep, IBulletWeaponItem itemInstance, ref HumanController.InputSample sample)
    {
        Character character = itemInstance.character;

        if ((character != null) && (itemInstance.clipAmmo > 0))
        {
            Socket muzzle;
            Ray    eyesRay = character.eyesRay;
            int    count   = 1;
            itemInstance.Consume(ref count);
            uLink.BitStream sendStream  = new uLink.BitStream(false);
            float           bulletRange = this.GetBulletRange(itemRep);
            for (int i = 0; i < this.numPellets; i++)
            {
                bool flag;
                Ray  ray = eyesRay;
                ray.direction = (Vector3)((Quaternion.LookRotation(eyesRay.direction) * Quaternion.Euler(UnityEngine.Random.Range(-this.xSpread, this.xSpread), UnityEngine.Random.Range(-this.ySpread, this.ySpread), 0f)) * Vector3.forward);
                Component hitComponent = null;
                this.FireSingleBullet(sendStream, ray, itemRep, out hitComponent, out flag);
                this.MakeTracer(ray.origin, ray.origin + ((Vector3)(ray.direction * bulletRange)), bulletRange, hitComponent, flag);
            }
            itemRep.ActionStream(1, uLink.RPCMode.Server, sendStream);
            bool firstPerson = (bool)vm;
            if (firstPerson)
            {
                muzzle = vm.muzzle;
            }
            else
            {
                muzzle = itemRep.muzzle;
            }
            this.DoWeaponEffects(character.transform, muzzle, firstPerson, itemRep);
            if (firstPerson)
            {
                vm.PlayFireAnimation();
            }
            float num4 = 1f;
            if (sample.aim)
            {
                num4 -= base.aimingRecoilSubtract;
            }
            else if (sample.crouch)
            {
                num4 -= base.crouchRecoilSubtract;
            }
            float            pitch            = UnityEngine.Random.Range(base.recoilPitchMin, base.recoilPitchMax) * num4;
            float            yaw              = UnityEngine.Random.Range(base.recoilYawMin, base.recoilYawMax) * num4;
            RecoilSimulation recoilSimulation = character.recoilSimulation;
            if (recoilSimulation != null)
            {
                recoilSimulation.AddRecoil(base.recoilDuration, pitch, yaw);
            }
            HeadBob bob = CameraMount.current.GetComponent <HeadBob>();
            if ((bob != null) && (base.shotBob != null))
            {
                bob.AddEffect(base.shotBob);
            }
        }
    }
예제 #3
0
 public void FallImpact(float fallspeed)
 {
     this.legBreakSound.Play(base.transform.position, 1f, 3f, 10f);
     if (base.localControlled)
     {
         HeadBob component = CameraMount.current.GetComponent <HeadBob>();
         component.AddEffect(this.fallbob);
     }
 }
예제 #4
0
    public void Hurt(float percent, GameObject attacker)
    {
        bool component;

        if (percent < 0.05f)
        {
            return;
        }
        this.lastTakeDamageTime = Time.time;
        if (CameraMount.current == null)
        {
            return;
        }
        HeadBob headBob = CameraMount.current.GetComponent <HeadBob>();

        if (headBob == null)
        {
            Debug.Log("no camera headbob");
        }
        if (headBob)
        {
            if (!attacker)
            {
                component = false;
            }
            else
            {
                Controllable controllable = attacker.GetComponent <Controllable>();
                component = (!controllable ? false : controllable.npcName == "zombie");
                if (!component)
                {
                    component = attacker.GetComponent <BasicWildLifeAI>() != null;
                }
            }
            headBob.AddEffect((!component ? this.takeDamageBob : this.meleeBob));
        }
    }
예제 #5
0
    public virtual void Local_FireWeapon(ViewModel vm, ItemRepresentation itemRep, IBulletWeaponItem itemInstance, ref HumanController.InputSample sample)
    {
        Component   component;
        Vector3     point;
        RaycastHit2 raycastHit2;
        IDMain      dMain;
        Socket      item;
        bool        flag;
        bool        flag1;
        Component   component1;
        IDMain      dMain1;
        Character   character = itemInstance.character;

        if (character == null)
        {
            return;
        }
        if (itemInstance.clipAmmo <= 0)
        {
            return;
        }
        Ray         ray         = character.eyesRay;
        NetEntityID netEntityID = NetEntityID.unassigned;
        bool        flag2       = false;
        int         num         = 1;

        itemInstance.Consume(ref num);
        bool       flag3      = Physics2.Raycast2(ray, out raycastHit2, this.GetBulletRange(itemRep), 406721553);
        TakeDamage takeDamage = null;

        if (!flag3)
        {
            dMain     = null;
            point     = ray.GetPoint(1000f);
            component = null;
        }
        else
        {
            point = raycastHit2.point;
            IDBase dBase = raycastHit2.id;
            if (!raycastHit2.remoteBodyPart)
            {
                component1 = raycastHit2.collider;
            }
            else
            {
                component1 = raycastHit2.remoteBodyPart;
            }
            component = component1;
            if (!dBase)
            {
                dMain1 = null;
            }
            else
            {
                dMain1 = dBase.idMain;
            }
            dMain = dMain1;
            if (dMain)
            {
                netEntityID = NetEntityID.Get(dMain);
                if (!netEntityID.isUnassigned)
                {
                    flag2      = true;
                    takeDamage = dMain.GetComponent <TakeDamage>();
                    if (takeDamage && takeDamage.ShouldPlayHitNotification())
                    {
                        this.PlayHitNotification(point, character);
                    }
                    bool flag4 = false;
                    if (raycastHit2.remoteBodyPart)
                    {
                        BodyPart bodyPart = raycastHit2.remoteBodyPart.bodyPart;
                        switch (bodyPart)
                        {
                        case BodyPart.Brain:
                        case BodyPart.L_Eye:
                        case BodyPart.R_Eye:
                        {
Label0:
                            flag4 = true;
                            break;
                        }

                        default:
                        {
                            switch (bodyPart)
                            {
                            case BodyPart.Head:
                            case BodyPart.Jaw:
                            {
                                goto Label0;
                            }

                            case BodyPart.Scalp:
                            case BodyPart.Nostrils:
                            {
                                flag4 = false;
                                break;
                            }

                            default:
                            {
                                goto case BodyPart.Nostrils;
                            }
                            }
                            break;
                        }
                        }
                    }
                    if (flag4)
                    {
                        this.headshotSound.Play();
                    }
                }
            }
        }
        if (!flag3)
        {
            flag1 = false;
        }
        else
        {
            flag1 = (!raycastHit2.isHitboxHit || raycastHit2.bodyPart.IsDefined() ? true : takeDamage != null);
        }
        bool flag5 = flag1;

        if (!vm)
        {
            item = itemRep.muzzle;
            flag = false;
        }
        else
        {
            item = vm.socketMap["muzzle"].socket;
            flag = true;
        }
        Vector3 vector3 = item.position;

        this.DoWeaponEffects(character.transform, vector3, point, item, flag, component, flag5, itemRep);
        if (flag)
        {
            vm.PlayFireAnimation();
        }
        float single = 1f;

        if ((!sample.aim ? false : sample.crouch))
        {
            single = single - (this.aimingRecoilSubtract + this.crouchRecoilSubtract * 0.5f);
        }
        else if (sample.aim)
        {
            single = single - this.aimingRecoilSubtract;
        }
        else if (sample.crouch)
        {
            single = single - this.crouchRecoilSubtract;
        }
        single = Mathf.Clamp01(single);
        float single1 = UnityEngine.Random.Range(this.recoilPitchMin, this.recoilPitchMax) * single;
        float single2 = UnityEngine.Random.Range(this.recoilYawMin, this.recoilYawMax) * single;

        if (BulletWeaponDataBlock.weaponRecoil && character.recoilSimulation)
        {
            character.recoilSimulation.AddRecoil(this.recoilDuration, single1, single2);
        }
        HeadBob headBob = CameraMount.current.GetComponent <HeadBob>();

        if (headBob && this.shotBob && BulletWeaponDataBlock.headRecoil)
        {
            headBob.AddEffect(this.shotBob);
        }
        uLink.BitStream bitStream = new uLink.BitStream(false);
        this.WriteHitInfo(bitStream, ref ray, flag3, ref raycastHit2, flag2, netEntityID);
        itemRep.ActionStream(1, uLink.RPCMode.Server, bitStream);
    }
예제 #6
0
    public override void Local_FireWeapon(ViewModel vm, ItemRepresentation itemRep, IBulletWeaponItem itemInstance, ref HumanController.InputSample sample)
    {
        bool      flag;
        Socket    socket;
        Character character = itemInstance.character;

        if (character == null)
        {
            return;
        }
        if (itemInstance.clipAmmo <= 0)
        {
            return;
        }
        Ray ray = character.eyesRay;
        int num = 1;

        itemInstance.Consume(ref num);
        uLink.BitStream bitStream   = new uLink.BitStream(false);
        float           bulletRange = this.GetBulletRange(itemRep);

        for (int i = 0; i < this.numPellets; i++)
        {
            Ray ray1 = ray;
            ray1.direction = (Quaternion.LookRotation(ray.direction) * Quaternion.Euler(UnityEngine.Random.Range(-this.xSpread, this.xSpread), UnityEngine.Random.Range(-this.ySpread, this.ySpread), 0f)) * Vector3.forward;
            Component component = null;
            this.FireSingleBullet(bitStream, ray1, itemRep, out component, out flag);
            this.MakeTracer(ray1.origin, ray1.origin + (ray1.direction * bulletRange), bulletRange, component, flag);
        }
        itemRep.ActionStream(1, uLink.RPCMode.Server, bitStream);
        bool flag1 = vm;

        if (!flag1)
        {
            socket = itemRep.muzzle;
        }
        else
        {
            socket = vm.muzzle;
        }
        this.DoWeaponEffects(character.transform, socket, flag1, itemRep);
        if (flag1)
        {
            vm.PlayFireAnimation();
        }
        float single = 1f;

        if (sample.aim)
        {
            single = single - this.aimingRecoilSubtract;
        }
        else if (sample.crouch)
        {
            single = single - this.crouchRecoilSubtract;
        }
        float            single1          = UnityEngine.Random.Range(this.recoilPitchMin, this.recoilPitchMax) * single;
        float            single2          = UnityEngine.Random.Range(this.recoilYawMin, this.recoilYawMax) * single;
        RecoilSimulation recoilSimulation = character.recoilSimulation;

        if (recoilSimulation)
        {
            recoilSimulation.AddRecoil(this.recoilDuration, single1, single2);
        }
        HeadBob headBob = CameraMount.current.GetComponent <HeadBob>();

        if (headBob && this.shotBob)
        {
            headBob.AddEffect(this.shotBob);
        }
    }
예제 #7
0
    public virtual void Local_FireWeapon(ViewModel vm, ItemRepresentation itemRep, IBulletWeaponItem itemInstance, ref HumanController.InputSample sample)
    {
        Component   component;
        Vector3     point;
        RaycastHit2 hit;
        IDMain      main;
        bool        flag4;
        Socket      muzzle;
        bool        flag5;
        Character   shooterOrNull = itemInstance.character;

        if (shooterOrNull == null)
        {
            return;
        }
        if (itemInstance.clipAmmo <= 0)
        {
            return;
        }
        Ray         eyesRay        = shooterOrNull.eyesRay;
        NetEntityID unassigned     = NetEntityID.unassigned;
        bool        hitNetworkView = false;
        int         count          = 1;

        itemInstance.Consume(ref count);
        bool       didHit = Physics2.Raycast2(eyesRay, out hit, this.GetBulletRange(itemRep), 0x183e1411);
        TakeDamage damage = null;

        if (!didHit)
        {
            main      = null;
            point     = eyesRay.GetPoint(1000f);
            component = null;
            goto Label_019E;
        }
        point = hit.point;
        IDBase id = hit.id;

        component = (hit.remoteBodyPart == null) ? ((Component)hit.collider) : ((Component)hit.remoteBodyPart);
        main      = (id == null) ? null : id.idMain;
        if (main == null)
        {
            goto Label_019E;
        }
        unassigned = NetEntityID.Get((MonoBehaviour)main);
        if (unassigned.isUnassigned)
        {
            goto Label_019E;
        }
        hitNetworkView = true;
        damage         = main.GetComponent <TakeDamage>();
        if ((damage != null) && damage.ShouldPlayHitNotification())
        {
            this.PlayHitNotification(point, shooterOrNull);
        }
        bool flag3 = false;

        if (hit.remoteBodyPart != null)
        {
            BodyPart bodyPart = hit.remoteBodyPart.bodyPart;
            switch (bodyPart)
            {
            case BodyPart.Brain:
            case BodyPart.L_Eye:
            case BodyPart.R_Eye:
                break;

            default:
                switch (bodyPart)
                {
                case BodyPart.Head:
                case BodyPart.Jaw:
                    break;

                case BodyPart.Scalp:
                case BodyPart.Nostrils:
                    goto Label_016C;

                default:
                    goto Label_016C;
                }
                break;
            }
            flag3 = true;
        }
        goto Label_0174;
Label_016C:
        flag3 = false;
Label_0174:
        if (flag3)
        {
            this.headshotSound.Play();
        }
Label_019E:
        flag4 = didHit && ((!hit.isHitboxHit || hit.bodyPart.IsDefined()) || (damage != null));
        if (vm != null)
        {
            Socket.Slot slot = vm.socketMap["muzzle"];
            muzzle = slot.socket;
            flag5  = true;
        }
        else
        {
            muzzle = itemRep.muzzle;
            flag5  = false;
        }
        Vector3 position = muzzle.position;

        this.DoWeaponEffects(shooterOrNull.transform, position, point, muzzle, flag5, component, flag4, itemRep);
        if (flag5)
        {
            vm.PlayFireAnimation();
        }
        float num2 = 1f;

        if (sample.aim && sample.crouch)
        {
            num2 -= this.aimingRecoilSubtract + (this.crouchRecoilSubtract * 0.5f);
        }
        else if (sample.aim)
        {
            num2 -= this.aimingRecoilSubtract;
        }
        else if (sample.crouch)
        {
            num2 -= this.crouchRecoilSubtract;
        }
        num2 = Mathf.Clamp01(num2);
        float pitch = Random.Range(this.recoilPitchMin, this.recoilPitchMax) * num2;
        float yaw   = Random.Range(this.recoilYawMin, this.recoilYawMax) * num2;

        if (weaponRecoil && (shooterOrNull.recoilSimulation != null))
        {
            shooterOrNull.recoilSimulation.AddRecoil(this.recoilDuration, pitch, yaw);
        }
        HeadBob bob = CameraMount.current.GetComponent <HeadBob>();

        if (((bob != null) && (this.shotBob != null)) && headRecoil)
        {
            bob.AddEffect(this.shotBob);
        }
        BitStream sendStream = new BitStream(false);

        this.WriteHitInfo(sendStream, ref eyesRay, didHit, ref hit, hitNetworkView, unassigned);
        itemRep.ActionStream(1, RPCMode.Server, sendStream);
    }