Table of Contents

Namespace Core.Modifiers

Classes

ModifierSystem

ENGINE: Central manager for all modifier scopes (global, country, province) Pattern used by: EU4 (modifier system), CK3 (effect manager), Stellaris (empire modifiers)

Architecture:

  • Global scope (inherited by all)
  • Country scopes (inherited by country provinces)
  • Province scopes (local only)

Scope Inheritance: Province Final = Province Local + Country + Global

Performance:

  • O(1) scope lookup
  • O(n) rebuild where n = active modifiers in scope chain
  • Dirty flag optimization (only rebuild when changed)

Multiplayer Safe:

  • Deterministic operations only
  • Fixed-size allocations
  • Command-based modifications

Structs

ActiveModifierList

ENGINE: Pool-based list of active modifiers with add/remove/expire logic Pattern used by: EU4 (timed modifiers), CK3 (character effects), Stellaris (empire modifiers)

Design:

  • Fixed-size array (zero allocations)
  • Lazy deletion (mark as empty, compact on rebuild)
  • Efficient iteration (skip empty slots)
  • Track active count for quick checks

Performance: O(n) iteration where n = active modifiers (not max capacity)

ModifierSet

ENGINE: Fixed-size modifier storage (cache-friendly, deterministic) Uses fixed arrays for zero allocations and cache locality

Performance: O(1) lookup, 8KB per instance (512 types × 2 longs × 8 bytes) Memory layout: Contiguous arrays for additive and multiplicative values

DETERMINISM: Stores FixedPoint64.RawValue (long) for cross-platform compatibility Pattern used by: EU4 (modifier system), CK3 (character modifiers), Stellaris (empire modifiers)

ModifierSource

ENGINE: Tracks the source of a modifier for tooltips and removal Pattern used by: EU4 (modifier tooltips), CK3 (effect stacking), Stellaris (modifier tracking)

Examples:

  • Building: Farm in Province #42 gives +5 production
  • Tech: "Advanced Agriculture" gives +20% production (permanent)
  • Event: "Harvest Festival" gives +10% production for 12 months (temporary)
ModifierValue

ENGINE: Modifier value with additive and multiplicative components Pattern used by: EU4, CK3, Stellaris, Victoria 3

Formula: (base + additive) * (1 + multiplicative) Example: base=10, additive=+5, multiplicative=+0.5 → (10+5)*(1+0.5) = 22.5

DETERMINISM: Uses FixedPoint64 for cross-platform multiplayer compatibility

ScopedModifierContainer

ENGINE: Container for modifiers with scope inheritance Pattern used by: EU4 (province ← country ← global), CK3 (character ← dynasty ← culture)

Scope Hierarchy:

  • Province modifiers (local only)
  • Country modifiers (inherited by all provinces)
  • Global modifiers (inherited by everyone)

Design:

  • ActiveModifierList for local modifiers
  • Reference to parent scope (optional)
  • Cached ModifierSet (dirty flag optimization)
  • Rebuild only when modifiers change

Performance: O(n) rebuild where n = local + inherited modifiers Cached lookups: O(1) after rebuild

Enums

ModifierScopeLevel

Identifies the scope level a modifier comes from (for tooltips)

ModifierSource.SourceType