Table of Contents

Class ProductManager

Namespace
S1API.Products
Assembly
S1API.dll

Provides management over all products in the game.

public static class ProductManager
Inheritance
ProductManager
Inherited Members

Fields

MaxPrice

Maximum price for any product (999).

public const int MaxPrice = 999

Field Value

int

MinPrice

Minimum price for any product (1).

public const int MinPrice = 1

Field Value

int

Properties

CocaineDiscovered

Gets whether cocaine has been discovered.

public static bool CocaineDiscovered { get; }

Property Value

bool

DiscoveredProducts

A list of product definitions discovered on this save.

public static ProductDefinition[] DiscoveredProducts { get; }

Property Value

ProductDefinition[]

FavouritedProducts

A list of favourited products.

public static ProductDefinition[] FavouritedProducts { get; }

Property Value

ProductDefinition[]

IsAcceptingOrders

Gets whether the player is currently accepting orders.

public static bool IsAcceptingOrders { get; }

Property Value

bool

ListedProducts

A list of products currently listed for sale.

public static ProductDefinition[] ListedProducts { get; }

Property Value

ProductDefinition[]

MethDiscovered

Gets whether meth has been discovered.

public static bool MethDiscovered { get; }

Property Value

bool

ShroomsDiscovered

Gets whether shrooms have been discovered.

public static bool ShroomsDiscovered { get; }

Property Value

bool

Methods

CalculateProductValue(ProductDefinition, float)

Calculates the value of a product based on its properties.

public static float CalculateProductValue(ProductDefinition product, float baseValue)

Parameters

product ProductDefinition

The product definition.

baseValue float

The base value to calculate from.

Returns

float

The calculated value.

ClearEffectCallbacks()

Removes all registered product effect callbacks.

public static void ClearEffectCallbacks()

ClearNpcEffectCallbacks()

Removes all registered NPC product effect callbacks.

public static void ClearNpcEffectCallbacks()

GetPrice(ProductDefinition)

Gets the current price of a product.

public static float GetPrice(ProductDefinition product)

Parameters

product ProductDefinition

The product definition.

Returns

float

The price of the product.

RemoveEffectCallback(PropertyBase)

Removes an effect callback by property.

public static bool RemoveEffectCallback(PropertyBase property)

Parameters

property PropertyBase

The product effect/property to remove.

Returns

bool

true if a callback was removed; otherwise false.

RemoveEffectCallback(string)

Removes an effect callback by effect ID.

public static bool RemoveEffectCallback(string effectId)

Parameters

effectId string

The product effect ID.

Returns

bool

true if a callback was removed; otherwise false.

RemoveEffectClearCallback(PropertyBase)

Removes a player effect clear callback by property.

public static bool RemoveEffectClearCallback(PropertyBase property)

Parameters

property PropertyBase

The product effect/property to remove.

Returns

bool

true if a callback was removed; otherwise false.

RemoveEffectClearCallback(string)

Removes a player effect clear callback by effect ID.

public static bool RemoveEffectClearCallback(string effectId)

Parameters

effectId string

The product effect ID.

Returns

bool

true if a callback was removed; otherwise false.

RemoveNpcEffectCallback(PropertyBase)

Removes an NPC effect callback by property.

public static bool RemoveNpcEffectCallback(PropertyBase property)

Parameters

property PropertyBase

The product effect/property to remove.

Returns

bool

true if a callback was removed; otherwise false.

RemoveNpcEffectCallback(string)

Removes an NPC effect callback by effect ID.

public static bool RemoveNpcEffectCallback(string effectId)

Parameters

effectId string

The product effect ID.

Returns

bool

true if a callback was removed; otherwise false.

RemoveNpcEffectClearCallback(PropertyBase)

Removes an NPC effect clear callback by property.

public static bool RemoveNpcEffectClearCallback(PropertyBase property)

Parameters

property PropertyBase

The product effect/property to remove.

Returns

bool

true if a callback was removed; otherwise false.

RemoveNpcEffectClearCallback(string)

Removes an NPC effect clear callback by effect ID.

public static bool RemoveNpcEffectClearCallback(string effectId)

Parameters

effectId string

The product effect ID.

Returns

bool

true if a callback was removed; otherwise false.

ResetEffectClearCallbacks()

Resets all registered player product effect clear callbacks.

public static void ResetEffectClearCallbacks()

