Table of Contents

Class NPCRelationshipDataBuilder

Namespace
S1API.Entities.Relation
Assembly
S1API.dll

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

relationData NPCRelationData
owner NPC
preserveUnlockState bool

If 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

type NPCRelationship.UnlockType

Returns

NPCRelationshipDataBuilder

SetUnlockType(string)

Sets unlock type by name ("Recommendation", "DirectApproach").

public NPCRelationshipDataBuilder SetUnlockType(string typeName)

Parameters

typeName string

Returns

NPCRelationshipDataBuilder

SetUnlocked(bool)

Sets whether the NPC is unlocked.

public NPCRelationshipDataBuilder SetUnlocked(bool unlocked)

Parameters

unlocked bool

Returns

NPCRelationshipDataBuilder

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

npcs NPC[]

Returns

NPCRelationshipDataBuilder

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

npcs IEnumerable<NPC>

Returns

NPCRelationshipDataBuilder

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

npcTypes Type[]

Returns

NPCRelationshipDataBuilder

WithConnectionsById(IEnumerable<string>)

Replaces the connections list with the given NPC IDs (case-insensitive).

public NPCRelationshipDataBuilder WithConnectionsById(IEnumerable<string> ids)

Parameters

ids IEnumerable<string>

Returns

NPCRelationshipDataBuilder

WithConnectionsById(params string[])

Replaces the connections list with the given NPC IDs (case-insensitive).

public NPCRelationshipDataBuilder WithConnectionsById(params string[] ids)

Parameters

ids string[]

Returns

NPCRelationshipDataBuilder

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

NPCRelationshipDataBuilder

Type Parameters

T1

First NPC type

T2

Second 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

NPCRelationshipDataBuilder

Type Parameters

T1

First NPC type

T2

Second NPC type

T3

Third NPC type

WithDelta(float)

Sets the relationship delta in [0, 5].

public NPCRelationshipDataBuilder WithDelta(float delta)

Parameters

delta float

Returns

NPCRelationshipDataBuilder

WithNormalized(float)

Sets the relationship delta using a normalized [0..1] value.

public NPCRelationshipDataBuilder WithNormalized(float normalized)

Parameters

normalized float

Returns

NPCRelationshipDataBuilder