本文整理汇总了C#中StreamHandler.UnalignedWriteBit方法的典型用法代码示例。如果您正苦于以下问题:C# StreamHandler.UnalignedWriteBit方法的具体用法?C# StreamHandler.UnalignedWriteBit怎么用?C# StreamHandler.UnalignedWriteBit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StreamHandler
的用法示例。
在下文中一共展示了StreamHandler.UnalignedWriteBit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteByteMask
protected void WriteByteMask(StreamHandler writer, byte b)
{
writer.UnalignedWriteBit(b != 0);
}
示例2: Save
public unsafe void Save(StreamHandler Writer)
{
var guid = this.Guid;
Writer
.UnalignedWriteBit(this.HaveAttackingTarget)
.UnalignedWriteBit(guid.Bytes[2] != 0)
.UnalignedWriteBit(this.HaveVehicleData)
.UnalignedWriteBit(guid.Bytes[1] != 0)
.UnalignedWriteBit(guid.Bytes[4] != 0)
.UnalignedWriteBit(guid.Bytes[3] != 0)
.UnalignedWriteBit(this.HaveTransportTime)
.UnalignedWriteBit(this.HaveGameObjectPosition)
.UnalignedWriteBit(false) // TODO
.UnalignedWriteBit(false) // TODO
.UnalignedWriteBit(this.HaveGameObjectRotation)
.UnalignedWriteBit(this.Living)
.UnalignedWriteBit(this.HavePosition)
.UnalignedWriteInt((uint)this.UnkUInt32.Length, 24)
.UnalignedWriteBit(guid.Bytes[0] != 0)
;
var p_guid = this.Guid;
if (this.Living)
{
Writer.UnalignedWriteBit(this.HaveTransportData);
if (this.HaveTransportData)
{
fixed (byte* bytes = this.TransportGuid.Bytes)
{
Writer
.UnalignedWriteBit(bytes[2] != 0)
.UnalignedWriteBit(bytes[7] != 0)
.UnalignedWriteBit(bytes[5] != 0)
.UnalignedWriteBit(this.HaveTransportTime3)
.UnalignedWriteBit(bytes[3] != 0)
.UnalignedWriteBit(bytes[0] != 0)
.UnalignedWriteBit(bytes[4] != 0)
.UnalignedWriteBit(bytes[1] != 0)
.UnalignedWriteBit(this.HaveTransportTime2)
.UnalignedWriteBit(bytes[6] != 0);
}
}
Writer
.UnalignedWriteBit(this.HaveSpline2)
.UnalignedWriteBit(p_guid.Bytes[7] != 0)
.UnalignedWriteBit(p_guid.Bytes[6] != 0)
.UnalignedWriteBit(p_guid.Bytes[5] != 0)
.UnalignedWriteBit(p_guid.Bytes[2] != 0)
.UnalignedWriteBit(p_guid.Bytes[4] != 0)
.UnalignedWriteBit(!(this.Flags != 0))
.UnalignedWriteBit(p_guid.Bytes[1] != 0)
.UnalignedWriteBit(this.SelfTarget)
.UnalignedWriteBit(!(this.TimeStamp != 0))
.UnalignedWriteBit(!(this.Flags2 != 0));
if (this.HaveSpline2)
{
Writer.UnalignedWriteBit(this.HaveSpline);
if (this.HaveSpline)
{
Writer
.UnalignedWriteBit(this.Spline.HaveDurationMultiplier)
.UnalignedWriteInt((uint)this.Spline.Flags, 25)
.UnalignedWriteInt((byte)this.Spline.SplineMode, 2)
.UnalignedWriteBit(this.Spline.HaveUnknown1)
.UnalignedWriteInt((uint)this.Spline.Points.Count, 22);
byte v;
switch (this.Spline.SplineType)
{
case SplineType.FacingSpot:
v = 0;
break;
case SplineType.Normal:
v = 1;
break;
case SplineType.FacingTarget:
v = 2;
break;
case SplineType.FacingAngle:
v = 3;
break;
default:
throw new InvalidOperationException();
}
Writer.UnalignedWriteInt(v, 2);
if (this.Spline.SplineType == SplineType.FacingTarget)
{
fixed (byte* bytes = this.Spline.FacingTarget.Bytes)
{
Writer
.UnalignedWriteBit(bytes[7] != 0)
.UnalignedWriteBit(bytes[3] != 0)
.UnalignedWriteBit(bytes[4] != 0)
.UnalignedWriteBit(bytes[2] != 0)
.UnalignedWriteBit(bytes[1] != 0)
//.........这里部分代码省略.........
示例3: WriteElement
protected virtual void WriteElement(StreamHandler writer, MovementStatusElements element, MovementStatus status, byte[] guid, byte[] tguid)
{
if (element >= MovementStatusElements.GuidByte0 && element <= MovementStatusElements.GuidByte7)
{
WriteByteMask(writer, guid[element - MovementStatusElements.GuidByte0]);
return;
}
if (element >= MovementStatusElements.TransportGuidByte0 &&
element <= MovementStatusElements.TransportGuidByte7)
{
if (status.HaveTransportData)
WriteByteMask(writer, tguid[element - MovementStatusElements.TransportGuidByte0]);
return;
}
if (element >= MovementStatusElements.GuidByte0_2 && element <= MovementStatusElements.GuidByte7_2)
{
WriteByteSeq(writer, guid[element - MovementStatusElements.GuidByte0_2]);
return;
}
if (element >= MovementStatusElements.TransportGuidByte0_2 &&
element <= MovementStatusElements.TransportGuidByte7_2)
{
if (status.HaveTransportData)
WriteByteSeq(writer, tguid[element - MovementStatusElements.TransportGuidByte0_2]);
return;
}
switch (element)
{
case MovementStatusElements.Flags:
writer.UnalignedWriteBit(status.Flags == 0);
break;
case MovementStatusElements.Flags_2:
if (status.Flags != 0)
writer.UnalignedWriteInt((uint)status.Flags, 30);
break;
case MovementStatusElements.Flags2:
writer.UnalignedWriteBit(status.Flags2 == 0);
break;
case MovementStatusElements.Flags2_2:
if (status.Flags2 != 0)
writer.UnalignedWriteInt((ushort)status.Flags2, 12);
break;
case MovementStatusElements.Timestamp:
writer.UnalignedWriteBit(status.TimeStamp == 0);
break;
case MovementStatusElements.Timestamp_2:
if (status.TimeStamp != 0)
writer.WriteUInt32(status.TimeStamp);
break;
case MovementStatusElements.Pitch:
writer.UnalignedWriteBit(!status.HavePitch);
break;
case MovementStatusElements.Pitch_2:
if (status.HavePitch)
writer.WriteSingle(status.Pitch);
break;
case MovementStatusElements.HaveFallData:
writer.UnalignedWriteBit(status.HaveFallData);
break;
case MovementStatusElements.HaveFallDirection:
if (status.HaveFallData)
writer.UnalignedWriteBit(status.HaveFallDirection);
break;
case MovementStatusElements.HaveTransportData:
writer.UnalignedWriteBit(status.HaveTransportData);
break;
case MovementStatusElements.TransportHaveTime2:
if (status.HaveTransportData)
writer.UnalignedWriteBit(status.HaveTransportTime2);
break;
case MovementStatusElements.TransportHaveTime3:
if (status.HaveTransportData)
writer.UnalignedWriteBit(status.HaveTransportTime3);
break;
case MovementStatusElements.HaveSpline:
writer.UnalignedWriteBit(status.HaveSpline);
break;
case MovementStatusElements.HaveSpline2:
writer.UnalignedWriteBit(status.HaveSpline2);
break;
case MovementStatusElements.SplineElev:
writer.UnalignedWriteBit(!status.HaveSplineElevation);
break;
case MovementStatusElements.SplineElev_2:
if (status.HaveSplineElevation)
writer.WriteSingle(status.SplineElevation);
break;
case MovementStatusElements.PositionX:
writer.WriteSingle(status.Position.X);
break;
case MovementStatusElements.PositionY:
writer.WriteSingle(status.Position.Y);
break;
case MovementStatusElements.PositionZ:
writer.WriteSingle(status.Position.Z);
break;
//.........这里部分代码省略.........
示例4: 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));
}
}