Files
CalamityModPublic/Particles/GenericBloom.cs
T
Xyk 4fa5b6c9d4 Lighting and particle adjustments
Added a nolight function for the GenericBloom particle

Adjusted Absorber dust light and sprite

Adjusted Arc Nova Diffuser's charge light so its green and scales with how charged it is

Adjusted Arc Nova Diffuser's charge shot to stop trying to spawn particles offscreen
2023-10-01 20:46:09 -07:00

48 lines
1.5 KiB
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class GenericBloom : Particle
{
public override string Texture => "CalamityMod/Particles/Light";
public override bool UseAdditiveBlend => true;
public override bool SetLifetime => true;
private float opacity;
private Color BaseColor;
private bool ProduceLight;
public GenericBloom(Vector2 position, Vector2 velocity, Color color, float scale, int lifeTime, bool produceLight = true)
{
Position = position;
Velocity = velocity;
BaseColor = color;
Scale = scale;
Lifetime = lifeTime;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
ProduceLight = produceLight;
}
public override void Update()
{
opacity = (float)Math.Sin(LifetimeCompletion * MathHelper.Pi);
Color = BaseColor * opacity;
if (ProduceLight)
{
Lighting.AddLight(Position, Color.R / 255f, Color.G / 255f, Color.B / 255f);
}
Velocity *= 0.95f;
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
Texture2D tex = ModContent.Request<Texture2D>(Texture).Value;
spriteBatch.Draw(tex, Position - Main.screenPosition, null, Color * opacity, Rotation, tex.Size() / 2f, Scale, SpriteEffects.None, 0);
}
}
}