// Token: 0x060032BF RID: 12991 RVA: 0x000C01CC File Offset: 0x000BE3CC
    public void ArrowReportMiss(global::ArrowMovement arrow, global::ItemRepresentation itemRepresentation)
    {
        BitStream bitStream = new BitStream(false);

        bitStream.Write <Vector3>(arrow.transform.position, new object[0]);
        itemRepresentation.ActionStream(3, 0, bitStream);
    }
Esempio n. 2
0
    // Token: 0x06003445 RID: 13381 RVA: 0x000C2C54 File Offset: 0x000C0E54
    public override void AttackReleased(global::ViewModel vm, global::ItemRepresentation itemRep, global::IThrowableItem itemInstance, ref global::HumanController.InputSample sample)
    {
        Debug.Log("Attack released!!!");
        vm.Play("throw");
        vm.PlayQueued("deploy");
        this.GetHandGrenadeItemInstance(itemInstance).nextPrimaryAttackTime   = Time.time + 1f;
        this.GetHandGrenadeItemInstance(itemInstance).nextSecondaryAttackTime = Time.time + 1f;
        global::Character component  = global::PlayerClient.GetLocalPlayer().controllable.GetComponent <global::Character>();
        Vector3           eyesOrigin = component.eyesOrigin;
        Vector3           forward    = component.eyesAngles.forward;
        BitStream         bitStream  = new BitStream(false);

        bitStream.WriteVector3(eyesOrigin);
        bitStream.WriteVector3(forward * this.GetHandGrenadeItemInstance(itemInstance).heldThrowStrength);
        Debug.Log("Throw strength is : " + this.GetHandGrenadeItemInstance(itemInstance).heldThrowStrength);
        this.GetHandGrenadeItemInstance(itemInstance).EndHoldingBack();
        itemRep.ActionStream(1, 0, bitStream);
    }
    // Token: 0x060032BD RID: 12989 RVA: 0x000C00F0 File Offset: 0x000BE2F0
    public virtual void Local_FireArrow(global::ViewModel vm, global::ItemRepresentation itemRep, global::IBowWeaponItem itemInstance, ref global::HumanController.InputSample sample)
    {
        if (vm)
        {
            vm.Play("fire_1", 0);
        }
        this.MakeReadyIn(itemInstance, this.fireRate);
        global::Character character = itemInstance.character;

        if (character == null)
        {
            return;
        }
        Ray     eyesRay    = character.eyesRay;
        Vector3 eyesOrigin = character.eyesOrigin;

        this.FireArrow(eyesOrigin, character.eyesRotation, itemRep, itemInstance);
        BitStream bitStream = new BitStream(false);

        bitStream.WriteVector3(eyesOrigin);
        bitStream.WriteQuaternion(character.eyesRotation);
        itemRep.ActionStream(1, 0, bitStream);
    }
Esempio n. 4
0
    // Token: 0x06003762 RID: 14178 RVA: 0x000C64C0 File Offset: 0x000C46C0
    public override void DoActualThrow(global::ItemRepresentation itemRep, global::IThrowableItem itemInstance, global::ViewModel vm)
    {
        global::Character component  = global::PlayerClient.GetLocalPlayer().controllable.GetComponent <global::Character>();
        Vector3           eyesOrigin = component.eyesOrigin;
        Vector3           forward    = component.eyesAngles.forward;

        if (vm)
        {
            vm.PlayQueued("deploy");
        }
        this.GetTorchInstance(itemInstance).Extinguish();
        int num = 1;

        if (itemInstance.Consume(ref num))
        {
            itemInstance.inventory.RemoveItem(itemInstance.slot);
        }
        BitStream bitStream = new BitStream(false);

        bitStream.WriteVector3(eyesOrigin);
        bitStream.WriteVector3(forward);
        itemRep.ActionStream(1, 0, bitStream);
    }
    // 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);
        }
    }
Esempio n. 6
0
    // Token: 0x060035F9 RID: 13817 RVA: 0x000C4EDC File Offset: 0x000C30DC
    public override 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;
        int num     = 1;

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

        for (int i = 0; i < this.numPellets; i++)
        {
            Ray ray = eyesRay;
            ray.direction = Quaternion.LookRotation(eyesRay.direction) * Quaternion.Euler(Random.Range(-this.xSpread, this.xSpread), Random.Range(-this.ySpread, this.ySpread), 0f) * Vector3.forward;
            Component component = null;
            bool      allowBlood;
            this.FireSingleBullet(bitStream, ray, itemRep, out component, out allowBlood);
            this.MakeTracer(ray.origin, ray.origin + ray.direction * bulletRange, bulletRange, component, allowBlood);
        }
        itemRep.ActionStream(1, 0, bitStream);
        bool           flag = vm;
        global::Socket muzzle;

        if (flag)
        {
            muzzle = vm.muzzle;
        }
        else
        {
            muzzle = itemRep.muzzle;
        }
        this.DoWeaponEffects(character.transform, muzzle, flag, itemRep);
        if (flag)
        {
            vm.PlayFireAnimation();
        }
        float num2 = 1f;

        if (sample.aim)
        {
            num2 -= this.aimingRecoilSubtract;
        }
        else if (sample.crouch)
        {
            num2 -= this.crouchRecoilSubtract;
        }
        float pitch = Random.Range(this.recoilPitchMin, this.recoilPitchMax) * num2;
        float yaw   = Random.Range(this.recoilYawMin, this.recoilYawMax) * num2;
        global::RecoilSimulation recoilSimulation = character.recoilSimulation;

        if (recoilSimulation)
        {
            recoilSimulation.AddRecoil(this.recoilDuration, pitch, yaw);
        }
        global::HeadBob component2 = global::CameraMount.current.GetComponent <global::HeadBob>();

        if (component2 && this.shotBob)
        {
            component2.AddEffect(this.shotBob);
        }
    }
    // 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);
    }
Esempio n. 8
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);
    }