* Split up GeneralDrawLayer.BeforeTiles into BeforeAllTiles and BeforeSolidTiles. * Moved screen renderers, metaballs and pixelated primitive drawing to use GeneralDrawLayer and subsequentially removed their own draw layer enums. * Moved screen renderers, metaballs, particles, pixelated primitive drawing and pixelated drawers draw calls to MechanicalILChanges. * Added TempParticle and TempParticleManager, used for defining temporary particle handlers in any file for short-term, fully-modifiable particle effects * Removed ParticleAutoDrawingOverride and added a "CustomShader" property and "PrepareCustomShader" method to Particle.cs. These should be used in conjunction when wanting to apply shader effects to particles. If anything more precise is needed, use the new TempParticleManager class.
68 lines
1.8 KiB
C#
68 lines
1.8 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using ReLogic.Content;
|
|
|
|
namespace CalamityMod.Systems.Graphic.TempParticleSystem
|
|
{
|
|
public class TempParticle
|
|
{
|
|
public Asset<Texture2D> StoredTexture;
|
|
|
|
public Vector2 Position;
|
|
|
|
public Vector2 StoredPosition;
|
|
|
|
public Vector2 Velocity;
|
|
|
|
public Vector2 Scale;
|
|
|
|
public Color DrawColor;
|
|
|
|
public float Rotation;
|
|
|
|
public float Opacity;
|
|
|
|
public float Depth;
|
|
|
|
public int Lifetime;
|
|
|
|
public int Time;
|
|
|
|
public int FrameX;
|
|
|
|
public int FrameY;
|
|
|
|
public int MaxVerticalFrames;
|
|
|
|
public int MaxHorizontalFrames;
|
|
|
|
public float[] ExtraData;
|
|
|
|
/// <summary>
|
|
/// An 0-1 interpolant representing how close this particle is from its <see cref="Lifetime"/>.
|
|
/// </summary>
|
|
public float LifetimeCompletionRatio => MathHelper.Clamp(Time / (float)Lifetime, 0f, 1f);
|
|
|
|
public void SetBasicParticleData(Asset<Texture2D> storedTexture, Vector2 position, Vector2 storedPosition, Vector2 velocity, Vector2 scale, Color drawColor, float rotation, float opacity, float depth, int lifetime, int frameX, int frameY, int maxHorizontalFrames, int maxVerticalFrames)
|
|
{
|
|
StoredTexture = storedTexture;
|
|
Position = position;
|
|
StoredPosition = storedPosition;
|
|
Velocity = velocity;
|
|
Scale = scale;
|
|
DrawColor = drawColor;
|
|
Rotation = rotation;
|
|
Opacity = opacity;
|
|
Depth = depth;
|
|
Lifetime = lifetime;
|
|
FrameX = frameX;
|
|
FrameY = frameY;
|
|
MaxHorizontalFrames = maxHorizontalFrames;
|
|
MaxVerticalFrames = maxVerticalFrames;
|
|
|
|
Time = 0;
|
|
ExtraData = new float[8];
|
|
}
|
|
}
|
|
}
|