Class CommandProcessor
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
-
objectCommandProcessor
Constructors
CommandProcessor(GameState)
public CommandProcessor(GameState gameState)
Parameters
gameStateGameState
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
bridgeINetworkBridge
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
commandTresultMessagestring
Returns
- bool
Type Parameters
T