Class NPCRelationship
Modder-facing wrapper for an NPC's relationship data. Provides safe access to relationship values, unlock state, connections, and convenience helpers which bridge to the base game's NPCRelationData. Relationship configuration must be done in ConfigurePrefab(NPCPrefabBuilder).
public sealed class NPCRelationship
- Inheritance
-
NPCRelationship
- Inherited Members
- Extension Methods
Remarks
Use this to manage NPC social connections, unlock states, and relationship levels with the player and other NPCs. Subscribe to OnChanged and OnUnlocked events for dynamic relationship interactions.
Properties
ConnectionIDs
Returns the IDs of current connection NPCs (safe across Mono and IL2CPP).
public List<string> ConnectionIDs { get; }
Property Value
Delta
Current relationship delta, clamped to [0, 5]. Setting invokes the game's SetRelationship.
public float Delta { get; set; }
Property Value
IsKnown
True if the NPC is known to the player (directly or via mutual connections).
public bool IsKnown { get; }
Property Value
IsMutuallyKnown
True if the NPC is known via mutual connections even if not directly unlocked.
public bool IsMutuallyKnown { get; }
Property Value
IsUnlocked
True if the NPC has been unlocked (known) to the player systems.
public bool IsUnlocked { get; }
Property Value
Normalized
Normalized relationship delta in [0, 1].
public float Normalized { get; }
Property Value
Type
The way this NPC was unlocked. Setting attempts to assign the base game's UnlockType via reflection without unlocking.
public NPCRelationship.UnlockType Type { get; set; }
Property Value
Methods
Add(float, bool)
Adds to the relationship delta (optionally networked).
public void Add(float delta, bool network = true)
Parameters
SetUnlockType(UnlockType)
Sets the underlying unlock type without changing locked state. Use Unlock(UnlockType, bool) if you intend to unlock as well.
public void SetUnlockType(NPCRelationship.UnlockType type)
Parameters
Unlock(UnlockType, bool)
Unlocks this NPC with the specified type.
public void Unlock(NPCRelationship.UnlockType type = UnlockType.DirectApproach, bool notify = true)
Parameters
typeNPCRelationship.UnlockTypenotifybool
UnlockConnections()
Unlocks all connected NPCs (recommendation unlocking).
public void UnlockConnections()
Events
OnChanged
Subscribes to relationship change events. Callback receives the change amount. Best-effort under IL2CPP; silently no-ops if delegate bridging is unavailable.
public event Action<float> OnChanged
Event Type
OnUnlocked
Subscribes to unlocked events. Callback receives unlock type and notify flag. Best-effort under IL2CPP; silently no-ops if delegate bridging is unavailable.
public event Action<NPCRelationship.UnlockType, bool> OnUnlocked