Namespace Core.Commands
Classes
- ArgAttribute
Marks a property as a command argument for auto-parsing and serialization.
Supported types:
- Primitives: int, float, double, bool, byte, ushort, uint, long
- Strings: string
- Fixed-point: FixedPoint64 (parsed from float)
Usage: [Arg(0, "amount")] public int Amount { get; set; }
[Arg(1, "target", Optional = true)] public ushort TargetId { get; set; }
- BaseCommand
Base class for commands with common functionality Provides default implementations and utilities
- ChangeProvinceOwnerCommand
Command to change province ownership Handles validation, execution, and undo for province conquest/transfer
- CommandAttribute
Marks a SimpleCommand class for auto-discovery and factory generation. Replaces the need for separate ICommandFactory + CommandMetadataAttribute.
Usage: [Command("my_command", Description = "Does something")] public class MyCommand : SimpleCommand { ... }
- 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);
- CommandMetadataAttribute
Attribute to define command metadata for auto-registration and help generation. Apply to ICommandFactory implementations for automatic discovery.
- 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
- CommandRegistry
Registry for command factories with auto-discovery. Discovers commands via reflection and provides lookup by name/alias.
Usage:
- Create registry instance
- Call DiscoverCommands() with assemblies to scan
- Use TryGetCommand() to find commands by name/alias
- CommandRegistry.CommandRegistration
Registration entry for a command.
- ProvinceCommandFactory
Command factory for creating common province commands Provides convenient methods for typical operations
- SimpleCommand
Simplified command base class with auto-serialization. Use [Command] attribute on class and [Arg] attributes on properties.
Benefits over BaseCommand:
- No separate factory class needed
- Auto-serialization of [Arg] properties
- Auto-generated usage/help text
- Optional Undo (default no-op)
Use BaseCommand instead when you need:
- Custom serialization format
- Complex undo logic
- Maximum performance (no reflection)
- SimpleCommandFactory
Auto-generates ICommandFactory wrappers for SimpleCommand classes. Handles argument parsing based on [Arg] attributes.
- TransferProvincesCommand
Command to transfer multiple provinces at once (useful for peace deals, vassal integration) Validates all provinces before executing any changes
Structs
- CommandResult
Command execution result Provides detailed feedback about command execution
Interfaces
- ICommand
Base interface for all game commands Commands provide validation, execution, and undo support All game state changes must go through commands for:
- Validation before execution
- Event emission for system coordination
- Multiplayer synchronization
- Replay/undo support
- ICommandFactory
Factory for creating commands from string arguments. Parses debug console input and creates ICommand instances.
Implement this interface and add [CommandMetadata] attribute for automatic discovery by CommandRegistry.
- INetworkCommand
Interface for commands that can be networked Provides serialization support for multiplayer