OpenRA Architecture Overview - guidebee/OpenRA GitHub Wiki
OpenRA Architecture Overview
Introduction
OpenRA (Open Red Alert) is an open-source game engine that recreates and modernizes classic Real-Time Strategy (RTS) games like Command & Conquer, Red Alert, and Dune 2000. This document provides a high-level overview of OpenRA's architecture, its main components, and how they interact with each other.
High-Level Architecture
OpenRA follows a modular architecture with a clear separation between the engine and the game content (mods). This design allows for flexibility and extensibility, enabling the creation of different game experiences using the same core engine.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β OpenRA Engine β
βββββββββββββββ¬ββββββββββββββββ¬βββββββββββββββββ¬ββββββββββββββββββ€
β Game Logic β Rendering β Input Handling β Network/Server β
β β Subsystem β β β
βββββββββββββββ΄ββββββββββββββββ΄βββββββββββββββββ΄ββββββββββββββββββ€
β Platform Abstraction β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Mod Framework β
βββββββββββββββ¬ββββββββββββββββ¬βββββββββββββββββ¬ββββββββββββββββββ€
β Mod Rules β Content Files β Scripts/Logic β UI/Chrome β
β β and Assets β β β
βββββββββββββββ΄ββββββββββββββββ΄βββββββββββββββββ΄ββββββββββββββββββ
Main Components
1. Engine Core (OpenRA.Game)
The foundation of OpenRA, providing the base functionality for game mechanics, rendering, and networking.
Key responsibilities:
- Game state management
- World simulation
- Actor system (entities in the game)
- Trait system (behavior components)
- Order execution
2. Platform Layer (OpenRA.Platforms.Default)
Handles platform-specific operations through abstractions:
- Graphics rendering (OpenGL)
- Audio playback
- Input handling
- File system operations
3. Mod Framework
Enables creation of different games (mods) using the same engine:
- Rule definitions (YAML-based)
- Content loading
- Custom logic implementation
- UI customization
4. Game Mods (OpenRA.Mods.Common, OpenRA.Mods.Cnc, OpenRA.Mods.D2k)
Game-specific implementations:
- OpenRA.Mods.Common: Shared functionality between mods
- OpenRA.Mods.Cnc: Command & Conquer specific features
- OpenRA.Mods.D2k: Dune 2000 specific features
5. Utility Tools
Support tools for development and content management:
- OpenRA.Utility: Command-line tool for mod operations
- OpenRA.Server: Dedicated game server
- OpenRA.Launcher: Game launcher
Component Interactions
Startup Flow
ββββββββββββββββ βββββββββββββββββ βββββββββββββββββββ
β Game Launcherβββββ>β Engine Core βββββ>β Mod Loading β
ββββββββββββββββ βββββββββββββββββ βββββββββββββββββββ
β β
βΌ βΌ
βββββββββββββββββ βββββββββββββββββββ
β Platform Init β β Rules Processingβ
βββββββββββββββββ βββββββββββββββββββ
β β
ββββββββββββββ¬ββββββββββββ
βΌ
βββββββββββββββββββ
β World Creation β
βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ
β Game Loop Start β
βββββββββββββββββββ
Game Loop
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Game Loop β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β β
βΌ βΌ βΌ
ββββββββββββββββββ ββββββββββββββββββ ββββββββββββββββββββββ
β Input Handling β β World Tick β β Rendering β
ββββββββββββββββββ ββββββββββββββββββ ββββββββββββββββββββββ
β β β
βΌ βΌ βΌ
ββββββββββββββββββ ββββββββββββββββββ ββββββββββββββββββββββ
β Order Creation β β Actor Updates β β Frame Composition β
ββββββββββββββββββ ββββββββββββββββββ ββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββ
β Network Sync β
ββββββββββββββββββ
Key Architectural Patterns
1. Trait System
OpenRA uses a composition-based system called "Traits" rather than class inheritance. Each game entity (Actor) is composed of multiple Traits that define its behavior. This approach provides flexibility and modularity.
Example trait hierarchy:
Actor
βββ Transform
βββ Selectable
βββ RenderSprites
βββ WithSpriteBody
βββ Mobile
βββ Targetable
βββ Armament
2. Order System
Game actions flow through an Order system:
- Player input generates Orders
- Orders are dispatched to Actors
- Orders are serialized for network play
- Actors process Orders through their Traits
3. Content Loading
The FileSystem
component (which you highlighted in the mod.yaml) is particularly important, as it handles:
- Loading game assets from original game files (MIX packages)
- Managing mod-specific content
- Supporting content installation
The ContentInstallerFileSystem
specifically handles the organization and loading of game content, allowing OpenRA to use assets from the original games while organizing them in a structured way.
Mod Configuration
The mod.yaml
file (as seen in your selection) is the central configuration for each game mod, defining:
- File system structure and content locations
- Game rules and sequences
- UI configuration
- Audio settings
- Game mechanics
This configuration-driven approach allows for extensive customization without changing the engine code.
Conclusion
OpenRA's architecture demonstrates a well-designed separation of concerns, with the engine providing core functionality while mods implement specific game logic and content. The trait-based composition system and YAML-based configuration enable flexibility and extensibility, making it possible to recreate different classic RTS games using the same underlying engine.