Table of Contents

Class DiplomacySaveLoadHandler

Namespace
Core.Diplomacy
Assembly
Core.dll

ENGINE LAYER - Handles diplomacy save/load serialization

RESPONSIBILITY:

  • Save diplomatic state to binary format
  • Load diplomatic state and rebuild indices
  • Rebuild derived data (activeWars, warsByCountry, modifierCache)

PATTERN: Stateless handler (receives data references from DiplomacySystem)

  • Does NOT own NativeCollections (passed as parameters)
  • Binary serialization for efficiency
  • Rebuilds indices after load (Pattern 14: Hybrid Save/Load)

FORMAT:

  • relationCount: int32
  • For each relationship:
    • country1, country2: ushort × 2
    • baseOpinion: int64 (FixedPoint64.RawValue)
    • atWar: bool
    • treatyFlags: byte
    • modifierCount: int32
    • For each modifier:
      • modifierTypeID: ushort
      • value: int64 (FixedPoint64.RawValue)
      • appliedTick: int32
      • decayRate: int32
public static class DiplomacySaveLoadHandler
Inheritance
object
DiplomacySaveLoadHandler

Methods

OnLoad(SaveGameData, NativeParallelHashMap<ulong, RelationData>, NativeParallelHashSet<ulong>, NativeParallelMultiHashMap<ushort, ushort>, NativeList<ModifierWithKey>, NativeParallelHashMap<ulong, int>)

Load diplomatic state from save data Rebuilds derived indices (activeWars, warsByCountry, modifierCache)

public static void OnLoad(SaveGameData saveData, NativeParallelHashMap<ulong, RelationData> relations, NativeParallelHashSet<ulong> activeWars, NativeParallelMultiHashMap<ushort, ushort> warsByCountry, NativeList<ModifierWithKey> allModifiers, NativeParallelHashMap<ulong, int> modifierCache)

Parameters

saveData SaveGameData
relations NativeParallelHashMap<ulong, RelationData>
activeWars NativeParallelHashSet<ulong>
warsByCountry NativeParallelMultiHashMap<ushort, ushort>
allModifiers NativeList<ModifierWithKey>
modifierCache NativeParallelHashMap<ulong, int>

OnSave(SaveGameData, NativeParallelHashMap<ulong, RelationData>, NativeList<ModifierWithKey>, NativeParallelHashSet<ulong>)

Save diplomatic state to save data Pattern 14: Hybrid Save/Load (state snapshot for speed)

public static void OnSave(SaveGameData saveData, NativeParallelHashMap<ulong, RelationData> relations, NativeList<ModifierWithKey> allModifiers, NativeParallelHashSet<ulong> activeWars)

Parameters

saveData SaveGameData
relations NativeParallelHashMap<ulong, RelationData>
allModifiers NativeList<ModifierWithKey>
activeWars NativeParallelHashSet<ulong>