Class NPCDealer
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
IsDealer
Returns whether this NPC currently has dealer functionality.
public bool IsDealer { get; }
Property Value
Methods
AssignCustomer(NPC)
Assigns a customer to this dealer.
public void AssignCustomer(NPC customer)
Parameters
customerNPC
ChangeCash(float)
Changes the dealer's cash balance by the specified amount.
public void ChangeCash(float amount)
Parameters
amountfloat
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
GetCash()
Gets the current cash balance held by this dealer.
public float GetCash()
Returns
HasBeenRecommended()
Gets whether the dealer has been recommended.
public bool HasBeenRecommended()
Returns
IsRecruited()
Gets whether the dealer has been recruited.
public bool IsRecruited()
Returns
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
customerNPC
Events
OnContractAccepted
Subscribe to contract accepted event.
public event Action OnContractAccepted
Event Type
OnRecommended
Subscribe to dealer recommended event.
public event Action OnRecommended
Event Type
OnRecruited
Subscribe to dealer recruited event.
public event Action OnRecruited