36 lines
1.0 KiB
C#
36 lines
1.0 KiB
C#
using System;
|
|
using VRage.Library.Collections;
|
|
|
|
namespace Global.Util
|
|
{
|
|
internal class SendBuffer : IBitSerializable
|
|
{
|
|
public int NumElements;
|
|
public long SenderUserId;
|
|
public byte[] VoiceDataBuffer;
|
|
|
|
public bool Serialize(BitStream stream, bool validate, bool acceptAndSetValue = true)
|
|
{
|
|
if (stream.Reading)
|
|
{
|
|
SenderUserId = stream.ReadInt64();
|
|
NumElements = stream.ReadInt32();
|
|
ArrayExtensions.EnsureCapacity(ref VoiceDataBuffer, NumElements);
|
|
stream.ReadBytes(VoiceDataBuffer, 0, NumElements);
|
|
}
|
|
else
|
|
{
|
|
stream.WriteInt64(SenderUserId);
|
|
stream.WriteInt32(NumElements);
|
|
stream.WriteBytes(VoiceDataBuffer, 0, NumElements);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public static implicit operator BitReaderWriter(SendBuffer buffer)
|
|
{
|
|
return new BitReaderWriter(buffer);
|
|
}
|
|
}
|
|
} |