Esempio n. 1
0
        public void Write(NetDataWriter writer)
        {
            writer.Put((byte)PacketType.State);
            writer.Put(world.Frame);

            if (arbiter)
            {
                HeaderPacketWriter headerPacket = new HeaderPacketWriter(3, writer);

                if ((WriteMode & WriteFlags.Input) != WriteFlags.None)
                {
                    WriteInput(writer);
                }

                headerPacket.WriteCurrentDataSizeToHeader();

                if ((WriteMode & WriteFlags.State) != WriteFlags.None)
                {
                    WriteStateful(writer);
                }

                headerPacket.WriteCurrentDataSizeToHeader();

                if ((WriteMode & WriteFlags.Fields) != WriteFlags.None)
                {
                    WriteFields(writer);
                }

                headerPacket.WriteCurrentDataSizeToHeader();
            }
            else
            {
                HeaderPacketWriter headerPacket = new HeaderPacketWriter(1, writer);

                if ((WriteMode & WriteFlags.Input) != WriteFlags.None)
                {
                    WriteInput(writer);
                }

                headerPacket.WriteCurrentDataSizeToHeader();
            }

            writeAll = false;
        }
Esempio n. 2
0
        public void WriteState(NetDataWriter writer)
        {
            writer.Put((byte)PacketType.State);
            writer.Put(world.Frame);

            HeaderPacketWriter headerPacket = new HeaderPacketWriter(5, writer);

            WriteSpawns(writer);
            headerPacket.WriteCurrentDataSizeToHeader();

            WriteOwnership(writer);
            headerPacket.WriteCurrentDataSizeToHeader();

            WriteStateful(writer);
            headerPacket.WriteCurrentDataSizeToHeader();

            WriteFields(writer);
            headerPacket.WriteCurrentDataSizeToHeader();

            WriteEvents(writer);
            headerPacket.WriteCurrentDataSizeToHeader();

            writeAll = false;
        }