108 lines
3.6 KiB
C#
108 lines
3.6 KiB
C#
using CalamityMod.Items.Placeables.Ores;
|
|
using CalamityMod.Rarities;
|
|
using CalamityMod.Tiles;
|
|
using CalamityMod.Tiles.Furniture.CraftingStations;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using ReLogic.Content;
|
|
using Terraria;
|
|
using Terraria.DataStructures;
|
|
using Terraria.GameContent;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Items.Materials
|
|
{
|
|
public class AuricBar : ModItem, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Items.Materials";
|
|
public static Asset<Texture2D> GlowTexture { get; private set; }
|
|
|
|
public override void Load()
|
|
{
|
|
if (!Main.dedServ)
|
|
{
|
|
GlowTexture = ModContent.Request<Texture2D>($"{Texture}_Glow");
|
|
}
|
|
}
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
Item.ResearchUnlockCount = 25;
|
|
|
|
|
|
ItemID.Sets.SortingPriorityMaterials[Type] = 120;
|
|
ItemID.Sets.AnimatesAsSoul[Type] = true;
|
|
ItemID.Sets.ItemNoGravity[Item.type] = true;
|
|
|
|
Main.RegisterItemAnimation(
|
|
Type,
|
|
new DrawAnimationVertical(5, 12) /* 5 ticks per frame, has 12 frames total */
|
|
);
|
|
}
|
|
|
|
public override void Unload()
|
|
{
|
|
GlowTexture = null;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Item.DefaultToPlaceableTile(ModContent.TileType<AuricTeslaBar>());
|
|
Item.value = Item.sellPrice(gold: 60);
|
|
Item.rare = ModContent.RarityType<Violet>();
|
|
}
|
|
|
|
public override void UseStyle(Player player, Rectangle heldItemFrame)
|
|
{
|
|
player.itemLocation += new Vector2(-20f * player.direction, 15f * player.gravDir).RotatedBy(player.itemRotation);
|
|
}
|
|
|
|
public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
|
|
{
|
|
CalamityUtils.DrawInventoryCustomScale(
|
|
spriteBatch,
|
|
texture: TextureAssets.Item[Type].Value,
|
|
position,
|
|
frame,
|
|
drawColor,
|
|
itemColor,
|
|
origin,
|
|
scale,
|
|
wantedScale: 1f,
|
|
drawOffset: new(-1f, 0f)
|
|
);
|
|
return false;
|
|
}
|
|
|
|
public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI)
|
|
{
|
|
var frame = Item.GetFrame(whoAmI);
|
|
var position = Item.Center - Main.screenPosition;
|
|
var origin = frame.Size() / 2f;
|
|
spriteBatch.Draw(TextureAssets.Item[Type].Value, position, frame, lightColor, rotation, origin, scale, SpriteEffects.None, 0);
|
|
spriteBatch.Draw(GlowTexture.Value, position, frame, lightColor, rotation, origin, scale, SpriteEffects.None, 0);
|
|
}
|
|
|
|
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, 0.7f * brightness, 0f);
|
|
}
|
|
|
|
public override void AddRecipes()
|
|
{
|
|
CreateRecipe(5).
|
|
AddIngredient<AuricOre>(60).
|
|
AddIngredient<YharonSoulFragment>().
|
|
AddTile<CosmicAnvil>().
|
|
Register();
|
|
}
|
|
}
|
|
}
|