Architecture Overview
This guide explains the core architecture of osu!, including the main game class, screens, overlays, and rulesets system.Core Architecture
osu! is built on the osu!framework, a custom game framework developed for the project. The architecture follows a modular design with clear separation of concerns.OsuGame Class
TheOsuGame class (located at osu.Game/OsuGame.cs:93) is the heart of the application. It:
- Extends
OsuGameBaseto add menus and binding logic - Implements multiple interfaces:
IKeyBindingHandler<GlobalAction>,ILocalUserPlayInfo,IPerformFromScreenRunner,IOverlayManager,ILinkHandler - Manages the global game state and coordinates all major systems
Key Components
Screens
Full-screen views like MainMenu, SongSelect, and Player
Overlays
Pop-up UI elements like Settings, Chat, and Notifications
Rulesets
Game mode implementations (osu!, osu!taiko, osu!catch, osu!mania)
Framework
Core rendering, input, and audio systems
Screen System
Screens represent full-screen game states and are managed by theScreenStack.
Screen Stack
TheOsuScreenStack manages navigation between screens:
osu.Game/OsuGame.cs:196
Common Screens
Main Menu & Intro
Main Menu & Intro
Song Selection
Song Selection
- SongSelect: Browse and select beatmaps
- SongSelectV2: New version of song select
- Includes carousel, filters, and beatmap details
- Located in
osu.Game/Screens/Select/andosu.Game/Screens/SelectV2/
Gameplay
Gameplay
- Player: Main gameplay screen
- ReplayPlayer: Replay viewing screen
- Handles game logic, rendering, and scoring
- Located in
osu.Game/Screens/Play/
Results
Results
- SoloResultsScreen: Display scores after gameplay
- RankingScreen: Show leaderboards and statistics
- Located in
osu.Game/Screens/Ranking/
Editor
Editor
- Editor: Beatmap editing interface
- Full-featured beatmap creation and modification
- Located in
osu.Game/Screens/Edit/
Online Play
Online Play
- Multiplayer: Multiplayer match screens
- Playlists: Playlist/room management
- DailyChallenge: Daily challenge mode
- Located in
osu.Game/Screens/OnlinePlay/
Screen Navigation
Screens use a push/pop navigation model:Overlay System
Overlays are UI elements that appear on top of screens without replacing them.Major Overlays
TheOsuGame class manages several key overlays:
Overlay Management
TheIOverlayManager interface provides overlay registration and lifecycle management:
- RegisterBlockingOverlay: Register overlays that can block interaction
- ShowBlockingOverlay: Display a blocking overlay
- HideBlockingOverlay: Hide a blocking overlay
osu.Game/OsuGame.cs:327
Overlay Types
Focused Overlays
Overlays that can receive focus and handle input exclusively (e.g., Settings, Mod Select)
Ruleset System
Rulesets are osu!‘s plugin system for game modes.
Core Rulesets
The game includes four official rulesets:- osu!standard - Click circles to the beat
- osu!taiko - Drum rhythm game
- osu!catch - Catch falling fruit
- osu!mania - Vertical scrolling rhythm game
Ruleset Architecture
Rulesets are loaded dynamically from assemblies:Custom Rulesets
Developers can create custom rulesets to add new gameplay styles. See the custom ruleset templates and directory.Ruleset Components
Each ruleset provides:- HitObjects: Gameplay objects (circles, sliders, etc.)
- Scoring: Score calculation and judgement
- Mods: Gameplay modifiers
- DrawableRuleset: Rendering and playfield setup
- RulesetInputManager: Input handling
- UI Components: Health bars, combo display, etc.
Dependency Injection
The game uses dependency injection extensively:Key Systems
Beatmap Management
- BeatmapManager: Imports, stores, and queries beatmaps
- WorkingBeatmap: Represents a loaded beatmap with audio and background
- BeatmapStore: Database access for beatmap metadata
Skinning
- SkinManager: Manages skin loading and application
- ISkin: Interface for skin resources
- LegacySkin: Compatibility with osu!stable skins
Online Services
- IAPIProvider: API communication with osu! servers
- ChatManager: Chat and messaging
- MultiplayerClient: Real-time multiplayer
- SpectatorClient: Live spectating
Input Handling
- OsuUserInputManager: Global input management
- KeyBindingContainer: Customizable key bindings
- GlobalAction: Application-wide actions
Configuration
The project uses MSBuild properties defined inDirectory.Build.props:
- C# Language Version: 12.0
- Nullable Reference Types: Enabled
- Code Analysis: Multiple analyzers including Microsoft.CodeAnalysis.BannedApiAnalyzers
- Documentation Generation: Enabled for all projects
Project Structure
Design Patterns
Component Lifecycle
- Construction: Create the component
- Load:
[BackgroundDependencyLoader]methods execute - LoadComplete: Component fully loaded
- Update: Per-frame updates
- Dispose: Cleanup resources
Event Handling
The game uses bindables for reactive state management:Performance Considerations
Next Steps
Contributing Guide
Learn how to contribute to osu!
Custom Rulesets
Create your own game mode
Project Management
Understand the development workflow
osu!framework
Explore the underlying framework