Class MapModeManager
Central manager for the map mode system Handles mode switching, texture updates, and handler coordination Performance: <0.1ms mode switching, efficient texture scheduling
public class MapModeManager : MonoBehaviour
- Inheritance
-
objectMapModeManager
Properties
CurrentMode
public MapMode CurrentMode { get; }
Property Value
IsInitialized
public bool IsInitialized { get; }
Property Value
- bool
Methods
ApplyPaletteChanges()
Apply pending palette changes to GPU. Call after a batch of UpdateProvinceColor calls.
public void ApplyPaletteChanges()
ForceTextureUpdate()
Force an immediate texture update for the current map mode
public void ForceTextureUpdate()
ForceUpdateIfActive(IMapModeHandler)
Force texture update only if the given handler is currently active. Called by GradientMapMode.MarkDirty() to trigger event-driven updates.
public void ForceUpdateIfActive(IMapModeHandler handler)
Parameters
handlerIMapModeHandler
GetCustomModeArrayIndex(int)
Get the array index for a registered custom mode. Returns -1 if not registered.
public int GetCustomModeArrayIndex(int customModeId)
Parameters
customModeIdint
Returns
- int
GetHandler(MapMode)
Get a specific map mode handler (for GAME layer to mark dirty) Returns null if handler not registered
public IMapModeHandler GetHandler(MapMode mode)
Parameters
modeMapMode
Returns
GetPaletteInfo()
Get palette dimensions and province limit info. GAME map modes need this to know capacity.
public (int maxProvinces, int maxModes, int rowsPerMode) GetPaletteInfo()
Returns
- (int totalBytes, int provinceBytes, int lookupBytes)
GetProvinceTooltip(ushort)
public string GetProvinceTooltip(ushort provinceId)
Parameters
provinceIdushort
Returns
- string
Initialize(GameState, Material, ProvinceMapping, object)
Initialize the map mode system ENGINE provides MECHANISM, GAME controls WHEN to initialize Called by GAME layer after handlers are registered
public void Initialize(GameState gameStateRef, Material material, ProvinceMapping mapping, object gameSystem = null)
Parameters
gameStateRefGameStatematerialMaterialmappingProvinceMappinggameSystemobjectOptional game-specific province system - engine passes through without knowing type
InvalidateAllMapModes()
Mark all map mode handlers as dirty so they recalculate on next activation. Call after loading a save to ensure all modes reflect the loaded state.
public void InvalidateAllMapModes()
RebindTextures()
Rebind all map mode textures to the material Call this after other systems rebind base textures to prevent losing map mode texture bindings
public void RebindTextures()
RegisterCustomMapMode(int)
Register a custom map mode and get its array index. Called by GAME layer when creating custom map modes.
public int RegisterCustomMapMode(int customModeId)
Parameters
customModeIdintUnique ID for this custom mode (typically ShaderModeID from handler)
Returns
- int
Palette index for this mode, or -1 if full
RegisterHandler(MapMode, IMapModeHandler)
Register a map mode handler - called by GAME layer during initialization Enables dependency injection: ENGINE provides mechanism, GAME provides policy
public void RegisterHandler(MapMode mode, IMapModeHandler handler)
Parameters
modeMapModehandlerIMapModeHandler
RequestDeferredUpdate(IMapModeHandler)
Request a deferred texture update for next frame. Multiple requests within same frame are batched into single update. Called by GradientMapMode.MarkDirty() to prevent multiple rebuilds per tick.
public void RequestDeferredUpdate(IMapModeHandler handler)
Parameters
handlerIMapModeHandler
SetMapMode(MapMode, bool)
public void SetMapMode(MapMode mode, bool forceUpdate = false)
Parameters
modeMapModeforceUpdatebool
UpdateMaterial(Material)
Update material reference when material is swapped Called by GAME layer (VisualStyleManager) when material changes
public void UpdateMaterial(Material newMaterial)
Parameters
newMaterialMaterial
UpdateProvinceColor(int, int, Color32)
Update a single province's color for a custom map mode. Use UpdateProvinceColors for batch updates.
public void UpdateProvinceColor(int paletteIndex, int provinceID, Color32 color)
Parameters
paletteIndexintprovinceIDintcolorColor32
UpdateProvinceColors(int, Dictionary<int, Color32>)
Update province colors for a custom map mode. Called by GAME map mode handlers when their data changes.
public void UpdateProvinceColors(int paletteIndex, Dictionary<int, Color32> provinceColors)
Parameters
paletteIndexintIndex returned from RegisterCustomMapMode
provinceColorsDictionary<int, Color32>Dictionary mapping province ID to color