ResetNpcEffectClearCallbacks()

Resets all registered NPC product effect clear callbacks.

public static void ResetNpcEffectClearCallbacks()

SetEffectCallback(PropertyBase, Action<Player>, bool)

Registers or replaces a callback for a product effect. When this effect triggers on the local player, the callback is invoked and can optionally allow base behavior.

public static void SetEffectCallback(PropertyBase property, Action<Player> callback, bool allowDefaultEffect = false)

Parameters

property PropertyBase

The product effect/property to override.

callback Action<Player>

The callback to invoke with the local player.

allowDefaultEffect bool

If true, the base game effect is also applied. If false, only the callback runs for this effect.

SetEffectCallback(string, Action<Player>, bool)

Registers or replaces a callback for a product effect ID. When this effect triggers on the local player, the callback is invoked and can optionally allow base behavior.

public static void SetEffectCallback(string effectId, Action<Player> callback, bool allowDefaultEffect = false)

Parameters

effectId string

The product effect ID.

callback Action<Player>

The callback to invoke with the local player.

allowDefaultEffect bool

If true, the base game effect is also applied. If false, only the callback runs for this effect.

SetEffectClearCallback(PropertyBase, Action<Player>, bool)

Registers or replaces a callback for when a product effect is cleared from the local player. The callback can optionally allow the base game clear behavior to run as well.

public static void SetEffectClearCallback(PropertyBase property, Action<Player> callback, bool allowDefaultEffect = false)

Parameters

property PropertyBase

The product effect/property to override.

callback Action<Player>

The callback to invoke with the local player when the effect clears.

allowDefaultEffect bool

If true, the base game effect is also cleared. If false, only the callback runs for this effect.

SetEffectClearCallback(string, Action<Player>, bool)

Registers or replaces a callback for when a product effect ID is cleared from the local player. The callback can optionally allow the base game clear behavior to run as well.

public static void SetEffectClearCallback(string effectId, Action<Player> callback, bool allowDefaultEffect = false)

Parameters

effectId string

The product effect ID.

callback Action<Player>

The callback to invoke with the local player when the effect clears.

allowDefaultEffect bool

If true, the base game effect is also cleared. If false, only the callback runs for this effect.

SetNpcEffectCallback(PropertyBase, Action<NPC>, bool)

Registers or replaces an NPC callback for a product effect. When this effect triggers on an NPC, the callback is invoked and can optionally allow base behavior.

public static void SetNpcEffectCallback(PropertyBase property, Action<NPC> callback, bool allowDefaultEffect = false)

Parameters

property PropertyBase

The product effect/property to override.

callback Action<NPC>

The callback to invoke with the target NPC.

allowDefaultEffect bool

If true, the base game effect is also applied. If false, only the callback runs for this effect.

SetNpcEffectCallback(string, Action<NPC>, bool)

Registers or replaces an NPC callback for a product effect ID. When this effect triggers on an NPC, the callback is invoked and can optionally allow base behavior.

public static void SetNpcEffectCallback(string effectId, Action<NPC> callback, bool allowDefaultEffect = false)

Parameters

effectId string

The product effect ID.

callback Action<NPC>

The callback to invoke with the target NPC.

allowDefaultEffect bool

If true, the base game effect is also applied. If false, only the callback runs for this effect.

SetNpcEffectClearCallback(PropertyBase, Action<NPC>, bool)

Registers or replaces a callback for when a product effect is cleared from an NPC. The callback can optionally allow the base game clear behavior to run as well.

public static void SetNpcEffectClearCallback(PropertyBase property, Action<NPC> callback, bool allowDefaultEffect = false)

Parameters

property PropertyBase

The product effect/property to override.

callback Action<NPC>

The callback to invoke with the target NPC when the effect clears.

allowDefaultEffect bool

If true, the base game effect is also cleared. If false, only the callback runs for this effect.

SetNpcEffectClearCallback(string, Action<NPC>, bool)

Registers or replaces a callback for when a product effect ID is cleared from an NPC. The callback can optionally allow the base game clear behavior to run as well.

public static void SetNpcEffectClearCallback(string effectId, Action<NPC> callback, bool allowDefaultEffect = false)

Parameters

effectId string

The product effect ID.

callback Action<NPC>

The callback to invoke with the target NPC when the effect clears.

allowDefaultEffect bool

If true, the base game effect is also cleared. If false, only the callback runs for this effect.