Files
CalamityModPublic/Particles/PointParticle.cs
T
Xyk b7f027b21d Polaris Parrotfish Rework
Rapidly fires an array of colorful star shots that bounce off tiles
However, only two shots can exist at once

Has GFB features similar to Dragoon Drizzlefish

Adds a few sounds a new very versatile particle
2024-02-04 10:56:38 -05:00

54 lines
2.0 KiB
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class PointParticle : Particle
{
public Color InitialColor;
public bool AffectedByGravity;
public bool UseAltVisual = true;
public override bool SetLifetime => true;
public override bool UseCustomDraw => true;
public override bool UseAdditiveBlend => UseAltVisual;
public override string Texture => "CalamityMod/Particles/PointParticle";
public PointParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color color, bool AddativeBlend = true)
{
Position = relativePosition;
Velocity = velocity;
AffectedByGravity = affectedByGravity;
Scale = scale;
Lifetime = lifetime;
Color = InitialColor = color;
UseAltVisual = AddativeBlend;
}
public override void Update()
{
Scale *= 0.95f;
Color = Color.Lerp(InitialColor, Color.Transparent, (float)Math.Pow(LifetimeCompletion, 3D));
Velocity *= 0.95f;
if (Velocity.Length() < 12f && AffectedByGravity)
{
Velocity.X *= 0.94f;
Velocity.Y += 0.25f;
}
Rotation = Velocity.ToRotation() + MathHelper.PiOver2;
}
public override void CustomDraw(SpriteBatch spriteBatch)
{
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);
}
}
}