Ejemplo n.º 1
0
            public void AddPacketInfo(PacketInfo packet)
            {
                if (packet.Direction == PacketDirection.Clientbound || packet.Direction == PacketDirection.Both)
                {
                    _clientboundPackets.Add(packet.Id, packet);
                }

                if (packet.Direction == PacketDirection.Serverbound || packet.Direction == PacketDirection.Both)
                {
                    _serverboundPackets.Add(packet.Id, packet);
                }
            }
Ejemplo n.º 2
0
        private PacketInfo BuildPacketInfoForType(Type packetType)
        {
            var packetAttribute = packetType.GetCustomAttribute <PacketAttribute>();

            var packetInfo = new PacketInfo
            {
                State     = packetAttribute.State,
                Direction = packetAttribute.Direction,
                Id        = packetAttribute.Id,
                Type      = packetType,
            };

            _fieldActionBuilder.BuildActionsForPacket(packetInfo);

            return(packetInfo);
        }
Ejemplo n.º 3
0
        public void BuildActionsForPacket(PacketInfo packetInfo)
        {
            // Manual packets require no field actions
            if (typeof(IManualPacket).IsAssignableFrom(packetInfo.Type))
            {
                return;
            }

            var actionList = new List <PacketFieldAction>();
            var fields     = GetFieldsOnPacket(packetInfo.Type);

            foreach (var field in fields)
            {
                actionList.Add(new PacketFieldAction
                {
                    ReaderAction = BuildReaderAction(field.Item1, field.Item2.Type),
                    WriterAction = BuildWriterAction(field.Item1, field.Item2.Type),
                });
            }

            packetInfo.FieldActions = actionList;
        }