using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace CalamityMod.Particles
{
public class Particle
{
///
/// The ID of the particle inside of the general particle handler's array. This is set automatically when the particle is created
///
public int ID;
///
/// The ID of the particle type as registered by the general particle handler. This is set automatically when the particle handler loads
///
public int Type;
///
/// The amount of frames this particle has existed for. You shouldn't have to touch this manually.
///
public int Time;
///
/// Set this to true if you NEED the particle to render even if the particle cap is reached.
///
public virtual bool Important => false;
///
/// Set this to true if you want your particle to automatically get removed when its time reaches its maximum lifetime
///
public virtual bool SetLifetime => false;
///
/// The maximum amount of frames a particle may stay alive if Particle.SetLifeTime is set to true
///
public int Lifetime = 0;
public float LifetimeCompletion => Lifetime != 0 ? Time / (float)Lifetime : 0;
///
/// The offset of the particle in relation to the origin of the set it belongs to. This is only used in the context of a Particle Set
///
public Vector2 RelativeOffset;
///
/// The inworld position of a particle. Keep in mind this isn't used in the context of a Particle Set, since all the particles work off their relative position to the set's origin
///
public Vector2 Position;
public Vector2 Velocity;
public Vector2 Origin;
public Color Color;
public float Rotation;
public float Scale;
public virtual int FrameVariants => 1;
public int Variant = 0;
public virtual string Texture => "";
///
/// Set this to true to disable default particle drawing, thus calling Particle.CustomDraw() instead.
///
public virtual bool UseCustomDraw => false;
///
/// Use this method if you want to handle the particle drawing yourself. Only called if Particle.UseCustomDraw is set to true.
///
public virtual void CustomDraw(SpriteBatch spriteBatch) { }
public virtual void CustomDraw(SpriteBatch spriteBatch, Vector2 basePosition) { }
///
/// Called for every update of the particle handler.
/// The particle's velocity gets automatically added to its position, and its time automatically increases.
///
public virtual void Update() { }
///
/// Set this to true to make your particle use additive blending instead of alphablend.
///
public virtual bool UseAdditiveBlend => false;
///
/// Set this to true to make your particles work with semi transparent pixels. Is overriden if UseAdditiveBlend is set to true.
///
public virtual bool UseHalfTransparency => false;
///
/// Removes the particle from the handler
///
public void Kill() => GeneralParticleHandler.RemoveParticle(this);
}
}