Struct ProvinceState
ENGINE LAYER - Core province simulation state - EXACTLY 8 bytes This is the foundation of the dual-layer architecture
ARCHITECTURE: Engine provides MECHANISM (how ownership works) Game layer provides POLICY (what game-specific data means)
This struct contains ONLY generic engine primitives:
- Ownership (who owns this province)
- Control (who controls it militarily)
- Terrain (what type of land)
- Game data slot (index into game-specific data)
Game-specific fields (development, forts, etc.) belong in Game layer.
CRITICAL: Never change the size of this struct - it must remain exactly 8 bytes for performance targets (10,000 provinces × 8 bytes = 80KB total)
public struct ProvinceState
Fields
controllerID
public ushort controllerID
Field Value
- ushort
gameDataSlot
public ushort gameDataSlot
Field Value
- ushort
ownerID
public ushort ownerID
Field Value
- ushort
terrainType
public ushort terrainType
Field Value
- ushort
Properties
IsOccupied
Check if province is controlled by someone different than owner (occupied)
public bool IsOccupied { get; }
Property Value
- bool
IsOcean
Check if province is ocean/water (terrain type 0)
public bool IsOcean { get; }
Property Value
- bool
IsOwned
Check if province is owned by anyone
public bool IsOwned { get; }
Property Value
- bool
Methods
CreateDefault(ushort, ushort)
Create a default province state (unowned, undeveloped)
public static ProvinceState CreateDefault(ushort terrainType = 1, ushort gameSlot = 0)
Parameters
terrainTypeushortgameSlotushort
Returns
CreateOcean(ushort)
Create province state for ocean/water
public static ProvinceState CreateOcean(ushort gameSlot = 0)
Parameters
gameSlotushort
Returns
CreateOwned(ushort, ushort, ushort)
Create province state with initial owner
public static ProvinceState CreateOwned(ushort owner, ushort terrainType = 1, ushort gameSlot = 0)
Parameters
ownerushortterrainTypeushortgameSlotushort
Returns
Equals(object)
Equality comparison for deterministic validation
public override bool Equals(object obj)
Parameters
objobject
Returns
- bool
FromBytes(byte[])
Deserialize from bytes for networking
public static ProvinceState FromBytes(byte[] bytes)
Parameters
bytesbyte[]
Returns
GetHashCode()
Calculate hash for state validation/checksums (deterministic for multiplayer)
public override int GetHashCode()
Returns
- int
ToBytes()
Serialize to bytes for networking (8 bytes exactly)
public byte[] ToBytes()
Returns
- byte[]
ToString()
Debug string representation
public override string ToString()
Returns
- string