This commit formats the entire codebase according to `dotnet format` and its limited understanding of our provided `.editorconfig`.
54 lines
2.3 KiB
C#
54 lines
2.3 KiB
C#
using System;
|
|
using CalamityMod.Rarities;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using Terraria;
|
|
using Terraria.GameContent;
|
|
using Terraria.Graphics.Shaders;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Items.Materials
|
|
{
|
|
public class PlasmaDriveCore : ModItem, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Items.Materials";
|
|
public override void SetDefaults()
|
|
{
|
|
Item.width = 30;
|
|
Item.height = 30;
|
|
Item.maxStack = 9999;
|
|
Item.value = Item.buyPrice(0, 0, 0, 0);
|
|
Item.rare = ModContent.RarityType<DarkOrange>();
|
|
}
|
|
|
|
public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale)
|
|
{
|
|
Texture2D tex = TextureAssets.Item[Item.type].Value;
|
|
|
|
//Give it an outline. Make it look really important and shiny. The player must not confuse this for a random material
|
|
spriteBatch.End();
|
|
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, Main.UIScaleMatrix);
|
|
Color outlineColor = Color.Lerp(Color.Cyan, Color.Orange, (float)Math.Sin(Main.GlobalTimeWrappedHourly * 2f) * 0.5f + 0.5f);
|
|
Vector3 outlineHSL = Main.rgbToHsl(outlineColor); //BasicTint uses the opposite hue i guess? or smth is fucked with the way shaders get their colors. anyways, we invert it
|
|
|
|
GameShaders.Misc["CalamityMod:BasicTint"].UseOpacity(1f);
|
|
GameShaders.Misc["CalamityMod:BasicTint"].UseColor(Main.hslToRgb(1 - outlineHSL.X, outlineHSL.Y, outlineHSL.Z));
|
|
GameShaders.Misc["CalamityMod:BasicTint"].Apply();
|
|
|
|
float outlineWidth = MathHelper.Lerp(2, 3, (float)Math.Sin(Main.GlobalTimeWrappedHourly * 2f) * 0.5f + 0.5f);
|
|
float positionOffset = outlineWidth * scale;
|
|
|
|
for (float i = 0; i < 1; i += 0.25f)
|
|
{
|
|
spriteBatch.Draw(tex, position + (i * MathHelper.TwoPi).ToRotationVector2() * positionOffset, frame, outlineColor, 0f, origin, scale, 0f, 0f);
|
|
}
|
|
|
|
spriteBatch.End();
|
|
spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, Main.UIScaleMatrix);
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|