Class CommandLogger
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
-
objectCommandLogger
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
commandBytesbyte[]
Returns
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
countint
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
commandICommand