Beispiel #1
0
        public NetOutgoingMessage SendMessage(Connection connection)
        {
            NetPeer peer = connection.Peer;
            NetOutgoingMessage sendMsg = peer.CreateMessage();
            sendMsg.Write((uint)PacketId, 16);

            Bitstream stream = new Bitstream(sendMsg);
            Serialize(stream);
            return sendMsg;
        }
Beispiel #2
0
        public static Packet Get(NetIncomingMessage message)
        {
            var packetId = message.ReadUInt16();
            var pdata = PacketFactory.GetPacketType(packetId);

            var newPacket = (Packet)Activator
                .CreateInstance(pdata.PacketType);

            if (newPacket != null)
            {
                Bitstream stream = new Bitstream(message);
                newPacket.Deserialize(stream);
                return newPacket;
            }

            //TODO
            return null;
        }
Beispiel #3
0
        public override void Deserialize(Bitstream msg)
        {
            State = new List<PlayerStateData>();
            int count = msg.ReadUInt16();
            for (int i = 0; i < count; ++i)
            {
                var o = new PlayerStateData();
                o.Forward = msg.ReadBool();
                o.Back = msg.ReadBool();
                o.Left = msg.ReadBool();
                o.Right = msg.ReadBool();

                o.Position = msg.ReadVector2();
                o.SimTick = (uint)msg.ReadInt32();

                State.Add(o);
            }
            SnapId = msg.ReadInt32();
        }
Beispiel #4
0
 public override void Serialize(Bitstream msg)
 {
     msg.Write(Message);
     msg.Write(From);
 }
Beispiel #5
0
 public override void Deserialize(Bitstream msg)
 {
     Message = msg.ReadString();
     From = msg.ReadString();
 }
Beispiel #6
0
 public override void Serialize(Bitstream msg)
 {
 }
Beispiel #7
0
 public override void Serialize(Bitstream msg)
 {
     msg.Write(Username);
 }
Beispiel #8
0
 public override void Deserialize(Bitstream msg)
 {
     Username = msg.ReadString();
 }
Beispiel #9
0
 public abstract void Serialize(Bitstream msg);