Decimation_Mod/Lib/Util/PlayerUtils.cs
FyloZ e61040d1e5 Added Trinity items drop.
Prevent Prefix on Trinity items.
2020-07-13 14:59:58 -04:00

46 lines
1.4 KiB
C#

using Decimation.Content;
using Decimation.Lib.Items;
using Terraria;
using Terraria.ModLoader;
namespace Decimation.Lib.Util
{
public static class PlayerUtils
{
public static DecimationPlayer GetModPlayer(this Player player)
{
return player.GetModPlayer<DecimationPlayer>();
}
public static void EquipAccessory(this Player player, DecimationAccessory accessory)
{
player.GetModPlayer().EquippedAccessories.Add(accessory.item.type);
}
public static bool HasEquippedAccessory(this Player player, int accessoryType)
{
return player.GetModPlayer().EquippedAccessories.Contains(accessoryType);
}
public static bool HasEquippedAccessory(this ModPlayer modPlayer, int accessoryType)
{
return modPlayer.player.GetModPlayer().EquippedAccessories.Contains(accessoryType);
}
public static bool HasEquippedAmulet(this Player player, int amuletType)
{
return player.GetModPlayer().AmuletSlotItem.type == amuletType;
}
public static void LeechMana(this Player player, Entity target, int minMana = 5, int maxMana = 15)
{
int manaAmount = Main.rand.Next(minMana, maxMana + 1);
player.ManaEffect(manaAmount);
if (target.GetType() == typeof(Player))
{
((Player) target).ManaEffect(-manaAmount);
}
}
}
}