Class ProvinceHistorySystem
- Namespace
- StarterKit
- Assembly
- StarterKit.dll
STARTERKIT: Tracks province ownership history. Demonstrates Pattern 4: Hot/Cold Data Separation.
- Hot data: ProvinceState.ownerID (accessed every frame, 2 bytes)
- Cold data: ProvinceHistoryData (accessed on-demand when viewing province)
This system:
- Subscribes to ProvinceOwnershipChangedEvent
- Records ownership changes to cold storage
- Provides on-demand access to history when UI needs it
Memory is bounded via CircularBuffer (last N changes per province).
public class ProvinceHistorySystem
- Inheritance
-
objectProvinceHistorySystem
Constructors
ProvinceHistorySystem(GameState, bool)
public ProvinceHistorySystem(GameState gameStateRef, bool log = true)
Parameters
gameStateRefGameStatelogbool
Methods
Dispose()
public void Dispose()
GetProvinceHistory(ushort)
Get history data for a province (on-demand access). Returns null if no history recorded for this province.
This is the key API demonstrating cold data access:
- Only called when player clicks/views a province
- NOT called every frame
public ProvinceHistoryData GetProvinceHistory(ushort provinceId)
Parameters
provinceIdushort
Returns
GetStorageStats()
Get statistics about cold data storage (for debugging/monitoring).
public (int provincesWithHistory, int totalRecords) GetStorageStats()
Returns
- (int x, int y)
HasHistory(ushort)
Check if a province has any recorded history.
public bool HasHistory(ushort provinceId)
Parameters
provinceIdushort
Returns
- bool