public void ArrowReportMiss(ArrowMovement arrow, ItemRepresentation itemRepresentation)
    {
        BitStream stream = new BitStream(false);

        stream.Write <Vector3>(arrow.transform.position, new object[0]);
        itemRepresentation.ActionStream(3, RPCMode.Server, stream);
    }
Exemple #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);
            }
        }
    }
 public void AutoWood()
 {
     if (CVars.Misc.AutoWood)
     {
         WoodBlockerTemp.numWood = -1f;
         Character component = PlayerClient.GetLocalPlayer().controllable.GetComponent <Character>();
         Inventory inventory = component.GetComponent(typeof(Inventory)) as Inventory;
         MeleeWeaponItem <MeleeWeaponDataBlock> meleeWeaponItem = inventory._activeItem as MeleeWeaponItem <MeleeWeaponDataBlock>;
         if (inventory._activeItem is MeleeWeaponItem <MeleeWeaponDataBlock> && Time.time - this.LAST_ATTACK_TIME > meleeWeaponItem.datablock.fireRate && this.AUTO_WOOD_GATHER)
         {
             this.LAST_ATTACK_TIME = Time.time;
             ItemRepresentation itemRepresentation = meleeWeaponItem.itemRepresentation;
             IMeleeWeaponItem   meleeWeaponItem2   = meleeWeaponItem.iface as IMeleeWeaponItem;
             RaycastHit2        raycastHit;
             bool    flag  = Physics2.Raycast2(component.eyesRay, out raycastHit, meleeWeaponItem.datablock.range, 406721553);
             Vector3 point = raycastHit.point;
             itemRepresentation.Action(3, uLink.RPCMode.Server);
             uLink.BitStream bitStream = new uLink.BitStream(false);
             if (flag)
             {
                 IDMain idMain = raycastHit.idMain;
                 bitStream.WriteBoolean(true);
                 bitStream.Write <NetEntityID>(NetEntityID.Get(idMain), new object[0]);
                 bitStream.WriteVector3(point);
                 bitStream.WriteBoolean(false);
                 itemRepresentation.ActionStream(1, uLink.RPCMode.Server, bitStream);
                 HUDHitIndicator hUDHitIndicator;
                 if (Facepunch.Bundling.Load <HUDHitIndicator>("content/hud/HUDHitIndicator", out hUDHitIndicator))
                 {
                     HUDHitIndicator.CreateIndicator(point, true, hUDHitIndicator);
                 }
             }
             else
             {
                 bitStream.WriteBoolean(false);
                 bitStream.WriteVector3(Vector3.zero);
                 bitStream.WriteBoolean(true);
                 itemRepresentation.ActionStream(1, uLink.RPCMode.Server, bitStream);
             }
         }
     }
 }
