Namespace Map.MapModes
Classes
- BaseMapModeHandler
Base class for map mode handlers with common functionality
- ColorGradient
ENGINE LAYER - Generic color gradient interpolation system
Responsibilities:
- Interpolate between color stops based on normalized value (0.0 to 1.0)
- Support any number of color stops (minimum 2)
- Smooth transitions between stops
Architecture:
- Pure mechanism, no game knowledge
- Reusable across any map mode that needs gradient visualization
- Game layer defines color stops and provides values to normalize
Performance:
- O(1) evaluation with 2-5 color stops (typical usage)
- No allocations during gradient evaluation
- Color stops stored in managed array (small, infrequent access)
- DebugMapModeHandler
Generic handler for debug visualization modes These modes don't need texture updates - they just set shader mode for visualization
- EnginePoliticalMapMode
ENGINE LAYER: Political map mode - displays province ownership by country colors Uses only ENGINE data (CountryQueries) - no GAME layer dependencies
- GradientComputeDispatcher
ENGINE LAYER - Manages GPU compute shader for gradient map mode colorization Processes province values into colored textures entirely on GPU for maximum performance
Performance: ~1ms for 11.5M pixels vs 105ms CPU-side processing Architecture: CPU simulation data → GPU colorization → Output texture (dual-layer)
- GradientMapMode
ENGINE LAYER - Generic gradient-based map mode handler
Architecture:
- Pure mechanism, no game-specific knowledge
- Concrete GAME modes override: GetGradient(), GetValueForProvince()
- Uses GPU compute shader for fast colorization (~1ms vs 125ms CPU)
- Uses MapModeManager's texture array for instant mode switching
Performance:
- GPU compute shader processes 11.5M pixels in ~1ms
- Texture updates only when dirty (data changed)
- Mode switching is instant (just changes shader int)
Usage (GAME Layer): public class FarmDensityMapMode : GradientMapMode { protected override ColorGradient GetGradient() => new ColorGradient(...); protected override float GetValueForProvince(ushort id) => buildingSystem.GetFarmCount(id); }
- MapModeDataTextures
Manages all data textures required for the map mode system Each texture is optimized for specific data types and update patterns Performance: Specialized formats, efficient updates, proper GPU memory layout
- MapModeManager
Central manager for the map mode system Handles mode switching, texture updates, and handler coordination Performance: <0.1ms mode switching, efficient texture scheduling
- TextureUpdateScheduler
Schedules texture updates for map mode handlers based on their update frequency Prevents unnecessary texture updates and optimizes performance
Structs
- GradientMapMode.ValueStats
Statistics for value distribution analysis
Interfaces
- IMapModeHandler
Interface for map mode handlers following the new architecture Each map mode is responsible for its own data textures and rendering logic Performance: <0.1ms mode switching, specialized texture updates
Enums
- MapMode
Map mode types supported by the system
- UpdateFrequency
How frequently a map mode's textures need updating