Additionally, changed GeneralParticleHandler's code to account for AffectedByLight in default drawing
59 lines
2.1 KiB
C#
59 lines
2.1 KiB
C#
using System;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using Terraria;
|
|
using Terraria.Graphics.Renderers;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Particles
|
|
{
|
|
public class WaterFlavoredParticle : Particle
|
|
{
|
|
public Color InitialColor;
|
|
public bool AffectedByGravity;
|
|
public override bool SetLifetime => true;
|
|
public override bool UseCustomDraw => true;
|
|
public override bool UseAdditiveBlend => false;
|
|
|
|
public override string Texture => "CalamityMod/Particles/WaterFlavored";
|
|
|
|
public WaterFlavoredParticle(Vector2 relativePosition, Vector2 velocity, bool affectedByGravity, int lifetime, float scale, Color color)
|
|
{
|
|
Position = relativePosition;
|
|
Velocity = velocity;
|
|
AffectedByGravity = affectedByGravity;
|
|
Scale = scale;
|
|
Lifetime = lifetime;
|
|
Color = InitialColor = color;
|
|
}
|
|
|
|
public override void Update()
|
|
{
|
|
Scale *= 0.93f;
|
|
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.65f, 1f) * Scale;
|
|
Texture2D texture = ModContent.Request<Texture2D>(Texture).Value;
|
|
|
|
Color lightColor = Color;
|
|
if (AffectedByLight)
|
|
{
|
|
lightColor = Color.MultiplyRGB(Lighting.GetColor((Position / 16).ToPoint()));
|
|
}
|
|
|
|
spriteBatch.Draw(texture, Position - Main.screenPosition, null, lightColor, Rotation, texture.Size() * 0.5f, scale, 0, 0f);
|
|
spriteBatch.Draw(texture, Position - Main.screenPosition, null, lightColor, Rotation, texture.Size() * 0.5f, scale * new Vector2(0.45f, 1f), 0, 0f);
|
|
}
|
|
}
|
|
}
|