Example #1
0
    // Token: 0x06003316 RID: 13078 RVA: 0x000C07F8 File Offset: 0x000BE9F8
    public virtual void Local_FireWeapon(global::ViewModel vm, global::ItemRepresentation itemRep, global::IBulletWeaponItem itemInstance, ref global::HumanController.InputSample sample)
    {
        global::Character character = itemInstance.character;

        if (character == null)
        {
            return;
        }
        if (itemInstance.clipAmmo <= 0)
        {
            return;
        }
        Ray eyesRay = character.eyesRay;
        global::NetEntityID hitView = global::NetEntityID.unassigned;
        bool hitNetworkView         = false;
        int  num = 1;

        itemInstance.Consume(ref num);
        RaycastHit2        raycastHit;
        bool               flag       = Physics2.Raycast2(eyesRay, ref raycastHit, this.GetBulletRange(itemRep), 406721553);
        global::TakeDamage takeDamage = null;
        Vector3            point;
        Component          hitComponent;

        if (flag)
        {
            point = raycastHit.point;
            IDBase id = raycastHit.id;
            hitComponent = ((!raycastHit.remoteBodyPart) ? raycastHit.collider : raycastHit.remoteBodyPart);
            IDMain idmain = (!id) ? null : id.idMain;
            if (idmain)
            {
                hitView = global::NetEntityID.Get(idmain);
                if (!hitView.isUnassigned)
                {
                    hitNetworkView = true;
                    takeDamage     = idmain.GetComponent <global::TakeDamage>();
                    if (takeDamage && takeDamage.ShouldPlayHitNotification())
                    {
                        this.PlayHitNotification(point, character);
                    }
                    bool flag2 = false;
                    if (raycastHit.remoteBodyPart)
                    {
                        BodyPart bodyPart = raycastHit.remoteBodyPart.bodyPart;
                        switch (bodyPart)
                        {
                        case 16:
                        case 20:
                        case 21:
                            break;

                        default:
                            switch (bodyPart)
                            {
                            case 9:
                            case 12:
                                goto IL_164;
                            }
                            flag2 = false;
                            goto IL_174;
                        }
IL_164:
                        flag2 = true;
                    }
IL_174:
                    if (flag2)
                    {
                        this.headshotSound.Play();
                    }
                }
            }
        }
        else
        {
            point        = eyesRay.GetPoint(1000f);
            hitComponent = null;
        }
        bool           allowBlood = flag && (!raycastHit.isHitboxHit || BodyParts.IsDefined(raycastHit.bodyPart) || takeDamage != null);
        global::Socket socket;
        bool           flag3;

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

        this.DoWeaponEffects(character.transform, position, point, socket, flag3, hitComponent, allowBlood, itemRep);
        if (flag3)
        {
            vm.PlayFireAnimation();
        }
        float num2  = 1f;
        bool  flag4 = sample.aim && sample.crouch;

        if (flag4)
        {
            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 (!global::BulletWeaponDataBlock.weaponRecoil && character.recoilSimulation)
        {
            character.recoilSimulation.AddRecoil(this.recoilDuration, pitch, yaw);
        }
        global::HeadBob component = global::CameraMount.current.GetComponent <global::HeadBob>();

        if (component && this.shotBob && global::BulletWeaponDataBlock.headRecoil)
        {
            component.AddEffect(this.shotBob);
        }
        BitStream bitStream = new BitStream(false);

        this.WriteHitInfo(bitStream, ref eyesRay, flag, ref raycastHit, hitNetworkView, hitView);
        itemRep.ActionStream(1, 0, bitStream);
    }
Example #2
0
    // Token: 0x0600331A RID: 13082 RVA: 0x000C0EC8 File Offset: 0x000BF0C8
    public override void DoAction1(BitStream stream, global::ItemRepresentation rep, ref uLink.NetworkMessageInfo info)
    {
        GameObject          gameObject;
        bool                flag;
        bool                flag2;
        BodyPart            bodyPart;
        IDRemoteBodyPart    idremoteBodyPart;
        global::NetEntityID netEntityID;
        Transform           transform;
        Vector3             endPos;
        Vector3             vector;
        bool                flag3;

        this.ReadHitInfo(stream, out gameObject, out flag, out flag2, out bodyPart, out idremoteBodyPart, out netEntityID, out transform, out endPos, out vector, out flag3);
        if (flag3)
        {
            this.headshotSound.Play(gameObject.transform.position, 1f, 4f, 30f);
        }
        this.DoWeaponEffects(rep.transform.parent, rep.muzzle.position, endPos, rep.muzzle, false, (!idremoteBodyPart) ? ((!gameObject) ? null : gameObject.GetComponentInChildren <CapsuleCollider>()) : idremoteBodyPart, flag && (!idremoteBodyPart || BodyParts.IsDefined(bodyPart) || gameObject.GetComponent <global::TakeDamage>() != null), rep);
    }