本文整理汇总了C#中StreamHandler.FlushUnalignedBits方法的典型用法代码示例。如果您正苦于以下问题:C# StreamHandler.FlushUnalignedBits方法的具体用法?C# StreamHandler.FlushUnalignedBits怎么用?C# StreamHandler.FlushUnalignedBits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StreamHandler
的用法示例。
在下文中一共展示了StreamHandler.FlushUnalignedBits方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteElement
protected override void WriteElement(StreamHandler writer, RegularMovementPacket.MovementStatusElements element, MovementStatus status, byte[] guid, byte[] tguid)
{
if (element == MovementStatusElements.GenericDword2)
{
writer.FlushUnalignedBits();
writer.WriteSingle(this.NewValue);
}
else
base.WriteElement(writer, element, status, guid, tguid);
}
示例2: ElementWrite
protected override void ElementWrite(StreamHandler writer, int index)
{
if (index == -2)
{
writer.FlushUnalignedBits();
writer.WriteUInt32(this.NewValue);
}
else
base.ElementWrite(writer, index);
}
示例3: WriteElement
protected override void WriteElement(StreamHandler writer, RegularMovementPacket.MovementStatusElements element, MovementStatus status, byte[] guid, byte[] tguid)
{
if (element == MovementStatusElements.GenericDword0)
{
writer.FlushUnalignedBits();
writer.WriteUInt32(this.ChangeCounter);
}
else
base.WriteElement(writer, element, status, guid, tguid);
}
示例4: ElementWrite
protected override void ElementWrite(StreamHandler writer, int index)
{
if (index == -1)
{
writer.FlushUnalignedBits();
writer.WriteUInt32(this.ChangeCounter);
}
else
throw new InvalidOperationException("Unknown write element: " + index);
}
示例5: WriteByteSeq
protected void WriteByteSeq(StreamHandler writer, byte b)
{
writer.FlushUnalignedBits();
if (b != 0)
writer.WriteByte((byte)(b ^ 1));
}
示例6: Save
//.........这里部分代码省略.........
{
Writer
.UnalignedWriteBit(bytes[1] != 0)
.UnalignedWriteBit(this.HaveTransportTime3)
.UnalignedWriteBit(bytes[3] != 0)
.UnalignedWriteBit(bytes[2] != 0)
.UnalignedWriteBit(bytes[6] != 0)
.UnalignedWriteBit(bytes[5] != 0)
.UnalignedWriteBit(bytes[0] != 0)
.UnalignedWriteBit(bytes[4] != 0)
.UnalignedWriteBit(this.HaveTransportTime2)
.UnalignedWriteBit(bytes[7] != 0);
}
}
// TODO: shorts here
if (this.HaveAttackingTarget)
{
fixed (byte* bytes = this.AttackingTarget.Bytes)
{
Writer
.UnalignedWriteBit(bytes[3] != 0)
.UnalignedWriteBit(bytes[4] != 0)
.UnalignedWriteBit(bytes[6] != 0)
.UnalignedWriteBit(bytes[0] != 0)
.UnalignedWriteBit(bytes[1] != 0)
.UnalignedWriteBit(bytes[7] != 0)
.UnalignedWriteBit(bytes[5] != 0)
.UnalignedWriteBit(bytes[2] != 0);
}
}
Writer.FlushUnalignedBits();
foreach (var val in this.UnkUInt32)
Writer.WriteUInt32(val);
if (this.HavePosition)
{
Writer
.WriteSingle(this.Position.Z)
.WriteSingle(this.Orientation)
.WriteSingle(this.Position.X)
.WriteSingle(this.Position.Y);
}
if (this.HaveVehicleData)
{
Writer
.WriteUInt32(this.VehicleId)
.WriteSingle(this.VehicleAimAdjustement);
}
if (this.HaveGameObjectPosition)
{
fixed (byte* bytes = this.TransportGuid.Bytes)
{
Writer
.WriteXorByte(bytes[1])
.WriteXorByte(bytes[4])
.WriteSingle(this.TransportPosition.Z);
if (this.HaveTransportTime3)
Writer.WriteUInt32(this.TransportTime3);
示例7: Save
public sealed override void Save(StreamHandler writer)
{
var seq_b = ByteSequence;
var seq_m = MaskSequence;
var b_xor = ByteXorValue;
int size = seq_m.Count(x => x >= 0);
if (size != seq_m.Length && this.IsMaskSequenceSwapped)
throw new InvalidOperationException("Cannot have elements in swapped MaskSequence.");
CheckSequences(seq_b, seq_m);
if (this.IsMaskSequenceSwapped)
{
var seq_m_copy = new int[seq_m.Length];
for (int i = 0; i < seq_m.Length; )
{
var t = i;
for (int j = t + 8 - 1; j >= t; --j, ++i)
seq_m_copy[j] = seq_m[i];
}
seq_m = seq_m_copy;
}
byte[] data = new byte[size];
PackedSave(data);
var mask = new BitArray(size);
for (int i = 0; i < size; ++i)
{
var el = seq_m[i];
if (el < 0)
ElementWrite(writer, el);
else
writer.UnalignedWriteBit(data[el] != 0);
}
writer.FlushUnalignedBits();
for (int i = 0; i < seq_b.Length; ++i)
{
var el = seq_b[i];
if (el < 0)
ElementWrite(writer, el);
else if (data[el] != 0)
writer.WriteByte((byte)(data[el] ^ b_xor));
}
}