Ejemplo n.º 1
0
        ////////////////
        // Server Receivers
        ////////////////

        private static void ReceiveInvasionRequestOnServer(BinaryReader reader, int playerWho)
        {
            // Server only
            if (Main.netMode != 2)
            {
                return;
            }

            int    musicType    = reader.ReadInt32();
            string spawnInfoEnc = reader.ReadString();
            var    spawnInfo    = JsonConvert.DeserializeObject <List <KeyValuePair <int, ISet <int> > > >(spawnInfoEnc);

            var myworld = ModContent.GetInstance <DynamicInvasionsWorld>();

            myworld.Logic.StartInvasion(musicType, spawnInfo.AsReadOnly());

            for (int i = 0; i < Main.player.Length; i++)
            {
                Player player = Main.player[i];
                if (player == null || !player.active)
                {
                    continue;
                }

                ServerPacketHandlers.SendInvasionFromServer(player, musicType, spawnInfoEnc);
            }
        }
Ejemplo n.º 2
0
        private static void ReceiveInvasionStatusRequestOnServer(BinaryReader reader, int playerWho)
        {
            // Server only
            if (Main.netMode != 2)
            {
                return;
            }

            ServerPacketHandlers.SendInvasionStatusFromServer(Main.player[playerWho]);
        }
Ejemplo n.º 3
0
        public static void RoutePacket(BinaryReader reader, int playerWho)
        {
            NetProtocolTypes protocol = (NetProtocolTypes)reader.ReadByte();

            switch (protocol)
            {
            case NetProtocolTypes.RequestInvasion:
                if (DynamicInvasionsMod.Config.DebugModeInfo)
                {
                    LogHelpers.Log("ServerPacketHandlers.RequestInvasion");
                }
                ServerPacketHandlers.ReceiveInvasionRequestOnServer(reader, playerWho);
                break;

            case NetProtocolTypes.RequestInvasionStatus:
                if (DynamicInvasionsMod.Config.DebugModeInfo)
                {
                    LogHelpers.Log("ServerPacketHandlers.RequestInvasionStatus");
                }
                ServerPacketHandlers.ReceiveInvasionStatusRequestOnServer(reader, playerWho);
                break;

            case NetProtocolTypes.RequestEndInvasion:
                if (DynamicInvasionsMod.Config.DebugModeInfo)
                {
                    LogHelpers.Log("ServerPacketHandlers.RequestEndInvasion");
                }
                ServerPacketHandlers.ReceiveEndInvasionRequestOnServer(reader, playerWho);
                break;

            default:
                if (DynamicInvasionsMod.Config.DebugModeInfo)
                {
                    LogHelpers.Log("ServerPacketHandlers ...? " + protocol);
                }
                break;
            }
        }
Ejemplo n.º 4
0
        private static void ReceiveEndInvasionRequestOnServer(BinaryReader reader, int playerWho)
        {
            // Server only
            if (Main.netMode != 2)
            {
                return;
            }

            var myworld = ModContent.GetInstance <DynamicInvasionsWorld>();

            myworld.Logic.EndInvasion();

            for (int i = 0; i < Main.player.Length; i++)
            {
                Player player = Main.player[i];
                if (player == null || !player.active)
                {
                    continue;
                }

                ServerPacketHandlers.SendEndInvasionFromServer(player);
            }
        }