コード例 #1
0
        private static byte[] CreateFilePacket(InitFileType type)
        {
            IPacketBuilder packetBuilder = new PacketBuilder();

            var nes = new NumberEncoderService();

            switch (type)
            {
            case InitFileType.Item:
                packetBuilder = packetBuilder
                                .AddChar((byte)InitReply.ItemFile).AddChar(1) //spacer
                                .AddString("EIF").AddInt(1)                   //RID
                                .AddShort(2)                                  //Len
                                .AddByte(1)                                   //filler byte
                                .AddBytes(new EIFRecord {
                    ID = 1, Name = "Test1"
                }.SerializeToByteArray(nes))
                                .AddBytes(new EIFRecord {
                    ID = 2, Name = "eof"
                }.SerializeToByteArray(nes));
                break;

            case InitFileType.Npc:
                packetBuilder = packetBuilder
                                .AddChar((byte)InitReply.NpcFile).AddChar(1) //spacer
                                .AddString("ENF").AddInt(1)                  //RID
                                .AddShort(2)                                 //Len
                                .AddByte(1)                                  //filler byte
                                .AddBytes(new ENFRecord {
                    ID = 1, Name = "Test1"
                }.SerializeToByteArray(nes))
                                .AddBytes(new ENFRecord {
                    ID = 2, Name = "eof"
                }.SerializeToByteArray(nes));
                break;

            case InitFileType.Spell:
                packetBuilder = packetBuilder
                                .AddChar((byte)InitReply.SpellFile).AddChar(1) //spacer
                                .AddString("ESF").AddInt(1)                    //RID
                                .AddShort(2)                                   //Len
                                .AddByte(1)                                    //filler byte
                                .AddBytes(new ESFRecord {
                    ID = 1, Name = "Test1", Shout = ""
                }.SerializeToByteArray(nes))
                                .AddBytes(new ESFRecord {
                    ID = 2, Name = "eof", Shout = ""
                }.SerializeToByteArray(nes));
                break;

            case InitFileType.Class:
                packetBuilder = packetBuilder
                                .AddChar((byte)InitReply.ClassFile).AddChar(1) //spacer
                                .AddString("ECF").AddInt(1)                    //RID
                                .AddShort(2)                                   //Len
                                .AddByte(1)                                    //filler byte
                                .AddBytes(new ECFRecord {
                    ID = 1, Name = "Test1"
                }.SerializeToByteArray(nes))
                                .AddBytes(new ECFRecord {
                    ID = 2, Name = "eof"
                }.SerializeToByteArray(nes));
                break;
            }

            return(packetBuilder.Build().RawData.ToArray());
        }