tModLoader v2024.11
A mod to make and play Terraria mods
ItemVariants Class Reference

Handles conditional variants for Items, commonly used for secret seeds. More...

Classes

class  VariantEntry
 

Static Public Member Functions

static void AddVariant (int itemId, ItemVariant variant, params ItemVariantCondition[] conditions)
 Registers an ItemVariant for the given Item.type. More...
 
static IEnumerable< VariantEntryGetVariants (int itemId)
 Gets all of the ItemVariants associated with itemId . More...
 
static bool HasVariant (int itemId, ItemVariant variant)
 Determines if an Item.type has a particular ItemVariant. More...
 
static ItemVariant SelectVariant (int itemId)
 Determines which ItemVariant should be applied to an item of type itemId . More...
 

Static Public Attributes

static ItemVariant DisabledBossSummonVariant
 Represents a variant of a boss summoning item that is conditionally disabled.
 
static ItemVariant EnabledVariant
 Represents a variant of an item that is conditionally enabled.
 
static ItemVariant RebalancedVariant
 Represents the rebalanced variant of items used on the "For the Worthy" seed.
 
static ItemVariant StrongerVariant
 Represents the stronger variant of items used on the Remix seed.
 
static ItemVariant WeakerVariant
 Represents the weaker variant of items used on the Remix seed.
 

Detailed Description

Handles conditional variants for Items, commonly used for secret seeds.

Member Function Documentation

◆ AddVariant()

static void ItemVariants.AddVariant ( int  itemId,
ItemVariant  variant,
params ItemVariantCondition[]  conditions 
)
static

Registers an ItemVariant for the given Item.type.

Parameters
itemIdThe Item.type to register the ItemVariant for.
variantThe ItemVariant to register to itemId .
conditionsThe conditions under which Items of type itemId will have variant applied. (SelectVariant(int))

◆ GetVariants()

static IEnumerable< VariantEntry > ItemVariants.GetVariants ( int  itemId)
static

Gets all of the ItemVariants associated with itemId .

Parameters
itemIdThe Item.type to get ItemVariants for.
Returns
A list of all registered ItemVariants for itemId .

◆ HasVariant()

static bool ItemVariants.HasVariant ( int  itemId,
ItemVariant  variant 
)
static

Determines if an Item.type has a particular ItemVariant.

Parameters
itemIdThe Item.type to check.
variantThe ItemVariant to check for.
Returns
true if itemId has a registered ItemVariant of type variant , false otherwise.

This method only checks if the given ItemVariant exists, not if it will be applied.

◆ SelectVariant()

static ItemVariant ItemVariants.SelectVariant ( int  itemId)
static

Determines which ItemVariant should be applied to an item of type itemId .

Parameters
itemIdThe Item.type to check.
Returns
The ItemVariant to use under the current conditions, or null if no appropriate ItemVariant exists.