Class StorableItemDefinitionBuilderBase<TSelf>
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
TSelfThe 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
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
sourceStorableItemDefinitionThe 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
definitionStorableItemDefinitionThe 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
idstringUnique identifier for the item (e.g., "my_custom_tool").
namestringDisplay name shown in UI.
descriptionstringItem description shown in tooltips.
categoryItemCategoryItem 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
availableboolTrue 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
equippableEquippableThe 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
iconSpriteThe 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
statusLegalStatusWhether 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
basePurchasePricefloatBase price when buying from shops.
resellMultiplierfloatFraction 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
rankFullRank?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
limitintMaximum 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
stationItemPrefabGameObjectA 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
stationItemPrefabis null.- ArgumentException
Thrown if
stationItemPrefabdoes not have a StationItem component.
WithStoredItem(GameObject)
Assigns a custom StoredItem prefab for this definition.
public TSelf WithStoredItem(GameObject storedItemPrefab)
Parameters
storedItemPrefabGameObjectPrefab 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