Пример #1
0
        public static Metadata Read(EndianBinaryReader r)
        {
            Metadata m = new Metadata();

            while (true)
            {
                byte f = r.ReadByte();
                if (f == 0x7F)
                {
                    return(m);
                }

                MetaField mf = new MetaField(f & 0x1F, (MetaType)(f >> 5));
                switch (mf.Type)
                {
                case MetaType.Byte:
                    mf.Byte = r.ReadSByte();
                    break;

                case MetaType.Short:
                    mf.Short = r.ReadInt16();
                    break;

                case MetaType.Int:
                    mf.Int = r.ReadInt32();
                    break;

                case MetaType.Float:
                    mf.Float = r.ReadSingle();
                    break;

                case MetaType.String:
                    mf.String = Packet.ReadString8(r);
                    break;

                case MetaType.Item:
                    mf.Item = SlotItem.Read(r);
                    break;

                case MetaType.Vector:
                    mf.Vector   = new CoordInt();
                    mf.Vector.X = r.ReadInt32();
                    mf.Vector.Y = r.ReadInt32();
                    mf.Vector.Z = r.ReadInt32();
                    break;

                case MetaType.VectorF:
                    mf.VectorF   = new CoordDouble();
                    mf.VectorF.X = r.ReadSingle();
                    mf.VectorF.Y = r.ReadSingle();
                    mf.VectorF.Z = r.ReadSingle();
                    break;

                default:
                    throw new NotImplementedException();
                }
                m.Fields.Add(mf.ID, mf);
            }
        }
Пример #2
0
        public void SetByte(int id, sbyte value)
        {
            MetaField f = new MetaField(id, MetaType.Byte);

            f.Byte = value;
            Fields.Remove(id);
            Fields.Add(id, f);
        }
Пример #3
0
        public void SetFloat(int id, float value)
        {
            MetaField f = new MetaField(id, MetaType.Float);

            f.Float = value;
            Fields.Remove(id);
            Fields.Add(id, f);
        }
Пример #4
0
        public void SetInt(int id, int value)
        {
            MetaField f = new MetaField(id, MetaType.Int);

            f.Int = value;
            Fields.Remove(id);
            Fields.Add(id, f);
        }
Пример #5
0
        public void SetShort(int id, short value)
        {
            MetaField f = new MetaField(id, MetaType.Short);

            f.Short = value;
            Fields.Remove(id);
            Fields.Add(id, f);
        }
Пример #6
0
        public void SetString(int id, string value)
        {
            MetaField f = new MetaField(id, MetaType.String);

            f.String = value;
            Fields.Remove(id);
            Fields.Add(id, f);
        }
Пример #7
0
 public void SetInt(int id, int value)
 {
     MetaField f = new MetaField(id, MetaType.Int);
     f.Int = value;
     Fields.Remove(id);
     Fields.Add(id, f);
 }
Пример #8
0
 public void SetString(int id, string value)
 {
     MetaField f = new MetaField(id, MetaType.String);
     f.String = value;
     Fields.Remove(id);
     Fields.Add(id, f);
 }
Пример #9
0
 public static Metadata Read(EndianBinaryReader r)
 {
     Metadata m = new Metadata();
     
     while (true)
     {
         byte f = r.ReadByte();
         if (f == 0x7F)
             return m;
         
         MetaField mf = new MetaField(f & 0x1F, (MetaType)(f >> 5));
         switch (mf.Type)
         {
             case MetaType.Byte:
                 mf.Byte = r.ReadSByte();
                 break;
             case MetaType.Short:
                 mf.Short = r.ReadInt16();
                 break;
             case MetaType.Int:
                 mf.Int = r.ReadInt32();
                 break;
             case MetaType.Float:
                 mf.Float = r.ReadSingle();
                 break;
             case MetaType.String:
                 mf.String = Packet.ReadString8(r);
                 break;
             case MetaType.Item:
                 mf.Item = SlotItem.Read(r);
                 break;
             case MetaType.Vector:
                 mf.Vector = new CoordInt();
                 mf.Vector.X = r.ReadInt32();
                 mf.Vector.Y = r.ReadInt32();
                 mf.Vector.Z = r.ReadInt32();
                 break;
             case MetaType.VectorF:
                 mf.VectorF = new CoordDouble();
                 mf.VectorF.X = r.ReadSingle();
                 mf.VectorF.Y = r.ReadSingle();
                 mf.VectorF.Z = r.ReadSingle();
                 break;
             default:
                 throw new NotImplementedException();
         }
         m.Fields.Add(mf.ID, mf);				
     }
 }
Пример #10
0
 public void SetFloat(int id, float value)
 {
     MetaField f = new MetaField(id, MetaType.Float);
     f.Float = value;
     Fields.Remove(id);
     Fields.Add(id, f);
 }
Пример #11
0
 public void SetByte(int id, sbyte value)
 {
     MetaField f = new MetaField(id, MetaType.Byte);
     f.Byte = value;
     Fields.Remove(id);
     Fields.Add(id, f);
 }
Пример #12
0
 public void SetShort(int id, short value)
 {
     MetaField f = new MetaField(id, MetaType.Short);
     f.Short = value;
     Fields.Remove(id);
     Fields.Add(id, f);
 }