Class DiplomacyTreatyManager
ENGINE LAYER - Manages treaties between countries
RESPONSIBILITY:
- Treaty queries (AreAllied, HasNonAggressionPact, IsGuaranteeing, HasMilitaryAccess)
- Treaty state changes (Form/Break Alliance, NAP, Guarantee, Military Access)
- Treaty relationship queries (GetAllies, GetAlliesRecursive, GetGuaranteeing, GetGuaranteedBy)
PATTERN: Stateless manager (receives data references from DiplomacySystem)
- Does NOT own NativeCollections (passed as parameters)
- Uses RelationData.treatyFlags bitfield for treaty storage
- Directional treaties (Guarantee, Military Access) use separate bits for each direction
PERFORMANCE:
- Treaty checks: O(1) dictionary lookup + bitfield check
- GetAllies: O(n) where n = total relationships
- GetAlliesRecursive: O(n) BFS traversal
public static class DiplomacyTreatyManager
- Inheritance
-
objectDiplomacyTreatyManager
Methods
AreAllied(ushort, ushort, NativeParallelHashMap<ulong, RelationData>)
Check if two countries have an alliance
public static bool AreAllied(ushort country1, ushort country2, NativeParallelHashMap<ulong, RelationData> relations)
Parameters
country1ushortcountry2ushortrelationsNativeParallelHashMap<ulong, RelationData>
Returns
- bool
BreakAlliance(ushort, ushort, NativeParallelHashMap<ulong, RelationData>)
Break alliance between two countries
public static void BreakAlliance(ushort country1, ushort country2, NativeParallelHashMap<ulong, RelationData> relations)
Parameters
country1ushortcountry2ushortrelationsNativeParallelHashMap<ulong, RelationData>
BreakNonAggressionPact(ushort, ushort, NativeParallelHashMap<ulong, RelationData>)
Break non-aggression pact between two countries
public static void BreakNonAggressionPact(ushort country1, ushort country2, NativeParallelHashMap<ulong, RelationData> relations)
Parameters
country1ushortcountry2ushortrelationsNativeParallelHashMap<ulong, RelationData>
FormAlliance(ushort, ushort, NativeParallelHashMap<ulong, RelationData>)
Form alliance between two countries Called by FormAllianceCommand after validation
public static void FormAlliance(ushort country1, ushort country2, NativeParallelHashMap<ulong, RelationData> relations)
Parameters
country1ushortcountry2ushortrelationsNativeParallelHashMap<ulong, RelationData>
FormNonAggressionPact(ushort, ushort, NativeParallelHashMap<ulong, RelationData>)
Form non-aggression pact between two countries
public static void FormNonAggressionPact(ushort country1, ushort country2, NativeParallelHashMap<ulong, RelationData> relations)
Parameters
country1ushortcountry2ushortrelationsNativeParallelHashMap<ulong, RelationData>
GetAllies(ushort, NativeParallelHashMap<ulong, RelationData>)
Get all allies of a country Returns list of country IDs that have alliance with given country
public static List<ushort> GetAllies(ushort countryID, NativeParallelHashMap<ulong, RelationData> relations)
Parameters
countryIDushortrelationsNativeParallelHashMap<ulong, RelationData>
Returns
- List<ushort>
GetAlliesRecursive(ushort, NativeParallelHashMap<ulong, RelationData>)
Get all allies recursively (alliance chain A→B→C) Uses BFS traversal to find all connected allies CRITICAL for war declaration validation and auto-join
public static HashSet<ushort> GetAlliesRecursive(ushort countryID, NativeParallelHashMap<ulong, RelationData> relations)
Parameters
countryIDushortrelationsNativeParallelHashMap<ulong, RelationData>
Returns
- HashSet<ushort>
GetGuaranteedBy(ushort, NativeParallelHashMap<ulong, RelationData>)
Get all countries that guarantee this country
public static List<ushort> GetGuaranteedBy(ushort guaranteedID, NativeParallelHashMap<ulong, RelationData> relations)
Parameters
guaranteedIDushortrelationsNativeParallelHashMap<ulong, RelationData>
Returns
- List<ushort>
GetGuaranteeing(ushort, NativeParallelHashMap<ulong, RelationData>)
Get all countries that this country guarantees
public static List<ushort> GetGuaranteeing(ushort guarantorID, NativeParallelHashMap<ulong, RelationData> relations)
Parameters
guarantorIDushortrelationsNativeParallelHashMap<ulong, RelationData>
Returns
- List<ushort>
GrantMilitaryAccess(ushort, ushort, NativeParallelHashMap<ulong, RelationData>)
Grant military access (directional)
public static void GrantMilitaryAccess(ushort granter, ushort recipient, NativeParallelHashMap<ulong, RelationData> relations)
Parameters
granterushortrecipientushortrelationsNativeParallelHashMap<ulong, RelationData>
GuaranteeIndependence(ushort, ushort, NativeParallelHashMap<ulong, RelationData>)
Guarantor guarantees guaranteed country's independence (directional)
public static void GuaranteeIndependence(ushort guarantor, ushort guaranteed, NativeParallelHashMap<ulong, RelationData> relations)
Parameters
guarantorushortguaranteedushortrelationsNativeParallelHashMap<ulong, RelationData>
HasMilitaryAccess(ushort, ushort, NativeParallelHashMap<ulong, RelationData>)
Check if granter grants military access to recipient Directional check
public static bool HasMilitaryAccess(ushort granter, ushort recipient, NativeParallelHashMap<ulong, RelationData> relations)
Parameters
granterushortrecipientushortrelationsNativeParallelHashMap<ulong, RelationData>
Returns
- bool
HasNonAggressionPact(ushort, ushort, NativeParallelHashMap<ulong, RelationData>)
Check if two countries have a non-aggression pact
public static bool HasNonAggressionPact(ushort country1, ushort country2, NativeParallelHashMap<ulong, RelationData> relations)
Parameters
country1ushortcountry2ushortrelationsNativeParallelHashMap<ulong, RelationData>
Returns
- bool
IsGuaranteeing(ushort, ushort, NativeParallelHashMap<ulong, RelationData>)
Check if guarantor country guarantees guaranteed country's independence Directional check
public static bool IsGuaranteeing(ushort guarantor, ushort guaranteed, NativeParallelHashMap<ulong, RelationData> relations)
Parameters
guarantorushortguaranteedushortrelationsNativeParallelHashMap<ulong, RelationData>
Returns
- bool
RevokeGuarantee(ushort, ushort, NativeParallelHashMap<ulong, RelationData>)
Revoke guarantee of independence
public static void RevokeGuarantee(ushort guarantor, ushort guaranteed, NativeParallelHashMap<ulong, RelationData> relations)
Parameters
guarantorushortguaranteedushortrelationsNativeParallelHashMap<ulong, RelationData>
RevokeMilitaryAccess(ushort, ushort, NativeParallelHashMap<ulong, RelationData>)
Revoke military access
public static void RevokeMilitaryAccess(ushort granter, ushort recipient, NativeParallelHashMap<ulong, RelationData> relations)
Parameters
granterushortrecipientushortrelationsNativeParallelHashMap<ulong, RelationData>