diff --git a/Content/Items/Materials/VisorShard.cs b/Content/Items/Materials/VisorShard.cs index 02eca15..fa9dfd8 100644 --- a/Content/Items/Materials/VisorShard.cs +++ b/Content/Items/Materials/VisorShard.cs @@ -1,20 +1,55 @@ +// Animated by Axl_The_Protogen using Terraria.ID; using Terraria; using Terraria.ModLoader; +using Terraria.DataStructures; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; +using System; +using Terraria.GameContent; using ForgottenWawiTech.Content.Rarities; namespace ForgottenWawiTech.Content.Items.Materials { public class VisorShard : ModItem { + private const int FRAME_COUNT = 9; + private const int TICKS_PER_FRAME = 10; + public override void SetStaticDefaults() + { + Main.RegisterItemAnimation(Type, new DrawAnimationVertical(TICKS_PER_FRAME, FRAME_COUNT)); + + } public override void SetDefaults() { - Item.width = 20; - Item.height = 20; + Item.width = 32; + Item.height = 32; Item.maxStack = 9999; Item.rare = ModContent.RarityType(); - Item.value = Item.buyPrice(gold: 1); + Item.value = Item.buyPrice(gold: 50); + } + + public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) + { + Texture2D texture = Terraria.GameContent.TextureAssets.Item[Type].Value; + + // Protect against incorrect frame count + int frameHeight = texture.Height / Math.Max(1, FRAME_COUNT); + int frame = (int)((Main.GameUpdateCount / (ulong)Math.Max(1, TICKS_PER_FRAME)) % (ulong)Math.Max(1, FRAME_COUNT)); + + Rectangle source = new Rectangle(0, frame * frameHeight, texture.Width, frameHeight); + + Vector2 drawPos = Item.Center - Main.screenPosition; + Vector2 origin = new Vector2(source.Width / 2f, source.Height / 2f); + + // Use alphaColor for dropped items (includes item alpha), multiplied by light + Color drawColor = lightColor; + + spriteBatch.Draw(texture, drawPos, source, drawColor, rotation, origin, scale, SpriteEffects.None, 0f); + + return false; // we've handled the draw } } } \ No newline at end of file diff --git a/Content/Items/Materials/VisorShard.png b/Content/Items/Materials/VisorShard.png index 9e0cf81..00594fb 100644 Binary files a/Content/Items/Materials/VisorShard.png and b/Content/Items/Materials/VisorShard.png differ diff --git a/Localization/en-US_Mods.ForgottenWawiTech.hjson b/Localization/en-US_Mods.ForgottenWawiTech.hjson index 1f27e29..646ea88 100644 --- a/Localization/en-US_Mods.ForgottenWawiTech.hjson +++ b/Localization/en-US_Mods.ForgottenWawiTech.hjson @@ -121,8 +121,8 @@ Items: { DisplayName: Visor Shard Tooltip: ''' - A fragment of a high-tech visor. - Emits a faint glow. + A fragment of a broken Nanite Visor. + Still hums with residual energy. ''' } @@ -231,10 +231,7 @@ Items: { } NeptuneTrophyItem: { - Tooltip: - ''' - Surprisingly large for a trophy. Especially from an otter. - ''' + Tooltip: Surprisingly large for a trophy. Especially from an otter. DisplayName: Neptune Trophy Item } }