Files
CalamityModPublic/Items/PermanentBoosters/Ectoheart.cs
T

62 lines
2.8 KiB
C#

using CalamityMod.CalPlayer;
using CalamityMod.Rarities;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.PermanentBoosters
{
public class Ectoheart : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Misc";
public int frameCounter = 0;
public int frame = 0;
public override void SetDefaults()
{
Item.width = 42;
Item.height = 44;
Item.useAnimation = 30;
Item.useTime = 30;
Item.useStyle = ItemUseStyleID.HoldUp;
Item.UseSound = SoundID.Item122;
Item.consumable = true;
Item.rare = ModContent.RarityType<PureGreen>(); // Not researchable, only drops one time.
}
public override bool CanUseItem(Player player) => !player.Calamity().adrenalineBoostThree;
public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale)
{
Texture2D texture = ModContent.Request<Texture2D>("CalamityMod/Items/PermanentBoosters/Ectoheart_Animated").Value;
spriteBatch.Draw(texture, position, Item.GetCurrentFrame(ref frame, ref frameCounter, 8, 3), Color.White, 0f, origin, scale, SpriteEffects.None, 0);
return false;
}
public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI)
{
Texture2D texture = ModContent.Request<Texture2D>("CalamityMod/Items/PermanentBoosters/Ectoheart_Animated").Value;
spriteBatch.Draw(texture, Item.position - Main.screenPosition, Item.GetCurrentFrame(ref frame, ref frameCounter, 8, 3), lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0);
return false;
}
public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI)
{
Texture2D texture = ModContent.Request<Texture2D>("CalamityMod/Items/PermanentBoosters/EctoheartGlow").Value;
spriteBatch.Draw(texture, Item.position - Main.screenPosition, Item.GetCurrentFrame(ref frame, ref frameCounter, 8, 3, false), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0);
}
public override bool? UseItem(Player player)
{
if (player.itemAnimation > 0 && player.itemTime == 0)
{
player.itemTime = Item.useTime;
CalamityPlayer modPlayer = player.Calamity();
modPlayer.adrenalineBoostThree = true;
}
return true;
}
}
}