137 lines
4.9 KiB
C#
137 lines
4.9 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using ReLogic.Graphics;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ModLoader;
|
|
using ForgottenWawiTech.Content.Rarities;
|
|
|
|
namespace ForgottenWawiTech.Content.Items.Global
|
|
{
|
|
public class TranscendentRarityTooltip : GlobalItem
|
|
{
|
|
public override bool PreDrawTooltipLine(Item item, DrawableTooltipLine line, ref int yOffset)
|
|
{
|
|
if (item.rare != ModContent.RarityType<TranscendentItem>())
|
|
return base.PreDrawTooltipLine(item, line, ref yOffset);
|
|
|
|
if (line.Mod != "Terraria" || line.Name != "ItemName")
|
|
return base.PreDrawTooltipLine(item, line, ref yOffset);
|
|
|
|
float time = Main.GlobalTimeWrappedHourly;
|
|
Vector2 position = new Vector2(line.X, line.Y);
|
|
float scale = line.BaseScale.X;
|
|
|
|
ModRarity rarity = RarityLoader.GetRarity(item.rare);
|
|
Color baseColor = rarity.RarityColor;
|
|
|
|
// Celestial orbit trail: faint echoes revolved around the text.
|
|
const int orbitCopies = 5;
|
|
for (int i = 0; i < orbitCopies; i++)
|
|
{
|
|
float angle = time * 1.2f + i * MathHelper.TwoPi / orbitCopies;
|
|
float radius = 4.5f + 1.5f * (float)Math.Sin(time * 2.4f + i);
|
|
Vector2 offset = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * radius;
|
|
|
|
float pulse = 0.35f + 0.25f * (float)Math.Sin(time * 3f + i);
|
|
Color orbitColor = Color.Lerp(baseColor, Color.White, pulse) * 0.55f;
|
|
|
|
DynamicSpriteFontExtensionMethods.DrawString(
|
|
Main.spriteBatch,
|
|
line.Font,
|
|
line.Text,
|
|
position + offset,
|
|
orbitColor,
|
|
line.Rotation,
|
|
line.Origin,
|
|
scale,
|
|
SpriteEffects.None,
|
|
0f
|
|
);
|
|
}
|
|
|
|
// Vertical aurora shimmer behind the main text.
|
|
Vector2 auroraOffset = new Vector2(0f, (float)Math.Sin(time * 4.2f) * 2.2f);
|
|
Color auroraColor = Color.Lerp(baseColor, new Color(240, 255, 220), 0.6f) * 0.7f;
|
|
DynamicSpriteFontExtensionMethods.DrawString(
|
|
Main.spriteBatch,
|
|
line.Font,
|
|
line.Text,
|
|
position + auroraOffset,
|
|
auroraColor,
|
|
line.Rotation,
|
|
line.Origin,
|
|
scale * 1.04f,
|
|
SpriteEffects.None,
|
|
0f
|
|
);
|
|
|
|
// Outline ensures readability against bright backgrounds.
|
|
Vector2[] outlines =
|
|
{
|
|
new Vector2(-1f, 0f),
|
|
new Vector2(1f, 0f),
|
|
new Vector2(0f, -1f),
|
|
new Vector2(0f, 1f)
|
|
};
|
|
|
|
foreach (Vector2 outline in outlines)
|
|
{
|
|
DynamicSpriteFontExtensionMethods.DrawString(
|
|
Main.spriteBatch,
|
|
line.Font,
|
|
line.Text,
|
|
position + outline,
|
|
Color.Black * 0.85f,
|
|
line.Rotation,
|
|
line.Origin,
|
|
scale,
|
|
SpriteEffects.None,
|
|
0f
|
|
);
|
|
}
|
|
|
|
// Main text with cascading prism shimmer.
|
|
float shimmer = (float)Math.Sin(time * 5.2f) * 0.5f + 0.5f;
|
|
Color highlight = Color.Lerp(baseColor, Color.White, 0.45f + shimmer * 0.35f);
|
|
Color finalColor = new Color(
|
|
(byte)MathHelper.Clamp(baseColor.R + (highlight.R - baseColor.R) * shimmer, 0, 255),
|
|
(byte)MathHelper.Clamp(baseColor.G + (highlight.G - baseColor.G) * shimmer, 0, 255),
|
|
(byte)MathHelper.Clamp(baseColor.B + (highlight.B - baseColor.B) * shimmer, 0, 255)
|
|
);
|
|
|
|
DynamicSpriteFontExtensionMethods.DrawString(
|
|
Main.spriteBatch,
|
|
line.Font,
|
|
line.Text,
|
|
position,
|
|
finalColor,
|
|
line.Rotation,
|
|
line.Origin,
|
|
scale,
|
|
SpriteEffects.None,
|
|
0f
|
|
);
|
|
|
|
// Add a rising stardust sweep that briefly flashes across the name.
|
|
float sweepPos = (float)Math.Sin(time * 1.6f) * 0.5f + 0.5f;
|
|
Vector2 sweepOffset = new Vector2((sweepPos - 0.5f) * 14f, -6f);
|
|
Color sweepColor = new Color(255, 255, 220) * 0.5f;
|
|
DynamicSpriteFontExtensionMethods.DrawString(
|
|
Main.spriteBatch,
|
|
line.Font,
|
|
line.Text,
|
|
position + sweepOffset,
|
|
sweepColor,
|
|
line.Rotation,
|
|
line.Origin,
|
|
scale * 0.9f,
|
|
SpriteEffects.None,
|
|
0f
|
|
);
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|