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

Inherits AbstractNPCShop.

Classes

class  Entry
 

Public Member Functions

 NPCShop (int npcType, string name="Shop")
 
NPCShop Add (int item, params Condition[] condition)
 Adds the specified item with the provided conditions to this shop. If all of the conditions are satisfied, the item will be available in the shop.
 
NPCShop Add (Item item, params Condition[] condition)
 This overload takes an Item instance instead of just an item type. This Item can be customized prior to being registered. This is commonly used to provide a custom shop price or currency for this shop entry: More...
 
NPCShop Add (params Entry[] entries)
 
NPCShop Add< T > (params Condition[] condition)
 
NPCShop AllowFillingLastSlot ()
 
override void FillShop (ICollection< Item > items, NPC npc)
 Unbounded variant of FillShop(Item[], NPC, out bool), for future forwards compatibility with tabbed or scrolling shops. More...
 
override void FillShop (Item[] items, NPC npc, out bool overflow)
 Fills a shop array with the contents of this shop, evaluating conditions and running callbacks.
Does not fill the entire array if there are insufficient entries.
The last slot will be kept empty (null) if FillLastSlot is false More...
 
override void FinishSetup ()
 
Entry GetEntry (int item)
 
NPCShop InsertAfter (Entry targetEntry, Item item, params Condition[] condition)
 
NPCShop InsertAfter (int targetItem, int item, params Condition[] condition)
 
NPCShop InsertAfter (int targetItem, Item item, params Condition[] condition)
 
NPCShop InsertBefore (Entry targetEntry, Item item, params Condition[] condition)
 
NPCShop InsertBefore (int targetItem, int item, params Condition[] condition)
 
NPCShop InsertBefore (int targetItem, Item item, params Condition[] condition)
 
bool TryGetEntry (int item, out Entry entry)
 
- Public Member Functions inherited from AbstractNPCShop
 AbstractNPCShop (int npcType, string name="Shop")
 
abstract void FillShop (ICollection< Item > items, NPC npc)
 Unbounded variant of FillShop(Item[], NPC, out bool), for future forwards compatibility with tabbed or scrolling shops. More...
 
abstract void FillShop (Item[] items, NPC npc, out bool overflow)
 Fills a shop array with the contents of this shop, evaluating conditions and running callbacks. More...
 
virtual void FinishSetup ()
 
void Register ()
 

Properties

override IEnumerable< EntryActiveEntries [get]
 
IReadOnlyList< EntryEntries [get]
 
bool FillLastSlot [get]
 
- Properties inherited from AbstractNPCShop
abstract IEnumerable< EntryActiveEntries [get]
 
string FullName [get]
 
string Name [get]
 
int NpcType [get]
 

Member Function Documentation

◆ Add()

NPCShop NPCShop.Add ( Item  item,
params Condition[]  condition 
)

This overload takes an Item instance instead of just an item type. This Item can be customized prior to being registered. This is commonly used to provide a custom shop price or currency for this shop entry:

npcShop.Add(new Item(ItemID.MagicDagger) { shopCustomPrice = 2, shopSpecialCurrency = ExampleMod.ExampleCustomCurrencyId }, Condition.RemixWorld);

◆ Add< T >()

NPCShop NPCShop.Add< T > ( params Condition[]  condition)

Type Constraints
T :ModItem 
T :Add 
T :ModContent.ItemType<T>() 
T :condition 

◆ FillShop() [1/2]

override void NPCShop.FillShop ( ICollection< Item items,
NPC  npc 
)
virtual

Unbounded variant of FillShop(Item[], NPC, out bool), for future forwards compatibility with tabbed or scrolling shops.

Parameters
itemsThe collection to be filled
npcThe NPC the player is talking to

Implements AbstractNPCShop.

◆ FillShop() [2/2]

override void NPCShop.FillShop ( Item[]  items,
NPC  npc,
out bool  overflow 
)
virtual

Fills a shop array with the contents of this shop, evaluating conditions and running callbacks.
Does not fill the entire array if there are insufficient entries.
The last slot will be kept empty (null) if FillLastSlot is false

Parameters
itemsArray to be filled.
npcThe NPC the player is talking to, for Entry.OnShopOpen(Item, NPC) calls.
overflowTrue if some items were unable to fit in the provided array.

Implements AbstractNPCShop.

◆ FinishSetup()

override void NPCShop.FinishSetup ( )
virtual

Reimplemented from AbstractNPCShop.