Overview
This page documents all components in the Relationship System. Use this as your API documentation when implementing relationships.
Essential components
Data assets
Scene-based
Save/load
New in v1.1
RelationshipManager
CoreCentral singleton facade managing all relationship operations. Delegates to 11 internal subsystems (EntityRegistry, RelationshipStore, RelationshipResolver, DecayProcessor, ModifierProcessor, InheritancePropagator, HistoryTracker, CapProcessor, DiplomacyManager, RuntimeFactionRegistry, RelationshipEventBus).
Create: Add Component → Relationship System → Relationship Manager
Properties
| Property | Type | Description |
|---|---|---|
| m_DebugLogging | bool | Enable console debug logging |
| m_EnableDecayProcessing | bool | Process decay for relationships with decay enabled |
| m_LogLevel | RelationshipLogLevel | Controls which log messages are printed (Error/Warning/Info/Debug) |
| m_DefaultDefinition | RelationshipDefinition | Fallback definition when no faction or override definition exists |
| m_PendingTimeout | float | Timeout in seconds for pending relationships (-1 = no timeout) |
| m_DecayInterval | float | Seconds between decay ticks (higher = better performance) |
Methods
RegisterEntity(IRelationshipEntity entity)UnregisterEntity(string entityId)GetRelationship(string entityAId, string entityBId)GetRelationship(string entityAId, string entityBId, RelationshipDefinition def)GetRelationshipValue(string entityAId, string entityBId)GetRelationshipLevel(string entityAId, string entityBId)ModifyRelationship(string entityAId, string entityBId, float delta)ModifyRelationship(string entityAId, string entityBId, float delta, RelationshipDefinition def)ModifyRelationship(string entityAId, string entityBId, float delta, string source)SetRelationship(string entityAId, string entityBId, float value)SetRelationship(string entityAId, string entityBId, float value, RelationshipDefinition def)LockRelationship(string entityAId, string entityBId)UnlockRelationship(string entityAId, string entityBId)CreateEntityOverride(string entityAId, string entityBId, RelationshipDefinition def)CreateScopedEntityOverride(string entityAId, string entityBId, RelationshipDefinition def)AddModifier(RelationshipModifier modifier)RemoveModifier(string modifierId)AddCap(string entityAId, string entityBId, RelationshipCap cap)RemoveCap(string entityAId, string entityBId, string capId)GetHistory(string entityAId, string entityBId)GetRecentHistory(string entityAId, string entityBId, int count)GetAllRelationships()ClearAllRelationships()CharacterRelationship
CoreMakes a GameObject a relationship participant. Implements IRelationshipEntity, IRelationshipTarget, and IFactionMember. Uses stable entity IDs for reliable save/load.
Create: Add Component → Relationship System → Character Relationship
Properties
| Property | Type | Description |
|---|---|---|
| m_IdMode | EntityIdMode | ID generation mode: Manual, GenerateFromName, or RuntimeAssigned |
| m_CharacterId | string | Stable unique identifier for this entity |
| m_CharacterName | string | Display name for this character |
| m_CharacterIcon | Sprite | Icon representing this character |
| m_Factions | List<Faction> | Factions this character belongs to (first = primary) |
| m_AutoRegister | bool | Auto-register with RelationshipManager on Start |
| m_AutoAssignFromTags | bool | Auto-process faction tags on Start |
Methods
Register()Unregister()SetEntityId(string entityId)GenerateDeterministicId()HasLegacyId()HasValidIdAddToFaction(Faction faction)RemoveFromFaction(Faction faction)BelongsToFaction(Faction faction)GetFactions()GetRelationshipWith(IRelationshipEntity other)ModifyRelationshipWith(IRelationshipEntity other, float delta)SetRelationshipWith(IRelationshipEntity other, float value)RelationshipDefinition
ScriptableObjectTemplate defining relationship behavior: value ranges, levels, symmetry mode, decay settings, history tracking, and stat modifiers.
Create: Assets → Create → Relationship System → Relationship Definition
Properties
| Property | Type | Description |
|---|---|---|
| displayName | string | Human-readable name |
| minValue | float | Minimum relationship value (absolute clamp) |
| maxValue | float | Maximum relationship value (absolute clamp) |
| startingValue | float | Initial value for new relationships |
| levels | List<RelationshipLevel> | Named tiers with thresholds and actions |
| isSymmetric | bool | If true A↔B (default). If false, A→B ≠ B→A |
| enableDecay | bool | Enable automatic value decay |
| decayMode | DecayMode | Linear, Curve, or Asymmetric decay |
| decayRate | float | Decay per second (Linear mode) |
| decayTarget | float | Target value for decay |
| decayCurve | AnimationCurve | Custom curve for Curve mode |
| decayRatePositive | float | Decay rate above target (Asymmetric mode) |
| decayRateNegative | float | Decay rate below target (Asymmetric mode) |
| enableHistory | bool | Enable change history tracking |
| maxHistoryEntries | int | Circular buffer size for history |
| statModifiers | List<StatModifier> | GC2 Stats integration (optional) |
Methods
GetLevelForValue(float value)ClampValue(float value)Validate()GetRelationshipId()IsDirectional (property)Faction
ScriptableObjectDefines a group that characters can belong to. Supports hierarchical structures with parent/child relationships and configurable inheritance rates.
Create: Assets → Create → Relationship System → Faction
Properties
| Property | Type | Description |
|---|---|---|
| factionName | string | Display name for the faction |
| factionIcon | Sprite | Icon representing this faction |
| description | string | Description text for UI |
| parentFaction | Faction | Parent in hierarchy (null = root) |
| autoAssignTags | List<string> | Auto-assign entities with these tags |
| inheritanceRate | float | 0-1 multiplier for parent relationship inheritance |
| dynamicInheritance | bool | Resolve inheritance at runtime (vs bake at start) |
| propagateToChildren | PropagationMode | How changes propagate to child factions |
| defaultRelationshipDefinition | RelationshipDefinition | Default definition for faction relationships |
Methods
GetHierarchyDepth()GetAncestors()IsDescendantOf(Faction other)EntityId (property)EntityName (property)RuntimeFaction
RuntimeDynamically created faction for player guilds, procedural content, or multiplayer. Created via RelationshipManager.CreateRuntimeFaction(). Fully serializable.
Create: Code: RelationshipManager.Instance.CreateRuntimeFaction(...)
Properties
| Property | Type | Description |
|---|---|---|
| FactionName | string | Display name (set at creation) |
| ParentFaction | Faction | Optional parent for inheritance |
| InheritanceRate | float | Inheritance multiplier from parent |
| EntityId | string | Auto-generated stable ID |
| Members | List<string> | Entity IDs of current members |
Methods
AddMember(string entityId)RemoveMember(string entityId)HasMember(string entityId)GetMemberCount()RelationshipInstructions
Scene ComponentDefines a set of GC2 instructions to execute when a relationship reaches a specific level. Attached to entities for level-based behaviors.
Create: Add Component → Relationship System → Relationship Instructions
Properties
| Property | Type | Description |
|---|---|---|
| m_TargetEntity | PropertyGetGameObject | The other entity in the relationship |
| m_Definition | RelationshipDefinition | Which definition to monitor |
| m_TargetLevel | RelationshipLevel | Level that triggers execution |
| m_Instructions | InstructionList | GC2 Instructions to execute |
| m_ExecuteOnce | bool | Only execute once per level transition |
| m_ExecuteOnEnter | bool | Execute when entering level |
| m_ExecuteOnExit | bool | Execute when exiting level |
Methods
Execute(Args args)ResetExecutionState()RelationshipInstructionManager
CoreManages execution of RelationshipInstructions across the scene. Subscribes to level change events and dispatches to appropriate instruction components.
Create: Add Component → Relationship System → Relationship Instruction Manager
Properties
| Property | Type | Description |
|---|---|---|
| m_AutoDiscover | bool | Auto-find RelationshipInstructions in scene |
| m_DebugLogging | bool | Log instruction executions |
Methods
RegisterInstructions(RelationshipInstructions instructions)UnregisterInstructions(RelationshipInstructions instructions)RefreshInstructions()RelationshipEventListener
Scene ComponentBridges RelationshipManager events to Unity Events. Filter by entity, faction, or definition. Use for UI updates, audio, VFX triggers.
Create: Add Component → Relationship System → Event Listener
Properties
| Property | Type | Description |
|---|---|---|
| m_EnableValueChanged | bool | Listen for value change events |
| m_EnableLevelChanged | bool | Listen for level change events |
| m_ListenToAll | bool | Listen to all relationships (vs filtered) |
| m_FilterEntityA | PropertyGetGameObject | Filter by Entity A |
| m_FilterEntityB | PropertyGetGameObject | Filter by Entity B |
| m_FilterDefinition | RelationshipDefinition | Filter by definition |
| m_OnValueChangedUnityEvent | UnityEvent<float,float> | Invoked with (oldValue, newValue) |
| m_OnLevelChangedUnityEvent | UnityEvent<string,string> | Invoked with (oldLevel, newLevel) |
AutoHostility
Scene ComponentAutomatically triggers combat when relationship falls below threshold. Requires GC2 Characters module. Checks at configurable intervals.
Create: Add Component → Relationship System → Auto Hostility
Properties
| Property | Type | Description |
|---|---|---|
| m_HostilityThreshold | float | Relationship value below which entity becomes hostile |
| m_CheckInterval | float | Seconds between hostility checks |
| m_TargetTag | string | Only check entities with this tag (empty = all) |
| m_AttackRange | float | Maximum distance to trigger attack |
| m_DebugLogging | bool | Log hostility triggers |
Methods
ForceCheck()SetEnabled(bool enabled)RelationshipRemember
PersistenceIntegrates with GC2 Remember system for save/load. Serializes all relationships, modifiers, caps, faction memberships, and runtime factions.
Create: Add Component → Relationship System → Relationship Remember
Properties
| Property | Type | Description |
|---|---|---|
| m_SaveRelationships | bool | Include relationships in save data |
| m_SaveModifiers | bool | Include active modifiers in save data |
| m_SaveCaps | bool | Include caps in save data |
| m_SaveFactionMemberships | bool | Include faction memberships |
| m_SaveRuntimeFactions | bool | Include runtime-created factions |
| m_SaveDiplomacyStates | bool | Include diplomacy states |
| m_DebugLogging | bool | Log save/load operations |
CapRegistrar
NEWScene ComponentVisual component for registering relationship caps without code. Supports GC2 PropertyGet for entity references. Caps use directional clamping (only prevent crossing boundaries).
Create: Add Component → Relationship System → Cap Registrar
Properties
| Property | Type | Description |
|---|---|---|
| m_EntityA | PropertyGetGameObject | First entity in the relationship (GC2 PropertyGet) |
| m_EntityB | PropertyGetGameObject | Second entity in the relationship (GC2 PropertyGet) |
| m_Definition | RelationshipDefinition | Optional definition scope for multi-dimensional relationships |
| m_CapId | string | Unique identifier for this cap (for later removal) |
| m_Source | string | Display name for cap source (e.g., 'Guild Quest') |
| m_UseMinCap | bool | Enable minimum value cap |
| m_MinValue | float | Minimum value (directional: prevents dropping below) |
| m_UseMaxCap | bool | Enable maximum value cap |
| m_MaxValue | float | Maximum value (directional: prevents rising above) |
| m_AutoRegister | bool | Automatically register cap on Start |
| m_AutoUnregister | bool | Automatically unregister cap on OnDestroy |
Methods
RegisterCap()UnregisterCap()UpdateCap()IsRegistered (property)