Table of Contents

Class CommandProcessor

Namespace
Core.Commands
Assembly
Core.dll

Processes commands (ICommand) with network synchronization. All game state changes flow through this processor.

Commands are validated locally, then:

  • Host: executes locally and broadcasts to clients
  • Client: sends to host for validation and execution
public class CommandProcessor
Inheritance
object
CommandProcessor

Constructors

CommandProcessor(GameState)

public CommandProcessor(GameState gameState)

Parameters

gameState GameState

Properties

IsAuthoritative

Whether we are the authoritative host (or single-player).

public bool IsAuthoritative { get; }

Property Value

bool

IsMultiplayer

Whether we are in a multiplayer session.

public bool IsMultiplayer { get; }

Property Value

bool

Methods

Dispose()

public void Dispose()

RegisterCommandType<T>()

Register a command type for network serialization. Must be called for all command types that will be networked. Call order must be identical on all clients!

public void RegisterCommandType<T>() where T : ICommand, new()

Type Parameters

T

SetNetworkBridge(INetworkBridge)

Set the network bridge for multiplayer. Pass null for single-player mode.

public void SetNetworkBridge(INetworkBridge bridge)

Parameters

bridge INetworkBridge

SubmitCommand<T>(T, out string)

Submit a command for execution. In multiplayer:

  • Clients send to host for validation
  • Host validates, executes, and broadcasts
public bool SubmitCommand<T>(T command, out string resultMessage) where T : ICommand

Parameters

command T
resultMessage string

Returns

bool

Type Parameters

T