TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches

◆ DefaultToFood()

void Terraria.Item.DefaultToFood ( int newwidth,
int newheight,
int foodbuff,
int foodbuffduration,
bool useGulpSound = false,
int animationTime = 17 )
inline

This method sets a variety of Item values common to food items.
Specifically:

UseSound = useGulpSound ? Item3 : Item2; useStyle = useGulpSound ? F:Terraria.ID.ItemUseStyleID.DrinkLiquid : F:Terraria.ID.ItemUseStyleID.EatFood; useTurn = true; useAnimation = useTime = animationTime; maxStack = F:Terraria.Item.CommonMaxStack; consumable = true; buffType = foodbuff ; buffTime = foodbuffduration ; rare = F:Terraria.ID.ItemRarityID.Blue; value = 20 silver;

Parameters
newwidth
newheight
foodbuff
foodbuffduration
useGulpSoundIf true, the gulp sound is set, otherwise the crunch sound is set
animationTime

Definition at line 48673 of file Item.cs.

48674 {
48675 if (useGulpSound)
48676 {
48678 }
48679 else
48680 {
48682 }
48683 if (useGulpSound)
48684 {
48685 useStyle = 9;
48686 }
48687 else
48688 {
48689 useStyle = 2;
48690 }
48691 useTurn = true;
48694 consumable = true;
48695 width = newwidth;
48696 height = newheight;
48699 rare = 1;
48700 value = buyPrice(0, 0, 20);
48701 }
int width
The width of this Entity's hitbox, in pixels.
Definition Entity.cs:46
int height
The height of this Entity's hitbox, in pixels.
Definition Entity.cs:51
static readonly SoundStyle Item3
Definition SoundID.cs:683
static readonly SoundStyle Item2
Definition SoundID.cs:681
SoundStyle? UseSound
The sound this item makes when used. Set this to an existing T:Terraria.ID.SoundID entry or assign to...
Definition Item.cs:534
static int buyPrice(int platinum=0, int gold=0, int silver=0, int copper=0)
Converts the provided buy price into copper coins. If assigned to F:Terraria.Item....
Definition Item.cs:49543
bool useTurn
Whether the player can turn around while the using animation of this item is happening....
Definition Item.cs:500
int useAnimation
The time span of the using animation for the item in ticks. This is independent of the time it takes ...
Definition Item.cs:384
int value
The number of copper coins this item is worth (aka, cost to buy from a merchant). Setting it to 10462...
Definition Item.cs:655
int rare
Indicates the rarity of an item. Assign to a T:Terraria.ID.ItemRarityID value. Vanilla values range f...
Definition Item.cs:587
int maxStack
The maximum number of items that can be contained within a single stack. F:Terraria....
Definition Item.cs:402
bool consumable
Whether the item is consumed after use. If consumed, the item stack will decrease by 1....
Definition Item.cs:488
int buffTime
The duration in ticks of the buff given by this item on use. There are 60 ticks per second,...
Definition Item.cs:690
int buffType
The Buff ID of the buff given by this item on use. To have a potion give multiple buffs,...
Definition Item.cs:683
int useStyle
Assign to an T:Terraria.ID.ItemUseStyleID value to give this item a specific animation while in use....
Definition Item.cs:366
static int CommonMaxStack
The default stack size for stackable items: 9999.
Definition Item.cs:94
int useTime
The time span of using the item in ticks. This is independent of the time it takes for the item anima...
Definition Item.cs:391

References Terraria.Item.buffTime, Terraria.Item.buffType, Terraria.Item.buyPrice(), Terraria.Item.CommonMaxStack, Terraria.Item.consumable, Terraria.Entity.height, Terraria.ID.SoundID.Item2, Terraria.ID.SoundID.Item3, Terraria.Item.maxStack, Terraria.Item.rare, Terraria.Item.useAnimation, Terraria.Item.UseSound, Terraria.Item.useStyle, Terraria.Item.useTime, Terraria.Item.useTurn, Terraria.Item.value, and Terraria.Entity.width.

Referenced by Terraria.Item.SetDefaults5(), and Terraria.Item.SetFoodDefaults().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: