Table of Contents

Class BaseCommand

Namespace
Core.Commands
Assembly
Core.dll

Base class for commands with common functionality Provides default implementations and utilities

public abstract class BaseCommand : ICommand
Inheritance
object
BaseCommand
Implements
Derived

Properties

CommandId

Get unique command ID for networking and logging

public virtual string CommandId { get; }

Property Value

string

Priority

Get command priority for execution ordering Higher priority commands execute first

public virtual int Priority { get; }

Property Value

int

Methods

Deserialize(BinaryReader)

Deserialize command data from binary reader Used for save/load and command replay Must reconstruct identical command state

public abstract void Deserialize(BinaryReader reader)

Parameters

reader BinaryReader

Binary reader to deserialize from

Execute(GameState)

Execute the command and modify game state Should emit appropriate events for other systems to react Must be deterministic for multiplayer compatibility

public abstract void Execute(GameState gameState)

Parameters

gameState GameState

Game state to modify

LogExecution(string)

Log command execution for debugging

protected void LogExecution(string action)

Parameters

action string

Serialize(BinaryWriter)

Serialize command data to binary writer Used for save/load and command logging Must be deterministic - same command = same bytes

public abstract void Serialize(BinaryWriter writer)

Parameters

writer BinaryWriter

Binary writer to serialize to

Undo(GameState)

Undo the command - restore previous state Required for replay systems and error recovery

public abstract void Undo(GameState gameState)

Parameters

gameState GameState

Game state to restore

Validate(GameState)

Validate that this command can be executed in the current game state. Should be fast and have no side effects.

public abstract bool Validate(GameState gameState)

Parameters

gameState GameState

Current game state for validation

Returns

bool

True if command can be executed

ValidateCountryId(GameState, ushort)

Utility for common validation checks

protected bool ValidateCountryId(GameState gameState, ushort countryId)

Parameters

gameState GameState
countryId ushort

Returns

bool

ValidateProvinceId(GameState, ushort)

Utility for common validation checks

protected bool ValidateProvinceId(GameState gameState, ushort provinceId)

Parameters

gameState GameState
provinceId ushort

Returns

bool