Example #1
0
        public override void ReceiveOnClient()
        {
            Player           plr      = Main.player[this.PlayerWho];
            var              otherplr = TmlLibraries.SafelyGetModPlayer <TMRPlayer>(plr);
            GunAnimationType animType = (GunAnimationType)this.AnimType;

            Item gun = plr.HeldItem;

            if (gun?.active != true)
            {
                return;
            }

            var mygun = gun.modItem as TheMadRangerItem;

            if (mygun == null)
            {
                return;
            }

            switch (animType)
            {
            case GunAnimationType.Recoil:
                otherplr.GunHandling.BeginRecoil(0f);
                break;

            case GunAnimationType.Holster:
                otherplr.GunHandling.BeginHolster(plr, mygun);
                break;

            case GunAnimationType.Reload:
                otherplr.GunHandling.BeginReload(plr, mygun);
                break;
            }
        }
Example #2
0
        ////////////////

        public override void ReceiveOnServer(int fromWho)
        {
            Player           plr      = Main.player[this.PlayerWho];
            var              otherplr = TmlLibraries.SafelyGetModPlayer <TMRPlayer>(plr);
            GunAnimationType animType = (GunAnimationType)this.AnimType;

            Item gun = plr.HeldItem;

            if (gun?.active != true)
            {
                return;
            }

            var mygun = gun.modItem as TheMadRangerItem;

            if (mygun == null)
            {
                return;
            }

            switch (animType)
            {
            //case GunAnimationType.Recoil:
            //	otherplr.GunHandling.BeginRecoil( 0f );
            //	break;
            case GunAnimationType.Holster:              // Might interrupt other item actions such that server should know
                otherplr.GunHandling.BeginHolster(plr, mygun);
                break;
                //case GunAnimationType.Reload:
                //	otherplr.GunHandling.BeginReload( plr );
                //	break;
            }

            SimplePacket.SendToClient(this, -1, fromWho);
        }
Example #3
0
        public static void Broadcast(GunAnimationType animType)
        {
            if (Main.netMode != 1)
            {
                throw new ModLibsException("Not a client.");
            }

            var packet = new GunAnimationPacket(Main.myPlayer, animType);

            SimplePacket.SendToServer(packet);
        }
Example #4
0
 private GunAnimationPacket(int playerWho, GunAnimationType animType)
 {
     this.PlayerWho = playerWho;
     this.AnimType  = (int)animType;
 }