Class ProductDefinition
Represents one registered product type in the active game runtime.
public class ProductDefinition : StorableItemDefinition
- Inheritance
-
ProductDefinition
- Derived
- Inherited Members
- Extension Methods
Remarks
A definition supplies the shared identity, price, properties, icon, and packaging policy for its instances. It is a wrapper over a native definition, not a new product-registration mechanism. Use the custom-product or native-family builders when a mod needs to register a definition.
Properties
BasePrice
Gets the native base price before market adjustments.
public float BasePrice { get; }
Property Value
DrugType
The native primary drug type for this product.
[Obsolete("Use PrimaryDrugType instead.", false)]
public EDrugType DrugType { get; }
Property Value
- EDrugType
Remarks
This compatibility member exposes a native game enum whose concrete type differs between Mono and IL2CPP. It is not cross-runtime compatible and is retained only for existing consumers. Prefer PrimaryDrugType in cross-runtime mods.
DrugTypeValues
Gets all drug types associated with this product definition without exposing runtime-specific game types.
public IReadOnlyList<DrugType> DrugTypeValues { get; }
Property Value
DrugTypes
The list of native drug type containers associated with this product definition. Returns a C# list for IL2CPP builds to avoid collection type mismatches.
[Obsolete("Use DrugTypeValues instead.", false)]
public List<DrugTypeContainer> DrugTypes { get; }
Property Value
- List<DrugTypeContainer>
Remarks
This compatibility member exposes native game types whose concrete definitions differ between Mono and IL2CPP. It is not cross-runtime compatible and is retained only for existing consumers. Prefer DrugTypeValues in cross-runtime mods.
Icon
Gets the current native inventory icon.
public Sprite Icon { get; }
Property Value
- Sprite
Remarks
The returned sprite is owned by the active Unity runtime. Do not destroy it. A generated custom-product icon can replace this reference after its capture completes.
MarketValue
Gets the product's native market value.
public float MarketValue { get; }
Property Value
Price
Gets the current price selected by the native product system.
public float Price { get; }
Property Value
PrimaryDrugType
Gets the primary drug type for this product without exposing runtime-specific game types.
public DrugType PrimaryDrugType { get; }
Property Value
Properties
Gets runtime-agnostic wrappers for the definition's product properties.
public IReadOnlyList<PropertyBase> Properties { get; }
Property Value
Remarks
Each call creates a read-only snapshot that works on both Mono and IL2CPP. Do not use the wrapper objects as stable identity keys; use their IDs when identity matters.
Methods
CreateInstance(int)
Creates an unpackaged standard-quality instance of this definition.
public override ItemInstance CreateInstance(int quantity = 1)
Parameters
quantityintThe native product quantity for the new instance.
Returns
- ItemInstance
A new API wrapper around the native product instance.
CreatePackagedInstance(int, PackagingDefinition)
Creates a standard-quality instance with the supplied native packaging.
public ProductInstance? CreatePackagedInstance(int quantity, PackagingDefinition packaging)
Parameters
quantityintThe native product quantity for the new instance.
packagingPackagingDefinitionA live packaging definition from the active game runtime.
Returns
- ProductInstance
A packaged product instance, or null when the packaging cannot be converted for the active runtime or native construction fails.