Пример #1
0
        public static void SendToClients(int playerWho, int toWho = -1)
        {
            if (Main.netMode != NetmodeID.Server)
            {
                throw new ModLibsException("Not server");
            }

            Player plr      = Main.player[playerWho];
            var    myplayer = plr.GetModPlayer <GreenHellPlayer>();
            int    buffIdx  = plr.FindBuffIndex(ModContent.BuffType <InfectionDeBuff>());
            int    buffTime = buffIdx >= 0 ? plr.buffTime[buffIdx] : 0;

            var protocol = new PlayerStatePayload(playerWho, myplayer.InfectionStage, buffTime);

            SimplePacket.SendToClient(protocol, toWho, playerWho);
        }
Пример #2
0
        public static void SendToServer()
        {
            if (Main.netMode != NetmodeID.MultiplayerClient)
            {
                throw new ModLibsException("Not client");
            }

            Player plr      = Main.LocalPlayer;
            var    myplayer = plr.GetModPlayer <GreenHellPlayer>();
            int    buffIdx  = plr.FindBuffIndex(ModContent.BuffType <InfectionDeBuff>());
            int    buffTime = buffIdx >= 0 ? plr.buffTime[buffIdx] : 0;

            var packet = new PlayerStatePayload(Main.myPlayer, myplayer.InfectionStage, buffTime);

            SimplePacket.SendToServer(packet);
        }