Table of Contents

Struct CooldownReconcileEntry

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

A single cooldown entry for reconcile serialization. Implements IEquatable<T> for efficient delta comparison in CharacterReconcileDataDeltaSerializer.

public struct CooldownReconcileEntry : IEquatable<CooldownReconcileEntry>
Implements
Inherited Members

Fields

AbilityID

The ability ID this cooldown is associated with.

public long AbilityID

Field Value

long

DurationTicks

The duration of this cooldown in ticks.

public uint DurationTicks

Field Value

uint

StartTick

The absolute network tick at which this cooldown started.

public uint StartTick

Field Value

uint

Methods

Equals(CooldownReconcileEntry)

Compares all fields for equality. Used by the delta serializer to determine which entries changed between ticks.

public bool Equals(CooldownReconcileEntry other)

Parameters

other CooldownReconcileEntry

Returns

bool

Equals(object)

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

ReadArrayDelta(Reader, CooldownReconcileEntry[])

Reads a cooldown array from the delta stream. High header bit = index-delta over prev, otherwise full array.

public static CooldownReconcileEntry[] ReadArrayDelta(Reader reader, CooldownReconcileEntry[] prev)

Parameters

reader Reader
prev CooldownReconcileEntry[]

Returns

CooldownReconcileEntry[]

Remarks

When count exceeds FishMMO.Shared.CooldownReconcileEntry.MaxEntries, remaining entry data is drained from the reader to keep the stream position valid for subsequent fields. The previous state is preserved.

Allocation note: Both full-array and index-delta paths allocate a fresh array per call (intentional — see issue #6: mutating in-place would corrupt the delta serializer’s prev reference). Full-array is rare (only when the cooldown count changes). Index-delta copies are small. If profiling shows GC pressure, consider System.Buffers.ArrayPool<CooldownReconcileEntry> with an explicit count sidecar, since Rent may return oversized arrays.

ReadFrom(Reader)

Reads a single entry's fields from the network reader.

public static CooldownReconcileEntry ReadFrom(Reader reader)

Parameters

reader Reader

Returns

CooldownReconcileEntry

WriteArrayDelta(Writer, CooldownReconcileEntry[], CooldownReconcileEntry[], DeltaSerializerOption)

Compares and writes cooldown arrays using index-delta compression. The wire header is a packed 16-bit value: high bit = delta mode, low 15 bits = entry count. FishMMO.Shared.CooldownReconcileEntry.MaxEntries is 4096, so this saves 2 bytes per array header and 2 bytes per changed index.

public static bool WriteArrayDelta(Writer writer, CooldownReconcileEntry[] prev, CooldownReconcileEntry[] next, DeltaSerializerOption option)

Parameters

writer Writer
prev CooldownReconcileEntry[]
next CooldownReconcileEntry[]
option DeltaSerializerOption

Returns

bool

Remarks

Null / empty equivalence: both null and empty arrays serialize as count == 0 on the wire, and ReadArrayDelta(Reader, CooldownReconcileEntry[]) returns null for both. Callers must treat null and empty as identical.

Position-based identity: index-delta uses array position, not AbilityID. When cooldowns are added or removed, the SortedDictionary iteration order may shift entries to different positions, causing more entries to appear changed than conceptually changed. This is correct (sends more bytes) but never incorrect. When the length changes, a full array is sent.

WriteTo(Writer)

Writes a single entry's fields to the network writer.

public void WriteTo(Writer writer)

Parameters

writer Writer