Table of Contents

Class CommandLogger

Namespace
Core.Commands
Assembly
Core.dll

ENGINE LAYER - Tracks executed commands for replay/verification

Purpose:

  • Hybrid save/load: Store recent commands for determinism verification
  • Bug reproduction: Log commands to reproduce exact game state
  • Replay system foundation: Command history for replay viewer

Architecture:

  • Ring buffer: Keeps last N commands only (bounded memory)
  • Serialization: Commands serialize to byte arrays
  • Integration: CommandProcessor calls LogCommand after execution

Usage: commandLogger.LogCommand(command); byte[][] recentCommands = commandLogger.GetRecentCommands(100);

public class CommandLogger : MonoBehaviour
Inheritance
object
CommandLogger

Fields

logCommandExecution

[Tooltip("Enable debug logging for command tracking")]
public bool logCommandExecution

Field Value

bool

maxCommandHistory

[Header("Configuration")]
[Tooltip("Maximum commands to keep in history (ring buffer size)")]
public int maxCommandHistory

Field Value

int

Methods

ClearHistory()

Clear command history

public void ClearHistory()

DeserializeCommand(byte[])

Deserialize command from byte array NOTE: Requires command type to be available at runtime

public ICommand DeserializeCommand(byte[] commandBytes)

Parameters

commandBytes byte[]

Returns

ICommand

GetAllCommands()

Get all logged commands

public List<byte[]> GetAllCommands()

Returns

List<byte[]>

GetRecentCommands(int)

Get recent commands (last N commands)

public List<byte[]> GetRecentCommands(int count)

Parameters

count int

Returns

List<byte[]>

GetStatistics()

Get statistics about logged commands

public (int totalCommands, long totalBytes, int currentBufferSize) GetStatistics()

Returns

(int totalCommands, long totalBytes, int currentBufferSize)

LogCommand(ICommand)

Log a command after execution

public void LogCommand(ICommand command)

Parameters

command ICommand