Exemple #1
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);
        }
    }
Exemple #2
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);
    }