Skip to main content

StreamCounter

A class in Alta.Serialization.Runtime, Alta.Serialization.

A write-only Stream that only counts bits, used to measure how big a serialized block will be (for example by SavingSystem and NetworkPrefab).

Constructors​

MemberWhat it is
StreamCounter(uint offset)Creates a StreamCounter from offset.

Fields​

2 private and internal fields
MemberWhat it is
private uint bitIndexAbsolute bit position, starting at the offset.
private uint offsetBit position the counter started at.

Properties​

MemberWhat it is
override uint BitIndex { get; }Bits counted since the starting offset.
override bool IsCounter { get; }Always true, so serializers can tell they are only being measured.
override uint TotalByteCount { get; }BitIndex in whole bytes, rounded down.

Methods​

MemberWhat it is
override void Align()Rounds the bit count up to the next whole byte.
override void BackTrack(uint bitCount)Subtracts bits from the count.
override object Clone()Copies the counter with its current count.
override void Dispose()Does nothing.
override void SerializeBits(ref uint value, int bitCount)Adds the bit count.
override void SerializeString(ref string value, Stream.StringEncoding encoding = 0)Adds a 16-bit length plus the aligned encoded bytes.
protected override void SerializeBytes(byte[] value, int byteCount)Adds 8 bits per byte.