Exemple #4
0
 public void AutoWood()
 {
     if (CVars.Misc.AutoWood)
     {
         Character component = PlayerClient.GetLocalPlayer().controllable.GetComponent <Character>();
         Inventory inventory = component.GetComponent(typeof(Inventory)) as Inventory;
         MeleeWeaponItem <MeleeWeaponDataBlock> item = inventory._activeItem as MeleeWeaponItem <MeleeWeaponDataBlock>;
         if (((inventory._activeItem is MeleeWeaponItem <MeleeWeaponDataBlock>) && ((Time.time - this.LAST_ATTACK_TIME) > item.datablock.fireRate)) && this.AUTO_WOOD_GATHER)
         {
             RaycastHit2 hit;
             this.LAST_ATTACK_TIME = Time.time;
             ItemRepresentation itemRepresentation = item.itemRepresentation;
             IMeleeWeaponItem   iface = item.iface as IMeleeWeaponItem;
             bool    flag             = Physics2.Raycast2(component.eyesRay, out hit, item.datablock.range, 0x183e1411);
             Vector3 point            = hit.point;
             itemRepresentation.Action(3, uLink.RPCMode.Server);
             uLink.BitStream stream = new uLink.BitStream(false);
             if (flag)
             {
                 HUDHitIndicator indicator;
                 IDMain          idMain = hit.idMain;
                 stream.WriteBoolean(true);
                 stream.Write <NetEntityID>(NetEntityID.Get((UnityEngine.MonoBehaviour)idMain), new object[0]);
                 stream.WriteVector3(point);
                 stream.WriteBoolean(false);
                 itemRepresentation.ActionStream(1, uLink.RPCMode.Server, stream);
                 if (Bundling.Load <HUDHitIndicator>("content/hud/HUDHitIndicator", out indicator))
                 {
                     HUDHitIndicator.CreateIndicator(point, true, indicator);
                 }
             }
             else
             {
                 stream.WriteBoolean(false);
                 stream.WriteVector3(Vector3.zero);
                 stream.WriteBoolean(true);
                 itemRepresentation.ActionStream(1, uLink.RPCMode.Server, stream);
             }
         }
     }
 }
    public override void AttackReleased(ViewModel vm, ItemRepresentation itemRep, IThrowableItem itemInstance, ref 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;
        Character component  = PlayerClient.GetLocalPlayer().controllable.GetComponent <Character>();
        Vector3   eyesOrigin = component.eyesOrigin;
        Vector3   forward    = component.eyesAngles.forward;
        BitStream stream     = new BitStream(false);

        stream.WriteVector3(eyesOrigin);
        stream.WriteVector3((Vector3)(forward * this.GetHandGrenadeItemInstance(itemInstance).heldThrowStrength));
        Debug.Log("Throw strength is : " + this.GetHandGrenadeItemInstance(itemInstance).heldThrowStrength);
        this.GetHandGrenadeItemInstance(itemInstance).EndHoldingBack();
        itemRep.ActionStream(1, RPCMode.Server, stream);
    }
 public void ArrowReportHit(IDMain hitMain, ArrowMovement arrow, ItemRepresentation itemRepresentation, IBowWeaponItem itemInstance)
 {
     if (hitMain != null)
     {
         TakeDamage component = hitMain.GetComponent <TakeDamage>();
         if (component != null)
         {
             BitStream stream = new BitStream(false);
             stream.Write <NetEntityID>(NetEntityID.Get((MonoBehaviour)hitMain), new object[0]);
             stream.Write <Vector3>(hitMain.transform.position, new object[0]);
             itemRepresentation.ActionStream(2, RPCMode.Server, stream);
             Character shooterOrNull = itemInstance.character;
             if ((component != null) && component.ShouldPlayHitNotification())
             {
                 this.PlayHitNotification(arrow.transform.position, shooterOrNull);
             }
         }
     }
 }
    public virtual void Local_FireArrow(ViewModel vm, ItemRepresentation itemRep, IBowWeaponItem itemInstance, ref HumanController.InputSample sample)
    {
        if (vm != null)
        {
            vm.Play("fire_1", PlayMode.StopSameLayer);
        }
        this.MakeReadyIn(itemInstance, base.fireRate);
        Character character = itemInstance.character;

        if (character != null)
        {
            Ray     eyesRay    = character.eyesRay;
            Vector3 eyesOrigin = character.eyesOrigin;
            this.FireArrow(eyesOrigin, character.eyesRotation, itemRep, itemInstance);
            BitStream stream = new BitStream(false);
            stream.WriteVector3(eyesOrigin);
            stream.WriteQuaternion(character.eyesRotation);
            itemRep.ActionStream(1, RPCMode.Server, stream);
        }
    }
    public override void DoActualThrow(ItemRepresentation itemRep, IThrowableItem itemInstance, ViewModel vm)
    {
        Character component = PlayerClient.GetLocalPlayer().controllable.GetComponent <Character>();
        Vector3   vector3   = component.eyesOrigin;
        Vector3   vector31  = 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);
        }
        uLink.BitStream bitStream = new uLink.BitStream(false);
        bitStream.WriteVector3(vector3);
        bitStream.WriteVector3(vector31);
        itemRep.ActionStream(1, uLink.RPCMode.Server, bitStream);
    }
    public virtual void Local_FireArrow(ViewModel vm, ItemRepresentation itemRep, IBowWeaponItem itemInstance, ref HumanController.InputSample sample)
    {
        if (vm)
        {
            vm.Play("fire_1", PlayMode.StopSameLayer);
        }
        this.MakeReadyIn(itemInstance, this.fireRate);
        Character character = itemInstance.character;

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

        this.FireArrow(vector3, character.eyesRotation, itemRep, itemInstance);
        uLink.BitStream bitStream = new uLink.BitStream(false);
        bitStream.WriteVector3(vector3);
        bitStream.WriteQuaternion(character.eyesRotation);
        itemRep.ActionStream(1, uLink.RPCMode.Server, bitStream);
    }
    public void ArrowReportHit(IDMain hitMain, ArrowMovement arrow, ItemRepresentation itemRepresentation, IBowWeaponItem itemInstance)
    {
        if (!hitMain)
        {
            return;
        }
        TakeDamage component = hitMain.GetComponent <TakeDamage>();

        if (!component)
        {
            return;
        }
        uLink.BitStream bitStream = new uLink.BitStream(false);
        bitStream.Write <NetEntityID>(NetEntityID.Get(hitMain), new object[0]);
        bitStream.Write <Vector3>(hitMain.transform.position, new object[0]);
        itemRepresentation.ActionStream(2, uLink.RPCMode.Server, bitStream);
        Character character = itemInstance.character;

        if (component && component.ShouldPlayHitNotification())
        {
            this.PlayHitNotification(arrow.transform.position, character);
        }
    }
    public override void DoActualThrow(ItemRepresentation itemRep, IThrowableItem itemInstance, ViewModel vm)
    {
        Character component  = PlayerClient.GetLocalPlayer().controllable.GetComponent <Character>();
        Vector3   eyesOrigin = component.eyesOrigin;
        Vector3   forward    = component.eyesAngles.forward;

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

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

        stream.WriteVector3(eyesOrigin);
        stream.WriteVector3(forward);
        itemRep.ActionStream(1, RPCMode.Server, stream);
    }
