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

◆ CheckMana() [2/2]

bool Terraria.Player.CheckMana ( Item item,
int amount = -1,
bool pay = false,
bool blockQuickMana = false )
inline

Determines if this player has enough mana to use an item.
If the player doesn't have enough mana and blockQuickMana is false, the player will activate any missing mana effects they have and try again.
The pay parameter can be used to consume the mana amount.

Parameters
itemThe item to use.
amountThe amount of mana needed. If -1, calculate using M:Terraria.Player.GetManaCost(Terraria.Item).
payIf true, actually use the mana requested.
blockQuickManaIf true, prevent on missing mana effects like the Mana Flower from activating if the player doesn't have enough mana.
Returns
true if the player has enough mana to use the item, false otherwise.

Definition at line 58647 of file Player.cs.

58648 {
58649 if (amount <= -1)
58650 {
58651 amount = GetManaCost(item);
58652 }
58653 if (statMana >= amount)
58654 {
58655 if (pay)
58656 {
58657 CombinedHooks.OnConsumeMana(this, item, amount);
58658 statMana -= amount;
58659 }
58660 return true;
58661 }
58662 if (blockQuickMana)
58663 {
58664 return false;
58665 }
58666 CombinedHooks.OnMissingMana(this, item, amount);
58667 if (statMana < amount && manaFlower)
58668 {
58669 QuickMana();
58670 }
58671 if (statMana >= amount)
58672 {
58673 if (pay)
58674 {
58675 CombinedHooks.OnConsumeMana(this, item, amount);
58676 statMana -= amount;
58677 }
58678 return true;
58679 }
58680 return false;
58681 }
static void OnMissingMana(Player player, Item item, int neededMana)
static void OnConsumeMana(Player player, Item item, int manaConsumed)
int GetManaCost(Item item)
Calculates the mana needed to use the given item.
Definition Player.cs:58616
void QuickMana()
Definition Player.cs:6010
int statMana
The current mana of this player. Capped at F:Terraria.Player.statManaMax2. If you increase this val...
Definition Player.cs:2111

References Terraria.Player.GetManaCost(), Terraria.Player.manaFlower, Terraria.ModLoader.CombinedHooks.OnConsumeMana(), Terraria.ModLoader.CombinedHooks.OnMissingMana(), Terraria.Player.QuickMana(), and Terraria.Player.statMana.

+ Here is the call graph for this function: