Mod Helpers  v5.9.6
A centralized collection of library code, helpful services, and end-user functions for mod management and information.
HamstarHelpers.Helpers.Items.ItemHelpers Class Reference

Assorted static functions pertaining to general use of item. More...

Static Public Member Functions

static IList< Item > GetActive ()
 Get all active items found lying around in the world. More...
 
static int CreateItem (Vector2 pos, int type, int stack, int width, int height, int prefix=0)
 Creates a world item and ensures it syncs. More...
 
static void DestroyItem (Item item)
 Destroyes an item (turns it to air). No sync. More...
 
static void DestroyWorldItem (int idx)
 Destroys a world item (ensures sync). More...
 
static void ReduceStack (Item item, int amt)
 Reduces an item's stack, accommodating if it's held in the mouse, if the stack becomes 0, and any needed sync. More...
 
static void ReduceWorldItemStack (int idx, int amt)
 Reduces a world item's stack. More...
 
static bool ConsumeItems (IEnumerable< Item > sourceItems, IDictionary< int, int > consumeAmounts, bool allOrNothing)
 Consumes a quantity of items (by type) from a given item source. Does not sync item changes. More...
 
static int CalculateStandardUseTime (Item item)
 Calculates the "use time" of an item, accounting for non-melee reuseDelay and items that incur "reuse" via. animations instead of the internal useTime value. More...
 
static int [] CreateCoins (long amount, Vector2 position)
 Creates the best fitting set and amount of coins totalling the given amount. Does not sync. More...
 

Detailed Description

Assorted static functions pertaining to general use of item.

Definition at line 12 of file ItemHelpers.cs.

Member Function Documentation

◆ CalculateStandardUseTime()

static int HamstarHelpers.Helpers.Items.ItemHelpers.CalculateStandardUseTime ( Item  item)
static

Calculates the "use time" of an item, accounting for non-melee reuseDelay and items that incur "reuse" via. animations instead of the internal useTime value.

Parameters
item
Returns
Tick duration between reuses.

Definition at line 177 of file ItemHelpers.cs.

◆ ConsumeItems()

static bool HamstarHelpers.Helpers.Items.ItemHelpers.ConsumeItems ( IEnumerable< Item >  sourceItems,
IDictionary< int, int >  consumeAmounts,
bool  allOrNothing 
)
static

Consumes a quantity of items (by type) from a given item source. Does not sync item changes.

Parameters
sourceItems
consumeAmounts
allOrNothingConsumes the given amount of items only if all of them are present.
Returns
true if all items consumed in full.

Definition at line 134 of file ItemHelpers.cs.

◆ CreateCoins()

static int [] HamstarHelpers.Helpers.Items.ItemHelpers.CreateCoins ( long  amount,
Vector2  position 
)
static

Creates the best fitting set and amount of coins totalling the given amount. Does not sync.

Parameters
amount
position
Returns
List of item whoAmI values of each coin.

Definition at line 210 of file ItemHelpers.cs.

◆ CreateItem()

static int HamstarHelpers.Helpers.Items.ItemHelpers.CreateItem ( Vector2  pos,
int  type,
int  stack,
int  width,
int  height,
int  prefix = 0 
)
static

Creates a world item and ensures it syncs.

Parameters
pos
type
stack
width
height
prefix
Returns

Definition at line 42 of file ItemHelpers.cs.

◆ DestroyItem()

static void HamstarHelpers.Helpers.Items.ItemHelpers.DestroyItem ( Item  item)
static

Destroyes an item (turns it to air). No sync.

Parameters
item

Definition at line 56 of file ItemHelpers.cs.

◆ DestroyWorldItem()

static void HamstarHelpers.Helpers.Items.ItemHelpers.DestroyWorldItem ( int  idx)
static

Destroys a world item (ensures sync).

Parameters
idx

Definition at line 67 of file ItemHelpers.cs.

◆ GetActive()

static IList<Item> HamstarHelpers.Helpers.Items.ItemHelpers.GetActive ( )
static

Get all active items found lying around in the world.

Returns

Definition at line 17 of file ItemHelpers.cs.

◆ ReduceStack()

static void HamstarHelpers.Helpers.Items.ItemHelpers.ReduceStack ( Item  item,
int  amt 
)
static

Reduces an item's stack, accommodating if it's held in the mouse, if the stack becomes 0, and any needed sync.

Parameters
item
amt

Definition at line 82 of file ItemHelpers.cs.

◆ ReduceWorldItemStack()

static void HamstarHelpers.Helpers.Items.ItemHelpers.ReduceWorldItemStack ( int  idx,
int  amt 
)
static

Reduces a world item's stack.

Parameters
idxIndex (whoAmI) of item in Main.item.
amt

Definition at line 118 of file ItemHelpers.cs.


The documentation for this class was generated from the following file: