Class CommandLog

Namespace
TDMaker.Core
Assembly
TDMaker.Core.dll

Fixed-capacity input recording with seed and versioned binary persistence. Record only external Enqueue calls between ticks.

public sealed class CommandLog
Inheritance
CommandLog
Inherited Members

Examples

var log = new CommandLog(sim.Seed); sim.StartRecording(log); /* enqueue and step */ sim.StopRecording(); log.WriteTo(stream);

Remarks

Recreate identical templates, initial spawns and extensions before replay. Commands generated inside Step are regenerated by their systems. Saving and loading allocate outside Step; custom commands require an ICommandCodec.

Constructors

CommandLog(uint, int)

Preallocates a command recording.

public CommandLog(uint seed, int capacity = 4096)

Parameters

seed uint
capacity int

Properties

Capacity

Maximum inputs without growing storage.

public int Capacity { get; }

Property Value

int

Entries

Records in submission order; ticks are nondecreasing.

public IReadOnlyList<CommandRecord> Entries { get; }

Property Value

IReadOnlyList<CommandRecord>

IsSealed

Whether recording has ended and the log can be replayed or saved.

public bool IsSealed { get; }

Property Value

bool

Seed

Original simulation seed.

public uint Seed { get; }

Property Value

uint

UpgradeFingerprint

Permanent-upgrade setup fingerprint captured at recording start; zero identifies an unmodified legacy setup.

public ulong UpgradeFingerprint { get; }

Property Value

ulong

Methods

ReadFrom(Stream, ICommandCodec, int)

Loads a sealed log without closing the caller's stream. The limit bounds input count; custom codecs validate their own payloads.

public static CommandLog ReadFrom(Stream stream, ICommandCodec customCodec = null, int maximumEntries = 1000000)

Parameters

stream Stream
customCodec ICommandCodec
maximumEntries int

Returns

CommandLog

WriteTo(Stream, ICommandCodec)

Writes the complete sealed log without closing the caller's stream.

public void WriteTo(Stream stream, ICommandCodec customCodec = null)

Parameters

stream Stream
customCodec ICommandCodec