Divine Meat sprites + misc

* Renamed DivineCornucopia to DivineMeat and added in its final sprites. Functionality remains the same.
* Added some minor visual additions to Divine Meat and Disgusting Meat when they are dropped on the ground in the world.
* Added some minor visual additions to Divine Swine.
* Divine Swine now increments its y-velocity while flying in random directions to prevent it from infinitely flying up and into space.
* Disgusting Meat can no longer be used while its animation is being played.
This commit is contained in:
fryzahh committed 2026-05-12 12:41:59 -04:00
1 parent 6c1bc0e700
commit 1910a4c918
15 files changed
+667 -72

No files matched your search

+6
View File
@@ -257,6 +257,9 @@ namespace CalamityMod.Effects
// A simple chromatic abberation effect shader with support for custom abberation colors.
internal static Asset<Effect> ChromaticAbberationShader;
// Distorts a texture using a sine wave of specified amplitude and frequency either vertically or horizontally.
internal static Asset<Effect> SineWaveDistortionShader;
#endregion
#region Big E's Shaders
@@ -519,6 +522,9 @@ namespace CalamityMod.Effects
ChromaticAbberationShader = LoadShader("ChromaticAbberationShader");
RegisterMiscShader(ChromaticAbberationShader, "ChormaAbberationPass", "ChromaticAbberation");
SineWaveDistortionShader = LoadShader("SineWaveDistortionShader");
RegisterMiscShader(SineWaveDistortionShader, "SinePass", "SineWaveDistortion");
#endregion
#region Loading Big E's Shaders
+27
View File
@@ -0,0 +1,27 @@
sampler baseTexture : register(s0);
float time;
float waveAmplitude;
float waveFrequency;
bool distortHorizontally;
float4 PixelShaderFunction(float4 sampleColor : COLOR0, float2 coords : TEXCOORD0) : COLOR0
{
float2 horizontalDistortion = sin(coords.x * waveFrequency + time) * waveAmplitude;
float2 verticalDistortion = sin(coords.y * waveFrequency + time) * waveAmplitude;
if (distortHorizontally)
coords.y += horizontalDistortion;
else
coords.x += verticalDistortion;
return tex2D(baseTexture, coords) * sampleColor;
}
technique Technique1
{
pass SinePass
{
PixelShader = compile ps_2_0 PixelShaderFunction();
}
}
Binary file not shown.
-42
View File
@@ -1,42 +0,0 @@
using CalamityMod.Items.Tools;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Potions.Food
{
public class DivineCornucopia : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Potions";
public override void SetStaticDefaults()
{
Item.ResearchUnlockCount = 5;
Main.RegisterItemAnimation(Type, new DrawAnimationVertical(int.MaxValue, 3));
ItemID.Sets.IsFood[Type] = true;
ItemID.Sets.FoodParticleColors[Type] = new Color[3] {
new Color(241, 4, 8),
new Color(142, 183, 57),
new Color(245, 222, 73),
};
}
public override void SetDefaults()
{
Item.width = 32;
Item.height = 28;
Item.useAnimation = Item.useTime = 17;
Item.rare = ItemRarityID.Blue;
Item.value = Item.buyPrice(silver: 50);
Item.maxStack = 1;
Item.UseSound = SoundID.Item2;
Item.useStyle = ItemUseStyleID.DrinkLiquid;
Item.buffType = BuffID.WellFed;
Item.buffTime = CalamityUtils.MinutesToFrames(30);
Item.useTurn = true;
Item.consumable = false;
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 506 B

+117
View File
@@ -0,0 +1,117 @@
using System;
using CalamityMod.Effects;
using CalamityMod.Items.Tools;
using CalamityMod.Particles;
using CalamityMod.Systems.Graphic.PixelationSystem;
using CalamityMod.Utilities.Daybreak;
using CalamityMod.Utilities.Daybreak.Buffers;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Potions.Food
{
public class DivineMeat : ModItem, ILocalizedModType
{
private static Asset<Texture2D> FadedStarRing;
private static Asset<Texture2D> BloomFlare;
public new string LocalizationCategory => "Items.Potions";
public override void Load()
{
if (!Main.dedServ)
{
BloomFlare = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/BloomFlare");
FadedStarRing = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/FadedStarRing");
}
}
public override void SetStaticDefaults()
{
Item.ResearchUnlockCount = 1;
Main.RegisterItemAnimation(Type, new DrawAnimationVertical(int.MaxValue, 3));
ItemID.Sets.IsFood[Type] = true;
ItemID.Sets.FoodParticleColors[Type] = new Color[4] {
new Color(27, 103, 155),
new Color(164, 255, 253),
new Color(250, 219, 127),
new Color(248, 211, 179),
};
}
public override void SetDefaults()
{
Item.width = 30;
Item.height = 40;
Item.useAnimation = Item.useTime = 17;
Item.rare = ItemRarityID.Blue;
Item.value = Item.buyPrice(silver: 50);
Item.maxStack = 1;
Item.UseSound = SoundID.Item2;
Item.useStyle = ItemUseStyleID.EatFood;
Item.buffType = BuffID.WellFed;
Item.buffTime = CalamityUtils.MinutesToFrames(30);
Item.useTurn = true;
Item.consumable = false;
}
public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI)
{
// Spawn some cute sparkles for added effect when dropped in the world.
if (Main.rand.NextBool(45))
{
int sparkleAmt = Main.rand.Next(1, 3);
for (int i = 0; i < sparkleAmt; i++)
{
Vector2 spawnPosition = Item.Center + Main.rand.NextVector2Circular(Item.width, Item.height);
Color drawColorBlue = Color.Lerp(new Color(44, 166, 247), new Color(123, 197, 247), Main.rand.NextFloat());
Color drawColorYellow = Color.Lerp(new Color(249, 197, 42), new Color(249, 221, 142), Main.rand.NextFloat());
Color sparkleColor = Utils.SelectRandom(Main.rand, drawColorBlue, drawColorYellow);
QuickSparkleParticle sparkle = new(spawnPosition, Vector2.Zero, sparkleColor, Main.rand.NextFloat(0.2f, 0.3f), Main.rand.Next(30, 45));
GeneralParticleHandler.QueueParticleForNextFrame(sparkle, true);
}
}
// Additional glowy effects similar to Divine Swine itself.
Main.GetItemDrawFrame(Item.type, out _, out Rectangle itemFrame);
Vector2 origin = itemFrame.Size() * 0.5f;
Vector2 drawPosition = Item.Bottom - Main.screenPosition - new Vector2(0f, origin.Y);
float sineWave = MathF.Sin((float)Main.timeForVisualEffects / 180f) * 0.5f + 0.5f;
Color drawColor = Color.White * MathHelper.Lerp(0.7f, 0f, sineWave);
spriteBatch.End(out var snapshot);
using var pixelationLease = RenderTargetPool.Shared.Rent(Main.graphics.GraphicsDevice, Main.screenWidth / 2, Main.screenHeight / 2, RenderTargetDescriptor.Default);
using (pixelationLease.Scope(clearColor: Color.Transparent))
{
Effect chromaAbberShader = CalamityShaders.ChromaticAbberationShader.Value;
chromaAbberShader.Parameters["abberationStrength"].SetValue(10f);
chromaAbberShader.Parameters["impactPosition"].SetValue(drawPosition);
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, chromaAbberShader, PixelationManager.PixelationMatrix);
float starCircleScale = MathHelper.Lerp(0.3f, 0.15f, sineWave);
float starCircleRotation = (float)(Main.timeForVisualEffects / 720f) + whoAmI;
spriteBatch.Draw(FadedStarRing.Value, drawPosition, null, drawColor with { A = 0 }, starCircleRotation, FadedStarRing.Size() * 0.5f, starCircleScale, 0, 0f);
float bloomFlareScale = MathHelper.Lerp(0.15f, 0.05f, sineWave);
float bloomFlareRotation = (float)(Main.timeForVisualEffects / 540f) + whoAmI;
spriteBatch.Draw(BloomFlare.Value, drawPosition, null, drawColor with { A = 0 }, -bloomFlareRotation, BloomFlare.Size() * 0.5f, bloomFlareScale, 0, 0f);
spriteBatch.End();
}
spriteBatch.Begin(snapshot);
spriteBatch.Draw(pixelationLease.Target, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 2f, 0, 0f);
return true;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 748 B

+100 -4
View File
@@ -1,19 +1,48 @@
using CalamityMod.Items.PermanentBoosters;
using System;
using CalamityMod.Effects;
using CalamityMod.Items.PermanentBoosters;
using CalamityMod.Items.Potions.Food;
using CalamityMod.Particles;
using CalamityMod.Systems.Graphic.PixelationSystem;
using CalamityMod.Utilities.Daybreak;
using CalamityMod.Utilities.Daybreak.Buffers;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.Audio;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;
using CalamityMod.Particles;
using Terraria.DataStructures;
namespace CalamityMod.Items.Tools
{
public class DisgustingMeat : ModItem, ILocalizedModType
{
private static Asset<Texture2D> SmallGreyscaleCircle;
public new string LocalizationCategory => "Items.Tools";
public override void Load()
{
if (!Main.dedServ)
{
SmallGreyscaleCircle = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/SmallGreyscaleCircle");
}
}
public override void SetStaticDefaults()
{
ItemID.Sets.FoodParticleColors[Type] = new Color[6] {
new Color(61, 69, 41),
new Color(91, 100, 48),
new Color(122, 123, 67),
new Color(128, 69, 46),
new Color(183, 116, 80),
new Color(95, 59, 46),
};
}
public override void SetDefaults()
{
Item.DefaultToFood(26, 36, 0, 0);
@@ -23,6 +52,12 @@ namespace CalamityMod.Items.Tools
public override bool AltFunctionUse(Player player) => true;
public override bool CanUseItem(Player player)
{
DisgustingMeatAnimationPlayer modPlayer = player.GetModPlayer<DisgustingMeatAnimationPlayer>();
return !modPlayer.DoingVomitAnimation;
}
public override bool? UseItem(Player player)
{
if (player.ItemTimeIsZero)
@@ -36,6 +71,67 @@ namespace CalamityMod.Items.Tools
return null;
}
public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI)
{
// Stink particles and flies coming off of the item while it's in the world (yuck!!) ((:sick:))
if (Main.rand.NextBool(25))
{
int stinkFumesAmt = Main.rand.Next(1, 3);
for (int i = 0; i < stinkFumesAmt; i++)
{
Vector2 fumesSpawnPosition = Item.Center + Main.rand.NextVector2Circular(Item.width - 8, Item.height - 8);
Color fumesInitialColor = Color.Lerp(Color.OliveDrab, Color.DarkGreen, Main.rand.NextFloat());
Color fumesFadeColor = Color.Lerp(fumesInitialColor, Color.GhostWhite, Main.rand.NextFloat(0.3f, 0.5f));
TimedSmokeParticle fumes = new(fumesSpawnPosition, Vector2.Zero, fumesInitialColor, fumesFadeColor, Main.rand.NextFloat(0.15f, 0.2f), Main.rand.NextFloat(0.4f, 0.6f), Main.rand.Next(45, 60), 0.002f * Main.rand.NextBool().ToDirectionInt(), true);
GeneralParticleHandler.QueueParticleForNextFrame(fumes);
}
}
if (Main.rand.NextBool(150))
{
Vector2 flyGroupSpawnPosition = Item.Top + new Vector2(Main.rand.NextFloat(-16f, 16f), Main.rand.NextFloat(-8f, 0f));
int fliesAmt = Main.rand.Next(1, 4);
for (int i = 0; i < fliesAmt; i++)
{
Vector2 flySpawnPosition = flyGroupSpawnPosition + Main.rand.NextVector2Circular(8f, 8f);
float flyScale = Main.rand.NextFloat(0.8f, 1f);
int flyLifetime = Main.rand.Next(360, 480);
FlyParticle fly = new(flySpawnPosition, flyScale, flyLifetime, Item);
GeneralParticleHandler.QueueParticleForNextFrame(fly);
}
}
// Stink lines.
spriteBatch.End(out var snapshot);
using var pixelationLease = RenderTargetPool.Shared.Rent(Main.graphics.GraphicsDevice, Main.screenWidth / 2, Main.screenHeight / 2, RenderTargetDescriptor.Default);
using (pixelationLease.Scope(clearColor: Color.Transparent))
{
Effect sineWaveDistortion = CalamityShaders.SineWaveDistortionShader.Value;
sineWaveDistortion.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 6f + whoAmI);
sineWaveDistortion.Parameters["waveAmplitude"].SetValue(0.25f);
sineWaveDistortion.Parameters["waveFrequency"].SetValue(20f);
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, sineWaveDistortion, PixelationManager.PixelationMatrix);
Main.GetItemDrawFrame(Item.type, out _, out Rectangle itemFrame);
Vector2 baseItemDrawOrigin = itemFrame.Size() * 0.5f;
Vector2 stinkLineScale = new(0.125f, 0.6f);
int stinkLineAmt = 2;
for (int i = 0; i < stinkLineAmt; i++)
{
float riseAndFall = MathHelper.Lerp(4f, -4f, MathF.Sin((float)Main.timeForVisualEffects / 120f + whoAmI + (i * 14)) * 0.5f + 0.5f);
Vector2 stinkLineDrawPosition = Item.Bottom + new Vector2(Utils.Remap(i, 0, stinkLineAmt - 1, -8f, 8f, true) - 4f, -24f + riseAndFall);
spriteBatch.Draw(SmallGreyscaleCircle.Value, stinkLineDrawPosition - Main.screenPosition - new Vector2(0f, baseItemDrawOrigin.Y), null, Color.DarkOliveGreen * 0.82f, 0f, SmallGreyscaleCircle.Size() * 0.5f, stinkLineScale * 0.7f * Item.scale, 0, 0f);
}
spriteBatch.End();
}
spriteBatch.Begin(snapshot);
spriteBatch.Draw(pixelationLease.Target, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 2f, 0, 0f);
}
}
public class DisgustingMeatAnimationPlayer : ModPlayer
@@ -416,12 +416,13 @@ Cometfruit: {
'''
}
DivineCornucopia: {
DisplayName: Divine Cornucopia
DivineMeat: {
DisplayName: Divine Meat
Tooltip:
'''
{$CommonItemTooltip.MinorStats}
'A bottomless wellspring of the finest produce'
Not consumabale
'A blessed strip of pork that never seems to be entirely consumed...'
'''
}
+94 -22
View File
@@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CalamityMod.Effects;
using CalamityMod.Enums;
using CalamityMod.Graphics.Metaballs;
using CalamityMod.Items.Ammo;
using CalamityMod.Items.Critters;
@@ -44,7 +45,7 @@ namespace CalamityMod.NPCs.NormalNPCs
private static Asset<Texture2D> MagicStarCircle;
private static Asset<Texture2D> FadedStarRing;
private static Asset<Texture2D> DistortionTexture;
private static Asset<Texture2D> DivineCornucopiaTexture;
private static Asset<Texture2D> DivineMeatTexture;
private static SoundStyle IdleSound = new("CalamityMod/Sounds/Custom/DivineSwine/DivineSwineIdle", 4);
private static SoundStyle CoinFailSound = new("CalamityMod/Sounds/Custom/DivineSwine/DivineSwineCoinFail", 3);
@@ -99,7 +100,7 @@ namespace CalamityMod.NPCs.NormalNPCs
MagicStarCircle = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/MagicStarCircle");
FadedStarRing = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/FadedStarRing");
DistortionTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/Smudges");
DivineCornucopiaTexture = ModContent.Request<Texture2D>("CalamityMod/Items/Potions/Food/DivineCornucopia");
DivineMeatTexture = ModContent.Request<Texture2D>("CalamityMod/Items/Potions/Food/DivineMeat");
}
}
@@ -186,6 +187,7 @@ namespace CalamityMod.NPCs.NormalNPCs
}
SoundEffects();
AmbientParticles();
AnimateSprite();
Lighting.AddLight(NPC.Center, DivineYellow.ToVector3() * NPC.scale * 0.825f);
@@ -235,6 +237,9 @@ namespace CalamityMod.NPCs.NormalNPCs
float idealSpeed = MaxSpeed / IdleMovementVector.Length();
NPC.velocity = Vector2.Lerp(NPC.velocity, IdleMovementVector * idealSpeed, MaxAcceleration);
IdleMovementTimer--;
if (NPC.velocity.Y < 2.2f)
NPC.velocity.Y += 0.022f;
}
NPC.spriteDirection = (NPC.velocity.X > 0).ToDirectionInt();
@@ -269,12 +274,30 @@ namespace CalamityMod.NPCs.NormalNPCs
{
Vector2 lightSpawnPosition = NPC.Center + Main.rand.NextVector2Unit() * lightSpawnDistance * Main.rand.NextFloat(0.7f, 1f);
Vector2 lightVelocity = (NPC.Center - lightSpawnPosition).SafeNormalize(Vector2.UnitY) * Main.rand.NextFloat(3f, 4f);
float lightScale = Main.rand.NextFloat(0.6f, 0.8f) * MathHelper.Clamp(Timer / 180f, 0f, 1f);
float lightScale = Utils.Remap(Timer, 0f, 180f, 0.3f, 0.9f, true);
Color lightColor = Color.Lerp(DivineBlue, DivineYellow, Main.rand.NextFloat());
SquishyLightParticle meatLight = new(lightSpawnPosition, lightVelocity, lightScale, lightColor, Main.rand.Next(30, 45));
GeneralParticleHandler.SpawnParticle(meatLight, true, Enums.GeneralDrawLayer.BeforeNPCs);
}
int sparkleSpawnRate = (int)Utils.Remap(Timer, 0f, 180f, 45, 5, true);
if (Main.rand.NextBool(sparkleSpawnRate))
{
int sparkleAmt = Main.rand.Next(1, 3);
for (int i = 0; i < sparkleAmt; i++)
{
Vector2 spawnPosition = NPC.Center + Main.rand.NextVector2Unit() * lightSpawnDistance * Main.rand.NextFloat(0.8f, 1.2f);
Color drawColorBlue = Color.Lerp(new Color(44, 166, 247), new Color(123, 197, 247), Main.rand.NextFloat());
Color drawColorYellow = Color.Lerp(new Color(249, 197, 42), new Color(249, 221, 142), Main.rand.NextFloat());
Color sparkleColor = Utils.SelectRandom(Main.rand, drawColorBlue, drawColorYellow);
float sparkleScale = Utils.Remap(Timer, 0f, 180f, 0.2f, 0.8f, true);
QuickSparkleParticle sparkle = new(spawnPosition, Vector2.Zero, sparkleColor, sparkleScale * Main.rand.NextFloat(0.5f, 1f), Main.rand.Next(20, 30));
GeneralParticleHandler.QueueParticleForNextFrame(sparkle, true);
}
}
if (Timer % 15f == 0f)
{
CustomPulse meatLightRing = new(NPC.Center, Vector2.Zero, DivineBlue, "CalamityMod/Particles/BloomRing", Vector2.One, 0f, glowRingScale, 0f, 25);
@@ -282,13 +305,13 @@ namespace CalamityMod.NPCs.NormalNPCs
}
}
// Cornucopia granted
// Divine meat granted
if (Timer == 210f)
{
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int cornucopia = Item.NewItem(NPC.GetSource_GiftOrReward(), NPC.Center, ModContent.ItemType<DivineCornucopia>());
Main.item[cornucopia].velocity = Vector2.UnitY * -3f;
int meat = Item.NewItem(NPC.GetSource_GiftOrReward(), NPC.Center, ModContent.ItemType<DivineMeat>());
Main.item[meat].velocity = Vector2.UnitY * -3f;
}
CustomPulse meatLightRing = new(NPC.Center, Vector2.Zero, DivineBlue, "CalamityMod/Particles/BloomRing", Vector2.One, 0f, 0f, 3f, 75);
@@ -300,9 +323,15 @@ namespace CalamityMod.NPCs.NormalNPCs
for (int i = 0; i < 25; i++)
{
Color drawColorBlue = Color.Lerp(new Color(44, 166, 247), new Color(123, 197, 247), Main.rand.NextFloat());
Color drawColorYellow = Color.Lerp(new Color(249, 197, 42), new Color(249, 221, 142), Main.rand.NextFloat());
Color sparkleColor = Utils.SelectRandom(Main.rand, drawColorBlue, drawColorYellow);
QuickSparkleParticle meatSparkle = new(NPC.Center, Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(13f, 15f), sparkleColor, Main.rand.NextFloat(0.6f, 0.8f), Main.rand.Next(45, 60));
Color lightColor = Color.Lerp(DivineBlue, DivineYellow, Main.rand.NextFloat());
SquishyLightParticle meatLight = new(NPC.Center, Vector2.One.RotatedByRandom(MathHelper.TwoPi) * Main.rand.NextFloat(3f, 5f), Main.rand.NextFloat(1.4f, 1.8f), lightColor, Main.rand.Next(45, 60));
GeneralParticleHandler.SpawnParticle(meatLight, true, Enums.GeneralDrawLayer.AfterNPCs);
GeneralParticleHandler.SpawnParticle(Main.rand.NextBool() ? meatSparkle : meatLight, true, Enums.GeneralDrawLayer.AfterNPCs);
}
// Despawn immediately afterwards.
@@ -330,8 +359,10 @@ namespace CalamityMod.NPCs.NormalNPCs
for (int i = 0; i < 25; i++)
{
QuickSparkleParticle meatSparkle = new(NPC.Center, Main.rand.NextVector2Circular(15f, 15f), Color.White, Main.rand.NextFloat(0.6f, 0.8f), Main.rand.Next(45, 60));
SquishyLightParticle meatLight = new(NPC.Center, Main.rand.NextVector2Circular(5f, 5f), Main.rand.NextFloat(0.6f, 0.8f), Color.White, Main.rand.Next(45, 60));
GeneralParticleHandler.SpawnParticle(meatLight, true, Enums.GeneralDrawLayer.AfterNPCs);
GeneralParticleHandler.SpawnParticle(Main.rand.NextBool() ? meatSparkle : meatLight, true, Enums.GeneralDrawLayer.AfterNPCs);
}
SoundEngine.PlaySound(SoundID.Item29 with { Volume = 0.1f }, NPC.Center);
@@ -370,6 +401,58 @@ namespace CalamityMod.NPCs.NormalNPCs
NPC.velocity = Vector2.Lerp(NPC.velocity, idealVelocity, turnAwayStrength);
}
public void AmbientParticles()
{
if (AIState != (int)BehaviorState.IdleAndFly)
return;
// Feathers, both falling and non falling ones.
if (Main.rand.NextBool(70))
{
int featherAmt = Main.rand.Next(1, 3);
for (int i = 0; i < featherAmt; i++)
{
Vector2 spawnPosition = NPC.Center + Main.rand.NextVector2Circular(NPC.width, NPC.height);
Vector2 velocity = Vector2.UnitY * Main.rand.NextFloat(0.25f, 0.75f);
Color featherColor = Color.Lerp(Color.Lerp(new Color(27, 103, 155), new Color(83, 184, 255), Main.rand.NextFloat()), new Color(221, 253, 255), Main.rand.NextFloat(0.4f));
float scale = Main.rand.NextFloat(0.8f, 1f);
FeatherParticle feather = new(spawnPosition, velocity, featherColor, scale, Main.rand.Next(360, 480), null, 0.8f, true, false, true);
GeneralDrawLayer featherLayer = Utils.SelectRandom(Main.rand, GeneralDrawLayer.BeforeNPCs, GeneralDrawLayer.AfterNPCs);
GeneralParticleHandler.SpawnParticle(feather, manualDrawLayerOverride: featherLayer);
}
}
// Small sparkles.
if (Main.rand.NextBool(45))
{
int sparkleAmt = Main.rand.Next(1, 3);
for (int i = 0; i < sparkleAmt; i++)
{
Vector2 spawnPosition = NPC.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(80f, 160f);
Color drawColorBlue = Color.Lerp(new Color(44, 166, 247), new Color(123, 197, 247), Main.rand.NextFloat());
Color drawColorYellow = Color.Lerp(new Color(249, 197, 42), new Color(249, 221, 142), Main.rand.NextFloat());
Color sparkleColor = Utils.SelectRandom(Main.rand, drawColorBlue, drawColorYellow);
QuickSparkleParticle sparkle = new(spawnPosition, Vector2.Zero, sparkleColor, Main.rand.NextFloat(0.2f, 0.3f), Main.rand.Next(30, 45));
GeneralParticleHandler.QueueParticleForNextFrame(sparkle, true);
}
}
}
public void AnimateSprite()
{
if (Timer % 5 == 0f)
{
FrameY++;
if (FrameY >= Main.npcFrameCount[Type] - 1)
FrameY = 0;
if (FrameY == 5)
NPC.velocity.Y -= (NPC.velocity.X != 0f) ? 2.2f : 0.46f;
}
}
public void SoundEffects()
{
if (NPC.soundDelay == 0 && Main.rand.NextBool(200) && (AIState != (int)BehaviorState.OfferingAccepted || AIState != (int)BehaviorState.OfferingFailed))
@@ -389,19 +472,6 @@ namespace CalamityMod.NPCs.NormalNPCs
Main.musicFade[Main.curMusic] = musicVolumeInterpolant;
}
public void AnimateSprite()
{
if (Timer % 5 == 0f)
{
FrameY++;
if (FrameY >= Main.npcFrameCount[Type] - 1)
FrameY = 0;
if (FrameY == 5)
NPC.velocity.Y -= (NPC.velocity.X != 0f) ? 2.2f : 0.46f;
}
}
private bool SoundCallbackMethod(ActiveSound soundInstance)
{
soundInstance.Position = NPC.Center;
@@ -516,6 +586,8 @@ namespace CalamityMod.NPCs.NormalNPCs
}
}
public override bool? DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) => false;
public override void FindFrame(int frameHeight)
{
if (NPC.IsABestiaryIconDummy)
@@ -650,7 +722,7 @@ namespace CalamityMod.NPCs.NormalNPCs
{
float rotation = (float)(Main.timeForVisualEffects / MathHelper.Pi * 0.08f) + NPC.whoAmI;
Vector2 backglowDrawPosition = drawPosition + Vector2.UnitX.RotatedBy(i * MathHelper.TwoPi / backShadowCount + rotation) * backShadowDistance;
spriteBatch.Draw(DivineCornucopiaTexture.Value, backglowDrawPosition, DivineCornucopiaTexture.Value.Frame(1, 3), NPC.GetAlpha(Color.White) * backShadowInterpolant, NPC.rotation, DivineCornucopiaTexture.Value.Frame(1, 3).Size() * 0.5f, 1f, 0, 0f);
spriteBatch.Draw(DivineMeatTexture.Value, backglowDrawPosition, DivineMeatTexture.Value.Frame(1, 3), NPC.GetAlpha(Color.White) * backShadowInterpolant, NPC.rotation, DivineMeatTexture.Value.Frame(1, 3).Size() * 0.5f, 1f, 0, 0f);
}
spriteBatch.SetBlendState(BlendState.AlphaBlend);
+160
View File
@@ -0,0 +1,160 @@
using System;
using System.Threading;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class FeatherParticle : Particle
{
public float RotationSpeed;
public float Opacity;
public float SwayAngleStrength;
public bool AffectedByWind;
public bool NoGravity;
public bool ShouldCollideWithTiles;
public bool DieWithTileCollision;
private int DeathTimer;
public static float WaveAngle => MathHelper.ToRadians(25f);
public float WaveFrameState { get; private set; }
public int SwayInterval { get; private set; }
public bool CurrentlyCollidingWithTiles { get; private set; }
public FeatherParticle(Vector2 position, Vector2 velocity, Color color, float scale, int lifetime, float? rotationSpeed = null, float swayAngleStrength = 1f, bool affectedByWind = false, bool noGravity = false, bool shouldCollideWithTiles = false, bool dieWithTileCollision = false)
{
Position = position;
Velocity = velocity;
Color = color;
Scale = scale;
Lifetime = lifetime;
RotationSpeed = rotationSpeed ?? Main.rand.NextFloat(120f, 150f) * Main.rand.NextBool().ToDirectionInt();
SwayAngleStrength = swayAngleStrength;
AffectedByWind = affectedByWind;
NoGravity = noGravity;
ShouldCollideWithTiles = shouldCollideWithTiles;
DieWithTileCollision = dieWithTileCollision;
Variant = Main.rand.Next(3);
Opacity = 0f;
SwayInterval = Main.rand.Next(75, 150);
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
}
public override string Texture => "CalamityMod/Particles/FeatherParticle";
public override bool SetLifetime => false;
public override bool UseCustomDraw => true;
public override int FrameVariants => 3;
public override void Update()
{
if (!CurrentlyCollidingWithTiles)
Rotation += (MathHelper.Pi / RotationSpeed) + (Velocity.X * 0.01f);
// Original math from AstralGodRay.cs.
int waveSign = (WaveFrameState > 0f).ToDirectionInt();
if (Math.Abs(WaveFrameState) < 1f)
{
int dirToUse = WaveFrameState == 0 ? (Main.rand.NextBool() ? -1 : 1) : waveSign;
waveSign = -dirToUse;
WaveFrameState = dirToUse * SwayInterval * 0.5f;
}
// Switch directions whenever necessary.
else if (Math.Abs(WaveFrameState) > SwayInterval)
WaveFrameState = -waveSign;
else
WaveFrameState += waveSign;
// Rotate velocity towards the wave angle to appear as if its swaying side to side.
float swayAngle = WaveAngle / (SwayInterval * 0.5f);
Velocity = Velocity.RotatedBy(waveSign * swayAngle * SwayAngleStrength);
Velocity.X *= 0.98f;
if (Velocity.Y < 0.6f && !NoGravity)
Velocity.Y += 0.005f;
else
Velocity.Y *= 0.98f;
// Move with wind speed.
if (AffectedByWind)
Velocity.X += Main.windSpeedCurrent / 3f;
// Tile collision.
if (ShouldCollideWithTiles)
{
CurrentlyCollidingWithTiles = false;
Vector2 hitboxDimensions = new(12f, 12f);
if (Collision.SolidCollision(Position, (int)hitboxDimensions.X, (int)hitboxDimensions.Y))
{
Velocity = Collision.TileCollision(Position, Velocity, (int)hitboxDimensions.X, (int)hitboxDimensions.Y);
CurrentlyCollidingWithTiles = true;
}
if (Collision.WetCollision(Position, (int)hitboxDimensions.X, (int)hitboxDimensions.Y))
{
Velocity.Y *= 0.8f;
CurrentlyCollidingWithTiles = true;
}
}
if (DieWithTileCollision && ShouldCollideWithTiles)
{
if (CurrentlyCollidingWithTiles)
{
Opacity = MathHelper.Lerp(1f, 0f, (float)(DeathTimer / 45));
if (DeathTimer >= 45)
{
Kill();
return;
}
DeathTimer++;
}
else
{
Opacity = MathHelper.Clamp(Opacity + 0.075f, 0f, 1f);
}
}
else
{
int fadeInTime = 45 - (int)(Lifetime * 0.2f);
if (fadeInTime < 20)
fadeInTime = 20;
int fadeOutTime = (int)(Lifetime * 0.8f);
Opacity = Utils.GetLerpValue(0, fadeInTime, Time, true) * Utils.GetLerpValue(Lifetime, fadeOutTime, Time);
if (Time >= Lifetime)
{
Kill();
return;
}
}
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D texture = GeneralParticleHandler.GetTexture(Type);
Color lightColor = Color.MultiplyRGB(Lighting.GetColor((Position / 16).ToPoint()));
Rectangle frame = texture.Frame(1, FrameVariants, 0, Variant);
spriteBatch.Draw(texture, Position - Main.screenPosition, frame, lightColor * Opacity, Rotation, frame.Size() * 0.5f, Scale, SpriteEffects.None, 0f);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 329 B

+94
View File
@@ -0,0 +1,94 @@
using System;
using CalamityMod.Systems.Graphic.TempParticleSystem;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
namespace CalamityMod.Particles
{
public class FlyParticle : Particle
{
public float Opacity;
private bool WasSpawnedWithAnchor;
public Entity AnchorEntity { get; private set; }
public Vector2 StoredPosition { get; private set; }
public float HeightToNeverGoBelow { get; private set; }
public FlyParticle(Vector2 position, float scale, int lifetime, Entity anchorEntity = null)
{
Position = position;
Scale = scale;
Lifetime = lifetime;
AnchorEntity = anchorEntity;
if (anchorEntity == null)
{
StoredPosition = position;
HeightToNeverGoBelow = position.Y + 8f;
WasSpawnedWithAnchor = false;
}
else
{
WasSpawnedWithAnchor = true;
}
Variant = Main.rand.Next(2);
Color = Color.White;
AffectedByLight = true;
}
public override string Texture => "Terraria/Images/Extra_262";
public override bool SetLifetime => true;
public override bool UseCustomDraw => true;
public override int FrameVariants => 2;
public override void Update()
{
if (WasSpawnedWithAnchor)
{
StoredPosition = AnchorEntity.Top;
HeightToNeverGoBelow = AnchorEntity.Top.Y + 8f;
if (!AnchorEntity.active || AnchorEntity == null)
{
Kill();
return;
}
}
Velocity += new Vector2(MathF.Sign(StoredPosition.X - Position.X) * 0.02f, MathF.Sign(StoredPosition.Y - Position.Y) * 0.02f);
if (Time % 30 == 0 && Main.rand.NextBool(2))
{
Velocity = Main.rand.NextVector2Circular(1f, 1f);
if (Main.rand.NextBool(2))
Velocity /= 2;
}
if (Position.Y > HeightToNeverGoBelow)
{
Position.Y = HeightToNeverGoBelow;
if (Velocity.Y > 0f)
Velocity *= -1f;
}
Variant = Time % 6 / 3;
int fadeInTime = (int)(Lifetime * 0.13f);
int fadeOutTime = (int)(Lifetime * 0.93f);
Opacity = Utils.GetLerpValue(0f, fadeInTime, Time, true) * Utils.GetLerpValue(Lifetime, Lifetime - fadeOutTime, Time, true);
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Color lightColor = Color.MultiplyRGB(Lighting.GetColor((Position / 16).ToPoint()));
Rectangle frame = GeneralParticleHandler.GetTexture(Type).Frame(1, FrameVariants, 0, Variant);
SpriteEffects effects = (Velocity.X > 0f) ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
Main.spriteBatch.Draw(GeneralParticleHandler.GetTexture(Type), Position - Main.screenPosition, frame, lightColor * Opacity, Rotation, frame.Size() * 0.5f, Scale, effects, 0f);
}
}
}
+59
View File
@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
using Terraria;
using Terraria.Graphics.Shaders;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class QuickSparkleParticle : Particle
{
public float StoredScale;
public float LightStrength;
public bool EmitLight;
public Vector2 StretchFactor;
public QuickSparkleParticle(Vector2 position, Vector2 velocity, Color color, float scale, int lifetime, Vector2? stretchFactor = null,bool emitLight = false, float lightStrength = 1.45f)
{
Position = position;
Velocity = velocity;
Color = color;
StoredScale = scale;
Lifetime = lifetime;
StretchFactor = stretchFactor ?? new(0.75f, 1.75f);
EmitLight = emitLight;
LightStrength = lightStrength;
}
public override bool SetLifetime => true;
public override bool UseAdditiveBlend => true;
public override bool UseCustomDraw => true;
public override string Texture => "CalamityMod/ExtraTextures/ShineFlare";
public override void Update()
{
Velocity *= 0.92f;
Scale = MathHelper.Lerp(0f, StoredScale, MathF.Sin(LifetimeCompletion * MathHelper.Pi));
if (EmitLight)
Lighting.AddLight(Position, Color.ToVector3() * Scale * LightStrength);
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(GeneralParticleHandler.GetTexture(Type), Position - Main.screenPosition, null, Color.White, Rotation, GeneralParticleHandler.GetTexture(Type).Size() * 0.5f, Scale * StretchFactor * 0.1f, 0, 0f);
spriteBatch.Draw(GeneralParticleHandler.GetTexture(Type), Position - Main.screenPosition, null, Color, Rotation, GeneralParticleHandler.GetTexture(Type).Size() * 0.5f, Scale * StretchFactor * 0.2f, 0, 0f);
}
}
}
+6 -1
View File
@@ -15,8 +15,9 @@ namespace CalamityMod.Particles
private Color ColorStart;
private Color ColorFade;
private float Spin;
private bool FadeIn;
public TimedSmokeParticle(Vector2 position, Vector2 velocity, Color colorStart, Color colorFade, float scale, float opacity, int timeleft, float rotationSpeed = 0f)
public TimedSmokeParticle(Vector2 position, Vector2 velocity, Color colorStart, Color colorFade, float scale, float opacity, int timeleft, float rotationSpeed = 0f, bool fadeIn = false)
{
Position = position;
Velocity = velocity;
@@ -27,6 +28,7 @@ namespace CalamityMod.Particles
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
Spin = rotationSpeed;
Lifetime = timeleft;
FadeIn = fadeIn;
Variant = Main.rand.Next(3);
}
@@ -48,6 +50,9 @@ namespace CalamityMod.Particles
Velocity -= Vector2.UnitY * 0.08f;
float opacityMult = 1 - (float)Math.Pow(LifetimeCompletion, 2);
if (FadeIn)
opacityMult = 1f * MathF.Sin(LifetimeCompletion * MathHelper.Pi);
Color = Color.Lerp(ColorStart, ColorFade, opacityMult) * (Opacity * opacityMult);
}
}