Class NPCRelationshipDataBuilder
Builder for configuring an NPC's relationship data from code. Supports setting relationship delta, unlock state/type, and connections by ID or wrapper.
public sealed class NPCRelationshipDataBuilder
- Inheritance
-
NPCRelationshipDataBuilder
- Inherited Members
- Extension Methods
Constructors
NPCRelationshipDataBuilder()
public NPCRelationshipDataBuilder()
Methods
ApplyTo(NPCRelationData, NPC, bool)
INTERNAL: Applies the configured values to a relation data instance.
public void ApplyTo(NPCRelationData relationData, NPC owner, bool preserveUnlockState = false)
Parameters
relationDataNPCRelationDataownerNPCpreserveUnlockStateboolIf true, will not modify unlock state if the NPC is already unlocked (preserves save data).
SetUnlockType(UnlockType)
Sets unlock type by enum.
public NPCRelationshipDataBuilder SetUnlockType(NPCRelationship.UnlockType type)
Parameters
Returns
SetUnlockType(string)
Sets unlock type by name ("Recommendation", "DirectApproach").
public NPCRelationshipDataBuilder SetUnlockType(string typeName)
Parameters
typeNamestring
Returns
SetUnlocked(bool)
Sets whether the NPC is unlocked.
public NPCRelationshipDataBuilder SetUnlocked(bool unlocked)
Parameters
unlockedbool
Returns
WithConnections(params NPC[])
Replaces the connections list using API NPC wrappers. Nulls are ignored.
[Obsolete("Use WithConnections<T1, T2, ...>() or WithConnectionsById instead. NPC instances are not available during prefab configuration.")]
public NPCRelationshipDataBuilder WithConnections(params NPC[] npcs)
Parameters
npcsNPC[]
Returns
WithConnections(IEnumerable<NPC>)
Replaces the connections list using API NPC wrappers. Nulls are ignored. For NPCs that aren't spawned yet (during prefab configuration), this will attempt to extract IDs from the NPC type's static NPCId property or by looking them up in the base game's NPC registry. Prefer WithConnections(params Type[]) or the generic overloads when you only have types available.
[Obsolete("Use WithConnections<T1, T2, ...>() or WithConnectionsById instead. NPC instances are not available during prefab configuration.")]
public NPCRelationshipDataBuilder WithConnections(IEnumerable<NPC> npcs)
Parameters
npcsIEnumerable<NPC>
Returns
WithConnections(params Type[])
Replaces the connections list using NPC types. This overload works during prefab configuration when NPC instances are not yet available. IDs are resolved from the static NPCId property.
public NPCRelationshipDataBuilder WithConnections(params Type[] npcTypes)
Parameters
npcTypesType[]
Returns
WithConnectionsById(IEnumerable<string>)
Replaces the connections list with the given NPC IDs (case-insensitive).
public NPCRelationshipDataBuilder WithConnectionsById(IEnumerable<string> ids)
Parameters
idsIEnumerable<string>
Returns
WithConnectionsById(params string[])
Replaces the connections list with the given NPC IDs (case-insensitive).
public NPCRelationshipDataBuilder WithConnectionsById(params string[] ids)
Parameters
idsstring[]
Returns
WithConnections<T1, T2>()
Replaces the connections list using NPC types. This overload works during prefab configuration when NPC instances are not yet available. IDs are resolved from the static NPCId property.
public NPCRelationshipDataBuilder WithConnections<T1, T2>() where T1 : NPC where T2 : NPC
Returns
Type Parameters
T1First NPC type
T2Second NPC type
WithConnections<T1, T2, T3>()
Replaces the connections list using NPC types. This overload works during prefab configuration when NPC instances are not yet available. IDs are resolved from the static NPCId property.
public NPCRelationshipDataBuilder WithConnections<T1, T2, T3>() where T1 : NPC where T2 : NPC where T3 : NPC
Returns
Type Parameters
T1First NPC type
T2Second NPC type
T3Third NPC type
WithDelta(float)
Sets the relationship delta in [0, 5].
public NPCRelationshipDataBuilder WithDelta(float delta)
Parameters
deltafloat
Returns
WithNormalized(float)
Sets the relationship delta using a normalized [0..1] value.
public NPCRelationshipDataBuilder WithNormalized(float normalized)
Parameters
normalizedfloat