示例#1
0
        public static void WriteLengthPrefixedString(EndianAwareBinaryWriter writer, string value)
        {
            var stringBytes = RobloxEncoding.GetBytes(value);

            writer.WriteInt32(stringBytes.Length);
            writer.WriteBytes(stringBytes);
        }
示例#2
0
 public void Serialize(EndianAwareBinaryWriter writer)
 {
     writer.WriteInt32(TypeId);
     Util.WriteLengthPrefixedString(writer, Name);
     writer.WriteByte((byte)(AdditionalData != null ? 1 : 0));
     writer.WriteInt32(InstanceCount);
     Util.WriteReferentArray(writer, Referents);
     if (AdditionalData != null)
     {
         writer.WriteBytes(AdditionalData);
     }
 }
示例#3
0
        public static void WriteFloatArray(EndianAwareBinaryWriter writer, float[] values)
        {
            var buffer = new byte[values.Length * sizeof(float)];

            for (var i = 0; i < values.Length; i++)
            {
                TransformFloat(values[i], buffer, i * sizeof(float));
            }
            var interleaved = InterleaveBytes(buffer, sizeof(float));

            writer.WriteBytes(interleaved);
        }
示例#4
0
        public static void WriteInterleavedPropertyDataHelper <T>(EndianAwareBinaryWriter writer, T[] values, int valueSize, Func <T, byte[]> convertProc)
        {
            var bytes = new byte[values.Length * valueSize];

            for (var i = 0; i < values.Length; i++)
            {
                var valBytes = convertProc(values[i]);
                Array.Copy(valBytes, 0, bytes, i * valueSize, valueSize);
            }

            var interleaved = InterleaveBytes(bytes, valueSize);

            writer.WriteBytes(interleaved);
        }
示例#5
0
        public static void WriteReferentArray(EndianAwareBinaryWriter writer, int[] values)
        {
            var bytes = new byte[values.Length * sizeof(int)];

            var last = 0;

            for (var i = 0; i < values.Length; i++)
            {
                var val         = values[i] - last;
                var transformed = TransformInt32(val);
                var valBytes    = EndianAwareBitConverter.GetBytes(transformed, Endianness.Big);
                last = values[i];
                Array.Copy(valBytes, 0, bytes, i * sizeof(int), sizeof(int));
            }

            var interleaved = InterleaveBytes(bytes, sizeof(int));

            writer.WriteBytes(interleaved);
        }
示例#6
0
        public static void WriteInt32Array(EndianAwareBinaryWriter writer, int[] values)
        {
            var bytes = TransformInt32Array(values);

            writer.WriteBytes(bytes);
        }