Made certain particles able to be affected by light + used that new setting in Aerialite stuff

This commit is contained in:
Xhack committed 2024-06-01 06:35:33 -04:00
1 parent 7afb072358
commit dfd067b87d
9 files changed
+73 -35

No files matched your search

+10
View File
@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CalamityMod.Items.BaseItems;
using CalamityMod.Items.Materials;
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Projectiles.Magic;
using CalamityMod.Projectiles.Ranged;
@@ -85,5 +86,14 @@ namespace CalamityMod.Items.Weapons.Magic
if (RetunedToMelody) RetunedToMelody = false;
else RetunedToMelody = true;
}
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<AerialiteBar>(8).
AddIngredient(ItemID.SunplateBlock, 3).
AddTile(TileID.SkyMill).
Register();
}
}
}
+10
View File
@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CalamityMod.Items.BaseItems;
using CalamityMod.Items.Materials;
using CalamityMod.Projectiles.Magic;
using CalamityMod.Projectiles.Ranged;
using Microsoft.Xna.Framework;
@@ -41,5 +42,14 @@ namespace CalamityMod.Items.Weapons.Ranged
Item.shoot = ModContent.ProjectileType<GildedGathererHarpoon>();
Item.scale = 1f;
}
public override void AddRecipes()
{
CreateRecipe().
AddIngredient<AerialiteBar>(8).
AddIngredient(ItemID.SunplateBlock, 3).
AddTile(TileID.SkyMill).
Register();
}
}
}
+10 -3
View File
@@ -21,10 +21,11 @@ namespace CalamityMod.Particles
private float Spin;
private bool StrongVisual;
private bool Glowing;
private bool AffectedByLight = false;
private float HueShift;
static int FrameAmount = 6;
public HeavySmokeParticle(Vector2 position, Vector2 velocity, Color color, int lifetime, float scale, float opacity, float rotationSpeed = 0f, bool glowing = false, float hueshift = 0f, bool required = false)
public HeavySmokeParticle(Vector2 position, Vector2 velocity, Color color, int lifetime, float scale, float opacity, float rotationSpeed = 0f, bool glowing = false, float hueshift = 0f, bool required = false, bool affectedByLight = false)
{
Position = position;
Velocity = velocity;
@@ -37,7 +38,7 @@ namespace CalamityMod.Particles
StrongVisual = required;
Glowing = glowing;
HueShift = hueshift;
AffectedByLight = affectedByLight;
}
public override void Update()
@@ -62,8 +63,14 @@ namespace CalamityMod.Particles
int animationFrame = (int)Math.Floor(Time / ((float)(Lifetime / (float)FrameAmount)));
Rectangle frame = new Rectangle(80 * Variant, 80 * animationFrame, 80, 80);
Color col = Color * Opacity;
spriteBatch.Draw(tex, Position - Main.screenPosition, frame, Color * Opacity, Rotation, frame.Size() / 2f, Scale, SpriteEffects.None, 0);
if (AffectedByLight)
{
col = Lighting.GetColor((Position / 16).ToPoint()).MultiplyRGBA(col);
}
spriteBatch.Draw(tex, Position - Main.screenPosition, frame, col, Rotation, frame.Size() / 2f, Scale, SpriteEffects.None, 0);
}
}
+4 -1
View File
@@ -12,8 +12,9 @@ namespace CalamityMod.Particles
private Color ColorFire;
private Color ColorFade;
private float Spin;
private bool AffectedByLight = false;
public SmallSmokeParticle(Vector2 position, Vector2 velocity, Color colorFire, Color colorFade, float scale, float opacity, float rotationSpeed = 0f)
public SmallSmokeParticle(Vector2 position, Vector2 velocity, Color colorFire, Color colorFade, float scale, float opacity, float rotationSpeed = 0f, bool affectedByLight = false)
{
Position = position;
Velocity = velocity;
@@ -23,6 +24,7 @@ namespace CalamityMod.Particles
Opacity = opacity;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
Spin = rotationSpeed;
AffectedByLight = affectedByLight;
}
public override void Update()
@@ -46,6 +48,7 @@ namespace CalamityMod.Particles
Color = Color.Lerp(ColorFire, ColorFade, MathHelper.Clamp((float)((255 - Opacity) - 100) / 80, 0f, 1f)) * (Opacity / 255f);
if (AffectedByLight) Color = Lighting.GetColor((Position / 16).ToPoint()).MultiplyRGBA(Color);
}
}
}
+12 -3
View File
@@ -10,6 +10,7 @@ namespace CalamityMod.Particles
{
public Color InitialColor;
public bool AffectedByGravity;
public bool AffectedByLight = false;
public bool FadeIn = false;
public float FadeInScale = 0f;
public override bool SetLifetime => true;
@@ -18,11 +19,12 @@ namespace CalamityMod.Particles
public override string Texture => "CalamityMod/Projectiles/StarProj";
public SparkParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color color, bool fadeIn = false)
public SparkParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color color, bool fadeIn = false, bool affectedByLight = false)
{
Position = relativePosition;
Velocity = velocity;
AffectedByGravity = affectedByGravity;
AffectedByLight = affectedByLight;
Scale = scale;
FadeInScale = scale;
Lifetime = lifetime;
@@ -65,8 +67,15 @@ namespace CalamityMod.Particles
Vector2 scale = new Vector2(0.5f, 1.6f) * Scale;
Texture2D texture = ModContent.Request<Texture2D>(Texture).Value;
spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale, 0, 0f);
spriteBatch.Draw(texture, Position - Main.screenPosition, null, Color, Rotation, texture.Size() * 0.5f, scale * new Vector2(0.45f, 1f), 0, 0f);
Color col = Color;
if (AffectedByLight)
{
col = Lighting.GetColor((Position / 16).ToPoint()).MultiplyRGB(Color);
}
spriteBatch.Draw(texture, Position - Main.screenPosition, null, col, Rotation, texture.Size() * 0.5f, scale, 0, 0f);
spriteBatch.Draw(texture, Position - Main.screenPosition, null, col, Rotation, texture.Size() * 0.5f, scale * new Vector2(0.45f, 1f), 0, 0f);
}
}
}
+4 -6
View File
@@ -22,7 +22,7 @@ using Terraria.Utilities.Terraria.Utilities;
namespace CalamityMod.Projectiles.Magic
{
public class SongOfParadiseDragon : ModProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer
public class SongOfParadiseDragon : ModProjectile, ILocalizedModType
{
public static SoundStyle CollideSound = new SoundStyle("CalamityMod/Sounds/Item/SongWyvernCollide");
public override string Texture => "CalamityMod/Projectiles/Magic/Jimmy";
@@ -122,7 +122,7 @@ namespace CalamityMod.Projectiles.Magic
{
}
void IPixelatedPrimitiveRenderer.RenderPixelatedPrimitives(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
public override bool PreDraw(ref Color lightColor)
{
Asset<Texture2D> tex = ModContent.Request<Texture2D>(Texture);
if (!Main.getGoodWorld)
@@ -151,10 +151,8 @@ namespace CalamityMod.Projectiles.Magic
}
GameShaders.Misc["CalamityMod:PrimitiveTexture"].Shader.Parameters["uPrimitiveSize"].SetValue(tex.Width());
GameShaders.Misc["CalamityMod:PrimitiveTexture"].Shader.Parameters["flipVertically"].SetValue(true);
PrimitiveRenderer.RenderTrail(positions, new PrimitiveSettings(W => { return Width; }, C => { return Lighting.GetColor((positions[Math.Clamp((int)((float)C * (float)positions.Count), 0, positions.Count)] / 16).ToPoint()); }, O => { return Vector2.Zero; }, false, true, GameShaders.Misc["CalamityMod:PrimitiveTexture"]), 75);
}
public override bool PreDraw(ref Color lightColor)
{
PrimitiveRenderer.RenderTrail(positions, new PrimitiveSettings(W => { return Width; }, C => { return Lighting.GetColor((positions[Math.Clamp((int)((float)C * (float)positions.Count), 0, positions.Count)] / 16).ToPoint()); }, O => { return Vector2.Zero; }, true, false, GameShaders.Misc["CalamityMod:PrimitiveTexture"]), 75);
return false;
}
}
+3 -3
View File
@@ -74,7 +74,7 @@ namespace CalamityMod.Projectiles.Melee
}
if ((int)AnimationProgress > (int)(Owner.itemAnimationMax / 1.5f))
{
GeneralParticleHandler.SpawnParticle(new HeavySmokeParticle(Owner.Center + (new Vector2(Main.rand.Next(30, 100), 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45))), new Vector2(0, 10 * -Projectile.ai[1] * Owner.direction).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)), Color.LightSkyBlue, 40, 1f, 0.4f, MathHelper.ToRadians(Main.rand.NextFloat(-10f, 10f)), true));
GeneralParticleHandler.SpawnParticle(new HeavySmokeParticle(Owner.Center + (new Vector2(Main.rand.Next(30, 100), 0).RotatedBy(FinalRotation + MathHelper.ToRadians(-45))), new Vector2(0, 10 * -Projectile.ai[1] * Owner.direction).RotatedBy(FinalRotation + MathHelper.ToRadians(-45)), Color.LightSkyBlue, 40, 1f, 0.4f, MathHelper.ToRadians(Main.rand.NextFloat(-10f, 10f)), true, affectedByLight: true));
}
float time = (AnimationProgress) - (Owner.itemAnimationMax / 3);
@@ -108,8 +108,8 @@ namespace CalamityMod.Projectiles.Melee
float bb = Main.rand.NextFloat(-50, 50);
GeneralParticleHandler.SpawnParticle(new HeavySmokeParticle(Owner.Center + new Vector2(105 * Projectile.scale, 0).RotatedBy(rot), new Vector2(5, 0).RotatedBy(rot + MathHelper.ToRadians(Main.rand.NextFloat(-20, 20))), Color.LightSkyBlue, 10, 2f, 0.3f, MathHelper.ToRadians(Main.rand.NextFloat(-10f, 10f)), true));
GeneralParticleHandler.SpawnParticle(new SparkParticle(Owner.Center + new Vector2(0, bb).RotatedBy(rot) + new Vector2(45 * Projectile.scale, 0).RotatedBy(rot), new Vector2(5, 0).RotatedBy(rot), false, 10, 1 - (Math.Abs(bb) / 50), Color.LightSkyBlue, true));
GeneralParticleHandler.SpawnParticle(new HeavySmokeParticle(Owner.Center + new Vector2(105 * Projectile.scale, 0).RotatedBy(rot), new Vector2(5, 0).RotatedBy(rot + MathHelper.ToRadians(Main.rand.NextFloat(-20, 20))), Color.LightSkyBlue, 10, 2f, 0.3f, MathHelper.ToRadians(Main.rand.NextFloat(-10f, 10f)), true, affectedByLight: true));
GeneralParticleHandler.SpawnParticle(new SparkParticle(Owner.Center + new Vector2(0, bb).RotatedBy(rot) + new Vector2(45 * Projectile.scale, 0).RotatedBy(rot), new Vector2(5, 0).RotatedBy(rot), false, 10, 1 - (Math.Abs(bb) / 50), Color.LightSkyBlue, true, affectedByLight: true));
}
else
{
+19 -18
View File
@@ -12,6 +12,7 @@ using CalamityMod.Projectiles.Typeless;
using CalamityMod.Sounds;
using CalamityMod.World;
using FullSerializer.Internal;
using Microsoft.CodeAnalysis.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ReLogic.Content;
@@ -26,7 +27,7 @@ namespace CalamityMod.Projectiles.Ranged
{
public class GildedGathererHarpoon : BaseCustomUseStyleProjectile, ILocalizedModType, IPixelatedPrimitiveRenderer
{
List<Vector2> positions = new List<Vector2>();
List<Vector2> LinePositions = new List<Vector2>();
public override Vector2 HitboxSize => new Vector2(16, 16);
public NPC npcToTarget = null;
public Vector2 latchOffset;
@@ -101,7 +102,7 @@ namespace CalamityMod.Projectiles.Ranged
{
for (int i = 0; i < 10; i++)
{
GeneralParticleHandler.SpawnParticle(new SparkParticle(Projectile.Center + (oldVelocity * 2), new Vector2(Main.rand.NextFloat(10), 0).RotatedBy(Projectile.rotation + MathHelper.ToRadians(Main.rand.NextFloat(-20, 20)) + MathHelper.ToRadians(180)), false, 12, Main.rand.NextFloat(0.5f, 1f), Main.rand.NextBool(4) ? Color.White : Color.LightSteelBlue, true));
GeneralParticleHandler.SpawnParticle(new SparkParticle(Projectile.Center + (oldVelocity * 2), new Vector2(Main.rand.NextFloat(10), 0).RotatedBy(Projectile.rotation + MathHelper.ToRadians(Main.rand.NextFloat(-20, 20)) + MathHelper.ToRadians(180)), false, 12, Main.rand.NextFloat(0.5f, 1f), Main.rand.NextBool(4) ? Color.White : Color.LightSteelBlue, true, true));
}
Player player = Main.player[Projectile.owner];
@@ -171,16 +172,16 @@ namespace CalamityMod.Projectiles.Ranged
for (int i = 0; i < 6; i++)
{
GeneralParticleHandler.SpawnParticle(
new HeavySmokeParticle(player.Center, player.DirectionTo(mousePos).RotatedBy(Main.rand.NextFloat(-0.1f, 0.1f)) * Main.rand.NextFloat(7, 15), Color.LightSkyBlue, 50, Main.rand.NextFloat(0.4f, 1f), 1f, Main.rand.NextFloat(-0.01f, 0.01f))
new HeavySmokeParticle(player.Center, player.DirectionTo(mousePos).RotatedBy(Main.rand.NextFloat(-0.1f, 0.1f)) * Main.rand.NextFloat(7, 15), Color.LightSkyBlue, 50, Main.rand.NextFloat(0.4f, 1f), 1f, Main.rand.NextFloat(-0.01f, 0.01f), affectedByLight: true)
);
}
for (int i = 0; i < 3; i++)
{
GeneralParticleHandler.SpawnParticle(
new SparkParticle(player.Center, player.DirectionTo(mousePos).RotatedBy(Main.rand.NextFloat(-0.1f, 0.1f) + MathHelper.ToRadians(90f)) * Main.rand.NextFloat(10, 20), false, 10, 1f, Color.LightSkyBlue)
new SparkParticle(player.Center, player.DirectionTo(mousePos).RotatedBy(Main.rand.NextFloat(-0.1f, 0.1f) + MathHelper.ToRadians(90f)) * Main.rand.NextFloat(10, 20), false, 10, 1f, Color.LightSkyBlue, affectedByLight: true)
);
GeneralParticleHandler.SpawnParticle(
new SparkParticle(player.Center, player.DirectionTo(mousePos).RotatedBy(Main.rand.NextFloat(-0.1f, 0.1f) + MathHelper.ToRadians(-90f)) * Main.rand.NextFloat(10, 20), false, 10, 1f, Color.LightSkyBlue)
new SparkParticle(player.Center, player.DirectionTo(mousePos).RotatedBy(Main.rand.NextFloat(-0.1f, 0.1f) + MathHelper.ToRadians(-90f)) * Main.rand.NextFloat(10, 20), false, 10, 1f, Color.LightSkyBlue, affectedByLight: true)
);
}
}
@@ -192,11 +193,11 @@ namespace CalamityMod.Projectiles.Ranged
for (int i = 0; i < 10; i++)
{
GeneralParticleHandler.SpawnParticle(new SparkParticle(vec, new Vector2(Main.rand.NextFloat(15), 0).RotatedBy(Projectile.rotation + MathHelper.ToRadians(Main.rand.NextFloat(-20, 20))), false, 12, Main.rand.NextFloat(0.5f, 1f), Main.rand.NextBool(4) ? Color.White : Color.LightSteelBlue, true));
GeneralParticleHandler.SpawnParticle(new SparkParticle(vec, new Vector2(Main.rand.NextFloat(15), 0).RotatedBy(Projectile.rotation + MathHelper.ToRadians(Main.rand.NextFloat(-20, 20))), false, 12, Main.rand.NextFloat(0.5f, 1f), Main.rand.NextBool(4) ? Color.White : Color.LightSteelBlue, true, true));
}
for (int i = 0; i < 10; i++)
{
GeneralParticleHandler.SpawnParticle(new SmallSmokeParticle(vec, new Vector2(Main.rand.NextFloat(5, 20), 0).RotatedBy(Projectile.rotation + MathHelper.ToRadians(Main.rand.NextFloat(-5, 5))), Color.CornflowerBlue, new Color(100, 100, 170), Main.rand.NextFloat(0.5f, 1f), 150f));
GeneralParticleHandler.SpawnParticle(new SmallSmokeParticle(vec, new Vector2(Main.rand.NextFloat(5, 20), 0).RotatedBy(Projectile.rotation + MathHelper.ToRadians(Main.rand.NextFloat(-5, 5))), Color.White, Color.LightSkyBlue, Main.rand.NextFloat(0.5f, 1f), 150f, affectedByLight: true));
}
SoundEngine.PlaySound(SoundID.Item99.WithPitchOffset(-0.5f), Projectile.Center);
Projectile.ai[1] = 1;
@@ -207,7 +208,7 @@ namespace CalamityMod.Projectiles.Ranged
for (int i = 0; i < 25; i++)
{
positions.Add(Projectile.Center);
LinePositions.Add(Projectile.Center);
}
}
}
@@ -234,19 +235,19 @@ namespace CalamityMod.Projectiles.Ranged
for (int i = 0; i < 23; i++)
{
GeneralParticleHandler.SpawnParticle(new SmallSmokeParticle(Projectile.Center + new Vector2(7, 0).RotatedBy(Projectile.rotation), new Vector2(i, 0).RotatedBy(Projectile.rotation), Color.White, Color.LightBlue, 0.07f * i, 150f));
GeneralParticleHandler.SpawnParticle(new SmallSmokeParticle(Projectile.Center + new Vector2(7, 0).RotatedBy(Projectile.rotation), new Vector2(i, 0).RotatedBy(Projectile.rotation), Color.White, Color.LightBlue, 0.07f * i, 150f, affectedByLight: true));
}
for (int i = 0; i < 6; i++)
{
GeneralParticleHandler.SpawnParticle(new SmallSmokeParticle(Projectile.Center + new Vector2(7, 0).RotatedBy(Projectile.rotation), new Vector2(Main.rand.NextFloat(8), 0).RotatedBy(Projectile.rotation + MathHelper.ToRadians(Main.rand.NextFloat(-20f, 20f))), Color.White, Color.LightBlue, Main.rand.NextFloat(1f, 1.5f), 150f));
GeneralParticleHandler.SpawnParticle(new SmallSmokeParticle(Projectile.Center + new Vector2(7, 0).RotatedBy(Projectile.rotation), new Vector2(Main.rand.NextFloat(8), 0).RotatedBy(Projectile.rotation + MathHelper.ToRadians(Main.rand.NextFloat(-20f, 20f))), Color.White, Color.LightBlue, Main.rand.NextFloat(1f, 1.5f), 150f, affectedByLight: true));
}
for (int i = 0; i < 3; i++)
{
GeneralParticleHandler.SpawnParticle(
new SparkParticle(Projectile.Center, player.DirectionTo(mousePos).RotatedBy(Main.rand.NextFloat(-0.1f, 0.1f) + MathHelper.ToRadians(90f)) * Main.rand.NextFloat(10, 20), false, 10, 1f, Color.LightSkyBlue)
new SparkParticle(Projectile.Center, player.DirectionTo(mousePos).RotatedBy(Main.rand.NextFloat(-0.1f, 0.1f) + MathHelper.ToRadians(90f)) * Main.rand.NextFloat(10, 20), false, 10, 1f, Color.LightSkyBlue, affectedByLight: true)
);
GeneralParticleHandler.SpawnParticle(
new SparkParticle(Projectile.Center, player.DirectionTo(mousePos).RotatedBy(Main.rand.NextFloat(-0.1f, 0.1f) + MathHelper.ToRadians(-90f)) * Main.rand.NextFloat(10, 20), false, 10, 1f, Color.LightSkyBlue)
new SparkParticle(Projectile.Center, player.DirectionTo(mousePos).RotatedBy(Main.rand.NextFloat(-0.1f, 0.1f) + MathHelper.ToRadians(-90f)) * Main.rand.NextFloat(10, 20), false, 10, 1f, Color.LightSkyBlue, affectedByLight: true)
);
}
}
@@ -335,7 +336,7 @@ namespace CalamityMod.Projectiles.Ranged
}
case 3:
{
GeneralParticleHandler.SpawnParticle(new SparkParticle(player.Center - (player.velocity) + new Vector2(Main.rand.NextFloat(5, 25), 0).RotatedByRandom(MathHelper.TwoPi), player.velocity, false, 8, Main.rand.NextFloat(0.2f, 1.2f), Color.White, true));
GeneralParticleHandler.SpawnParticle(new SparkParticle(player.Center - (player.velocity) + new Vector2(Main.rand.NextFloat(5, 25), 0).RotatedByRandom(MathHelper.TwoPi), player.velocity, false, 8, Main.rand.NextFloat(0.2f, 1.2f), Color.White, true, true));
Vector2 v2 = mousePos - player.Center;
@@ -352,13 +353,13 @@ namespace CalamityMod.Projectiles.Ranged
}
}
for (float i = 0; i < positions.Count; i++)
for (float i = 0; i < LinePositions.Count; i++)
{
positions[(int)i] = Vector2.Lerp(positions[(int)i], Vector2.Lerp(AbsolutePosition + new Vector2(0, 6), player.Center + ArmOffset(), (i / (float)positions.Count)),
MathHelper.Clamp(CalamityUtils.CircInEasing(i / (float)positions.Count, 1), 0f, 1f)
LinePositions[(int)i] = Vector2.Lerp(LinePositions[(int)i], Vector2.Lerp(AbsolutePosition + new Vector2(0, 6), player.Center + ArmOffset(), (i / (float)LinePositions.Count)),
MathHelper.Clamp(CalamityUtils.CircInEasing(i / (float)LinePositions.Count, 1), 0f, 1f)
);
positions[(int)i] = Vector2.Lerp(positions[(int)i], Vector2.Lerp(AbsolutePosition + new Vector2(0, 6), player.Center + ArmOffset(), (i / (float)positions.Count)),
MathHelper.Lerp(1f,0f,CalamityUtils.CircOutEasing(i / (float)positions.Count, 1))
LinePositions[(int)i] = Vector2.Lerp(LinePositions[(int)i], Vector2.Lerp(AbsolutePosition + new Vector2(0, 6), player.Center + ArmOffset(), (i / (float)LinePositions.Count)),
MathHelper.Lerp(1f,0f,CalamityUtils.CircOutEasing(i / (float)LinePositions.Count, 1))
);
}
+1 -1
View File
@@ -63,7 +63,7 @@ namespace CalamityMod.Projectiles.Rogue
if (Projectile.frameCounter == 0)
{
GeneralParticleHandler.SpawnParticle(new SmallSmokeParticle(
Projectile.Center, new Vector2(2, 0).RotatedBy(Main.rand.NextFloat(MathHelper.TwoPi)), Color.White, Color.LightSkyBlue, (1f + Main.rand.NextFloat(0.3f)) * Projectile.scale, 50f));
Projectile.Center, new Vector2(2, 0).RotatedBy(Main.rand.NextFloat(MathHelper.TwoPi)), Color.White, Color.LightSkyBlue, (1f + Main.rand.NextFloat(0.3f)) * Projectile.scale, 50f, affectedByLight: true));
}
Projectile.ai[1]++;
if (Projectile.ai[1] > 40)