Class NPCCustomer
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
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
infoContractInfoThe 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
dealerNPCDealerThe 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
playerPlayer
SetAwaitingDelivery(bool)
Sets whether the customer is awaiting delivery.
public void SetAwaitingDelivery(bool awaiting)
Parameters
awaitingbool
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
OnDealCompleted
Subscribe to deal completed event.
public event Action OnDealCompleted
Event Type
OnUnlocked
Subscribe to customer unlocked event.
public event Action OnUnlocked