Table of Contents

Class NPCCustomer

Namespace
S1API.Entities
Assembly
S1API.dll

Modder-facing customer wrapper for an NPC. Provides helpers to configure and interact with customer behavior, including deal offers, contracts, and customer events. Customer configuration must be done in ConfigurePrefab(NPCPrefabBuilder).

public sealed class NPCCustomer
Inheritance
NPCCustomer
Inherited Members
Extension Methods

Remarks

Use this to enable NPCs to act as business customers that buy products from the player. Subscribe to events like OnDealCompleted and OnUnlocked for dynamic customer interactions.

Properties

IsCustomer

Returns whether this NPC currently has a Customer component.

public bool IsCustomer { get; }

Property Value

bool

Methods

EnsureCustomer()

Ensures this NPC has a Customer component, creating one if absent.

public void EnsureCustomer()

ForceDealOffer()

Forces the NPC to generate and offer a random contract based on their Customer data and relationship with the player.

The generated contract is based on:

  • Available products listed for sale in ProductManagerApp
  • NPC's drug type affinities and preferences
  • NPC's spending budget (adjusted by relationship level)
  • NPC's quality standards
  • Current addiction level

For custom contracts with specific products/prices, use OfferContract(ContractInfo) instead.

public bool ForceDealOffer()

Returns

bool

True if a contract was generated and offered, false if generation failed.

OfferContract(ContractInfo)

Offers a custom contract to this customer using an API-friendly ContractInfo. This method allows you to specify exactly what products, quantities, prices, and delivery details the contract should have. For automatic contract generation based on NPC preferences, use ForceDealOffer() instead.

public bool OfferContract(ContractInfo info)

Parameters

info ContractInfo

The contract info containing the specific products, quantities, prices, and delivery details.

Returns

bool

True if the contract was successfully offered, false otherwise.

RecommendDealer(NPCDealer)

Recommends a dealer to the player. This marks the dealer as recommended and shows UI feedback.

public void RecommendDealer(NPCDealer dealer)

Parameters

dealer NPCDealer

The dealer NPC to recommend.

RequestProduct(Player)

Requests a product from the specified player (or local player if null).

public void RequestProduct(Player player = null)

Parameters

player Player

SetAwaitingDelivery(bool)

Sets whether the customer is awaiting delivery.

public void SetAwaitingDelivery(bool awaiting)

Parameters

awaiting bool

SetupDialog()

Sets up customer dialogue

public void SetupDialog()

Unlock()

Marks this customer as unlocked (visible to the player systems).

public void Unlock()

Events

OnContractAssigned

Subscribe to contract assigned event. Provides payment, product count, and delivery window via callback.

public event Action<float, int, int, int> OnContractAssigned

Event Type

Action<float, int, int, int>

OnDealCompleted

Subscribe to deal completed event.

public event Action OnDealCompleted

Event Type

Action

OnUnlocked

Subscribe to customer unlocked event.

public event Action OnUnlocked

Event Type

Action