public ref struct BitWriterWrites fields that are not a whole number of bytes long.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
The whole of delta compression is here. A tick number that only ever advances by one costs one bit to say so; a health value between 0 and 100 costs seven; a "this field did not change" flag costs one instead of the four bytes of the field it is standing in for. Rounding each of those up to a byte is what makes a snapshot three times the size it needs to be, and a bandwidth budget that then has to shed things it did not need to.
Bits are packed low-to-high within each byte, and bytes ascend. That is stated because it is a wire format rather than an implementation detail: the same values produce the same bytes on every platform, which is what the bit-exactness gate asserts.
Overflow behaves as PacketWriter's does — a flag and a refusal to hand over a truncated packet — for the same reason, and because the two are used together on the same buffer.
Fields and properties (4)
public readonly int BitsWrittenHow many bits have been written.
public readonly int BytesWrittenHow many bytes those bits occupy, rounded up.
public readonly int BitsRemainingHow many bits are left.
public bool OverflowedWhether a write did not fit. Once set, nothing more is written.
Methods (13)
public BitWriter(Span<byte> buffer)Creates a writer over a buffer.
public void Write(uint value, int count)Writes the low bits of a value.
public void WriteBool(bool value)Writes one bit.
public void WriteUInt32(uint value)Writes a whole 32-bit value.
public void WriteInt32(int value)Writes a whole 32-bit signed value.
public void WriteSingle(float value)Writes a float by its bits, when it has no declared range to be quantized into.
public void WriteQuantized(float value, in QuantizeRange range)Writes a float in as many bits as its range says it is worth.
public void WriteVariable(uint value)Writes a value in as few seven-bit groups as it needs, each with a bit saying whether another follows.
public void WriteBitsFrom(ReadOnlySpan<byte> source, int count)Copies bits that are already encoded, at whatever offset this writer is at.
public void Rewind(int bitPosition)Puts the writer back to an earlier position, discarding what was written after it.
public void Align()Moves to the next byte boundary, so bytes can be written whole.
public void WriteBytes(ReadOnlySpan<byte> bytes)Writes bytes, aligning first.
public readonly bool TryFinish(out ReadOnlySpan<byte> packet)Hands over the packet, if all of it fits.
Used by (78, showing 40)
- RpcSendersMultiplayer
- Vixen_Samples_Multiplayer_CombatantReplicatorMultiplayer
- Vixen_Samples_Multiplayer_VitalsReplicatorMultiplayer
- AnsweringVixen.Net.Tests
- AwaitableRpcTestsVixen.Net.Tests
- BitCodecTestsVixen.Net.Tests
- BitExactnessTestsVixen.Net.Tests
- BitReaderVixen.Net
- BitReaderTargetVixen.Net.Fuzz
- BoolCodecVixen.Net.Engine
- BroadcastRouterVixen.Net
- BroadcastTestsVixen.Net.Tests
- ByteCodecVixen.Net.Engine
- ChatVixen.Net.Tests
- ClientPredictionTestsVixen.Net.Tests
- CountdownVixen.Net.Tests
- DeltaCodecVixen.Net
- DeltaCodecTargetVixen.Net.Fuzz
- DeltaTestsVixen.Net.Tests
- FrameVixen.Net
- FuzzInputVixen.Net.Fuzz
- HandWrittenTransformReplicatorVixen.Net.Generators.Tests
- HealthReplicatorVixen.Net.Tests
- IBroadcastVixen.Net
- IComponentReplicatorVixen.Net
- IPredictedInputVixen.Net
- ISyncCodecVixen.Net.Engine
- ISyncFieldVixen.Net.Engine
- ISyncListVixen.Net.Engine
- InputBufferTargetVixen.Net.Fuzz
- InputLogVixen.Net
- Int32CodecVixen.Net.Engine
- MathCodecVixen.Net
- MotionTestsVixen.Net.Tests
- MoveVixen.Net.Tests
- MoveVixen.Net.Tests
- NetworkAnimatorParametersReplicatorVixen.Net.Animation
- NetworkAnimatorReplicatorVixen.Net.Animation
- NetworkAnimatorTestsVixen.Net.Animation.Tests
- NetworkAudioSourceReplicatorVixen.Net.Audio