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); } }
public void SetByte(int id, sbyte value) { MetaField f = new MetaField(id, MetaType.Byte); f.Byte = value; Fields.Remove(id); Fields.Add(id, f); }
public void SetFloat(int id, float value) { MetaField f = new MetaField(id, MetaType.Float); f.Float = value; Fields.Remove(id); Fields.Add(id, f); }
public void SetInt(int id, int value) { MetaField f = new MetaField(id, MetaType.Int); f.Int = value; Fields.Remove(id); Fields.Add(id, f); }
public void SetShort(int id, short value) { MetaField f = new MetaField(id, MetaType.Short); f.Short = value; Fields.Remove(id); Fields.Add(id, f); }
public void SetString(int id, string value) { MetaField f = new MetaField(id, MetaType.String); f.String = value; Fields.Remove(id); Fields.Add(id, f); }
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); } }