diff --git a/Content/Items/Materials/ContainmentUnit.png b/Content/Items/Materials/ContainmentUnit.png index 0898439..36c3cec 100644 Binary files a/Content/Items/Materials/ContainmentUnit.png and b/Content/Items/Materials/ContainmentUnit.png differ diff --git a/Content/Items/Materials/MiniSingularity.cs b/Content/Items/Materials/MiniSingularity.cs index 859ae19..c66cf1a 100644 --- a/Content/Items/Materials/MiniSingularity.cs +++ b/Content/Items/Materials/MiniSingularity.cs @@ -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(); 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() + .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; + } } } \ No newline at end of file diff --git a/Content/Items/Materials/MiniSingularity.png b/Content/Items/Materials/MiniSingularity.png index 9e0cf81..b2df271 100644 Binary files a/Content/Items/Materials/MiniSingularity.png and b/Content/Items/Materials/MiniSingularity.png differ diff --git a/Content/NPCs/TownNPCs/AvalianTrader.cs b/Content/NPCs/TownNPCs/AvalianTrader.cs index d2cbd1e..9121c1c 100644 --- a/Content/NPCs/TownNPCs/AvalianTrader.cs +++ b/Content/NPCs/TownNPCs/AvalianTrader.cs @@ -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 SetNPCNameList() diff --git a/build.txt b/build.txt index 4d5ef53..f161e28 100644 --- a/build.txt +++ b/build.txt @@ -1,3 +1,3 @@ displayName = The Forgotten Wawi Tech author = Several Wonderful People -version = 0.1 \ No newline at end of file +version = 0.0.1-indev261125 \ No newline at end of file