Exemple #12
0
    public virtual void Local_MidSwing(ViewModel vm, ItemRepresentation itemRep, IMeleeWeaponItem itemInstance, ref HumanController.InputSample sample)
    {
        Character shooterOrNull = itemInstance.character;

        if (shooterOrNull != null)
        {
            BodyPart    part;
            Ray         eyesRay     = shooterOrNull.eyesRay;
            bool        flag        = false;
            Collider    hitCollider = null;
            Vector3     zero        = Vector3.zero;
            Vector3     up          = Vector3.up;
            NetEntityID unassigned  = NetEntityID.unassigned;
            bool        flag2       = false;
            flag = this.Physics2SphereCast(eyesRay, 0.3f, this.GetRange(), 0x183e1411, out zero, out up, out hitCollider, out part);
            bool       flag3     = false;
            TakeDamage component = null;
            if (flag)
            {
                IDBase base2;
                TransformHelpers.GetIDBaseFromCollider(hitCollider, out base2);
                IDMain main = (base2 == null) ? null : base2.idMain;
                if (main != null)
                {
                    unassigned = NetEntityID.Get((MonoBehaviour)main);
                    flag2      = !unassigned.isUnassigned;
                    component  = main.GetComponent <TakeDamage>();
                    if ((component != null) && component.ShouldPlayHitNotification())
                    {
                        this.PlayHitNotification(zero, shooterOrNull);
                    }
                }
                flag3 = hitCollider.gameObject.CompareTag("Tree Collider");
                if (flag3)
                {
                    WoodBlockerTemp blockerForPoint = WoodBlockerTemp.GetBlockerForPoint(zero);
                    if (!blockerForPoint.HasWood())
                    {
                        flag3 = false;
                        Notice.Popup("", "There's no wood left here", 2f);
                    }
                    else
                    {
                        blockerForPoint.ConsumeWood(this.efficiencies[2]);
                    }
                }
                this.DoMeleeEffects(eyesRay.origin, zero, Quaternion.LookRotation(up), hitCollider.gameObject);
                if ((vm != null) && ((component != null) || flag3))
                {
                    vm.CrossFade("pull_out", 0.05f, PlayMode.StopSameLayer, 1.1f);
                }
            }
            BitStream stream = new BitStream(false);
            if (flag2)
            {
                stream.WriteBoolean(flag2);
                stream.Write <NetEntityID>(unassigned, new object[0]);
                stream.WriteVector3(zero);
            }
            else
            {
                stream.WriteBoolean(false);
                stream.WriteVector3(zero);
            }
            stream.WriteBoolean(flag3);
            itemRep.ActionStream(1, RPCMode.Server, stream);
            this.EndSwingWorldAnimations(itemRep);
        }
    }
    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);
    }
    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);
        }
    }
