59 lines
2.4 KiB
C#
59 lines
2.4 KiB
C#
using CalamityMod.Rarities;
|
|
using CalamityMod.Tiles;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Items.Materials
|
|
{
|
|
public class CosmiliteBar : ModItem, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Items.Materials";
|
|
public int frameCounter = 0;
|
|
public int frame = 0;
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
Item.ResearchUnlockCount = 25;
|
|
ItemID.Sets.SortingPriorityMaterials[Type] = 114;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Item.createTile = ModContent.TileType<CosmiliteBarTile>();
|
|
Item.width = 32;
|
|
Item.height = 24;
|
|
Item.maxStack = 9999;
|
|
Item.value = Item.sellPrice(gold: 20);
|
|
Item.rare = ModContent.RarityType<DarkBlue>();
|
|
Item.useStyle = ItemUseStyleID.Swing;
|
|
Item.useTurn = true;
|
|
Item.useAnimation = 15;
|
|
Item.useTime = 10;
|
|
Item.autoReuse = true;
|
|
Item.consumable = true;
|
|
}
|
|
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/Materials/CosmiliteBar_Animated").Value;
|
|
spriteBatch.Draw(texture, position, Item.GetCurrentFrame(ref frame, ref frameCounter, 6, 10), 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/Materials/CosmiliteBar_Animated").Value;
|
|
spriteBatch.Draw(texture, Item.position - Main.screenPosition, Item.GetCurrentFrame(ref frame, ref frameCounter, 6, 10), lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0);
|
|
return false;
|
|
}
|
|
|
|
public override void Update(ref float gravity, ref float maxFallSpeed)
|
|
{
|
|
float brightness = Main.essScale * Main.rand.NextFloat(0.9f, 1.1f);
|
|
Lighting.AddLight(Item.Center, 0.5f * brightness, 0f, 0.5f * brightness);
|
|
}
|
|
}
|
|
}
|