Example #1
0
    // Token: 0x060035F8 RID: 13816 RVA: 0x000C4DD0 File Offset: 0x000C2FD0
    public virtual void FireSingleBullet(BitStream sendStream, Ray ray, global::ItemRepresentation itemRep, out Component hitComponent, out bool allowBlood)
    {
        global::NetEntityID hitView = global::NetEntityID.unassigned;
        bool        flag            = false;
        RaycastHit2 raycastHit;
        bool        flag2 = Physics2.Raycast2(ray, ref raycastHit, this.GetBulletRange(itemRep), 406721553);

        if (flag2)
        {
            Vector3 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)
                {
                    global::TakeDamage component = idmain.GetComponent <global::TakeDamage>();
                    if (component)
                    {
                        flag = true;
                        if (component.ShouldPlayHitNotification())
                        {
                            this.PlayHitNotification(point, null);
                        }
                    }
                }
            }
        }
        else
        {
            Vector3 point = ray.GetPoint(this.GetBulletRange(itemRep));
            hitComponent = null;
        }
        this.WriteHitInfo(sendStream, ref ray, flag2, ref raycastHit, flag, hitView);
        allowBlood = (flag2 && flag);
    }
    // Token: 0x060032C0 RID: 12992 RVA: 0x000C0200 File Offset: 0x000BE400
    public void ArrowReportHit(IDMain hitMain, global::ArrowMovement arrow, global::ItemRepresentation itemRepresentation, global::IBowWeaponItem itemInstance)
    {
        if (!hitMain)
        {
            return;
        }
        global::TakeDamage component = hitMain.GetComponent <global::TakeDamage>();

        if (!component)
        {
            return;
        }
        BitStream bitStream = new BitStream(false);

        bitStream.Write <global::NetEntityID>(global::NetEntityID.Get(hitMain), new object[0]);
        bitStream.Write <Vector3>(hitMain.transform.position, new object[0]);
        itemRepresentation.ActionStream(2, 0, bitStream);
        global::Character character = itemInstance.character;

        if (component && component.ShouldPlayHitNotification())
        {
            this.PlayHitNotification(arrow.transform.position, character);
        }
    }
    // Token: 0x0600353A RID: 13626 RVA: 0x000C3E1C File Offset: 0x000C201C
    public virtual void Local_MidSwing(global::ViewModel vm, global::ItemRepresentation itemRep, global::IMeleeWeaponItem itemInstance, ref global::HumanController.InputSample sample)
    {
        global::Character character = itemInstance.character;

        if (character == null)
        {
            return;
        }
        Ray                 eyesRay     = character.eyesRay;
        Collider            collider    = null;
        Vector3             zero        = Vector3.zero;
        Vector3             up          = Vector3.up;
        global::NetEntityID netEntityID = global::NetEntityID.unassigned;
        bool                flag        = false;
        BodyPart            bodyPart;
        bool                flag2      = this.Physics2SphereCast(eyesRay, 0.3f, this.GetRange(), 406721553, out zero, out up, out collider, out bodyPart);
        bool                flag3      = false;
        global::TakeDamage  takeDamage = null;

        if (flag2)
        {
            IDBase idbase;
            global::TransformHelpers.GetIDBaseFromCollider(collider, out idbase);
            IDMain idmain = (!idbase) ? null : idbase.idMain;
            if (idmain)
            {
                netEntityID = global::NetEntityID.Get(idmain);
                flag        = !netEntityID.isUnassigned;
                takeDamage  = idmain.GetComponent <global::TakeDamage>();
                if (takeDamage && takeDamage.ShouldPlayHitNotification())
                {
                    this.PlayHitNotification(zero, character);
                }
            }
            flag3 = collider.gameObject.CompareTag("Tree Collider");
            if (flag3)
            {
                global::WoodBlockerTemp blockerForPoint = global::WoodBlockerTemp.GetBlockerForPoint(zero);
                if (!blockerForPoint.HasWood())
                {
                    flag3 = false;
                    Rust.Notice.Popup("", "There's no wood left here", 2f);
                }
                else
                {
                    blockerForPoint.ConsumeWood(this.efficiencies[2]);
                }
            }
            this.DoMeleeEffects(eyesRay.origin, zero, Quaternion.LookRotation(up), collider.gameObject);
            if (vm && (takeDamage || flag3))
            {
                vm.CrossFade("pull_out", 0.05f, 0, 1.1f);
            }
        }
        BitStream bitStream = new BitStream(false);

        if (flag)
        {
            bitStream.WriteBoolean(flag);
            bitStream.Write <global::NetEntityID>(netEntityID, new object[0]);
            bitStream.WriteVector3(zero);
        }
        else
        {
            bitStream.WriteBoolean(false);
            bitStream.WriteVector3(zero);
        }
        bitStream.WriteBoolean(flag3);
        itemRep.ActionStream(1, 0, bitStream);
        this.EndSwingWorldAnimations(itemRep);
    }
Example #4
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);
    }