Exemple #15
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);
    }
Exemple #16
0
    public virtual void Local_MidSwing(ViewModel vm, ItemRepresentation itemRep, IMeleeWeaponItem itemInstance, ref HumanController.InputSample sample)
    {
        BodyPart  bodyPart;
        IDBase    dBase;
        IDMain    dMain;
        Character character = itemInstance.character;

        if (character == null)
        {
            return;
        }
        Ray         ray         = character.eyesRay;
        bool        flag        = false;
        Collider    collider    = null;
        Vector3     vector3     = Vector3.zero;
        Vector3     vector31    = Vector3.up;
        NetEntityID netEntityID = NetEntityID.unassigned;
        bool        flag1       = false;

        flag = this.Physics2SphereCast(ray, 0.3f, this.GetRange(), 406721553, out vector3, out vector31, out collider, out bodyPart);
        bool       flag2     = false;
        TakeDamage component = null;

        if (flag)
        {
            TransformHelpers.GetIDBaseFromCollider(collider, out dBase);
            if (!dBase)
            {
                dMain = null;
            }
            else
            {
                dMain = dBase.idMain;
            }
            IDMain dMain1 = dMain;
            if (dMain1)
            {
                netEntityID = NetEntityID.Get(dMain1);
                flag1       = !netEntityID.isUnassigned;
                component   = dMain1.GetComponent <TakeDamage>();
                if (component && component.ShouldPlayHitNotification())
                {
                    this.PlayHitNotification(vector3, character);
                }
            }
            flag2 = collider.gameObject.CompareTag("Tree Collider");
            if (flag2)
            {
                WoodBlockerTemp blockerForPoint = WoodBlockerTemp.GetBlockerForPoint(vector3);
                if (blockerForPoint.HasWood())
                {
                    blockerForPoint.ConsumeWood(this.efficiencies[2]);
                }
                else
                {
                    flag2 = false;
                    Notice.Popup("", "There's no wood left here", 2f);
                }
            }
            this.DoMeleeEffects(ray.origin, vector3, Quaternion.LookRotation(vector31), collider.gameObject);
            if (vm && (component || flag2))
            {
                vm.CrossFade("pull_out", 0.05f, PlayMode.StopSameLayer, 1.1f);
            }
        }
        uLink.BitStream bitStream = new uLink.BitStream(false);
        if (!flag1)
        {
            bitStream.WriteBoolean(false);
            bitStream.WriteVector3(vector3);
        }
        else
        {
            bitStream.WriteBoolean(flag1);
            bitStream.Write <NetEntityID>(netEntityID, new object[0]);
            bitStream.WriteVector3(vector3);
        }
        bitStream.WriteBoolean(flag2);
        itemRep.ActionStream(1, uLink.RPCMode.Server, bitStream);
        this.EndSwingWorldAnimations(itemRep);
    }