Table of Contents

Class NPCDealer

Namespace
S1API.Entities
Assembly
S1API.dll

Modder-facing dealer wrapper for an NPC. Provides helpers to configure and interact with dealer behavior, including customer assignment, cash management, and contract handling. Dealer configuration must be done in ConfigurePrefab(NPCPrefabBuilder).

public sealed class NPCDealer
Inheritance
NPCDealer
Inherited Members
Extension Methods

Remarks

Use this to enable NPCs to act as dealers that sell products to assigned customers. Subscribe to events like OnRecruited and OnContractAccepted for dynamic dealer interactions.

Properties

Home

Gets or sets the home building for this dealer.

public Building? Home { get; set; }

Property Value

Building

IsDealer

Returns whether this NPC currently has dealer functionality.

public bool IsDealer { get; }

Property Value

bool

Methods

AssignCustomer(NPC)

Assigns a customer to this dealer.

public void AssignCustomer(NPC customer)

Parameters

customer NPC

ChangeCash(float)

Changes the dealer's cash balance by the specified amount.

public void ChangeCash(float amount)

Parameters

amount float

CollectCash()

Collects all cash from the dealer and transfers it to the player.

public void CollectCash()

EnsureDealer()

Ensures this NPC has dealer functionality, initializing it if present.

public void EnsureDealer()

Remarks

Note: Since Dealer inherits from NPC in the base game (not a component), this will only work if the wrapped NPC is already a Dealer instance. For custom NPCs created via S1API, dealer functionality must be configured at prefab creation time using EnsureDealer(). This method is called automatically when the NPC spawns if EnsureDealer() was used.

GetAssignedCustomers()

Gets the list of assigned customers.

public List<NPC> GetAssignedCustomers()

Returns

List<NPC>

GetCash()

Gets the current cash balance held by this dealer.

public float GetCash()

Returns

float

HasBeenRecommended()

Gets whether the dealer has been recommended.

public bool HasBeenRecommended()

Returns

bool

IsRecruited()

Gets whether the dealer has been recruited.

public bool IsRecruited()

Returns

bool

MarkAsRecommended()

Marks this dealer as recommended (by another NPC).

public void MarkAsRecommended()

RecruitDealer()

Marks this dealer as recruited (hired by the player).

public void RecruitDealer()

RemoveCustomer(NPC)

Removes a customer assignment from this dealer.

public void RemoveCustomer(NPC customer)

Parameters

customer NPC

Events

OnContractAccepted

Subscribe to contract accepted event.

public event Action OnContractAccepted

Event Type

Action

OnRecommended

Subscribe to dealer recommended event.

public event Action OnRecommended

Event Type

Action

OnRecruited

Subscribe to dealer recruited event.

public event Action OnRecruited

Event Type

Action