Class FieldCodec
Encodes and decodes one section of fields — a record body, an event or command payload — per 03-wire-protocol § 5 and decisions W11–W13: the leading bit pack, then each byte-aligned field in wire order.
public static class FieldCodec
- Inheritance
-
FieldCodec
- Inherited Members
Fields
GroundedHeight
The height a grounded segment decodes to (#1616): the positive quiet NaN, 0x7FF8000000000000 — the pattern JavaScript and C++ produce, where
.NET's NaN is 0xFFF8000000000000. One bit pattern in every SDK keeps the golden vectors byte-comparable.
public static readonly double GroundedHeight
Field Value
MaxListComponents
The largest number of components one numeric decode yields, a list's included.
public const int MaxListComponents = 1020
Field Value
Methods
PackedCode(FieldPlan, double)
The code a packed field (bool, bits) stores for value.
public static uint PackedCode(FieldPlan field, double value)
Parameters
Returns
Exceptions
- ArgumentException
A
bitsvalue that is not an integer in its range.
ReadGroundAxes(ref WireReader, FieldPlan, scoped Span<double>, int, RealmFrame)
Decodes a grounded segment's position or velocity (#1616): every axis of a pos3 or vel3 but up, which is NaN for a
position and 0 for a velocity — the client derives the height from its terrain.
public static void ReadGroundAxes(ref WireReader reader, FieldPlan field, scoped Span<double> destination, int up, RealmFrame frame = null)
Parameters
readerWireReaderThe reader.
fieldFieldPlanThe position or velocity codec.
destinationSpan<double>Receives three values.
upintThe omitted axis, 0 to 2.
frameRealmFrameThe realm frame, for a position.
ReadInteger64(ref WireReader, FieldPlan, scoped Span<ulong>)
Decodes one 64-bit integer field (W32) into destination, as bit patterns.
public static void ReadInteger64(ref WireReader reader, FieldPlan field, scoped Span<ulong> destination)
Parameters
readerWireReaderThe reader.
fieldFieldPlanA
u64,i64,varu64orvari64field.destinationSpan<ulong>Receives Components values.
ReadNumber(ref WireReader, FieldPlan, uint, scoped Span<double>, RealmFrame)
Decodes one numeric value of field into destination.
public static void ReadNumber(ref WireReader reader, FieldPlan field, uint frameTick, scoped Span<double> destination, RealmFrame frame = null)
Parameters
readerWireReaderThe reader.
fieldFieldPlanA byte-aligned numeric field (or list element, or position codec).
frameTickuintThe frame's tick, for
tickLo.destinationSpan<double>Receives Components values.
frameRealmFrameThe realm frame a position decodes over; a position with none is a protocol error (1002).
ReadPackedBits(ReadOnlySpan<byte>, int, int)
Extracts count bits starting at offset from a pack, least significant bit first (W12).
public static uint ReadPackedBits(ReadOnlySpan<byte> pack, int offset, int count)
Parameters
packReadOnlySpan<byte>The pack bytes.
offsetintThe first bit.
countintThe width, 1 to 24.
Returns
- uint
The unsigned value.
ReadSection<TSink>(ref WireReader, SectionPlan, uint, ref TSink, RealmFrame)
Decodes a section, handing each field's value to sink.
public static void ReadSection<TSink>(ref WireReader reader, SectionPlan section, uint frameTick, ref TSink sink, RealmFrame frame = null) where TSink : IFieldSink, allows ref struct
Parameters
readerWireReaderThe reader, positioned at the section's first byte.
sectionSectionPlanThe section.
frameTickuintThe tick of the frame being decoded, which
tickLorebuilds against.sinkTSinkReceives the values.
frameRealmFrameThe session's realm frame, which a position field decodes over (SUB-30); null when it holds none.
Type Parameters
TSinkThe sink type; a struct keeps the call inlined.
WriteCollectionHeader(ref WireWriter, FieldPlan, int, int)
Writes a collection's header, varu total | varu sent (W34); its elements follow, each written with WriteSection(ref WireWriter, SectionPlan, Func<FieldPlan, FieldValue>, RealmFrame) over
ElementSection.
public static void WriteCollectionHeader(ref WireWriter writer, FieldPlan field, int total, int sent)
Parameters
writerWireWriterThe writer.
fieldFieldPlanThe collection field.
totalintHow many elements the entity holds.
sentintHow many follow: at most
totaland the codec'smaxCount.
WriteGroundAxes(ref WireWriter, FieldPlan, scoped ReadOnlySpan<double>, int, RealmFrame)
Encodes a grounded segment's position or velocity (#1616): every axis but up.
public static void WriteGroundAxes(ref WireWriter writer, FieldPlan field, scoped ReadOnlySpan<double> components, int up, RealmFrame frame = null)
Parameters
writerWireWriterThe writer.
fieldFieldPlanThe position or velocity codec.
componentsReadOnlySpan<double>Three values; the up one is ignored.
upintThe omitted axis, 0 to 2.
frameRealmFrameThe realm frame, for a position.
WriteInteger64(ref WireWriter, FieldPlan, scoped ReadOnlySpan<ulong>)
Encodes one 64-bit integer field (W32) from bit patterns.
public static void WriteInteger64(ref WireWriter writer, FieldPlan field, scoped ReadOnlySpan<ulong> components)
Parameters
writerWireWriterThe writer.
fieldFieldPlanA
u64,i64,varu64orvari64field.componentsReadOnlySpan<ulong>At least Components values; a signed value as its two's complement.
WriteNumber(ref WireWriter, FieldPlan, scoped ReadOnlySpan<double>, RealmFrame)
Encodes one numeric value of field.
public static void WriteNumber(ref WireWriter writer, FieldPlan field, scoped ReadOnlySpan<double> components, RealmFrame frame = null)
Parameters
writerWireWriterThe writer.
fieldFieldPlanA byte-aligned numeric field (or list element, or position codec).
componentsReadOnlySpan<double>At least Components values.
frameRealmFrameThe realm frame a position is quantized over; a position with none is refused.
WritePackedBits(Span<byte>, int, int, uint)
Stores count bits of value at offset in a pack, least significant bit first.
public static void WritePackedBits(Span<byte> pack, int offset, int count, uint value)
Parameters
packSpan<byte>The pack bytes.
offsetintThe first bit.
countintThe width, 1 to 24.
valueuintThe value; bits above
countmust be zero.
WriteSection(ref WireWriter, SectionPlan, Func<FieldPlan, FieldValue>, RealmFrame)
Encodes a section from values, which is asked for each field in wire order.
public static void WriteSection(ref WireWriter writer, SectionPlan section, Func<FieldPlan, FieldValue> values, RealmFrame frame = null)
Parameters
writerWireWriterThe writer.
sectionSectionPlanThe section.
valuesFunc<FieldPlan, FieldValue>Supplies each field's value.
frameRealmFrameThe realm frame a position field is quantized over (SUB-30); null when there is none.