* 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.
71 lines
2.2 KiB
C#
71 lines
2.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using CalamityMod.Enums;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using Terraria;
|
|
using Terraria.ModLoader;
|
|
using static CalamityMod.Graphics.Metaballs.StreamGougeMetaball;
|
|
|
|
namespace CalamityMod.Graphics.Metaballs
|
|
{
|
|
public class VoidGeneratorMetaball : Metaball
|
|
{
|
|
public static List<CosmicParticle> Particles
|
|
{
|
|
get;
|
|
private set;
|
|
} = new();
|
|
|
|
public override bool AnythingToDraw => Particles.Any();
|
|
|
|
public override IEnumerable<Texture2D> Layers
|
|
{
|
|
get
|
|
{
|
|
yield return LayerAsset.Value;
|
|
}
|
|
}
|
|
|
|
public override GeneralDrawLayer DrawLayer => GeneralDrawLayer.BeforeProjectiles;
|
|
|
|
public override Color EdgeColor => Color.Lerp(Color.Purple, Color.Black, 0.75f);
|
|
|
|
public override void Update()
|
|
{
|
|
// Update all particle instances.
|
|
// Once sufficiently small, they vanish.
|
|
for (int i = 0; i < Particles.Count; i++)
|
|
Particles[i].Update();
|
|
Particles.RemoveAll(p => p.Size <= 2f);
|
|
}
|
|
|
|
public static CosmicParticle SpawnParticle(Vector2 position, Vector2 velocity, float size)
|
|
{
|
|
CosmicParticle particle = new(position, velocity, size);
|
|
Particles.Add(particle);
|
|
|
|
return particle;
|
|
}
|
|
|
|
// Make the texture scroll.
|
|
public override Vector2 CalculateManualOffsetForLayer(int layerIndex)
|
|
{
|
|
return Vector2.UnitX * Main.GlobalTimeWrappedHourly * 0.037f;
|
|
}
|
|
|
|
public override void DrawInstances()
|
|
{
|
|
Texture2D tex = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/BasicCircle").Value;
|
|
|
|
foreach (CosmicParticle particle in Particles)
|
|
{
|
|
Vector2 drawPosition = particle.Center - Main.screenPosition;
|
|
Vector2 origin = tex.Size() * 0.5f;
|
|
Vector2 scale = Vector2.One * particle.Size / tex.Size();
|
|
Main.spriteBatch.Draw(tex, drawPosition, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0f);
|
|
}
|
|
}
|
|
}
|
|
}
|