Add sprite for Mini Singularity

This commit is contained in:
2025-11-27 12:17:35 +00:00
parent 8cf8baffe2
commit 4d82879f77
5 changed files with 66 additions and 6 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 888 B

+63 -4
View File
@@ -1,5 +1,10 @@
using Terraria.ID;
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.GameContent;
using Terraria.ID;
using Terraria.ModLoader;
using ForgottenWawiTech.Content.Rarities;
@@ -7,11 +12,29 @@ namespace ForgottenWawiTech.Content.Items.Materials
{
public class MiniSingularity : ModItem
{
private const int FrameCount = 8;
private const int TicksPerFrame = 5;
private const int AfterimageCount = 12;
private const float AfterimageRadiusMultiplier = 0.58f;
private const float AfterimageOpacity = 0.22f;
private const float AfterimageScaleJitter = 0.12f;
private const float AfterimageOrbitSpeed = 2.1f;
private const float AfterimageDriftAmplitude = 0.35f;
private const float AfterimageDriftFrequency = 0.85f;
private const float AfterimageRotationJitter = 0.35f;
private const float AfterimageNoiseRadiusMultiplier = 0.08f;
public override void SetStaticDefaults()
{
Main.RegisterItemAnimation(Type, new DrawAnimationVertical(TicksPerFrame, FrameCount));
ItemID.Sets.AnimatesAsSoul[Type] = true;
ItemID.Sets.ItemNoGravity[Type] = true;
}
public override void SetDefaults()
{
Item.width = 20;
Item.height = 20;
Item.width = 32;
Item.height = 32;
Item.maxStack = 9999;
Item.rare = ModContent.RarityType<SingularityItem>();
Item.value = Item.buyPrice(gold: 50);
@@ -25,8 +48,44 @@ namespace ForgottenWawiTech.Content.Items.Materials
.AddIngredient(ItemID.FragmentVortex, 5)
.AddIngredient(ItemID.FragmentStardust, 5)
.AddIngredient(ItemID.WormholePotion, 1)
.AddTile<Content.Tiles.CraftingStations.SingularitySealingUnit>()
.AddTile(TileID.LunarCraftingStation)
.Register();
}
public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI)
{
Texture2D texture = TextureAssets.Item[Type].Value;
int frameHeight = texture.Height / Math.Max(1, FrameCount);
int frameIndex = (int)((Main.GameUpdateCount / (ulong)Math.Max(1, TicksPerFrame)) % (ulong)Math.Max(1, FrameCount));
Rectangle frame = new Rectangle(0, frameIndex * frameHeight, texture.Width, frameHeight);
Vector2 drawPosition = Item.Center - Main.screenPosition;
Vector2 origin = frame.Size() / 2f;
float baseRadius = frame.Width * scale * AfterimageRadiusMultiplier;
float time = (float)Main.GlobalTimeWrappedHourly;
float seededOffset = whoAmI * 0.27f;
// Orbiting ghosted frames to emulate light being smeared and pulled inward.
for (int i = 0; i < AfterimageCount; i++)
{
float progress = i / (float)AfterimageCount;
float angle = (time * AfterimageOrbitSpeed) + seededOffset + progress * MathHelper.TwoPi;
float drift = (float)Math.Sin((time + progress * 5f + seededOffset) * AfterimageDriftFrequency) * AfterimageDriftAmplitude;
float radius = baseRadius * (1f + drift);
float jitter = (float)Math.Sin((time * 1.6f) + progress * 11f + seededOffset) * AfterimageRotationJitter;
Vector2 offset = (angle + jitter).ToRotationVector2() * radius;
Vector2 noise = new Vector2(
(float)Math.Sin((time * 2.4f) + progress * 13f + seededOffset),
(float)Math.Cos((time * 2.1f) + progress * 17f + seededOffset)) * (baseRadius * AfterimageNoiseRadiusMultiplier);
float scaleJitter = 1f + (float)Math.Sin((time * 3.2f) + progress * 7f + seededOffset) * AfterimageScaleJitter;
Color afterimageColor = Color.Lerp(lightColor, Color.Black, 0.6f) * AfterimageOpacity;
spriteBatch.Draw(texture, drawPosition + offset + noise, frame, afterimageColor, rotation, origin, scale * scaleJitter, SpriteEffects.None, 0f);
}
spriteBatch.Draw(texture, drawPosition, frame, lightColor, rotation, origin, scale, SpriteEffects.None, 0f);
return false;
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 504 B

After

Width:  |  Height:  |  Size: 35 KiB

+2 -1
View File
@@ -112,7 +112,8 @@ namespace ForgottenWawiTech.Content.NPCs.TownNPCs
public override bool CanTownNPCSpawn(int numTownNPCs)
{
// Only spawn if a player has obtained RGBass in this world
return ForgottenWawiTechSystem.hasObtainedRGBass;
//return ForgottenWawiTechSystem.hasObtainedRGBass;
return true; // Temporary for testing
}
public override List<string> SetNPCNameList()
+1 -1
View File
@@ -1,3 +1,3 @@
displayName = The Forgotten Wawi Tech
author = Several Wonderful People
version = 0.1
version = 0.0.1-indev261125