Table of Contents

Class FieldCodec

Namespace
Typhon.Protocol
Assembly
Typhon.Protocol.dll

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

double

MaxListComponents

The largest number of components one numeric decode yields, a list's included.

public const int MaxListComponents = 1020

Field Value

int

Methods

PackedCode(FieldPlan, double)

The code a packed field (bool, bits) stores for value.

public static uint PackedCode(FieldPlan field, double value)

Parameters

field FieldPlan

A packed field.

value double

Its value.

Returns

uint

The code, BitCount bits wide.

Exceptions

ArgumentException

A bits value 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

reader WireReader

The reader.

field FieldPlan

The position or velocity codec.

destination Span<double>

Receives three values.

up int

The omitted axis, 0 to 2.

frame RealmFrame

The 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

reader WireReader

The reader.

field FieldPlan

A u64, i64, varu64 or vari64 field.

destination Span<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

reader WireReader

The reader.

field FieldPlan

A byte-aligned numeric field (or list element, or position codec).

frameTick uint

The frame's tick, for tickLo.

destination Span<double>

Receives Components values.

frame RealmFrame

The 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

pack ReadOnlySpan<byte>

The pack bytes.

offset int

The first bit.

count int

The 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

reader WireReader

The reader, positioned at the section's first byte.

section SectionPlan

The section.

frameTick uint

The tick of the frame being decoded, which tickLo rebuilds against.

sink TSink

Receives the values.

frame RealmFrame

The session's realm frame, which a position field decodes over (SUB-30); null when it holds none.

Type Parameters

TSink

The 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

writer WireWriter

The writer.

field FieldPlan

The collection field.

total int

How many elements the entity holds.

sent int

How many follow: at most total and the codec's maxCount.

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

writer WireWriter

The writer.

field FieldPlan

The position or velocity codec.

components ReadOnlySpan<double>

Three values; the up one is ignored.

up int

The omitted axis, 0 to 2.

frame RealmFrame

The 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

writer WireWriter

The writer.

field FieldPlan

A u64, i64, varu64 or vari64 field.

components ReadOnlySpan<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

writer WireWriter

The writer.

field FieldPlan

A byte-aligned numeric field (or list element, or position codec).

components ReadOnlySpan<double>

At least Components values.

frame RealmFrame

The 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

pack Span<byte>

The pack bytes.

offset int

The first bit.

count int

The width, 1 to 24.

value uint

The value; bits above count must 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

writer WireWriter

The writer.

section SectionPlan

The section.

values Func<FieldPlan, FieldValue>

Supplies each field's value.

frame RealmFrame

The realm frame a position field is quantized over (SUB-30); null when there is none.