Table of Contents

Class StorableItemDefinitionBuilderBase<TSelf>

Namespace
S1API.Items.Storable
Assembly
S1API.dll

INTERNAL: Generic base builder for composing item definitions at runtime, with fluent methods returning the correct subclass type.

public abstract class StorableItemDefinitionBuilderBase<TSelf> where TSelf : StorableItemDefinitionBuilderBase<TSelf>

Type Parameters

TSelf

The concrete builder type being implemented (e.g., StorableItemDefinitionBuilder).

Inheritance
StorableItemDefinitionBuilderBase<TSelf>
Derived
Inherited Members
Extension Methods

Fields

Definition

INTERNAL: The underlying game item definition being composed by this builder.

protected readonly StorableItemDefinition Definition

Field Value

StorableItemDefinition

Properties

HasCustomStoredItem

INTERNAL: Whether a custom StoredItem was assigned via WithStoredItem(GameObject). Subclasses use this to avoid overwriting a modder-supplied StoredItem.

protected bool HasCustomStoredItem { get; }

Property Value

bool

Methods

Build()

Builds the item definition, registers it with the game's registry, and returns a wrapper.

protected virtual StorableItemDefinition Build()

Returns

StorableItemDefinition

A wrapper around the created storable item definition.

Remarks

Designated virtual, usually shadowed in subclasses due to different return type.

CopyPropertiesFrom(StorableItemDefinition)

Copies all properties from a source definition to the current definition.

protected virtual void CopyPropertiesFrom(StorableItemDefinition source)

Parameters

source StorableItemDefinition

The source definition to copy from.

CreateWrapper(StorableItemDefinition)

Creates a wrapper around the given item definition. Subclasses can override this to return a more specific wrapper type.

protected virtual StorableItemDefinition CreateWrapper(StorableItemDefinition definition)

Parameters

definition StorableItemDefinition

The item definition to wrap.

Returns

StorableItemDefinition

A wrapper around the given item definition.

WithBasicInfo(string, string, string, ItemCategory)

Sets the basic information for the item.

public TSelf WithBasicInfo(string id, string name, string description, ItemCategory category)

Parameters

id string

Unique identifier for the item (e.g., "my_custom_tool").

name string

Display name shown in UI.

description string

Item description shown in tooltips.

category ItemCategory

Item category for inventory organization.

Returns

TSelf

The builder instance for fluent chaining.

WithDemoAvailability(bool)

Sets whether this item is available in the demo version of the game.

public TSelf WithDemoAvailability(bool available)

Parameters

available bool

True if available in demo, false otherwise.

Returns

TSelf

The builder instance for fluent chaining.

WithEquippable(Equippable)

Attaches an equippable component to this item, allowing it to be equipped by the player.

public TSelf WithEquippable(Equippable equippable)

Parameters

equippable Equippable

The equippable wrapper to attach.

Returns

TSelf

The builder instance for fluent chaining.

WithIcon(Sprite)

Sets the icon sprite displayed for this item in UI.

public TSelf WithIcon(Sprite icon)

Parameters

icon Sprite

The sprite to use as the item icon.

Returns

TSelf

The builder instance for fluent chaining.

WithLegalStatus(LegalStatus)

Sets the legal status of the item.

public TSelf WithLegalStatus(LegalStatus status)

Parameters

status LegalStatus

Whether the item is legal or illegal.

Returns

TSelf

The builder instance for fluent chaining.

WithPricing(float, float)

Configures the economic properties of the item.

public TSelf WithPricing(float basePurchasePrice, float resellMultiplier = 0.5)

Parameters

basePurchasePrice float

Base price when buying from shops.

resellMultiplier float

Fraction of purchase price recovered when selling (0.0 to 1.0).

Returns

TSelf

The builder instance for fluent chaining.

WithRequiredRank(FullRank?)

Assigns a level requirement for purchasing this item in shops.

public TSelf WithRequiredRank(FullRank? rank)

Parameters

rank FullRank?

The required rank to purchase this item, or null to remove level requirement.

Returns

TSelf

The builder instance for fluent chaining.

WithStackLimit(int)

Sets the maximum stack size for this item.

public TSelf WithStackLimit(int limit)

Parameters

limit int

Maximum quantity per inventory slot (1-999).

Returns

TSelf

The builder instance for fluent chaining.

WithStationItem(GameObject)

Assigns a StationItem prefab to this item definition so it can be used as a station/minigame ingredient (e.g., Chemistry Station).

public TSelf WithStationItem(GameObject stationItemPrefab)

Parameters

stationItemPrefab GameObject

A prefab GameObject that has a StationItem component.

Returns

TSelf

The builder instance for fluent chaining.

Remarks

S1API clones and caches the prefab under a hidden DontDestroyOnLoad root by default. This avoids mutating shared prefabs and helps keep the reference stable across scene loads.

Exceptions

ArgumentNullException

Thrown if stationItemPrefab is null.

ArgumentException

Thrown if stationItemPrefab does not have a StationItem component.

WithStoredItem(GameObject)

Assigns a custom StoredItem prefab for this definition.

public TSelf WithStoredItem(GameObject storedItemPrefab)

Parameters

storedItemPrefab GameObject

Prefab containing a StoredItem component.

Returns

TSelf

The builder instance for fluent chaining.

WithoutStationItem()

Clears the StationItem reference for this definition.

public TSelf WithoutStationItem()

Returns

TSelf