Class DiplomacyModifierProcessor
ENGINE LAYER - Processes opinion modifier decay with Burst compilation
RESPONSIBILITY:
- Decay opinion modifiers (DecayOpinionModifiers with Burst job)
- Rebuild modifier cache after compaction
PATTERN: Stateless processor (receives data references from DiplomacySystem)
- Does NOT own NativeCollections (passed as parameters)
- Uses Burst-compiled parallel job for performance
- Sequential compaction for determinism
PERFORMANCE:
- 610,750 modifiers processed in 3ms (87% improvement from Burst)
- Parallel marking (IJobParallelFor) + sequential compaction (deterministic)
- O(1) cache rebuild for GetOpinion performance
ARCHITECTURE:
- Step 1: Burst job marks decayed modifiers (parallel, read-only)
- Step 2: Sequential compaction (deterministic ordering)
- Step 3: Rebuild modifierCache for O(1) GetOpinion lookups
public static class DiplomacyModifierProcessor
- Inheritance
-
objectDiplomacyModifierProcessor
Methods
DecayOpinionModifiers(int, NativeList<ModifierWithKey>, NativeParallelHashMap<ulong, int>)
Decay all opinion modifiers and remove fully decayed ones Called monthly by DiplomacyMonthlyTickHandler Target: <5ms for 610k modifiers (with Burst compilation)
public static void DecayOpinionModifiers(int currentTick, NativeList<ModifierWithKey> allModifiers, NativeParallelHashMap<ulong, int> modifierCache)
Parameters
currentTickintallModifiersNativeList<ModifierWithKey>modifierCacheNativeParallelHashMap<ulong, int>
RebuildModifierCache(NativeList<ModifierWithKey>, NativeParallelHashMap<ulong, int>)
Rebuild modifier cache after compaction Maps relationshipKey → first modifier index for O(1) GetOpinion lookups
public static void RebuildModifierCache(NativeList<ModifierWithKey> allModifiers, NativeParallelHashMap<ulong, int> modifierCache)
Parameters
allModifiersNativeList<ModifierWithKey>modifierCacheNativeParallelHashMap<ulong, int>