tModLoader v2024.05
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)
 
NPCShop Add (Item item, params Condition[] condition)
 
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< 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.