# Conflicts:
#	Graphics/Primitives/PrimitiveTrail.cs
#	NPCs/AcidRain/AcidEel.cs
#	NPCs/ExoMechs/Apollo/Apollo.cs
#	NPCs/ExoMechs/Ares/AresBody.cs
#	NPCs/ExoMechs/Artemis/Artemis.cs
#	NPCs/SupremeCalamitas/BrimstoneHeart.cs
#	Projectiles/Boss/ApolloChargeTelegraph.cs
#	Projectiles/Boss/AresTeslaOrb.cs
#	Projectiles/Boss/ArtemisChargeTelegraph.cs
#	Projectiles/Boss/ArtemisSpinLaserbeam.cs
#	Projectiles/Boss/CirrusPhotonRipperPrismTooth.cs
#	Projectiles/Boss/DraedonSummonLaser.cs
#	Projectiles/Boss/DyingSun.cs
#	Projectiles/DraedonsArsenal/PhaseslayerProjectile.cs
#	Projectiles/Enemy/GammRayBurst.cs
#	Projectiles/Magic/ApotheosisEnergy.cs
#	Projectiles/Magic/ArtAttackStar.cs
#	Projectiles/Magic/EternityHex.cs
#	Projectiles/Magic/FabBolt.cs
#	Projectiles/Magic/FabRay.cs
#	Projectiles/Magic/RainbowRocket.cs
#	Projectiles/Magic/WulfrumBolt.cs
#	Projectiles/Melee/Exobeam.cs
#	Projectiles/Melee/MarniteObliteratorProj.cs
#	Projectiles/Melee/PrismTooth.cs
#	Projectiles/Melee/RendingNeedle.cs
#	Projectiles/Melee/StygianShieldAttack.cs
#	Projectiles/Melee/TaintedBladeSlasher.cs
#	Projectiles/Melee/TerratomereBeam.cs
#	Projectiles/Melee/TerratomereBigSlash.cs
#	Projectiles/Melee/TerratomereHoldoutProj.cs
#	Projectiles/Melee/ViolenceSlashProjectile.cs
#	Projectiles/Melee/ViolenceThrownProjectile.cs
#	Projectiles/Ranged/ExoCrystalArrow.cs
#	Projectiles/Ranged/ExoLightningBolt.cs
#	Projectiles/Ranged/MeowCreature.cs
#	Projectiles/Ranged/PristineFire.cs
#	Projectiles/Ranged/SpeedBlasterShot.cs
#	Projectiles/Ranged/TelluricGlareArrow.cs
#	Projectiles/Ranged/TheMaelstromShark.cs
#	Projectiles/Rogue/DynamicPursuerElectricity.cs
#	Projectiles/Rogue/ScarletDevilProjectile.cs
#	Projectiles/Rogue/StormfrontLightning.cs
#	Projectiles/Rogue/WulfrumKnifeProj.cs
#	Projectiles/Summon/CosmilampBeam.cs
#	Projectiles/Summon/DaedalusLightning.cs
#	Projectiles/Summon/SmallAresArms/MinionTeslaOrb.cs
#	Projectiles/Summon/WulfrumDroid.cs
#	Projectiles/Summon/WulfrumEnergyBurst.cs
#	Projectiles/Summon/WulfrumFusionBolt.cs
#	Projectiles/Typeless/GemTechArmorGem.cs
#	Projectiles/Typeless/SuicideBomberDemon.cs
#	Projectiles/Typeless/WulfrumHook.cs
This commit is contained in:
tomat committed 2024-02-28 22:29:35 -08:00
commit c80265a899
73 files changed
+866 -759

No files matched your search

@@ -0,0 +1,20 @@
using Microsoft.Xna.Framework.Graphics;
namespace CalamityMod.Graphics.Primitives
{
/// <summary>
/// Use to sucessfully render primitives with pixelation with an NPC or Projectile.
/// </summary>
public interface IPixelatedPrimitiveRenderer
{
/// <summary>
/// The layer to render the primitive(s) to.
/// </summary>
PixelationPrimitiveLayer LayerToRenderTo => PixelationPrimitiveLayer.BeforeProjectiles;
/// <summary>
/// Render primitives that use pixelation here.
/// </summary>
void RenderPixelatedPrimitives(SpriteBatch spriteBatch);
}
}
@@ -0,0 +1,15 @@
using Microsoft.Xna.Framework.Graphics;
namespace CalamityMod.Graphics.Primitives
{
/// <summary>
/// Controls what layer the <see cref="IPixelatedPrimitiveRenderer.RenderPixelatedPrimitives"/> renders to.
/// </summary>
public enum PixelationPrimitiveLayer
{
BeforeNPCs,
AfterNPCs,
BeforeProjectiles,
AfterProjectiles
}
}
@@ -0,0 +1,158 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Graphics.Primitives
{
public class PrimitivePixelationSystem : ModSystem
{
#region Fields/Properties
private static ManagedRenderTarget PixelationTarget_BeforeNPCs;
private static ManagedRenderTarget PixelationTarget_AfterNPCs;
private static ManagedRenderTarget PixelationTarget_BeforeProjectiles;
private static ManagedRenderTarget PixelationTarget_AfterProjectiles;
private static RenderTarget2D CreatePixelTarget(int width, int height) => new(Main.instance.GraphicsDevice, width / 2, height / 2);
/// <summary>
/// Whether the system is currently rendering any primitives.
/// </summary>
public static bool CurrentlyRendering
{
get;
private set;
}
#endregion
#region Loading
public override void Load()
{
On_Main.CheckMonoliths += DrawToTargets;
On_Main.DoDraw_DrawNPCsOverTiles += DrawTarget_NPCs;
On_Main.DrawProjectiles += DrawTarget_Projectiles;
PixelationTarget_BeforeNPCs = new(true, CreatePixelTarget);
PixelationTarget_AfterNPCs = new(true, CreatePixelTarget);
PixelationTarget_BeforeProjectiles = new(true, CreatePixelTarget);
PixelationTarget_AfterProjectiles = new(true, CreatePixelTarget);
}
public override void Unload()
{
On_Main.CheckMonoliths -= DrawToTargets;
On_Main.DoDraw_DrawNPCsOverTiles -= DrawTarget_NPCs;
}
#endregion
#region Drawing To Targets
private void DrawToTargets(On_Main.orig_CheckMonoliths orig)
{
if (Main.gameMenu)
{
orig();
return;
}
var beforeNPCs = new List<IPixelatedPrimitiveRenderer>();
var afterNPCs = new List<IPixelatedPrimitiveRenderer>();
var beforeProjectiles = new List<IPixelatedPrimitiveRenderer>();
var afterProjectiles = new List<IPixelatedPrimitiveRenderer>();
// Check every active projectile.
for (int i = 0; i < Main.maxProjectiles; i++)
{
var projectile = Main.projectile[i];
// If the projectile is active, a mod projectile, and uses the interface, add it to the list of primitives to draw this frame.
if (projectile.active && projectile.ModProjectile != null && projectile.ModProjectile is IPixelatedPrimitiveRenderer pixelPrimitiveProjectile)
{
var listToUse = pixelPrimitiveProjectile.LayerToRenderTo switch
{
PixelationPrimitiveLayer.BeforeNPCs => beforeNPCs,
PixelationPrimitiveLayer.AfterNPCs => afterNPCs,
PixelationPrimitiveLayer.BeforeProjectiles => beforeProjectiles,
_ => afterProjectiles
};
listToUse.Add(pixelPrimitiveProjectile);
}
}
// Check every active NPC.
for (int i = 0; i < Main.maxNPCs; i++)
{
var npc = Main.npc[i];
// If the NPC is active, a mod NPC, and uses the interface, add it to the list of primitives to draw this frame.
if (npc.active && npc.ModNPC != null && npc.ModNPC is IPixelatedPrimitiveRenderer pixelPrimitiveNPC)
{
var listToUse = pixelPrimitiveNPC.LayerToRenderTo switch
{
PixelationPrimitiveLayer.BeforeNPCs => beforeNPCs,
PixelationPrimitiveLayer.AfterNPCs => afterNPCs,
PixelationPrimitiveLayer.BeforeProjectiles => beforeProjectiles,
_ => afterProjectiles
};
listToUse.Add(pixelPrimitiveNPC);
}
}
CurrentlyRendering = true;
DrawPrimsToRenderTarget(PixelationTarget_BeforeNPCs, beforeNPCs);
DrawPrimsToRenderTarget(PixelationTarget_AfterNPCs, afterNPCs);
DrawPrimsToRenderTarget(PixelationTarget_BeforeProjectiles, beforeProjectiles);
DrawPrimsToRenderTarget(PixelationTarget_AfterProjectiles, afterProjectiles);
Main.instance.GraphicsDevice.SetRenderTarget(null);
CurrentlyRendering = false;
orig();
}
private static void DrawPrimsToRenderTarget(RenderTarget2D renderTarget, List<IPixelatedPrimitiveRenderer> pixelPrimitives)
{
// Swap to the target regardless, in order to clear any leftover content from last frame. Not doing this results in the final frame lingering once it stops rendering.
renderTarget.SwapTo();
if (pixelPrimitives.Any())
{
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null);
foreach (var pixelPrimitiveDrawer in pixelPrimitives)
pixelPrimitiveDrawer.RenderPixelatedPrimitives(Main.spriteBatch);
Main.spriteBatch.End();
}
}
#endregion
#region Target Drawing
private void DrawTarget_NPCs(On_Main.orig_DoDraw_DrawNPCsOverTiles orig, Main self)
{
DrawTargetScaled(PixelationTarget_BeforeNPCs);
orig(self);
DrawTargetScaled(PixelationTarget_AfterNPCs);
}
private void DrawTarget_Projectiles(On_Main.orig_DrawProjectiles orig, Main self)
{
DrawTargetScaled(PixelationTarget_BeforeProjectiles);
orig(self);
DrawTargetScaled(PixelationTarget_AfterProjectiles);
}
private static void DrawTargetScaled(ManagedRenderTarget target)
{
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
Main.spriteBatch.Draw(target, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0f);
Main.spriteBatch.End();
}
#endregion
}
}
+296
View File
@@ -0,0 +1,296 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Graphics.Shaders;
namespace CalamityMod.Graphics.Primitives
{
/// <summary>
/// This both acts as an instanceable struct containing primitive trail data, and as a manager that creates and renders said instances. <br/><br/>
/// <b>To use normally, in the draw method of an NPC or Projectile call <see cref="Prepare"/>.</b><br/>
/// <list type="bullet">
/// <item>The first param should be the positions to use for the trail.</item>
/// <item>The second is a struct that allows you to choose a desired configuration of settings to use with the trail, to allow for customization.</item>
/// <item>The third controls how many points are created for the trail, and the fourth determines whether the primitive is subsequently rendered.</item>
/// <item>If you do not render in <see cref="Prepare"/>, you <b>MUST</b> call <see cref="Render"/> manually on the created instance to make it actually appear.</item>
/// </list>
/// If you wish to use pixelation, you <b>MUST</b> make the NPC/Projectile inherit <see cref="IPixelatedPrimitiveRenderer"/> and use <see cref="IPixelatedPrimitiveRenderer.RenderPixelatedPrimitives"/> instead.<br/>
/// You can also optionally specify a render layer with <see cref="IPixelatedPrimitiveRenderer.LayerToRenderTo"/>. It is <see cref="PixelationPrimitiveLayer.BeforeNPCs"/> by default.
/// </summary>
public readonly struct PrimitiveSet
{
#region Instance Members
/// <summary>
/// The vertices of the set.
/// </summary>
public readonly VertexPosition2DColorTexture[] Vertices;
/// <summary>
/// The indices of the set.
/// </summary>
public readonly int[] Indices;
/// <summary>
/// The settings of the set.
/// </summary>
public readonly PrimitiveSettings Settings;
private PrimitiveSet(VertexPosition2DColorTexture[] vertices, int[] indices, PrimitiveSettings settings)
{
Vertices = vertices;
Indices = indices;
Settings = settings;
}
#endregion
#region Static Members
private static void PerformPixelationSafetyChecks(PrimitiveSettings settings)
{
// Don't allow accidental screw ups with these.
if (settings.Pixelate && !PrimitivePixelationSystem.CurrentlyRendering)
throw new Exception("Error: Primitives using pixelation MUST be prepared/rendered from the IPixelatedPrimitiveRenderer.RenderPixelatedPrimitives method, did you forget to use the interface?");
else if (!settings.Pixelate && PrimitivePixelationSystem.CurrentlyRendering)
throw new Exception("Error: Primitives not using pixelation MUST NOT be prepared/rendered from the IPixelatedPrimitiveRenderer.RenderPixelatedPrimitives method.");
}
/// <summary>
/// Prepares a <see cref="PrimitiveSet"/> based on the provided information, and optionally renders it.
/// </summary>
/// <param name="positions">The list of positions to use. Keep in mind that these are expected to be in <b>world position</b>, and <see cref="Main.screenPosition"/> is automatically subtracted from them all.</param>
/// <param name="settings">The primitive draw settings to use.</param>
/// <param name="pointsToCreate">The amount of points to use. More is higher detailed, but less performant. By default, is the number of positions provided. <b>Going above 100 is NOT recommended.</b></param>
/// <param name="render">Whether to render the set.</param>
/// <returns>The prepared set.</returns>
public static PrimitiveSet? Prepare(IEnumerable<Vector2> positions, PrimitiveSettings settings, int? pointsToCreate = null, bool render = true)
{
PerformPixelationSafetyChecks(settings);
int positionCount = positions.Count();
// Return if not enough to draw anything.
if (positionCount <= 2)
return null;
// Cull out any zeroed points.
positions = positions.Where(p => p != Vector2.Zero);
List<Vector2> trailPoints = PreparePointsRectangleTrail(positions, settings, pointsToCreate ?? positionCount).ToList();
// A trail with only one point or less has nothing to connect to, and therefore, can't make a trail.
if (trailPoints.Count <= 2)
return null;
// If the trail point has any NaN positions, don't draw anything.
if (trailPoints.Any(point => point.HasNaNs()))
return null;
// If the trail points are all equal, don't draw anything.
if (trailPoints.All(point => point == trailPoints[0]))
return null;
IEnumerable<VertexPosition2DColorTexture> vertices = CreateVerticesRectangleTrail(trailPoints.ToList(), settings);
int[] indices = CreateIndicesRectangleTrail(trailPoints.Count);
// Create the set, and just return it if not asked to render.
PrimitiveSet set = new(vertices.ToArray(), indices, settings);
if (!render)
return set;
// Else render the set and return it.
return set.Render();
}
#endregion
#region Instance Methods
/// <summary>
/// Renders the provided primitive set to the screen.
/// </summary>
/// <returns>The provided set.</returns>
public PrimitiveSet Render()
{
PerformPixelationSafetyChecks(Settings);
if (Indices.Length % 6 != 0 || Vertices.Length <= 3)
return this;
// Perform screen culling, for performance reasons.
Main.instance.GraphicsDevice.RasterizerState = RasterizerState.CullNone;
Main.instance.GraphicsDevice.RasterizerState.ScissorTestEnable = true;
Main.instance.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, Main.screenWidth, Main.screenHeight);
Matrix view;
Matrix projection;
if (Settings.Pixelate)
CalcuatePixelatedPerspectiveMatrices(out view, out projection);
else
CalamityUtils.CalculatePerspectiveMatricies(out view, out projection);
var shaderToUse = Settings.Shader ?? GameShaders.Misc["CalamityMod:StandardPrimitiveShader"];
shaderToUse.Shader.Parameters["uWorldViewProjection"].SetValue(view * projection);
shaderToUse.Apply();
// Render the set.
Main.instance.GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, Vertices, 0, Vertices.Length, Indices, 0, Indices.Length / 3);
Main.pixelShader.CurrentTechnique.Passes[0].Apply();
return this;
}
#endregion
#region Set Preperation
private static IEnumerable<Vector2> PreparePointsRectangleTrail(IEnumerable<Vector2> positions, PrimitiveSettings settings, int pointsToCreate)
{
// Don't smoothen the points unless explicitly told do so.
if (!settings.Smoothen)
{
List<Vector2> basePoints = positions.Where(originalPosition => originalPosition != Vector2.Zero).ToList();
List<Vector2> endPoints = new();
if (basePoints.Count <= 2)
return endPoints;
// Remap the original positions across a certain length.
for (int i = 0; i < pointsToCreate; i++)
{
float completionRatio = i / (float)(pointsToCreate - 1f);
int currentIndex = (int)(completionRatio * (basePoints.Count - 1));
Vector2 currentPoint = basePoints[currentIndex];
Vector2 nextPoint = basePoints[(currentIndex + 1) % basePoints.Count];
endPoints.Add(Vector2.Lerp(currentPoint, nextPoint, completionRatio * (basePoints.Count - 1) % 0.99999f) - Main.screenPosition);
}
return endPoints;
}
List<Vector2> controlPoints = new();
for (int i = 0; i < positions.Count(); i++)
{
// Don't incorporate points that are zeroed out.
// They are almost certainly a result of incomplete oldPos arrays.
if (positions.ElementAt(i) == Vector2.Zero)
continue;
float completionRatio = i / (float)positions.Count();
Vector2 offset = -Main.screenPosition;
if (settings.OffsetFunction != null)
offset += settings.OffsetFunction(completionRatio);
controlPoints.Add(positions.ElementAt(i) + offset);
}
List<Vector2> points = new();
// Avoid stupid index errors.
if (controlPoints.Count <= 4)
return controlPoints;
for (int j = 0; j < pointsToCreate; j++)
{
float splineInterpolant = j / (float)pointsToCreate;
float localSplineInterpolant = splineInterpolant * (controlPoints.Count - 1f) % 1f;
int localSplineIndex = (int)(splineInterpolant * (controlPoints.Count - 1f));
Vector2 farLeft;
Vector2 left = controlPoints[localSplineIndex];
Vector2 right = controlPoints[localSplineIndex + 1];
Vector2 farRight;
// Special case: If the spline attempts to access the previous/next index but the index is already at the very beginning/end, simply
// cheat a little bit by creating a phantom point that's mirrored from the previous one.
if (localSplineIndex <= 0)
{
Vector2 mirrored = left * 2f - right;
farLeft = mirrored;
}
else
farLeft = controlPoints[localSplineIndex - 1];
if (localSplineIndex >= controlPoints.Count - 2)
{
Vector2 mirrored = right * 2f - left;
farRight = mirrored;
}
else
farRight = controlPoints[localSplineIndex + 2];
points.Add(Vector2.CatmullRom(farLeft, left, right, farRight, localSplineInterpolant));
}
// Manually insert the front and end points.
points.Insert(0, controlPoints.First());
points.Add(controlPoints.Last());
return points;
}
private static IEnumerable<VertexPosition2DColorTexture> CreateVerticesRectangleTrail(List<Vector2> positions, PrimitiveSettings settings)
{
List<VertexPosition2DColorTexture> vertices = new();
for (int i = 0; i < positions.Count; i++)
{
float completionRatio = i / (float)(positions.Count - 1);
float widthAtVertex = settings.WidthFunction(completionRatio);
Color vertexColor = settings.ColorFunction(completionRatio);
Vector2 currentPosition = positions[i];
Vector2 directionToAhead = i == positions.Count - 1 ? (positions[i] - positions[i - 1]).SafeNormalize(Vector2.Zero) : (positions[i + 1] - positions[i]).SafeNormalize(Vector2.Zero);
Vector2 leftCurrentTextureCoord = new(completionRatio, 0f);
Vector2 rightCurrentTextureCoord = new(completionRatio, 1f);
// Point 90 degrees away from the direction towards the next point, and use it to mark the edges of the rectangle.
// This doesn't use RotatedBy for the sake of performance (there can potentially be a lot of trail points).
Vector2 sideDirection = new(-directionToAhead.Y, directionToAhead.X);
Vector2 left = currentPosition - sideDirection * widthAtVertex;
Vector2 right = currentPosition + sideDirection * widthAtVertex;
// Override the initial vertex positions if requested.
if (i == 0 && settings.InitialVertexPositionsOverride.HasValue && settings.InitialVertexPositionsOverride.Value.Item1 != Vector2.Zero && settings.InitialVertexPositionsOverride.Value.Item2 != Vector2.Zero)
{
left = settings.InitialVertexPositionsOverride.Value.Item1;
right = settings.InitialVertexPositionsOverride.Value.Item2;
}
// What this is doing, at its core, is defining a rectangle based on two triangles.
// These triangles are defined based on the width of the strip at that point.
// The resulting rectangles combined are what make the trail itself.
vertices.Add(new VertexPosition2DColorTexture(left, vertexColor, leftCurrentTextureCoord));
vertices.Add(new VertexPosition2DColorTexture(right, vertexColor, rightCurrentTextureCoord));
}
return vertices;
}
private static int[] CreateIndicesRectangleTrail(int pointCount)
{
// What this is doing is basically representing each point on the vertices list as
// indices. These indices should come together to create a tiny rectangle that acts
// as a segment on the trail. This is achieved here by splitting the indices (or rather, points)
// into 2 triangles, which requires 6 points.
// The logic here basically determines which indices are connected together.
int totalIndices = (pointCount - 1) * 6;
int[] indices = new int[totalIndices];
for (int i = 0; i < pointCount - 2; i++)
{
int startingTriangleIndex = i * 6;
int connectToIndex = i * 2;
indices[startingTriangleIndex] = connectToIndex;
indices[startingTriangleIndex + 1] = connectToIndex + 1;
indices[startingTriangleIndex + 2] = connectToIndex + 2;
indices[startingTriangleIndex + 3] = connectToIndex + 2;
indices[startingTriangleIndex + 4] = connectToIndex + 1;
indices[startingTriangleIndex + 5] = connectToIndex + 3;
}
return indices;
}
private static void CalcuatePixelatedPerspectiveMatrices(out Matrix viewMatrix, out Matrix projectionMatrix)
{
// Due to the scaling, the normal transformation calcuations do not work with pixelated primitives.
projectionMatrix = Matrix.CreateOrthographicOffCenter(0, Main.screenWidth, Main.screenHeight, 0, -1, 1);
viewMatrix = Matrix.Identity;
}
#endregion
}
}
+92
View File
@@ -0,0 +1,92 @@
using Microsoft.Xna.Framework;
using Terraria.Graphics.Shaders;
namespace CalamityMod.Graphics.Primitives
{
/// <summary>
/// Contains all the various options to use when creating a primitive trail. New members can be added freely without breaking existing implementations.
/// </summary>
public readonly struct PrimitiveSettings
{
#region Delegates
/// <summary>
/// A delegate to dynamically determine the width of the trail at each position.
/// </summary>
/// <param name="trailLengthInterpolant">The current position along the trail as a 0-1 interlopant value.</param>
/// <returns>The width for the current point.</returns>
public delegate float VertexWidthFunction(float trailLengthInterpolant);
/// <summary>
/// A delegate to dynamically determine the color of the trail at each position.
/// </summary>
/// <param name="trailLengthInterpolant">The current position along the trail as a 0-1 interlopant value.</param>
/// <returns>The color for the current point.</returns>
public delegate Color VertexColorFunction(float trailLengthInterpolant);
/// <summary>
/// A delegate to dynamically determine the offset of the trail at each position.
/// </summary>
/// <param name="trailLengthInterpolant">The current position along the trail as a 0-1 interlopant value.</param>
/// <returns>The offset for the current point.</returns>
public delegate Vector2 VertexOffsetFunction(float trailLengthInterpolant);
#endregion
#region Instance Fields
/// <summary>
/// Used to determine the width of each vertex.
/// </summary>
public readonly VertexWidthFunction WidthFunction;
/// <summary>
/// Used to determine the color of each vertex.
/// </summary>
public readonly VertexColorFunction ColorFunction;
/// <summary>
/// Used to offset each position when generating them.
/// </summary>
public readonly VertexOffsetFunction OffsetFunction;
/// <summary>
/// Whether to use smoothening when generating the vertex positions from the provided ones Recommended to be on by default.
/// </summary>
public readonly bool Smoothen;
/// <summary>
/// Whether to pixelate the primitives. Recommended to be on by default.
/// </summary>
public readonly bool Pixelate;
/// <summary>
/// The shader to apply when rendering.
/// </summary>
public readonly MiscShaderData Shader;
/// <summary>
/// An optional override to force the trail to use the provided positions as the side positions of the initial vertex. They are the left and right positions respectively.
/// </summary>
public readonly (Vector2, Vector2)? InitialVertexPositionsOverride;
#endregion
/// <summary>
/// Contains all the various options to use when creating a primitive trail.
/// </summary>
/// <param name="widthFunction">Used to determine the width of each vertex.</param>
/// <param name="colorFunction">Used to determine the color of each vertex.</param>
/// <param name="offsetFunction">Used to offset each position when generating them.</param>
/// <param name="smoothen">Whether to use smoothening when generating the vertex positions from the provided ones. Recommended to be enabled.</param>
/// <param name="pixelate">Whether to pixelate the primitives. Recommended to be enabled if the effect was designed with this in mind.</param>
/// <param name="shader">The shader to apply when rendering the primitives.</param>
/// <param name="initialVertexPositionsOverride">An optional override to force the trail to use the provided positions as the side positions of the initial vertex. They are the left and right positions respectively and should be in screen space.</param>
public PrimitiveSettings(VertexWidthFunction widthFunction, VertexColorFunction colorFunction, VertexOffsetFunction offsetFunction = null, bool smoothen = true, bool pixelate = false, MiscShaderData shader = null, (Vector2, Vector2)? initialVertexPositionsOverride = null)
{
WidthFunction = widthFunction;
ColorFunction = colorFunction;
OffsetFunction = offsetFunction;
Smoothen = smoothen;
Pixelate = pixelate;
Shader = shader;
InitialVertexPositionsOverride = initialVertexPositionsOverride;
}
}
}
-262
View File
@@ -1,262 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using CalamityMod.DataStructures;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Graphics.Shaders;
namespace CalamityMod
{
public class PrimitiveTrail
{
public struct VertexPosition2DColor : IVertexType
{
public Vector2 Position;
public Color Color;
public Vector2 TextureCoordinates;
public VertexDeclaration VertexDeclaration => _vertexDeclaration;
private static readonly VertexDeclaration _vertexDeclaration = new VertexDeclaration(new VertexElement[]
{
new VertexElement(0, VertexElementFormat.Vector2, VertexElementUsage.Position, 0),
new VertexElement(8, VertexElementFormat.Color, VertexElementUsage.Color, 0),
new VertexElement(12, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0),
});
public VertexPosition2DColor(Vector2 position, Color color, Vector2 textureCoordinates)
{
Position = position;
Color = color;
TextureCoordinates = textureCoordinates;
}
}
public delegate float VertexWidthFunction(float completionRatio);
public delegate Color VertexColorFunction(float completionRatio);
public int DegreeOfBezierCurveCornerSmoothening;
public VertexWidthFunction WidthFunction;
public VertexColorFunction ColorFunction;
public MiscShaderData SpecialShader;
public TrailPointRetrievalFunction TrailPointFunction;
public Vector2 OverridingStickPointStart = Vector2.Zero;
public Vector2 OverridingStickPointEnd = Vector2.Zero;
public delegate List<Vector2> TrailPointRetrievalFunction(IEnumerable<Vector2> originalPositions, Vector2 generalOffset, int totalTrailPoints, IEnumerable<float> originalRotations = null);
public PrimitiveTrail(VertexWidthFunction widthFunction, VertexColorFunction colorFunction, TrailPointRetrievalFunction pointFunction = null, MiscShaderData specialShader = null)
{
if (widthFunction is null || colorFunction is null)
throw new NullReferenceException($"In order to create a primitive trail, a non-null {(widthFunction is null ? "width" : "color")} function must be specified.");
WidthFunction = widthFunction;
ColorFunction = colorFunction;
// Default to bezier smoothening if nothing else is inputted.
if (pointFunction is null)
pointFunction = SmoothBezierPointRetreivalFunction;
TrailPointFunction = pointFunction;
SpecialShader = specialShader ?? GameShaders.Misc["CalamityMod:StandardPrimitiveShader"];
if (specialShader != null)
SpecialShader = specialShader;
}
public static List<Vector2> RigidPointRetreivalFunction(IEnumerable<Vector2> originalPositions, Vector2 generalOffset, int totalTrailPoints, IEnumerable<float> _ = null)
{
List<Vector2> basePoints = originalPositions.Where(originalPosition => originalPosition != Vector2.Zero).ToList();
List<Vector2> endPoints = new List<Vector2>();
if (basePoints.Count < 2)
{
for (int i = 0; i < basePoints.Count; i++)
basePoints[i] += generalOffset;
return basePoints;
}
// Remap the original positions across a certain length.
for (int i = 0; i < totalTrailPoints; i++)
{
float completionRatio = i / (float)(totalTrailPoints - 1f);
int currentIndex = (int)(completionRatio * (basePoints.Count - 1));
Vector2 currentPoint = basePoints[currentIndex];
Vector2 nextPoint = basePoints[(currentIndex + 1) % basePoints.Count];
endPoints.Add(Vector2.Lerp(currentPoint, nextPoint, completionRatio * (basePoints.Count - 1) % 0.99999f) + generalOffset);
}
endPoints.Add(basePoints.Last() + generalOffset);
return endPoints;
}
// NOTE: Beziers can be laggy when a lot of control points are used, since our implementation
// uses a recursive Lerp that gets more computationally expensive the more original indices.
// n(n + 1)/2 linear interpolations to be precise, where n is the amount of original indices.
public List<Vector2> SmoothBezierPointRetreivalFunction(IEnumerable<Vector2> originalPositions, Vector2 generalOffset, int totalTrailPoints, IEnumerable<float> originalRotations = null)
{
List<Vector2> controlPoints = new List<Vector2>();
for (int i = 0; i < originalPositions.Count(); i++)
{
// Don't incorporate points that are zeroed out.
// They are almost certainly a result of incomplete oldPos arrays.
if (originalPositions.ElementAt(i) == Vector2.Zero)
continue;
controlPoints.Add(originalPositions.ElementAt(i) + generalOffset);
}
bool pointCountCondition = DegreeOfBezierCurveCornerSmoothening <= 0 || controlPoints.Count < DegreeOfBezierCurveCornerSmoothening * 3;
int effectivePointCount = DegreeOfBezierCurveCornerSmoothening > 0 ? totalTrailPoints * DegreeOfBezierCurveCornerSmoothening : totalTrailPoints;
BezierCurve bezierCurve = new BezierCurve(controlPoints.Where((_, i) =>
{
return DegreeOfBezierCurveCornerSmoothening <= 0 ||
i % DegreeOfBezierCurveCornerSmoothening == 0 ||
i == 0 ||
i == controlPoints.Count - 1 ||
pointCountCondition;
}).ToArray());
return controlPoints.Count <= 1 ? controlPoints : bezierCurve.GetPoints(effectivePointCount);
}
// Using this method requires oldRot be supplied to the Draw method for the sake of determining how many points need to be made at a given time step.
// Furthermore, since the point count is dynamic, the point count int parameter has no purpose. It can be supplied simply with zero.
public static List<Vector2> SmoothCatmullRomPointRetreivalFunction(IEnumerable<Vector2> originalPositions, Vector2 generalOffset, int _, IEnumerable<float> originalRotations)
{
List<Vector2> smoothenedPoints = new List<Vector2>();
for (int i = 0; i < originalPositions.Count() - 1; i++)
{
Vector2 currentPosition = originalPositions.ElementAt(i);
Vector2 aheadPosition = originalPositions.ElementAt(i + 1);
// Don't incorporate points that are zeroed out.
// They are almost certainly a result of incomplete oldPos arrays.
if (currentPosition == Vector2.Zero || aheadPosition == Vector2.Zero)
continue;
float currentRotation = MathHelper.WrapAngle(originalRotations.ElementAt(i));
float aheadRotation = MathHelper.WrapAngle(originalRotations.ElementAt(i + 1));
// Determine the amount of extra points to draw based on the rotational offset between the two time steps.
int pointsToAdd = (int)Math.Round(Math.Abs(MathHelper.WrapAngle(aheadRotation - currentRotation)) * 8f / MathHelper.Pi);
// Add a base point.
smoothenedPoints.Add(currentPosition + generalOffset);
// If no new points are needed, skip this.
if (pointsToAdd == 0)
continue;
float segmentLength = Vector2.Distance(currentPosition, aheadPosition);
float increment = 1f / (pointsToAdd + 2);
Vector2 backEnd = currentPosition + currentRotation.ToRotationVector2() * segmentLength;
Vector2 frontEnd = aheadPosition + aheadRotation.ToRotationVector2() * -segmentLength;
// Create smoothened points based on a Catmull-Rom spline.
for (float j = increment; j < 1f; j += increment)
smoothenedPoints.Add(Vector2.CatmullRom(backEnd, currentPosition, aheadPosition, frontEnd, j) + generalOffset);
}
return smoothenedPoints;
}
public VertexPosition2DColor[] GetVerticesFromTrailPoints(List<Vector2> trailPoints)
{
VertexPosition2DColor[] vertices = new VertexPosition2DColor[trailPoints.Count * 2 - 2];
for (int i = 0; i < trailPoints.Count - 1; i++)
{
float completionRatio = i / (float)trailPoints.Count;
float widthAtVertex = WidthFunction(completionRatio);
Color vertexColor = ColorFunction(completionRatio);
Vector2 currentPosition = trailPoints[i];
Vector2 positionAhead = trailPoints[i + 1];
Vector2 directionToAhead = (positionAhead - trailPoints[i]).SafeNormalize(Vector2.Zero);
Vector2 leftCurrentTextureCoord = new Vector2(completionRatio, 0f);
Vector2 rightCurrentTextureCoord = new Vector2(completionRatio, 1f);
// Point 90 degrees away from the direction towards the next point, and use it to mark the edges of the rectangle.
// This doesn't use RotatedBy for the sake of performance (there can potentially be a lot of trail points).
Vector2 sideDirection = new Vector2(-directionToAhead.Y, directionToAhead.X);
Vector2 left = currentPosition - sideDirection * widthAtVertex;
Vector2 right = currentPosition + sideDirection * widthAtVertex;
if (i == 0 && OverridingStickPointStart != Vector2.Zero)
{
left = OverridingStickPointStart;
right = OverridingStickPointEnd;
}
// What this is doing, at its core, is defining a rectangle based on two triangles.
// These triangles are defined based on the width of the strip at that point.
// The resulting rectangles combined are what make the trail itself.
vertices[i * 2] = new VertexPosition2DColor(left, vertexColor, leftCurrentTextureCoord);
vertices[i * 2 + 1] = new VertexPosition2DColor(right, vertexColor, rightCurrentTextureCoord);
}
return vertices.ToArray();
}
public short[] GetIndicesFromTrailPoints(int pointCount)
{
// What this is doing is basically representing each point on the vertices list as
// indices. These indices should come together to create a tiny rectangle that acts
// as a segment on the trail. This is achieved here by splitting the indices (or rather, points)
// into 2 triangles, which requires 6 points.
// The logic here basically determines which indices are connected together.
int totalIndices = (pointCount - 1) * 6;
short[] indices = new short[totalIndices];
for (int i = 0; i < pointCount - 2; i++)
{
int startingTriangleIndex = i * 6;
int connectToIndex = i * 2;
indices[startingTriangleIndex] = (short)connectToIndex;
indices[startingTriangleIndex + 1] = (short)(connectToIndex + 1);
indices[startingTriangleIndex + 2] = (short)(connectToIndex + 2);
indices[startingTriangleIndex + 3] = (short)(connectToIndex + 2);
indices[startingTriangleIndex + 4] = (short)(connectToIndex + 1);
indices[startingTriangleIndex + 5] = (short)(connectToIndex + 3);
}
return indices;
}
public void Draw(IEnumerable<Vector2> originalPositions, Vector2 generalOffset, int totalTrailPoints, IEnumerable<float> originalRotations = null)
{
List<Vector2> trailPoints = TrailPointFunction(originalPositions, generalOffset, totalTrailPoints, originalRotations);
// A trail with only one point or less has nothing to connect to, and therefore, can't make a trail.
if (trailPoints.Count < 2)
return;
// If the trail points have any NaN positions, don't draw anything.
if (trailPoints.Any(point => point.HasNaNs()))
return;
// If the trail points are all equal, don't draw anything.
if (trailPoints.All(point => point == trailPoints[0]))
return;
CalamityUtils.CalculatePerspectiveMatricies(out Matrix view, out Matrix projection);
VertexPosition2DColor[] vertices = GetVerticesFromTrailPoints(trailPoints);
short[] triangleIndices = GetIndicesFromTrailPoints(trailPoints.Count);
// Don't draw anything if the indicies/vertices are in any way invalid.
// If they are, the graphics engine, along with the entire game, will crash.
if (triangleIndices.Length % 6 != 0 || vertices.Length % 2 != 0)
return;
Main.instance.GraphicsDevice.RasterizerState = RasterizerState.CullNone;
Main.instance.GraphicsDevice.RasterizerState.ScissorTestEnable = true;
Main.instance.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, Main.screenWidth, Main.screenHeight); //offscreen culling
SpecialShader.Shader.Parameters["uWorldViewProjection"].SetValue(view * projection);
SpecialShader.Apply();
Main.instance.GraphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, vertices, 0, vertices.Length, triangleIndices, 0, triangleIndices.Length / 3);
Main.pixelShader.CurrentTechnique.Passes[0].Apply();
}
}
}
@@ -0,0 +1,46 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace CalamityMod.Graphics.Primitives
{
/// <summary>
/// A custom vertex type with a position using Vector2 instead of Vector4, as Terraria is only a 2D game.
/// </summary>
/// <remarks>This represents a vertex that will be rendered by the GPU.</remarks>
public readonly struct VertexPosition2DColorTexture : IVertexType
{
/// <summary>
/// The position of the vertex.
/// </summary>
public readonly Vector2 Position;
/// <summary>
/// The color of the vertex.
/// </summary>
public readonly Color Color;
/// <summary>
/// The texture-coordinate of the vertex.
/// </summary>
public readonly Vector2 TextureCoordinates;
/// <summary>
/// The vertex declaration. This declares the layout and size of the data in the vertex shader.
/// </summary>
public VertexDeclaration VertexDeclaration => VertexDeclaration2D;
public static readonly VertexDeclaration VertexDeclaration2D = new(new VertexElement[]
{
new(0, VertexElementFormat.Vector2, VertexElementUsage.Position, 0),
new(8, VertexElementFormat.Color, VertexElementUsage.Color, 0),
new(12, VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0),
});
public VertexPosition2DColorTexture(Vector2 position, Color color, Vector2 textureCoordinates)
{
Position = position;
Color = color;
TextureCoordinates = textureCoordinates;
}
}
}
+4 -8
View File
@@ -3,6 +3,7 @@ using System.Linq;
using CalamityMod.BiomeManagers;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.Dusts;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Materials;
using CalamityMod.Items.Placeables.Banners;
using CalamityMod.Items.Weapons.Magic;
@@ -22,8 +23,6 @@ namespace CalamityMod.NPCs.AcidRain
{
public Player Target => Main.player[NPC.target];
public PrimitiveTrail SegmentDrawer = null;
public override void SetStaticDefaults()
{
Main.npcFrameCount[NPC.type] = 6;
@@ -79,7 +78,7 @@ namespace CalamityMod.NPCs.AcidRain
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
{
bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[]
bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[]
{
new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.AcidEel")
});
@@ -187,9 +186,6 @@ namespace CalamityMod.NPCs.AcidRain
return false;
}
// Initialize the segment drawer.
SegmentDrawer ??= new(SegmentWidthFunction, _ => NPC.GetAlpha(Color.White), null, GameShaders.Misc["CalamityMod:PrimitiveTexture"]);
Texture2D headTexture = ModContent.Request<Texture2D>(Texture).Value;
Texture2D tailTexture = ModContent.Request<Texture2D>("CalamityMod/NPCs/AcidRain/AcidEelTail").Value;
Vector2[] segmentPositions = (Vector2[])NPC.oldPos.Clone();
@@ -205,7 +201,7 @@ namespace CalamityMod.NPCs.AcidRain
for (int i = 0; i < segmentPositions.Length; i++)
{
segmentPositions[i] += NPC.Size * 0.5f - screenPos - NPC.rotation.ToRotationVector2() * Math.Sign(NPC.velocity.X) * 8f;
segmentPositions[i] += NPC.Size * 0.5f - NPC.rotation.ToRotationVector2() * Math.Sign(NPC.velocity.X) * 8f;
if (segmentAreaTopLeft.X > segmentPositions[i].X)
segmentAreaTopLeft.X = segmentPositions[i].X;
if (segmentAreaTopLeft.Y > segmentPositions[i].Y)
@@ -234,7 +230,7 @@ namespace CalamityMod.NPCs.AcidRain
Vector2 tailDrawPosition = segmentPositions[^1] - tailRotation.ToRotationVector2() * 4f;
SpriteEffects tailDirection = NPC.velocity.X < 0f ? SpriteEffects.None : SpriteEffects.FlipVertically;
Main.EntitySpriteDraw(tailTexture, tailDrawPosition, tailArea, NPC.GetAlpha(Color.White), tailRotation, tailArea.Size() * new Vector2(0f, 0.5f), NPC.scale, tailDirection, 0);
SegmentDrawer.Draw(segmentPositions, Vector2.Zero, 36);
PrimitiveSet.Prepare(segmentPositions, new(SegmentWidthFunction, _ => NPC.GetAlpha(Color.White), pixelate: false, shader: GameShaders.Misc["CalamityMod:PrimitiveTexture"]), 36);
}
return false;
+10 -25
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using CalamityMod.Events;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Potions;
using CalamityMod.Items.Weapons.DraedonsArsenal;
using CalamityMod.NPCs.ExoMechs.Ares;
@@ -116,13 +117,6 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
// Intensity of flash effects during the charge combo
public float ChargeComboFlash;
// Primitive trail drawers for thrusters when charging
public PrimitiveTrail ChargeFlameTrail = null;
public PrimitiveTrail ChargeFlameTrailBig = null;
// Primitive trail drawer for the ribbon things
public PrimitiveTrail RibbonTrail = null;
public static string NameToDisplay = "XS-03 Apollo";
public static readonly SoundStyle MissileLaunchSound = new("CalamityMod/Sounds/Custom/ExoMechs/ApolloMissileLaunch") { Volume = 1.3f };
@@ -172,7 +166,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
{
bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[]
bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[]
{
new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Apollo")
});
@@ -1497,16 +1491,6 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
{
// Declare the trail drawers if they have yet to be defined.
if (ChargeFlameTrail is null)
ChargeFlameTrail = new PrimitiveTrail(FlameTrailWidthFunction, FlameTrailColorFunction, null, GameShaders.Misc["CalamityMod:ImpFlameTrail"]);
if (ChargeFlameTrailBig is null)
ChargeFlameTrailBig = new PrimitiveTrail(FlameTrailWidthFunctionBig, FlameTrailColorFunctionBig, null, GameShaders.Misc["CalamityMod:ImpFlameTrail"]);
if (RibbonTrail is null)
RibbonTrail = new PrimitiveTrail(RibbonTrailWidthFunction, RibbonTrailColorFunction);
// Prepare the flame trail shader with its map texture.
GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak"));
@@ -1569,7 +1553,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
currentSegmentRotation += segmentRotationOffset;
}
RibbonTrail.Draw(ribbonDrawPositions, -screenPos, 66);
PrimitiveSet.Prepare(ribbonDrawPositions, new(RibbonTrailWidthFunction, RibbonTrailColorFunction), 66);
}
int instanceCount = (int)MathHelper.Lerp(1f, 15f, ChargeComboFlash);
@@ -1634,11 +1618,12 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
for (int i = 0; i < 4; i++)
{
Vector2 drawOffset = (MathHelper.TwoPi * i / 4f).ToRotationVector2() * 8f;
ChargeFlameTrailBig.Draw(drawPositions, drawOffset - screenPos, 70);
PrimitiveSet.Prepare(drawPositions, new(FlameTrailWidthFunctionBig, FlameTrailColorFunctionBig, (_) => drawOffset, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 70);
}
}
else
ChargeFlameTrail.Draw(drawPositions, -screenPos, 70);
PrimitiveSet.Prepare(drawPositions, new(FlameTrailWidthFunction, FlameTrailColorFunction, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 70);
}
}
@@ -1720,7 +1705,7 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
public override void HitEffect(NPC.HitInfo hit)
{
for (int k = 0; k < 3; k++)
Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.TerraBlade, 0f, 0f, 100, new Color(0, 255, 255), 1f);
Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f);
if (NPC.soundDelay == 0)
{
@@ -1732,14 +1717,14 @@ namespace CalamityMod.NPCs.ExoMechs.Apollo
{
for (int num193 = 0; num193 < 2; num193++)
{
Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.TerraBlade, 0f, 0f, 100, new Color(0, 255, 255), 1.5f);
Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f);
}
for (int i = 0; i < 20; i++)
{
int plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.TerraBlade, 0f, 0f, 0, new Color(0, 255, 255), 2.5f);
int plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f);
Main.dust[plasmaDust].noGravity = true;
Main.dust[plasmaDust].velocity *= 3f;
plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.TerraBlade, 0f, 0f, 100, new Color(0, 255, 255), 1.5f);
plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f);
Main.dust[plasmaDust].velocity *= 2f;
Main.dust[plasmaDust].noGravity = true;
}
+17 -25
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using CalamityMod.Events;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items;
using CalamityMod.Items.Accessories;
using CalamityMod.Items.Armor.Vanity;
@@ -94,10 +95,6 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
public ThanatosSmokeParticleSet SmokeDrawer = new ThanatosSmokeParticleSet(-1, 3, 0f, 16f, 1.5f);
// Drawers for arm segments.
public PrimitiveTrail LightningDrawer;
public PrimitiveTrail LightningBackgroundDrawer;
// This stores the sound slot of the deathray sound Ares makes, so it may be properly updated in terms of position and looped.
public SlotId DeathraySoundSlot;
@@ -199,7 +196,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
{
bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[]
bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[]
{
new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Ares")
});
@@ -316,7 +313,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
Vector2 NeuronLeft = new Vector2(NPC.Center.X - xoffset, NPC.Center.Y + yoffset);
NPC.alpha = 0;
NPC.dontTakeDamage = true;
neurontimer++;
neurontimer++;
if (Main.netMode != NetmodeID.MultiplayerClient)
{
if (neurontimer >= 180)
@@ -330,7 +327,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
Vector2 betweenR = NeuronRight + velocity * 650;
Vector2 betweenL = NeuronLeft + velocity * 650;
Terraria.Audio.SoundEngine.PlaySound(CommonCalamitySounds.LaserCannonSound with { Volume = CommonCalamitySounds.LaserCannonSound.Volume - 0.2f, Pitch = CommonCalamitySounds.LaserCannonSound.Pitch + 0.2f }, NeuronRight);
Projectile.NewProjectile(NPC.GetSource_FromAI(), betweenL, betweenL + velocity, ModContent.ProjectileType<ArtemisLaser>(), 111, 0f, Main.myPlayer, 7, NPC.whoAmI);
Projectile.NewProjectile(NPC.GetSource_FromAI(), betweenR, betweenR + velocity, ModContent.ProjectileType<ArtemisLaser>(), 111, 0f, Main.myPlayer, 7, NPC.whoAmI);
@@ -922,7 +919,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
if (calamityGlobalNPC.newAI[2] == deathrayTelegraphDuration)
{
DeathraySoundSlot = SoundEngine.PlaySound(LaserStartSound, NPC.Center);
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int type = ModContent.ProjectileType<AresDeathBeamStart>();
@@ -1279,11 +1276,6 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
public void DrawArm(SpriteBatch spriteBatch, Vector2 handPosition, Vector2 screenOffset, Color glowmaskColor, int direction, bool backArm)
{
if (LightningDrawer is null)
LightningDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, PrimitiveTrail.RigidPointRetreivalFunction);
if (LightningBackgroundDrawer is null)
LightningBackgroundDrawer = new PrimitiveTrail(BackgroundWidthFunction, BackgroundColorFunction, PrimitiveTrail.RigidPointRetreivalFunction);
SpriteEffects spriteDirection = direction == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
float distanceFromHand = NPC.Distance(handPosition);
float frameTime = Main.GlobalTimeWrappedHourly * 0.9f % 1f;
@@ -1336,13 +1328,13 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
if (NPC.Opacity > 0f && !NPC.IsABestiaryIconDummy)
{
List<Vector2> arm2ElectricArcPoints = AresTeslaOrb.DetermineElectricArcPoints(armSegmentDrawPosition, arm2DrawPosition + arm2Rotation.ToRotationVector2() * -direction * 20f, 250290787);
LightningBackgroundDrawer.Draw(arm2ElectricArcPoints, -Main.screenPosition, 90);
LightningDrawer.Draw(arm2ElectricArcPoints, -Main.screenPosition, 90);
PrimitiveSet.Prepare(arm2ElectricArcPoints, new(BackgroundWidthFunction, BackgroundColorFunction, smoothen: false), 90);
PrimitiveSet.Prepare(arm2ElectricArcPoints, new(WidthFunction, ColorFunction, smoothen: false), 90);
// Draw electricity between the final arm and the hand.
List<Vector2> handElectricArcPoints = AresTeslaOrb.DetermineElectricArcPoints(arm2DrawPosition - arm2Rotation.ToRotationVector2() * direction * 100f, handPosition, 27182);
LightningBackgroundDrawer.Draw(handElectricArcPoints, -Main.screenPosition, 90);
LightningDrawer.Draw(handElectricArcPoints, -Main.screenPosition, 90);
PrimitiveSet.Prepare(handElectricArcPoints, new(BackgroundWidthFunction, BackgroundColorFunction, smoothen: false), 90);
PrimitiveSet.Prepare(handElectricArcPoints, new(WidthFunction, ColorFunction, smoothen: false), 90);
}
shoulderDrawPosition += Vector2.UnitY * NPC.gfxOffY - screenOffset;
@@ -1398,13 +1390,13 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
if (NPC.Opacity > 0f && !NPC.IsABestiaryIconDummy)
{
List<Vector2> arm2ElectricArcPoints = AresTeslaOrb.DetermineElectricArcPoints(arm1DrawPosition - arm2Rotation.ToRotationVector2() * direction * 10f, arm1DrawPosition + arm2Rotation.ToRotationVector2() * direction * 20f, 31416);
LightningBackgroundDrawer.Draw(arm2ElectricArcPoints, -Main.screenPosition, 90);
LightningDrawer.Draw(arm2ElectricArcPoints, -Main.screenPosition, 90);
PrimitiveSet.Prepare(arm2ElectricArcPoints, new(BackgroundWidthFunction, BackgroundColorFunction, smoothen: false), 90);
PrimitiveSet.Prepare(arm2ElectricArcPoints, new(WidthFunction, ColorFunction, smoothen: false), 90);
// Draw electricity between the final arm and the hand.
List<Vector2> handElectricArcPoints = AresTeslaOrb.DetermineElectricArcPoints(arm2DrawPosition - arm2Rotation.ToRotationVector2() * direction * 20f, handPosition, 27182);
LightningBackgroundDrawer.Draw(handElectricArcPoints, -Main.screenPosition, 90);
LightningDrawer.Draw(handElectricArcPoints, -Main.screenPosition, 90);
PrimitiveSet.Prepare(handElectricArcPoints, new(BackgroundWidthFunction, BackgroundColorFunction, smoothen: false), 90);
PrimitiveSet.Prepare(handElectricArcPoints, new(WidthFunction, ColorFunction, smoothen: false), 90);
}
shoulderDrawPosition += Vector2.UnitY * NPC.gfxOffY - screenOffset;
@@ -1597,7 +1589,7 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
public override void HitEffect(NPC.HitInfo hit)
{
for (int k = 0; k < 3; k++)
Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.TerraBlade, 0f, 0f, 100, new Color(0, 255, 255), 1f);
Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f);
if (NPC.soundDelay == 0)
{
@@ -1609,14 +1601,14 @@ namespace CalamityMod.NPCs.ExoMechs.Ares
{
for (int i = 0; i < 2; i++)
{
Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.TerraBlade, 0f, 0f, 100, new Color(0, 255, 255), 1.5f);
Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f);
}
for (int j = 0; j < 20; j++)
{
int plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.TerraBlade, 0f, 0f, 0, new Color(0, 255, 255), 2.5f);
int plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f);
Main.dust[plasmaDust].noGravity = true;
Main.dust[plasmaDust].velocity *= 3f;
plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.TerraBlade, 0f, 0f, 100, new Color(0, 255, 255), 1.5f);
plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f);
Main.dust[plasmaDust].velocity *= 2f;
Main.dust[plasmaDust].noGravity = true;
}
+10 -26
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using CalamityMod.Events;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Potions;
using CalamityMod.NPCs.ExoMechs.Ares;
using CalamityMod.NPCs.ExoMechs.Thanatos;
@@ -148,13 +149,6 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
// Intensity of flash effects during the charge combo
public float ChargeFlash;
// Primitive trail drawers for thrusters when charging
public PrimitiveTrail ChargeFlameTrail = null;
public PrimitiveTrail ChargeFlameTrailBig = null;
// Primitive trail drawer for the ribbon things
public PrimitiveTrail RibbonTrail = null;
//This stores the sound slot of the ML laser sound it makes, so it may be properly updated in terms of position.
private SlotId DeathraySoundSlot;
@@ -204,7 +198,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry)
{
bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[]
bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[]
{
new FlavorTextBestiaryInfoElement("Mods.CalamityMod.Bestiary.Artemis")
});
@@ -1128,7 +1122,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
{
calamityGlobalNPC.newAI[3] = 0f;
AIState = (float)Phase.Deathray;
for (int i = 0; i < Main.maxProjectiles; i++)
for (int i = 0; i < Main.maxProjectiles; i ++)
{
if (Main.projectile[i].type == ModContent.ProjectileType<ArtemisSpinLaserbeam>())
{
@@ -1392,16 +1386,6 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
{
// Declare the trail drawers if they have yet to be defined.
if (ChargeFlameTrail is null)
ChargeFlameTrail = new PrimitiveTrail(FlameTrailWidthFunction, FlameTrailColorFunction, null, GameShaders.Misc["CalamityMod:ImpFlameTrail"]);
if (ChargeFlameTrailBig is null)
ChargeFlameTrailBig = new PrimitiveTrail(FlameTrailWidthFunctionBig, FlameTrailColorFunctionBig, null, GameShaders.Misc["CalamityMod:ImpFlameTrail"]);
if (RibbonTrail is null)
RibbonTrail = new PrimitiveTrail(RibbonTrailWidthFunction, RibbonTrailColorFunction);
// Prepare the flame trail shader with its map texture.
GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak"));
@@ -1464,7 +1448,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
currentSegmentRotation += segmentRotationOffset;
}
RibbonTrail.Draw(ribbonDrawPositions, -screenPos, 66);
PrimitiveSet.Prepare(ribbonDrawPositions, new(RibbonTrailWidthFunction, RibbonTrailColorFunction), 66);
}
int instanceCount = (int)MathHelper.Lerp(1f, 15f, ChargeFlash);
@@ -1529,11 +1513,11 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
for (int i = 0; i < 4; i++)
{
Vector2 drawOffset = (MathHelper.TwoPi * i / 4f).ToRotationVector2() * 8f;
ChargeFlameTrailBig.Draw(drawPositions, drawOffset - screenPos, 70);
PrimitiveSet.Prepare(drawPositions, new(FlameTrailWidthFunctionBig, FlameTrailColorFunctionBig, (_) => drawOffset, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 70);
}
}
else
ChargeFlameTrail.Draw(drawPositions, -screenPos, 70);
PrimitiveSet.Prepare(drawPositions, new(FlameTrailWidthFunction, FlameTrailColorFunction, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 70);
}
}
@@ -1552,7 +1536,7 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
public override void HitEffect(NPC.HitInfo hit)
{
for (int k = 0; k < 3; k++)
Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.TerraBlade, 0f, 0f, 100, new Color(0, 255, 255), 1f);
Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1f);
if (NPC.soundDelay == 0)
{
@@ -1564,14 +1548,14 @@ namespace CalamityMod.NPCs.ExoMechs.Artemis
{
for (int i = 0; i < 2; i++)
{
Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.TerraBlade, 0f, 0f, 100, new Color(0, 255, 255), 1.5f);
Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f);
}
for (int j = 0; j < 20; j++)
{
int plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.TerraBlade, 0f, 0f, 0, new Color(0, 255, 255), 2.5f);
int plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 0, new Color(0, 255, 255), 2.5f);
Main.dust[plasmaDust].noGravity = true;
Main.dust[plasmaDust].velocity *= 3f;
plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, DustID.TerraBlade, 0f, 0f, 100, new Color(0, 255, 255), 1.5f);
plasmaDust = Dust.NewDust(new Vector2(NPC.position.X, NPC.position.Y), NPC.width, NPC.height, 107, 0f, 0f, 100, new Color(0, 255, 255), 1.5f);
Main.dust[plasmaDust].velocity *= 2f;
Main.dust[plasmaDust].noGravity = true;
}
+2 -4
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Projectiles.Rogue;
using CalamityMod.World;
using Microsoft.Xna.Framework;
@@ -13,7 +14,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas
{
public class BrimstoneHeart : ModNPC
{
public PrimitiveTrail ChainDrawer = null;
public int ChainHeartIndex => (int)NPC.ai[0];
public List<Vector2> ChainEndpoints = new();
public override void SetStaticDefaults()
@@ -113,8 +113,6 @@ namespace CalamityMod.NPCs.SupremeCalamitas
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
{
if (ChainDrawer is null)
ChainDrawer = new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction);
if (NPC.IsABestiaryIconDummy)
return true;
@@ -125,7 +123,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas
NPC.Center,
ChainEndpoints[i] + NPC.DirectionTo(ChainEndpoints[i]) * 25f
};
ChainDrawer.Draw(points, -screenPos, 40);
PrimitiveSet.Prepare(points, new(PrimitiveWidthFunction, PrimitiveColorFunction), 40);
}
return true;
+2 -5
View File
@@ -1,5 +1,6 @@
using System.IO;
using CalamityMod.Events;
using CalamityMod.Graphics.Primitives;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Terraria;
@@ -17,7 +18,6 @@ namespace CalamityMod.Projectiles.Boss
public NPC ThingToAttachTo => Main.npc.IndexInRange((int)Projectile.ai[1]) ? Main.npc[(int)Projectile.ai[1]] : null;
public PrimitiveTrail TelegraphDrawer = null;
public const float TelegraphFadeTime = 15f;
public const float TelegraphWidth = 1132.07774f; // a squared plus b squared equals c squared, dumbass
@@ -113,9 +113,6 @@ namespace CalamityMod.Projectiles.Boss
public override bool PreDraw(ref Color lightColor)
{
if (TelegraphDrawer is null)
TelegraphDrawer = new PrimitiveTrail(TelegraphPrimitiveWidth, TelegraphPrimitiveColor, PrimitiveTrail.RigidPointRetreivalFunction, GameShaders.Misc["CalamityMod:Flame"]);
GameShaders.Misc["CalamityMod:Flame"].UseImage1("Images/Misc/Perlin");
GameShaders.Misc["CalamityMod:Flame"].UseSaturation(0.41f);
@@ -131,7 +128,7 @@ namespace CalamityMod.Projectiles.Boss
// It is not used anywhere else.
Projectile.ai[0] = i;
TelegraphDrawer.Draw(positions, Projectile.Size * 0.5f - Main.screenPosition, 55);
PrimitiveSet.Prepare(positions, new(TelegraphPrimitiveWidth, TelegraphPrimitiveColor, (_) => Projectile.Size * 0.5f, smoothen: false, shader: GameShaders.Misc["CalamityMod:Flame"]), 55);
}
return false;
}
+5 -11
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using CalamityMod.Events;
using CalamityMod.Graphics.Primitives;
using CalamityMod.NPCs;
using CalamityMod.NPCs.ExoMechs.Ares;
using CalamityMod.World;
@@ -16,8 +17,6 @@ namespace CalamityMod.Projectiles.Boss
{
public new string LocalizationCategory => "Projectiles.Boss";
public ref float Identity => ref Projectile.ai[0];
public PrimitiveTrail LightningDrawer;
public PrimitiveTrail LightningBackgroundDrawer;
private const int timeLeft = 480;
public override void SetStaticDefaults()
@@ -95,7 +94,7 @@ namespace CalamityMod.Projectiles.Boss
Vector2 dustVel = new Vector2(dustSpeed, 0.0f).RotatedBy(Projectile.velocity.ToRotation());
dustVel = dustVel.RotatedBy(-angleRandom);
dustVel = dustVel.RotatedByRandom(2f * angleRandom);
int randomDustType = Main.rand.NextBool(2)? 206 : 229;
int randomDustType = Main.rand.Next(2) == 0 ? 206 : 229;
float scale = randomDustType == 206 ? 1.5f : 1f;
int teslaDust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 200, default, 2.5f * scale);
@@ -121,7 +120,7 @@ namespace CalamityMod.Projectiles.Boss
Vector2 dustVel = new Vector2(dustSpeed, 0f).RotatedBy(Projectile.velocity.ToRotation());
dustVel = dustVel.RotatedBy(-angleRandom);
dustVel = dustVel.RotatedByRandom(2f * angleRandom);
int randomDustType = Main.rand.NextBool(2)? 206 : 229;
int randomDustType = Main.rand.Next(2) == 0 ? 206 : 229;
float scale = randomDustType == 206 ? 1.5f : 1f;
int teslaDust2 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, randomDustType, dustVel.X, dustVel.Y, 0, default, 3f * scale);
@@ -226,17 +225,12 @@ namespace CalamityMod.Projectiles.Boss
public override bool PreDraw(ref Color lightColor)
{
if (LightningDrawer is null)
LightningDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, PrimitiveTrail.RigidPointRetreivalFunction);
if (LightningBackgroundDrawer is null)
LightningBackgroundDrawer = new PrimitiveTrail(BackgroundWidthFunction, BackgroundColorFunction, PrimitiveTrail.RigidPointRetreivalFunction);
Projectile orbToAttachTo = GetOrbToAttachTo();
if (orbToAttachTo != null)
{
List<Vector2> arcPoints = DetermineElectricArcPoints(Projectile.Center, orbToAttachTo.Center, 117);
LightningBackgroundDrawer.Draw(arcPoints, -Main.screenPosition, 90);
LightningDrawer.Draw(arcPoints, -Main.screenPosition, 90);
PrimitiveSet.Prepare(arcPoints, new(BackgroundWidthFunction, BackgroundColorFunction, smoothen: false), 90);
PrimitiveSet.Prepare(arcPoints, new(WidthFunction, ColorFunction, smoothen: false), 90);
}
lightColor.R = (byte)(255 * Projectile.Opacity);
+2 -6
View File
@@ -1,4 +1,5 @@
using System.IO;
using CalamityMod.Graphics.Primitives;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.Graphics.Shaders;
@@ -15,7 +16,6 @@ namespace CalamityMod.Projectiles.Boss
public NPC ThingToAttachTo => Main.npc.IndexInRange((int)Projectile.ai[1]) ? Main.npc[(int)Projectile.ai[1]] : null;
public Vector2 OldVelocity;
public PrimitiveTrail TelegraphDrawer = null;
public const float TelegraphWidth = 2000f;
public override void SetStaticDefaults()
@@ -89,9 +89,6 @@ namespace CalamityMod.Projectiles.Boss
public override bool PreDraw(ref Color lightColor)
{
if (TelegraphDrawer is null)
TelegraphDrawer = new PrimitiveTrail(TelegraphPrimitiveWidth, TelegraphPrimitiveColor, specialShader: GameShaders.Misc["CalamityMod:Flame"]);
GameShaders.Misc["CalamityMod:Flame"].UseImage1("Images/Misc/Perlin");
GameShaders.Misc["CalamityMod:Flame"].UseSaturation(0.28f);
Vector2[] drawPositions = new Vector2[]
@@ -99,8 +96,7 @@ namespace CalamityMod.Projectiles.Boss
Projectile.Center,
Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitY) * TelegraphWidth
};
TelegraphDrawer.Draw(drawPositions, Projectile.Size * 0.5f - Main.screenPosition, 87);
PrimitiveSet.Prepare(drawPositions, new(TelegraphPrimitiveWidth, TelegraphPrimitiveColor, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:Flame"]), 87);
return false;
}
}
+2 -8
View File
@@ -2,6 +2,7 @@
using System.IO;
using System.Linq;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Graphics.Primitives;
using CalamityMod.NPCs.ExoMechs.Artemis;
using CalamityMod.Projectiles.BaseProjectiles;
using Microsoft.Xna.Framework;
@@ -17,11 +18,6 @@ namespace CalamityMod.Projectiles.Boss
public class ArtemisSpinLaserbeam : BaseLaserbeamProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Boss";
public PrimitiveTrail LaserDrawer
{
get;
set;
} = null;
public int OwnerIndex
{
@@ -136,7 +132,6 @@ namespace CalamityMod.Projectiles.Boss
// This should never happen, but just in case.
if (Projectile.velocity == Vector2.Zero)
return false;
LaserDrawer ??= new(LaserWidthFunction, LaserColorFunction, null, GameShaders.Misc["CalamityMod:ArtemisLaser"]);
Vector2 laserEnd = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitY) * LaserLength;
Vector2[] baseDrawPoints = new Vector2[8];
@@ -147,8 +142,7 @@ namespace CalamityMod.Projectiles.Boss
GameShaders.Misc["CalamityMod:ArtemisLaser"].UseColor(Color.Cyan);
GameShaders.Misc["CalamityMod:ArtemisLaser"].UseImage1("Images/Extra_189");
GameShaders.Misc["CalamityMod:ArtemisLaser"].UseImage2("Images/Misc/Perlin");
LaserDrawer.Draw(baseDrawPoints, -Main.screenPosition, 64);
PrimitiveSet.Prepare(baseDrawPoints, new(LaserWidthFunction, LaserColorFunction, shader: GameShaders.Misc["CalamityMod:ArtemisLaser"]), 64);
return false;
}
@@ -1,5 +1,6 @@
using System;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Graphics.Primitives;
using CalamityMod.NPCs.SupremeCalamitas;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -17,7 +18,6 @@ namespace CalamityMod.Projectiles.Boss
public override string Texture => "CalamityMod/Projectiles/Melee/PrismTooth";
internal PrimitiveTrail TrailDrawer;
public const int Lifetime = 80;
public NPC Cirrus => Main.npc.IndexInRange((int)Projectile.ai[2]) ? Main.npc[(int)Projectile.ai[2]] : null;
@@ -138,9 +138,6 @@ namespace CalamityMod.Projectiles.Boss
if (Time <= 5f)
return true;
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:PrismaticStreak"]);
// Variable adjustment vector used to prevent the trail for starting somewhat that isn't behind
// the crystal. This may appear in small amounts, with offsets of a few pixels, but at the speed
// these crystals go, it's probably not something to worry too much about.
@@ -158,7 +155,7 @@ namespace CalamityMod.Projectiles.Boss
Main.spriteBatch.EnterShaderRegion();
GameShaders.Misc["CalamityMod:PrismaticStreak"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak"));
TrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f + generalOffset - Main.screenPosition, 65);
PrimitiveSet.Prepare(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + generalOffset, shader: GameShaders.Misc["CalamityMod:PrismaticStreak"]), 65);
Main.spriteBatch.ExitShaderRegion();
return true;
}
+4 -7
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Weapons.DraedonsArsenal;
using CalamityMod.World;
using Microsoft.Xna.Framework;
@@ -17,10 +18,9 @@ namespace CalamityMod.Projectiles.Boss
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public PrimitiveTrail RayDrawer = null;
private const int Lifetime = CalamityWorld.DraedonSummonCountdownMax - 60;
public override void SetStaticDefaults()
public override void SetStaticDefaults()
{
ProjectileID.Sets.DrawScreenCheckFluff[Projectile.type] = 10000;
}
@@ -80,17 +80,14 @@ namespace CalamityMod.Projectiles.Boss
public override bool PreDraw(ref Color lightColor)
{
if (RayDrawer is null)
RayDrawer = new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, specialShader: GameShaders.Misc["CalamityMod:Flame"]);
GameShaders.Misc["CalamityMod:Flame"].UseImage1("Images/Misc/Perlin");
Vector2[] basePoints = new Vector2[8];
for (int i = 0; i < basePoints.Length; i++)
basePoints[i] = Projectile.Center - Vector2.UnitY * i / basePoints.Length * LaserLength;
Vector2 overallOffset = Projectile.Size * 0.5f - Main.screenPosition;
RayDrawer.Draw(basePoints, overallOffset, 92);
Vector2 overallOffset = Projectile.Size * 0.5f;
PrimitiveSet.Prepare(basePoints, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => overallOffset, shader: GameShaders.Misc["CalamityMod:Flame"]), 92);
return false;
}
+3 -7
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using CalamityMod.Graphics.Primitives;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Terraria;
@@ -11,8 +12,7 @@ namespace CalamityMod.Projectiles.Boss
{
public class DyingSun : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Boss";
public PrimitiveTrail FireDrawer;
public new string LocalizationCategory => "Projectiles.Boss";
public ref float Time => ref Projectile.ai[0];
public ref float Radius => ref Projectile.ai[1];
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
@@ -51,9 +51,6 @@ namespace CalamityMod.Projectiles.Boss
public override bool PreDraw(ref Color lightColor)
{
if (FireDrawer is null)
FireDrawer = new PrimitiveTrail(SunWidthFunction, SunColorFunction, null, GameShaders.Misc["CalamityMod:Flame"]);
GameShaders.Misc["CalamityMod:Flame"].UseSaturation(0.45f);
GameShaders.Misc["CalamityMod:Flame"].UseImage1("Images/Misc/Perlin");
@@ -72,8 +69,7 @@ namespace CalamityMod.Projectiles.Boss
rotationPoints.Add(adjustedAngle);
drawPoints.Add(Vector2.Lerp(Projectile.Center - offsetDirection * Radius / 2f, Projectile.Center + offsetDirection * Radius / 2f, i / 16f));
}
FireDrawer.Draw(drawPoints, -Main.screenPosition, 24);
PrimitiveSet.Prepare(drawPoints, new(SunWidthFunction, SunColorFunction, shader: GameShaders.Misc["CalamityMod:Flame"]), 24);
}
return false;
}
+2 -5
View File
@@ -1,6 +1,7 @@
using System.IO;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.CalPlayer;
using CalamityMod.Graphics.Primitives;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -13,7 +14,6 @@ namespace CalamityMod.Projectiles.Boss
public class InfernadoRevenge : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Boss";
internal PrimitiveTrail TornadoDrawer;
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public const int TornadoHeight = 8800;
public override void SetStaticDefaults()
@@ -72,9 +72,6 @@ namespace CalamityMod.Projectiles.Boss
public override bool PreDraw(ref Color lightColor)
{
if (TornadoDrawer is null)
TornadoDrawer = new PrimitiveTrail(_ => Projectile.width * 0.5f + 16f, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:Bordernado"]);
GameShaders.Misc["CalamityMod:Bordernado"].UseSaturation(-0.2f);
GameShaders.Misc["CalamityMod:Bordernado"].SetShaderTexture(ModContent.Request<Texture2D>("Terraria/Images/Misc/Perlin"));
Vector2[] drawPoints = new Vector2[5];
@@ -87,7 +84,7 @@ namespace CalamityMod.Projectiles.Boss
drawPoints[i] = Vector2.Lerp(top, bottom, i / (float)(drawPoints.Length - 1));
drawPoints[drawPoints.Length - 1] = bottom;
TornadoDrawer.Draw(drawPoints, -Main.screenPosition, 85);
PrimitiveSet.Prepare(drawPoints, new((_) => Projectile.width * 0.5f + 16f, ColorFunction, shader: GameShaders.Misc["CalamityMod:Bordernado"]), 85);
Texture2D vortexTexture = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Boss/OldDukeVortex").Value;
for (int i = 0; i < 110; i++)
@@ -2,6 +2,7 @@
using System.IO;
using System.Linq;
using CalamityMod.Dusts;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items;
using CalamityMod.Items.Weapons.DraedonsArsenal;
using CalamityMod.Items.Weapons.Ranged;
@@ -137,7 +138,7 @@ namespace CalamityMod.Projectiles.DraedonsArsenal
// This formula ensures that the sword has a sudden and extremely harsh responsiveness penalty when the mouse is close to the player.
// Otherwise it controls perfectly fine.
float aimResponsiveness = 0.035f + 0.3f * (float)Math.Pow(distRatio, 1D / 3);
float aimResponsiveness = 0.035f + 0.3f * (float)Math.Pow(distRatio, 1D/3);
// Update the sword's angle with the responsiveness determined by mouse position.
// Also flag for netcode sync if applicable (this is the only way the sword can rotate in multiplayer).
@@ -271,7 +272,6 @@ namespace CalamityMod.Projectiles.DraedonsArsenal
}
}
internal PrimitiveTrail TrailDrawer;
internal Color ColorFunction(float completionRatio)
{
float averageRotation = Projectile.oldRot.Take(20).Average(angle => MathHelper.WrapAngle(angle) + MathHelper.Pi);
@@ -307,9 +307,6 @@ namespace CalamityMod.Projectiles.DraedonsArsenal
Rectangle frame = IsSmall ? bladeTexture.Frame(1, 3, 0, BladeFrameY) : bladeTexture.Frame(3, 7, BladeFrameX, BladeFrameY);
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"]);
GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/SwordSlashTexture"));
Player player = Main.player[Projectile.owner];
@@ -327,8 +324,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal
float angularTurn = i * swingAngularDirection * -0.09f;
drawPoints[i] = Projectile.position + perpendicularDirection.RotatedBy(angularTurn) * offsetFactor;
}
PrimitiveSet.Prepare(drawPoints, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + bladeOffset, shader: GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"]), 50);
TrailDrawer.Draw(drawPoints, Projectile.Size * 0.5f + bladeOffset - Main.screenPosition, 50);
Main.EntitySpriteDraw(bladeTexture, Projectile.Center + bladeOffset - Main.screenPosition, frame, Color.White, Projectile.rotation + MathHelper.PiOver2, origin, Projectile.scale, SpriteEffects.None, 0);
Main.EntitySpriteDraw(hiltTexture, Projectile.Center - Main.screenPosition, null, lightColor, Projectile.rotation + MathHelper.PiOver2, hiltTexture.Size() * 0.5f, Projectile.scale, SpriteEffects.None, 0);
@@ -1,5 +1,6 @@
using System;
using System.IO;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Weapons.DraedonsArsenal;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
@@ -184,10 +185,8 @@ namespace CalamityMod.Projectiles.DraedonsArsenal
Vector2 origin = frame.Size() * 0.5f;
Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0);
PrimitiveTrail trail = new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]);
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/FabstaffStreak"));
trail.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition, 92);
PrimitiveSet.Prepare(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 92);
return false;
}
}
+2 -7
View File
@@ -2,6 +2,7 @@
using System.IO;
using System.Linq;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Graphics.Primitives;
using CalamityMod.NPCs.AcidRain;
using CalamityMod.Projectiles.BaseProjectiles;
using Microsoft.Xna.Framework;
@@ -17,11 +18,6 @@ namespace CalamityMod.Projectiles.Enemy
public class GammaRayBurst : BaseLaserbeamProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Enemy";
public PrimitiveTrail LaserDrawer
{
get;
set;
} = null;
public int OwnerIndex
{
@@ -112,7 +108,6 @@ namespace CalamityMod.Projectiles.Enemy
// This should never happen, but just in case.
if (Projectile.velocity == Vector2.Zero)
return false;
LaserDrawer ??= new(LaserWidthFunction, LaserColorFunction, null, GameShaders.Misc["CalamityMod:ArtemisLaser"]);
Vector2 laserEnd = Projectile.Center + Projectile.velocity.SafeNormalize(Vector2.UnitY) * LaserLength;
Vector2[] baseDrawPoints = new Vector2[8];
@@ -124,7 +119,7 @@ namespace CalamityMod.Projectiles.Enemy
GameShaders.Misc["CalamityMod:ArtemisLaser"].UseImage1("Images/Extra_189");
GameShaders.Misc["CalamityMod:ArtemisLaser"].UseImage2("Images/Misc/Perlin");
LaserDrawer.Draw(baseDrawPoints, -Main.screenPosition, 64);
PrimitiveSet.Prepare(baseDrawPoints, new(LaserWidthFunction, LaserColorFunction, shader: GameShaders.Misc["CalamityMod:ArtemisLaser"]), 64);
return false;
}
+2 -5
View File
@@ -1,4 +1,5 @@
using System;
using CalamityMod.Graphics.Primitives;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
@@ -8,7 +9,6 @@ namespace CalamityMod.Projectiles.Magic
public class ApotheosisEnergy : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Magic";
internal PrimitiveTrail TrailDrawer = null;
public override void SetStaticDefaults()
{
@@ -88,10 +88,7 @@ namespace CalamityMod.Projectiles.Magic
public override bool PreDraw(ref Color lightColor)
{
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction);
TrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition, 85);
PrimitiveSet.Prepare(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f), 85);
return false;
}
}
+4 -7
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Weapons.Magic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -15,7 +16,6 @@ namespace CalamityMod.Projectiles.Magic
public class ArtAttackStar : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Magic";
public PrimitiveTrail TrailDrawer = null;
public Player Owner => Main.player[Projectile.owner];
public ref float Time => ref Projectile.ai[0];
public const int StarShapeCreationDelay = 12;
@@ -60,7 +60,7 @@ namespace CalamityMod.Projectiles.Magic
for (int i = end - 1; i >= start; i--)
{
float distanceFromStar = Vector2.Distance(Projectile.position, Projectile.oldPos[i]);
if (distanceFromStar < (distanceTraveled * 0.7f + 30f))
if (distanceFromStar < (distanceTraveled * 0.7f + 30f))
{
shapeIsComplete = true;
@@ -119,7 +119,7 @@ namespace CalamityMod.Projectiles.Magic
for (int i = 0; i < 3; i++)
{
Dust rainbowMagic = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(8f, 8f), 261);
rainbowMagic.velocity = Main.rand.NextVector2Circular(6f, 6f) - ((Projectile.position - Projectile.oldPos[1]) / 3f).RotatedByRandom(0.51f);
rainbowMagic.velocity = Main.rand.NextVector2Circular(6f, 6f) - ((Projectile.position - Projectile.oldPos[1])/3f).RotatedByRandom(0.51f);
rainbowMagic.color = Main.hslToRgb(Main.rand.NextFloat(), 1f, Main.rand.NextFloat(0.5f, 0.9f));
rainbowMagic.color.A = 128;
@@ -217,9 +217,6 @@ namespace CalamityMod.Projectiles.Magic
public override bool PreDraw(ref Color lightColor)
{
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(TrailWidth, TrailColor, null, GameShaders.Misc["CalamityMod:ArtAttack"]);
Texture2D texture = ModContent.Request<Texture2D>(Texture).Value;
Vector2 drawPosition = Projectile.Center - Main.screenPosition + Vector2.UnitY * Projectile.gfxOffY;
Vector2 origin = texture.Size() * 0.5f;
@@ -228,7 +225,7 @@ namespace CalamityMod.Projectiles.Magic
GameShaders.Misc["CalamityMod:ArtAttack"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/FabstaffStreak"));
GameShaders.Misc["CalamityMod:ArtAttack"].Apply();
TrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition, 180);
PrimitiveSet.Prepare(Projectile.oldPos, new(TrailWidth, TrailColor, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ArtAttack"]), 180);
Main.spriteBatch.ExitShaderRegion();
Main.EntitySpriteDraw(texture, drawPosition, null, Projectile.GetAlpha(Color.White), Projectile.rotation, origin, Projectile.scale, 0, 0);
+2 -5
View File
@@ -1,4 +1,5 @@
using System;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Weapons.Magic;
using CalamityMod.Projectiles.Typeless;
using Microsoft.Xna.Framework;
@@ -16,7 +17,6 @@ namespace CalamityMod.Projectiles.Magic
public new string LocalizationCategory => "Projectiles.Magic";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
internal PrimitiveTrail LemniscateDrawer = null;
public int TargetNPCIndex
{
get => (int)Projectile.ai[0];
@@ -228,11 +228,8 @@ namespace CalamityMod.Projectiles.Magic
public override bool PreDraw(ref Color lightColor)
{
if (LemniscateDrawer is null)
LemniscateDrawer = new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, null, GameShaders.Misc["CalamityMod:TrailStreak"]);
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/EternityStreak"));
LemniscateDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition, 84);
PrimitiveSet.Prepare(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 84);
return false;
}
}
+4 -4
View File
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Weapons.Magic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -13,7 +14,6 @@ namespace CalamityMod.Projectiles.Magic
public class ExoVortex : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Magic";
public PrimitiveTrail EnergyTrail = null;
public float Hue => Projectile.ai[0];
@@ -105,6 +105,8 @@ namespace CalamityMod.Projectiles.Magic
return c * Utils.GetLerpValue(0.04f, 0.2f, completionRatio, true) * velocityOpacityFadeout;
}
public Vector2 PrimitiveOffsetFunction(float completionRatio) => Projectile.Size * 0.5f + Projectile.velocity.SafeNormalize(Vector2.Zero) * Projectile.scale * 2f;
public override bool PreDraw(ref Color lightColor)
{
Main.spriteBatch.EnterShaderRegion(BlendState.Additive);
@@ -114,10 +116,8 @@ namespace CalamityMod.Projectiles.Magic
Main.spriteBatch.EnterShaderRegion();
// Draw the streak trail.
EnergyTrail ??= new(PrimitiveWidthFunction, PrimitiveTrailColor, null, GameShaders.Misc["CalamityMod:SideStreakTrail"]);
GameShaders.Misc["CalamityMod:SideStreakTrail"].UseImage1("Images/Misc/Perlin");
EnergyTrail.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition + Projectile.velocity.SafeNormalize(Vector2.Zero) * Projectile.scale * 2f, 51);
PrimitiveSet.Prepare(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveTrailColor, PrimitiveOffsetFunction, shader: GameShaders.Misc["CalamityMod:SideStreakTrail"]), 51);
Main.spriteBatch.EnterShaderRegion(BlendState.Additive);
GameShaders.Misc["CalamityMod:ExoVortex"].Apply();
+4 -4
View File
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Weapons.Magic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -13,7 +14,6 @@ namespace CalamityMod.Projectiles.Magic
public class ExoVortex2 : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Magic";
public PrimitiveTrail EnergyTrail = null;
public float Hue => Projectile.ai[0];
@@ -109,6 +109,8 @@ namespace CalamityMod.Projectiles.Magic
return c * Utils.GetLerpValue(0.04f, 0.2f, completionRatio, true) * velocityOpacityFadeout;
}
public Vector2 PrimitiveOffsetFunction(float completionRatio) => Projectile.Size * 0.5f + Projectile.velocity.SafeNormalize(Vector2.Zero) * Projectile.scale * 2f;
public override bool PreDraw(ref Color lightColor)
{
Main.spriteBatch.EnterShaderRegion(BlendState.Additive);
@@ -118,10 +120,8 @@ namespace CalamityMod.Projectiles.Magic
Main.spriteBatch.EnterShaderRegion();
// Draw the streak trail.
EnergyTrail ??= new(PrimitiveWidthFunction, PrimitiveTrailColor, null, GameShaders.Misc["CalamityMod:SideStreakTrail"]);
GameShaders.Misc["CalamityMod:SideStreakTrail"].UseImage1("Images/Misc/Perlin");
EnergyTrail.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition + Projectile.velocity.SafeNormalize(Vector2.Zero) * Projectile.scale * 2f, 51);
PrimitiveSet.Prepare(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveTrailColor, PrimitiveOffsetFunction, shader: GameShaders.Misc["CalamityMod:SideStreakTrail"]), 51);
Main.spriteBatch.EnterShaderRegion(BlendState.Additive);
GameShaders.Misc["CalamityMod:ExoVortex"].Apply();
+2 -5
View File
@@ -1,4 +1,5 @@
using System;
using CalamityMod.Graphics.Primitives;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -10,7 +11,6 @@ namespace CalamityMod.Projectiles.Magic
public class FabBolt : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Magic";
internal PrimitiveTrail TrailDrawer;
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public bool FadingOut
@@ -71,11 +71,8 @@ namespace CalamityMod.Projectiles.Magic
public override bool PreDraw(ref Color lightColor)
{
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, PrimitiveTrail.RigidPointRetreivalFunction, GameShaders.Misc["CalamityMod:TrailStreak"]);
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/FabstaffStreak"));
TrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition, 80, Projectile.oldRot);
PrimitiveSet.Prepare(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, smoothen: false, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 80);
return false;
}
+5 -5
View File
@@ -1,5 +1,6 @@
using System;
using CalamityMod.Buffs.Alcohol;
using CalamityMod.Graphics.Primitives;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -12,7 +13,7 @@ namespace CalamityMod.Projectiles.Magic
public class FabRay : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Magic";
internal PrimitiveTrail TrailDrawer;
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public override void SetStaticDefaults()
@@ -100,13 +101,12 @@ namespace CalamityMod.Projectiles.Magic
return MathHelper.Lerp(0f, 32f * Projectile.Opacity, expansionCompletion);
}
internal Vector2 OffsetFunction(float completionRatio) => Projectile.Size * 0.5f;
public override bool PreDraw(ref Color lightColor)
{
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]);
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak"));
TrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition, 32);
PrimitiveSet.Prepare(Projectile.oldPos, new PrimitiveSettings(WidthFunction, ColorFunction, OffsetFunction, pixelate: false, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 32);
return false;
}
+2 -5
View File
@@ -1,5 +1,6 @@
using System;
using CalamityMod.DataStructures;
using CalamityMod.Graphics.Primitives;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -24,7 +25,6 @@ namespace CalamityMod.Projectiles.Magic
Count = 7
}
internal PrimitiveTrail TrailDrawer = null;
public ref float Time => ref Projectile.ai[0];
public PartyCannonExplosionType RocketType
{
@@ -135,11 +135,8 @@ namespace CalamityMod.Projectiles.Magic
public override bool PreDraw(ref Color lightColor)
{
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction);
Projectile.oldPos[0] = Projectile.position + Projectile.velocity.SafeNormalize(Vector2.Zero) * 50f;
TrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition + Projectile.velocity, 80);
PrimitiveSet.Prepare(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + Projectile.velocity), 80);
Texture2D rocketTexture = ModContent.Request<Texture2D>(Texture).Value;
Main.EntitySpriteDraw(rocketTexture,
+2 -5
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Graphics.Metaballs;
using CalamityMod.Graphics.Primitives;
using CalamityMod.World;
using Microsoft.Xna.Framework;
using Terraria;
@@ -15,7 +16,6 @@ namespace CalamityMod.Projectiles.Magic
public class RancorLaserbeam : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Magic";
public PrimitiveTrail RayDrawer = null;
public Player Owner => Main.player[Projectile.owner];
public Projectile MagicCircle
{
@@ -162,16 +162,13 @@ namespace CalamityMod.Projectiles.Magic
public override bool PreDraw(ref Color lightColor)
{
RayDrawer ??= new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, specialShader: GameShaders.Misc["CalamityMod:Flame"]);
GameShaders.Misc["CalamityMod:Flame"].UseImage1("Images/Misc/Perlin");
Vector2[] basePoints = new Vector2[24];
for (int i = 0; i < basePoints.Length; i++)
basePoints[i] = Projectile.Center + Projectile.velocity * i / (basePoints.Length - 1f) * LaserLength;
Vector2 overallOffset = -Main.screenPosition;
RayDrawer.Draw(basePoints, overallOffset, 92);
PrimitiveSet.Prepare(basePoints, new(PrimitiveWidthFunction, PrimitiveColorFunction, shader: GameShaders.Misc["CalamityMod:Flame"]), 92);
return false;
}
+5 -10
View File
@@ -1,4 +1,5 @@
using System;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Weapons.Magic;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
@@ -38,7 +39,6 @@ namespace CalamityMod.Projectiles.Magic
public static float HomingRange = 250;
public static float HomingAngle = MathHelper.PiOver4 * 1.65f;
internal PrimitiveTrail TrailDrawer;
internal Color PrimColorMult = Color.White;
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
@@ -127,7 +127,7 @@ namespace CalamityMod.Projectiles.Magic
{
float distanceFromTarget = (Target.Center - Projectile.Center).Length();
Projectile.rotation = Projectile.rotation.AngleTowards((Target.Center - Projectile.Center).ToRotation(), 0.07f * (float)Math.Pow((1 - distanceFromTarget / HomingRange), 2));
Projectile.rotation = Projectile.rotation.AngleTowards((Target.Center - Projectile.Center).ToRotation(), 0.07f * (float)Math.Pow(( 1 - distanceFromTarget / HomingRange), 2));
}
Projectile.velocity *= 0.983f;
@@ -170,7 +170,7 @@ namespace CalamityMod.Projectiles.Magic
Vector2 velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(MathHelper.Pi / 6f) * Main.rand.NextFloat(4, 10);
GeneralParticleHandler.SpawnParticle(new TechyHoloysquareParticle(center, velocity, Main.rand.NextFloat(1f, 2f), Main.rand.NextBool() ? new Color(99, 255, 229) : new Color(25, 132, 247), 25));
}
}
}
@@ -183,7 +183,7 @@ namespace CalamityMod.Projectiles.Magic
internal float WidthFunction(float completionRatio)
{
return 9.4f;
return 9.4f;
}
public override bool PreDraw(ref Color lightColor)
@@ -191,20 +191,15 @@ namespace CalamityMod.Projectiles.Magic
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]);
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(Request<Texture2D>("CalamityMod/ExtraTextures/Trails/BasicTrail"));
CalamityUtils.DrawChromaticAberration(Vector2.UnitX, 3.5f, delegate (Vector2 offset, Color colorMod)
{
PrimColorMult = colorMod;
TrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition + offset, 30);
PrimitiveSet.Prepare(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + offset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30);
});
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
+2 -6
View File
@@ -1,4 +1,5 @@
using System;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -13,7 +14,6 @@ namespace CalamityMod.Projectiles.Melee
public class EonBolt : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
internal PrimitiveTrail TrailDrawer;
public override string Texture => "CalamityMod/Projectiles/Melee/GalaxiaBolt";
@@ -102,15 +102,11 @@ namespace CalamityMod.Projectiles.Melee
public override bool PreDraw(ref Color lightColor)
{
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]);
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak"));
TrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition, 30);
PrimitiveSet.Prepare(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30);
Texture2D texture = Request<Texture2D>("CalamityMod/Projectiles/Melee/GalaxiaBolt").Value;
Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, Color.Lerp(lightColor, Color.White, 0.5f), Projectile.rotation, texture.Size() / 2f, Projectile.scale, SpriteEffects.None, 0);
return false;
}
}
+5 -17
View File
@@ -1,5 +1,6 @@
using System;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Weapons.Melee;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -21,8 +22,6 @@ namespace CalamityMod.Projectiles.Melee
public static float MaxWidth = 30;
public ref float Time => ref Projectile.ai[0];
public PrimitiveTrail TrailDrawer = null;
public PrimitiveTrail MiniTrailDrawer = null;
public static Asset<Texture2D> BloomTex;
public static Asset<Texture2D> SlashTex;
@@ -148,10 +147,6 @@ namespace CalamityMod.Projectiles.Melee
//Draw the blade.
Main.EntitySpriteDraw(texture, Projectile.oldPos[2] + Projectile.Size / 2f - Main.screenPosition, null, Color.White with { A = 0 }, Projectile.rotation + MathHelper.PiOver4, texture.Size() / 2f, bladeScale * Projectile.scale, 0, 0);
if (BloomTex == null)
BloomTex = ModContent.Request<Texture2D>("CalamityMod/Particles/BloomCircle");
Texture2D bloomTex = BloomTex.Value;
@@ -163,10 +158,6 @@ namespace CalamityMod.Projectiles.Melee
Main.EntitySpriteDraw(bloomTex, Projectile.oldPos[2] + Projectile.Size / 2f - Main.screenPosition, null, (mainColor * 0.1f) with { A = 0 }, 0, bloomTex.Size() / 2f, 1.3f * Projectile.scale, 0, 0);
Main.EntitySpriteDraw(bloomTex, Projectile.oldPos[1] + Projectile.Size / 2f - Main.screenPosition, null, (mainColor * 0.5f) with { A = 0 }, 0, bloomTex.Size() / 2f, 0.34f * Projectile.scale, 0, 0);
TrailDrawer ??= new(TrailWidth, TrailColor, null, GameShaders.Misc["CalamityMod:ExobladePierce"]);
MiniTrailDrawer ??= new(MiniTrailWidth, MiniTrailColor, null, GameShaders.Misc["CalamityMod:ExobladePierce"]);
Main.spriteBatch.EnterShaderRegion();
if (TrailTex == null)
@@ -179,22 +170,19 @@ namespace CalamityMod.Projectiles.Melee
GameShaders.Misc["CalamityMod:ExobladePierce"].Apply();
GameShaders.Misc["CalamityMod:ExobladePierce"].Apply();
TrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition, 30, Projectile.oldRot);
PrimitiveSet.Prepare(Projectile.oldPos, new(TrailWidth, TrailColor, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 30);
GameShaders.Misc["CalamityMod:ExobladePierce"].UseColor(Color.White);
GameShaders.Misc["CalamityMod:ExobladePierce"].UseSecondaryColor(Color.White);
MiniTrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition, 30, Projectile.oldRot);
PrimitiveSet.Prepare(Projectile.oldPos, new(MiniTrailWidth, MiniTrailColor, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 30);
Main.spriteBatch.ExitShaderRegion();
//Draw the bloom above the trail
Main.EntitySpriteDraw(bloomTex, Projectile.oldPos[2] + Projectile.Size / 2f - Main.screenPosition, null, (Color.White * 0.2f) with { A = 0 }, 0, bloomTex.Size() / 2f, 0.78f * Projectile.scale, 0, 0);
Main.EntitySpriteDraw(bloomTex, Projectile.oldPos[1] + Projectile.Size / 2f - Main.screenPosition, null, (Color.White * 0.5f) with { A = 0 }, 0, bloomTex.Size() / 2f, 0.2f * Projectile.scale, 0, 0);
Main.EntitySpriteDraw(bloomTex, Projectile.oldPos[1] + Projectile.Size / 2f - Main.screenPosition, null, (Color.White * 0.5f) with { A = 0 }, 0, bloomTex.Size() / 2f, 0.2f * Projectile.scale, 0, 0);
return false;
}
}
+4 -11
View File
@@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.Dusts;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
@@ -25,10 +26,6 @@ namespace CalamityMod.Projectiles.Melee
public override LocalizedText DisplayName => CalamityUtils.GetItemName<Exoblade>();
public Player Owner => Main.player[Projectile.owner];
public PrimitiveTrail SlashDrawer = null;
public PrimitiveTrail PierceAfterimageDrawer = null;
const float BladeLength = 180;
public int GetSwingTime
@@ -454,10 +451,6 @@ namespace CalamityMod.Projectiles.Melee
if (Projectile.Opacity <= 0f || InPostBonkStasis)
return false;
// Initialize the primitives drawers.
SlashDrawer ??= new(SlashWidthFunction, SlashColorFunction, null, GameShaders.Misc["CalamityMod:ExobladeSlash"]);
PierceAfterimageDrawer ??= new(PierceWidthFunction, PierceColorFunction, null, GameShaders.Misc["CalamityMod:ExobladePierce"]);
DrawSlash();
DrawPierceTrail();
DrawBlade();
@@ -480,7 +473,7 @@ namespace CalamityMod.Projectiles.Melee
GameShaders.Misc["CalamityMod:ExobladeSlash"].Shader.Parameters["flipped"].SetValue(Direction == 1);
GameShaders.Misc["CalamityMod:ExobladeSlash"].Apply();
SlashDrawer.Draw(GenerateSlashPoints(), Projectile.Center - Main.screenPosition, 95);
PrimitiveSet.Prepare(GenerateSlashPoints(), new(SlashWidthFunction, SlashColorFunction, (_) => Projectile.Center, shader: GameShaders.Misc["CalamityMod:ExobladeSlash"]), 95);
Main.spriteBatch.ExitShaderRegion();
}
@@ -499,13 +492,13 @@ namespace CalamityMod.Projectiles.Melee
mainColor = Color.Lerp(Color.White, mainColor, 0.4f + 0.6f * (float)Math.Pow(LungeProgression, 0.5f));
secondaryColor = Color.Lerp(Color.White, secondaryColor, 0.4f + 0.6f * (float)Math.Pow(LungeProgression, 0.5f));
Vector2 trailOffset = (Projectile.rotation - Direction * MathHelper.PiOver4).ToRotationVector2() * 98f + Projectile.Size * 0.5f - Main.screenPosition;
Vector2 trailOffset = (Projectile.rotation - Direction * MathHelper.PiOver4).ToRotationVector2() * 98f + Projectile.Size * 0.5f;
GameShaders.Misc["CalamityMod:ExobladePierce"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/EternityStreak"));
GameShaders.Misc["CalamityMod:ExobladePierce"].UseImage2("Images/Extra_189");
GameShaders.Misc["CalamityMod:ExobladePierce"].UseColor(mainColor);
GameShaders.Misc["CalamityMod:ExobladePierce"].UseSecondaryColor(secondaryColor);
GameShaders.Misc["CalamityMod:ExobladePierce"].Apply();
PierceAfterimageDrawer.Draw(Projectile.oldPos.Take(51), trailOffset, 53);
PrimitiveSet.Prepare(Projectile.oldPos.Take(51), new(PierceWidthFunction, PierceColorFunction, (_) => trailOffset, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 53);
Main.spriteBatch.ExitShaderRegion();
}
+4 -9
View File
@@ -1,4 +1,5 @@
using System;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Tools;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -19,7 +20,6 @@ namespace CalamityMod.Projectiles.Melee
public override string Texture => "CalamityMod/Items/Tools/MarniteObliterator";
public static Asset<Texture2D> GlowmaskTex;
public static Asset<Texture2D> BloomTex;
internal PrimitiveTrail TrailDrawer;
public Player Owner => Main.player[Projectile.owner];
public ref float MoveInIntervals => ref Projectile.localAI[0];
@@ -63,8 +63,8 @@ namespace CalamityMod.Projectiles.Melee
Lighting.AddLight(Projectile.Center, Color.Blue.ToVector3() * 0.7f);
}
if (MoveInIntervals > 0f)
MoveInIntervals -= 1f;
if (MoveInIntervals > 0f)
MoveInIntervals -= 1f;
if (Owner.CantUseHoldout())
Projectile.Kill();
@@ -125,7 +125,6 @@ namespace CalamityMod.Projectiles.Melee
return 29.4f * completionRatio;
}
public void DrawBeam(Texture2D beamTex, Vector2 direction, int beamIndex)
{
Vector2 startPos = Owner.MountedCenter + direction * 17f + direction.RotatedBy(MathHelper.PiOver2) * (float)Math.Cos(MathHelper.TwoPi * beamIndex / 3f + SpeenBeams * 0.06f) * 13f;
@@ -174,12 +173,8 @@ namespace CalamityMod.Projectiles.Melee
Main.EntitySpriteDraw(bloomTex, Projectile.Center - Main.screenPosition, null, Color.DeepSkyBlue * 0.3f, MathHelper.PiOver2, bloomTex.Size() / 2f, 0.3f * Projectile.scale, SpriteEffects.None, 0);
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]);
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/DoubleTrail"));
TrailDrawer.Draw(new Vector2[] { Projectile.Center, Owner.MountedCenter - normalizedVelocity * 13f }, -Main.screenPosition, 30);
PrimitiveSet.Prepare(new Vector2[] { Projectile.Center, Owner.MountedCenter - normalizedVelocity * 13f }, new(WidthFunction, ColorFunction, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30);
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
+2 -5
View File
@@ -1,5 +1,6 @@
using System;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Graphics.Primitives;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -13,7 +14,6 @@ namespace CalamityMod.Projectiles.Melee
public class PrismTooth : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
internal PrimitiveTrail TrailDrawer;
public const int Lifetime = 80;
public Player Owner => Main.player[Projectile.owner];
public ref float ShootReach => ref Projectile.ai[0];
@@ -115,9 +115,6 @@ namespace CalamityMod.Projectiles.Melee
if (Time <= 5f)
return true;
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:PrismaticStreak"]);
// Variable adjustment vector used to prevent the trail for starting somewhat that isn't behind
// the crystal. This may appear in small amounts, with offsets of a few pixels, but at the speed
// these crystals go, it's probably not something to worry too much about.
@@ -135,7 +132,7 @@ namespace CalamityMod.Projectiles.Melee
Main.spriteBatch.EnterShaderRegion();
GameShaders.Misc["CalamityMod:PrismaticStreak"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak"));
TrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f + generalOffset - Main.screenPosition, 65);
PrimitiveSet.Prepare(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + generalOffset, shader: GameShaders.Misc["CalamityMod:PrismaticStreak"]), 65);
Main.spriteBatch.ExitShaderRegion();
return true;
}
+6 -10
View File
@@ -1,4 +1,5 @@
using System;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -16,7 +17,6 @@ namespace CalamityMod.Projectiles.Melee
{
public new string LocalizationCategory => "Projectiles.Melee";
internal PrimitiveTrail TrailDrawer;
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10;
@@ -54,12 +54,12 @@ namespace CalamityMod.Projectiles.Melee
Projectile.velocity *= (1 - (float)Math.Pow(Timer / MaxTime, 3) * 0.3f);
if (Main.rand.NextBool(2))
if (Main.rand.Next(2) == 0)
{
Particle smoke = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, Color.Lerp(Color.DodgerBlue, Color.MediumVioletRed, (float)Math.Sin(Main.GlobalTimeWrappedHourly * 6f)), 30, Main.rand.NextFloat(0.6f, 1.2f) * Projectile.scale * 0.6f, 0.28f, 0, false, 0, true);
GeneralParticleHandler.SpawnParticle(smoke);
if (Main.rand.NextBool(3))
if (Main.rand.Next(3) == 0)
{
Particle smokeGlow = new HeavySmokeParticle(Projectile.Center, Projectile.velocity * 0.5f, Main.hslToRgb(Main.rand.NextFloat(), 1, 0.7f), 20, Main.rand.NextFloat(0.4f, 0.7f) * Projectile.scale * 0.6f, 0.8f, 0, true, 0.05f, true);
GeneralParticleHandler.SpawnParticle(smokeGlow);
@@ -85,6 +85,7 @@ namespace CalamityMod.Projectiles.Melee
return MathHelper.Lerp(0f, 14f * Projectile.scale, expansionCompletion);
}
public Vector2 OffsetFunction(float completionRatio) => Projectile.Size * 0.5f - Utils.SafeNormalize(Projectile.velocity, Vector2.Zero) * 30.5f;
public override bool PreDraw(ref Color lightColor)
{
@@ -93,11 +94,8 @@ namespace CalamityMod.Projectiles.Melee
Texture2D texture = Request<Texture2D>("CalamityMod/Projectiles/Melee/RendingNeedle").Value;
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]);
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak"));
TrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Utils.SafeNormalize(Projectile.velocity, Vector2.Zero) * 30.5f - Main.screenPosition, 30);
PrimitiveSet.Prepare(Projectile.oldPos, new(WidthFunction, ColorFunction, OffsetFunction, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30);
Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, Color.Lerp(lightColor, Color.White, 0.5f), Projectile.rotation, texture.Size() / 2f, Projectile.scale, SpriteEffects.None, 0);
@@ -114,14 +112,12 @@ namespace CalamityMod.Projectiles.Melee
Vector2 sparkCenter = Projectile.Center - Utils.SafeNormalize(Projectile.velocity, Vector2.Zero) * 30.5f - Main.screenPosition;
Main.EntitySpriteDraw(bloomTexture, sparkCenter, null, color * 0.5f, 0, bloomTexture.Size() / 2f, 4 * properBloomSize, SpriteEffects.None, 0);
Main.EntitySpriteDraw(bloomTexture, sparkCenter, null, color* 0.5f, 0, bloomTexture.Size() / 2f, 4 * properBloomSize, SpriteEffects.None, 0);
Main.EntitySpriteDraw(starTexture, sparkCenter, null, color * 0.5f, rotation + MathHelper.PiOver4, starTexture.Size() / 2f, 2 * 0.75f, SpriteEffects.None, 0);
Main.EntitySpriteDraw(starTexture, sparkCenter, null, Color.White, rotation, starTexture.Size() / 2f, 2, SpriteEffects.None, 0);
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
return false;
}
+7 -9
View File
@@ -1,4 +1,5 @@
using System;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
@@ -30,7 +31,6 @@ namespace CalamityMod.Projectiles.Melee
public ref float DashTime => ref Projectile.ai[1];
public Vector2 DashDestination = Vector2.Zero;
internal PrimitiveTrail TrailDrawer;
// Rawest placeholder sound
public static readonly SoundStyle DashSound = new("CalamityMod/Sounds/Custom/ExoMechs/ApolloMissileLaunch") { Volume = 0.6f };
@@ -56,11 +56,11 @@ namespace CalamityMod.Projectiles.Melee
{
if (Owner is null || Owner.dead || Owner.ActiveItem().type != ModContent.ItemType<StygianShield>())
Projectile.Kill();
Owner.heldProj = Projectile.whoAmI;
// TODO -- Windup sound (definitely requires a custom looping sound)
// Dashing behavior
Projectile.Opacity = Utils.GetLerpValue(0f, DashDuration * 0.7f, DashTime, true);
if (DashDestination != Vector2.Zero)
@@ -150,7 +150,7 @@ namespace CalamityMod.Projectiles.Melee
Projectile.ExpandHitboxBy(100);
Projectile.tileCollide = true;
return;
}
}
}
// Otherwise, kill the projectile
Projectile.Kill();
@@ -220,11 +220,9 @@ namespace CalamityMod.Projectiles.Melee
Color shieldColor = Color.LightSalmon;
// Main trail
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]);
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak"));
TrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f + extraOffset - (direction * 80f), 10);
PrimitiveSet.Prepare(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + extraOffset + Main.screenPosition - direction * 80f,
shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 10);
ArrowEffect.Parameters["halfSpreadAngle"].SetValue(MathHelper.ToRadians(7.5f));
ArrowEffect.Parameters["edgeColor"].SetValue(headColor.ToVector3());
@@ -237,7 +235,7 @@ namespace CalamityMod.Projectiles.Melee
// Blooming shield and rings
Main.spriteBatch.EnterShaderRegion(BlendState.Additive);
float shieldRot = arrowFace - MathHelper.Pi;
Main.EntitySpriteDraw(shieldTex, Projectile.Center + extraOffset, null, shieldColor, shieldRot, shieldTex.Size() / 2f, 1.25f * scaleMult, SpriteEffects.None);
Main.EntitySpriteDraw(bloomTex, Projectile.Center + extraOffset, null, shieldColor * 0.75f, 0f, bloomTex.Size() / 2f, 0.5f * scaleMult, SpriteEffects.None);
+10 -12
View File
@@ -1,6 +1,7 @@
using System;
using System.IO;
using CalamityMod.CalPlayer;
using CalamityMod.Graphics.Primitives;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -15,7 +16,6 @@ namespace CalamityMod.Projectiles.Melee
public class TaintedBladeSlasher : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
internal PrimitiveTrail TrailDrawer = null;
public ref float SwordItemID => ref Projectile.ai[1];
public ref float VerticalOffset => ref Projectile.localAI[0];
public ref float Time => ref Projectile.localAI[1];
@@ -209,9 +209,6 @@ namespace CalamityMod.Projectiles.Melee
public override bool PreDraw(ref Color lightColor)
{
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, specialShader: GameShaders.Misc["CalamityMod:FadingSolidTrail"]);
Texture2D forearmTexture = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Melee/TaintedForearm").Value;
Texture2D armTexture = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Melee/TaintedArm").Value;
Texture2D handTexture = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Melee/TaintedHand").Value;
@@ -248,13 +245,6 @@ namespace CalamityMod.Projectiles.Melee
Vector2 top = BladeCenterPosition + BladeOffsetDirection * BladeFrame.Height * 0.5f - Main.screenPosition;
Vector2 offsetToBlade = (top - bottom).SafeNormalize(Vector2.Zero).RotatedBy(MathHelper.PiOver2) * 5f;
TrailDrawer.OverridingStickPointStart = BladeCenterPosition - BladeOffsetDirection * BladeFrame.Height * 0.5f + offsetToBlade - Main.screenPosition;
TrailDrawer.OverridingStickPointEnd = BladeCenterPosition + BladeOffsetDirection * BladeFrame.Height * 0.5f + offsetToBlade - Main.screenPosition;
// Swap the ends if needed so that the trail faces the right direction.
if (Owner.direction == -1)
Utils.Swap(ref TrailDrawer.OverridingStickPointStart, ref TrailDrawer.OverridingStickPointEnd);
Vector2[] drawPoints = new Vector2[Projectile.oldPos.Length];
Vector2 perpendicularDirection = BladeOffsetDirection.SafeNormalize(Vector2.UnitY).RotatedBy(MathHelper.PiOver2);
for (int i = 1; i < drawPoints.Length; i++)
@@ -265,7 +255,15 @@ namespace CalamityMod.Projectiles.Melee
drawPoints[i] = Projectile.Center + perpendicularDirection.RotatedBy(i * -0.014f * Owner.direction) * i * -Owner.direction * 6f;
}
TrailDrawer.Draw(drawPoints, BladeCenterPosition - Projectile.position - Main.screenPosition, 67);
var leftVertexPosition = BladeCenterPosition - BladeOffsetDirection * BladeFrame.Height * 0.5f + offsetToBlade - Main.screenPosition;
var rightVertexPosition = BladeCenterPosition + BladeOffsetDirection * BladeFrame.Height * 0.5f + offsetToBlade - Main.screenPosition;
// Swap the ends if needed so that the trail faces the right direction.
if (Owner.direction == -1)
Utils.Swap(ref leftVertexPosition, ref rightVertexPosition);
PrimitiveSet.Prepare(drawPoints, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => BladeCenterPosition - Projectile.position,
shader: GameShaders.Misc["CalamityMod:FadingSolidTrail"], initialVertexPositionsOverride: (leftVertexPosition, rightVertexPosition)), 67);
}
// Draw the blade.
+4 -8
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using CalamityMod.Graphics.Primitives;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -12,8 +13,6 @@ namespace CalamityMod.Projectiles.Melee
public new string LocalizationCategory => "Projectiles.Melee";
public Vector2[] ControlPoints;
public PrimitiveTrail SlashDrawer = null;
public bool Flipped => Projectile.ai[0] == 1f;
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
@@ -43,15 +42,12 @@ namespace CalamityMod.Projectiles.Melee
public float SlashWidthFunction(float completionRatio) => Projectile.scale * 22f;
public Color SlashColorFunction(float completionRatio) => Color.Lime * Utils.GetLerpValue(0.04f, 0.27f, completionRatio, true) * Projectile.Opacity;
public override bool PreDraw(ref Color lightColor)
{
// Initialize the primitive drawer.
SlashDrawer ??= new(SlashWidthFunction, SlashColorFunction, null, GameShaders.Misc["CalamityMod:ExobladeSlash"]);
// Draw the slash effect.
Main.spriteBatch.EnterShaderRegion();
TerratomereHoldoutProj.PrepareSlashShader(Flipped);
List<Vector2> points = new List<Vector2>();
@@ -59,7 +55,7 @@ namespace CalamityMod.Projectiles.Melee
points.Add(ControlPoints[i] + ControlPoints[i].SafeNormalize(Vector2.Zero) * (Projectile.scale - 1f) * 40f);
for (int i = 0; i < 3; i++)
SlashDrawer.Draw(points, Projectile.Center - Main.screenPosition, 65);
PrimitiveSet.Prepare(points, new(SlashWidthFunction, SlashColorFunction, (_) => Projectile.Center, shader: GameShaders.Misc["CalamityMod:ExobladeSlash"]), 65);
Main.spriteBatch.ExitShaderRegion();
return false;
+4 -8
View File
@@ -1,4 +1,5 @@
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Weapons.Melee;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -12,9 +13,7 @@ namespace CalamityMod.Projectiles.Melee
{
public new string LocalizationCategory => "Projectiles.Melee";
public int TargetIndex = -1;
public PrimitiveTrail SlashDrawer = null;
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public override void SetStaticDefaults()
@@ -63,16 +62,13 @@ namespace CalamityMod.Projectiles.Melee
public override bool PreDraw(ref Color lightColor)
{
// Initialize the slash drawer.
SlashDrawer ??= new PrimitiveTrail(SlashWidthFunction, SlashColorFunction, null, GameShaders.Misc["CalamityMod:ExobladePierce"]);
GameShaders.Misc["CalamityMod:ExobladePierce"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/BlobbyNoise"));
GameShaders.Misc["CalamityMod:ExobladePierce"].UseImage2("Images/Extra_189");
GameShaders.Misc["CalamityMod:ExobladePierce"].UseColor(Terratomere.TerraColor1);
GameShaders.Misc["CalamityMod:ExobladePierce"].UseSecondaryColor(Terratomere.TerraColor2);
for (int i = 0; i < 4; i++)
SlashDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition, 30);
PrimitiveSet.Prepare(Projectile.oldPos, new(SlashWidthFunction, SlashColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ExobladePierce"]), 30);
return false;
}
+4 -7
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Weapons.Melee;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -17,7 +18,6 @@ namespace CalamityMod.Projectiles.Melee
public class TerratomereHoldoutProj : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
public PrimitiveTrail SlashDrawer = null;
public Player Owner => Main.player[Projectile.owner];
@@ -153,7 +153,7 @@ namespace CalamityMod.Projectiles.Melee
// Create the slash.
if (Time == (int)(Terratomere.SwingTime * (SwingCompletionRatio + 0.15f)))
SoundEngine.PlaySound(Terratomere.SwingSound, Projectile.Center);
if (Main.myPlayer == Projectile.owner && Time == (int)(Terratomere.SwingTime * (SwingCompletionRatio + 0.34f)))
{
Vector2 bigSlashVelocity = Projectile.SafeDirectionTo(Main.MouseWorld) * Owner.ActiveItem().shootSpeed;
@@ -230,9 +230,6 @@ namespace CalamityMod.Projectiles.Melee
public void DrawSlash()
{
// Initialize the primitive drawer.
SlashDrawer ??= new(SlashWidthFunction, SlashColorFunction, null, GameShaders.Misc["CalamityMod:ExobladeSlash"]);
// Draw the slash effect.
Main.spriteBatch.EnterShaderRegion();
@@ -240,7 +237,7 @@ namespace CalamityMod.Projectiles.Melee
PrepareSlashShader(Direction == 1);
if (SwingCompletionAtStartOfTrail > SwingCompletionRatio)
SlashDrawer.Draw(GenerateSlashPoints(), Projectile.Center - Main.screenPosition, 95);
PrimitiveSet.Prepare(GenerateSlashPoints(), new(SlashWidthFunction, SlashColorFunction, (_) => Projectile.Center, shader: GameShaders.Misc["CalamityMod:ExobladeSlash"]), 95);
Main.spriteBatch.ExitShaderRegion();
}
@@ -274,7 +271,7 @@ namespace CalamityMod.Projectiles.Melee
{
if (Owner.moonLeech)
return;
Owner.statLife += Terratomere.TrueMeleeHitHeal;
Owner.HealEffect(Terratomere.TrueMeleeHitHeal);
}
+2 -5
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Weapons.Melee;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -15,7 +16,6 @@ namespace CalamityMod.Projectiles.Melee
public class ViolenceSlashProjectile : ModProjectile
{
public override LocalizedText DisplayName => CalamityUtils.GetItemName<Violence>();
internal PrimitiveTrail SliceAfterimageDrawer = null;
internal Player Owner => Main.player[Projectile.owner];
internal ref float Time => ref Projectile.ai[0];
internal float SwingSine => (float)Math.Sin(MathHelper.TwoPi * Time / 50f);
@@ -98,9 +98,6 @@ namespace CalamityMod.Projectiles.Melee
public override bool PreDraw(ref Color lightColor)
{
if (SliceAfterimageDrawer is null)
SliceAfterimageDrawer = new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, specialShader: GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"]);
GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/SwordSlashTexture"));
Texture2D spearProjectile = ModContent.Request<Texture2D>(Texture).Value;
@@ -116,7 +113,7 @@ namespace CalamityMod.Projectiles.Melee
positions.Add(position);
}
SliceAfterimageDrawer.Draw(positions, Projectile.Size * 0.5f - Main.screenPosition, 50);
PrimitiveSet.Prepare(positions, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:PhaseslayerRipEffect"]), 50);
return true;
}
}
@@ -1,4 +1,5 @@
using System;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
@@ -15,7 +16,6 @@ namespace CalamityMod.Projectiles.Melee
public class ViolenceThrownProjectile : ModProjectile
{
public override LocalizedText DisplayName => CalamityUtils.GetItemName<Violence>();
internal PrimitiveTrail StreakDrawer = null;
internal Player Owner => Main.player[Projectile.owner];
internal ref float Time => ref Projectile.ai[0];
public override string Texture => "CalamityMod/Items/Weapons/Melee/Violence";
@@ -197,9 +197,6 @@ namespace CalamityMod.Projectiles.Melee
public override bool PreDraw(ref Color lightColor)
{
if (StreakDrawer is null)
StreakDrawer = new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]);
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/FabstaffStreak"));
Texture2D spearProjectile = ModContent.Request<Texture2D>(Texture).Value;
@@ -218,7 +215,7 @@ namespace CalamityMod.Projectiles.Melee
drawPoints[i] -= (Projectile.oldRot[i] + MathHelper.PiOver4).ToRotationVector2() * Projectile.height * 0.5f;
if (Time > Projectile.oldPos.Length)
StreakDrawer.Draw(drawPoints, Projectile.Size * 0.5f - Main.screenPosition, 88);
PrimitiveSet.Prepare(drawPoints, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 88);
Vector2 drawPosition = Projectile.Center - Main.screenPosition;
for (int i = 0; i < 6; i++)
+2 -7
View File
@@ -1,4 +1,5 @@
using System;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Weapons.Melee;
using CalamityMod.Items.Weapons.Rogue;
using CalamityMod.Sounds;
@@ -18,7 +19,6 @@ namespace CalamityMod.Projectiles.Melee
public class WulfrumScrew : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Melee";
internal PrimitiveTrail TrailDrawer;
internal Color PrimColorMult = Color.White;
@@ -200,17 +200,12 @@ namespace CalamityMod.Projectiles.Melee
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
//Draw a trail
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]);
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(Request<Texture2D>("CalamityMod/ExtraTextures/Trails/BasicTrail"));
CalamityUtils.DrawChromaticAberration(Vector2.UnitX, 1f, delegate (Vector2 offset, Color colorMod)
{
PrimColorMult = colorMod;
TrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition + offset, 30);
PrimitiveSet.Prepare(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + offset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30);
});
//Draw the screw with chroma abberation
+4 -6
View File
@@ -1,7 +1,9 @@
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Weapons.Ranged;
using CalamityMod.Particles;
using CalamityMod.Sounds;
using Microsoft.CodeAnalysis;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -15,7 +17,6 @@ namespace CalamityMod.Projectiles.Ranged
public class ExoCrystalArrow : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Ranged";
public PrimitiveTrail PierceAfterimageDrawer = null;
public bool CreateLightning => Projectile.ai[0] == 1f;
@@ -77,8 +78,6 @@ namespace CalamityMod.Projectiles.Ranged
public override bool PreDraw(ref Color lightColor)
{
PierceAfterimageDrawer ??= new(PrimitiveWidthFunction, PrimitiveColorFunction, null, GameShaders.Misc["CalamityMod:HeavenlyGaleTrail"]);
float localIdentityOffset = Projectile.identity * 0.1372f;
Color mainColor = CalamityUtils.MulticolorLerp((Main.GlobalTimeWrappedHourly * 2f + localIdentityOffset) % 1f, Color.Cyan, Color.Lime, Color.GreenYellow, Color.Goldenrod, Color.Orange);
Color secondaryColor = CalamityUtils.MulticolorLerp((Main.GlobalTimeWrappedHourly * 2f + localIdentityOffset + 0.2f) % 1f, Color.Cyan, Color.Lime, Color.GreenYellow, Color.Goldenrod, Color.Orange);
@@ -86,14 +85,13 @@ namespace CalamityMod.Projectiles.Ranged
mainColor = Color.Lerp(Color.White, mainColor, 0.85f);
secondaryColor = Color.Lerp(Color.White, secondaryColor, 0.85f);
Vector2 trailOffset = Projectile.Size * 0.5f - Main.screenPosition;
Vector2 trailOffset = Projectile.Size * 0.5f;
GameShaders.Misc["CalamityMod:HeavenlyGaleTrail"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/EternityStreak"));
GameShaders.Misc["CalamityMod:HeavenlyGaleTrail"].UseImage2("Images/Extra_189");
GameShaders.Misc["CalamityMod:HeavenlyGaleTrail"].UseColor(mainColor);
GameShaders.Misc["CalamityMod:HeavenlyGaleTrail"].UseSecondaryColor(secondaryColor);
GameShaders.Misc["CalamityMod:HeavenlyGaleTrail"].Apply();
PierceAfterimageDrawer.Draw(Projectile.oldPos, trailOffset, 53);
PrimitiveSet.Prepare(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => trailOffset, shader: GameShaders.Misc["CalamityMod:HeavenlyGaleTrail"]), 53);
Texture2D tex = ModContent.Request<Texture2D>(Texture).Value;
Vector2 origin = tex.Size() * 0.5f;
Vector2 drawPosition = Projectile.Center - Main.screenPosition;
+3 -6
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Weapons.Ranged;
using Microsoft.Xna.Framework;
using Terraria;
@@ -17,7 +18,6 @@ namespace CalamityMod.Projectiles.Ranged
public class ExoLightningBolt : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Ranged";
internal PrimitiveTrail LightningDrawer;
public bool HasPlayedSound;
@@ -78,7 +78,7 @@ namespace CalamityMod.Projectiles.Ranged
float adjustedTimeLife = Projectile.timeLeft / Projectile.MaxUpdates;
Projectile.Opacity = Utils.GetLerpValue(0f, 9f, adjustedTimeLife, true) * Utils.GetLerpValue(Lifetime, Lifetime - 3f, adjustedTimeLife, true);
Projectile.scale = Projectile.Opacity;
// Play a strike sound on the first frame.
if (!HasPlayedSound)
{
@@ -162,13 +162,10 @@ namespace CalamityMod.Projectiles.Ranged
public override bool PreDraw(ref Color lightColor)
{
if (LightningDrawer is null)
LightningDrawer = new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, PrimitiveTrail.RigidPointRetreivalFunction, GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"]);
GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"].UseImage1("Images/Misc/Perlin");
GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"].Apply();
LightningDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition, 18);
PrimitiveSet.Prepare(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.5f, false, shader: GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"]), 18);
return false;
}
+2 -5
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Systems;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -17,7 +18,6 @@ namespace CalamityMod.Projectiles.Ranged
public new string LocalizationCategory => "Projectiles.Ranged";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
private static readonly int trailLength = 35;
private PrimitiveTrail trailDrawer;
internal List<Vector2> trailPositions;
// Lifetime of a bullet. Defined in terms of updates because Terraria's engine is trash.
@@ -212,11 +212,8 @@ namespace CalamityMod.Projectiles.Ranged
if (trailPositions is null)
return false;
if (trailDrawer is null)
trailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, PrimitiveTrail.RigidPointRetreivalFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]);
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/BasicTrail"));
trailDrawer.Draw(trailPositions, Projectile.Size * 0.5f - Main.screenPosition, trailLength);
PrimitiveSet.Prepare(trailPositions, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, false, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), trailLength);
return false;
}
+2 -7
View File
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -14,8 +15,6 @@ namespace CalamityMod.Projectiles.Ranged
{
public new string LocalizationCategory => "Projectiles.Ranged";
internal PrimitiveTrail TrailDrawer;
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 36;
@@ -63,11 +62,7 @@ namespace CalamityMod.Projectiles.Ranged
// The creature glows
public override void PostDraw(Color lightColor)
{
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction);
TrailDrawer.Draw(Projectile.oldPos.Where(oldPos => oldPos != Vector2.Zero), Projectile.Size * 0.5f - Main.screenPosition, 30);
PrimitiveSet.Prepare(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f), 30);
Texture2D glow = ModContent.Request<Texture2D>(Texture).Value;
Main.EntitySpriteDraw(glow, Projectile.Center - Main.screenPosition, null, Color.White, Projectile.rotation, glow.Size() * 0.5f, Projectile.scale, SpriteEffects.None);
}
@@ -1,4 +1,5 @@
using CalamityMod.Particles;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -176,10 +177,8 @@ namespace CalamityMod.Projectiles.Ranged
float rotation = Projectile.rotation + MathHelper.PiOver2;
Vector2 origin = texture.Size() * 0.5f;
PrimitiveTrail trail = new PrimitiveTrail(TrailWidthFunction, ColorTrailFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]);
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/SwordSlashTexture"));
trail.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition, 50);
PrimitiveSet.Prepare(Projectile.oldPos, new(TrailWidthFunction, ColorTrailFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 50);
if (CalamityConfig.Instance.Afterimages)
{
for (int i = 0; i < 3; i++)
+3 -8
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Dusts;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -16,9 +17,6 @@ namespace CalamityMod.Projectiles.Ranged
public new string LocalizationCategory => "Projectiles.Ranged";
public override string Texture => "CalamityMod/Particles/MediumMist";
// Helix trail thing
public PrimitiveTrail HelixTrail = null;
public override void SetStaticDefaults()
{
ProjectileID.Sets.TrailCacheLength[Type] = 20;
@@ -69,7 +67,7 @@ namespace CalamityMod.Projectiles.Ranged
GeneralParticleHandler.SpawnParticle(spark);
LineParticle spark2 = new LineParticle(Projectile.Center, -Projectile.velocity.RotatedBy(Main.rand.NextFloat(-0.23f, -0.56f)) * Main.rand.NextFloat(0.4f, 2.5f), false, 8, 1.2f, Main.rand.NextBool() ? Color.Orange : Color.DarkOrange);
GeneralParticleHandler.SpawnParticle(spark2);
for (int i = 0; i <= 3; i++)
{
Dust dust = Dust.NewDustPerfect(Projectile.Center, Main.rand.NextBool() ? 169 : 158, new Vector2(5, 5).RotatedByRandom(100) * Main.rand.NextFloat(0.2f, 1.5f), 0, default, Main.rand.NextFloat(1.6f, 2.2f));
@@ -92,9 +90,6 @@ namespace CalamityMod.Projectiles.Ranged
public override bool PreDraw(ref Color lightColor)
{
if (HelixTrail is null)
HelixTrail = new PrimitiveTrail(HelixTrailWidthFunction, HelixTrailColorFunction);
// Draw a double helix trail
for (int direction = -1; direction <= 1; direction += 2)
{
@@ -109,7 +104,7 @@ namespace CalamityMod.Projectiles.Ranged
Vector2 sinOffset = (Vector2.UnitY * direction * MathF.Sin(i * MathHelper.Pi * 0.125f) * 24f).RotatedBy(Projectile.oldRot[i]);
trailPositions.Add(Projectile.oldPos[i] + sinOffset);
}
HelixTrail.Draw(trailPositions, Projectile.Size * 0.5f - Main.screenPosition, 60);
PrimitiveSet.Prepare(trailPositions, new(HelixTrailWidthFunction, HelixTrailColorFunction, (_) => Projectile.Size * 0.5f), 60);
}
return false;
}
+2 -5
View File
@@ -1,5 +1,6 @@
using System.Linq;
using CalamityMod.Graphics.Metaballs;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Terraria;
@@ -18,7 +19,6 @@ namespace CalamityMod.Projectiles.Ranged
public static readonly SoundStyle ShotImpact = new("CalamityMod/Sounds/Item/SplatshotImpact") { PitchVariance = 0.3f, Volume = 2.5f };
public static readonly SoundStyle ShotImpactBig = new("CalamityMod/Sounds/Item/SplatshotBigImpact") { PitchVariance = 0.3f, Volume = 4f };
internal PrimitiveTrail TrailDrawer;
public override void SetStaticDefaults()
{
@@ -180,10 +180,7 @@ namespace CalamityMod.Projectiles.Ranged
internal Color ColorFunction(float completionRatio) => GetColor(Projectile.ai[0]) * Projectile.Opacity;
public override bool PreDraw(ref Color lightColor)
{
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction);
TrailDrawer.Draw(Projectile.oldPos.Where(oldPos => oldPos != Vector2.Zero), Projectile.Size * 0.5f - Main.screenPosition, 20);
PrimitiveSet.Prepare(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f), 20);
return true;
}
}
+5 -8
View File
@@ -1,6 +1,7 @@
using System;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Dusts;
using CalamityMod.Graphics.Primitives;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -16,7 +17,6 @@ namespace CalamityMod.Projectiles.Ranged
public new string LocalizationCategory => "Projectiles.Ranged";
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
public PrimitiveTrail TrailDrawer = null;
private const int Lifetime = 180;
private static Color ShaderColorOne = new Color(237, 194, 66);
private static Color ShaderColorTwo = new Color(235, 227, 117);
@@ -100,13 +100,10 @@ namespace CalamityMod.Projectiles.Ranged
public override bool PreDraw(ref Color lightColor)
{
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]);
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/FabstaffStreak"));
Vector2 overallOffset = Projectile.Size * 0.5f - Main.screenPosition;
Vector2 overallOffset = Projectile.Size * 0.5f;
overallOffset += Projectile.velocity * 1.4f;
TrailDrawer.Draw(Projectile.oldPos, overallOffset, 92); // 58
PrimitiveSet.Prepare(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => overallOffset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 92);
return false;
}
@@ -128,11 +125,11 @@ namespace CalamityMod.Projectiles.Ranged
}
for (int i = 0; i < 20; i++)
{
Dust holyFire = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.GoldCoin, 0f, 0f, 100, default, 3f);
Dust holyFire = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 3f);
holyFire.noGravity = true;
holyFire.velocity *= 5f;
holyFire = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.GoldCoin, 0f, 0f, 100, default, 2f);
holyFire = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, 246, 0f, 0f, 100, default, 2f);
holyFire.velocity *= 2f;
}
}
+2 -5
View File
@@ -1,4 +1,5 @@
using System;
using CalamityMod.Graphics.Primitives;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -12,7 +13,6 @@ namespace CalamityMod.Projectiles.Ranged
public class TheMaelstromShark : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Ranged";
public PrimitiveTrail LightningTrailDrawer = null;
public override void SetStaticDefaults()
{
Main.projFrames[Projectile.type] = 6;
@@ -97,11 +97,8 @@ namespace CalamityMod.Projectiles.Ranged
Vector2 drawPosition = Projectile.Center - Main.screenPosition;
SpriteEffects direction = Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
if (LightningTrailDrawer is null)
LightningTrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]);
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak"));
LightningTrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition, 60);
PrimitiveSet.Prepare(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 60);
Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, direction, 0);
return false;
}
+2 -6
View File
@@ -1,4 +1,5 @@
using System;
using CalamityMod.Graphics.Primitives;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -12,7 +13,6 @@ namespace CalamityMod.Projectiles.Ranged
public class WulfrumScrapBullet : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Ranged";
internal PrimitiveTrail TrailDrawer;
public override void SetStaticDefaults()
{
@@ -60,12 +60,8 @@ namespace CalamityMod.Projectiles.Ranged
public override bool PreDraw(ref Color lightColor)
{
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]);
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(Request<Texture2D>("CalamityMod/ExtraTextures/Trails/BasicTrail"));
TrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition, 30);
PrimitiveSet.Prepare(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30);
return false;
}
}
@@ -1,6 +1,5 @@
using System;
using System.IO;
using System.Linq;
using CalamityMod.Graphics.Primitives;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
@@ -12,7 +11,6 @@ namespace CalamityMod.Projectiles.Rogue
public class DynamicPursuerElectricity : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Rogue";
internal PrimitiveTrail LightningDrawer;
public const int MaximumBranchingIterations = 3;
public const float LightningTurnRandomnessFactor = 1.7f;
@@ -116,7 +114,7 @@ namespace CalamityMod.Projectiles.Rogue
internal float WidthFunction(float completionRatio)
{
float baseWidth = MathHelper.Lerp(2f, 6f, (float)Math.Sin(MathHelper.Pi * 4f * completionRatio) * 0.5f + 0.5f) * Projectile.scale;
float baseWidth = MathHelper.Lerp(4f, 7f, (float)Math.Sin(MathHelper.Pi * 4f * completionRatio) * 0.5f + 0.5f) * Projectile.scale;
return baseWidth * (float)Math.Sin(MathHelper.Pi * completionRatio);
}
internal Color ColorFunction(float completionRatio)
@@ -126,10 +124,7 @@ namespace CalamityMod.Projectiles.Rogue
}
public override bool PreDraw(ref Color lightColor)
{
if (LightningDrawer is null)
LightningDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, PrimitiveTrail.RigidPointRetreivalFunction);
LightningDrawer.Draw(Projectile.oldPos.Where(oldPos => oldPos != Vector2.Zero), Projectile.Size * 0.5f - Main.screenPosition, 300);
PrimitiveSet.Prepare(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, false), 90);
return false;
}
}
@@ -11,7 +11,6 @@ namespace CalamityMod.Projectiles.Rogue
public class FishboneBoomerangProjectile : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Rogue";
internal PrimitiveTrail TrailRenderer;
public override string Texture => "CalamityMod/Items/Weapons/Rogue/FishboneBoomerang";
public static int ChargeupTime = 10;
+4 -6
View File
@@ -1,4 +1,5 @@
using System;
using CalamityMod.Graphics.Primitives;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -12,7 +13,6 @@ namespace CalamityMod.Projectiles.Rogue
public class ScarletDevilProjectile : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Rogue";
internal PrimitiveTrail TrailDrawer;
public ref float ShootTimer => ref Projectile.ai[0];
public override string Texture => "CalamityMod/Items/Weapons/Rogue/ScarletDevil";
@@ -44,7 +44,7 @@ namespace CalamityMod.Projectiles.Rogue
if (!Main.dedServ)
{
for (int i = 0; i < (Projectile.Calamity().stealthStrike && Main.rand.NextBool() ? 2 : 1); i++)
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.Firework_Red, Projectile.velocity.X * 0.25f, Projectile.velocity.Y * 0.25f, 0, new Color(255, 255, 255), 0.85f);
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 130, Projectile.velocity.X * 0.25f, Projectile.velocity.Y * 0.25f, 0, new Color(255, 255, 255), 0.85f);
}
ShootTimer++;
@@ -175,11 +175,9 @@ namespace CalamityMod.Projectiles.Rogue
}
else
{
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, PrimitiveTrail.RigidPointRetreivalFunction, GameShaders.Misc["CalamityMod:OverpoweredTouhouSpearShader"]);
GameShaders.Misc["CalamityMod:OverpoweredTouhouSpearShader"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak"));
TrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition + Projectile.velocity.SafeNormalize(Vector2.Zero) * 86f, 60);
PrimitiveSet.Prepare(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + Projectile.velocity.SafeNormalize(Vector2.Zero) * 86f, false,
shader: GameShaders.Misc["CalamityMod:OverpoweredTouhouSpearShader"]), 60);
Texture2D spearTexture = ModContent.Request<Texture2D>(Texture).Value;
+5 -7
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using CalamityMod.Buffs.DamageOverTime;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Weapons.Rogue;
using CalamityMod.Projectiles.Rogue;
using CalamityMod.Sounds;
@@ -21,7 +22,6 @@ namespace CalamityMod.Projectiles.Rogue
public class StormfrontLightning : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Rogue";
internal PrimitiveTrail LightningDrawer;
private int noTileHitCounter = 81; //Using other projectile's methods to not collide until a certain time has passed, allowing use inside caves
@@ -48,7 +48,7 @@ namespace CalamityMod.Projectiles.Rogue
Projectile.width = 35;
Projectile.height = 35;
Projectile.alpha = 255;
Projectile.penetrate = 4;
Projectile.penetrate =4;
Projectile.ignoreWater = true;
Projectile.tileCollide = false;
Projectile.friendly = true;
@@ -83,7 +83,7 @@ namespace CalamityMod.Projectiles.Rogue
//dust sparks are now a feature
if (Main.rand.NextBool(10))
{
int d = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, DustID.Electric, 0f, 0f, 100, new Color(Main.rand.Next(20, 100), 204, 250), 1f);
int d = Dust.NewDust(Projectile.Center, Projectile.width, Projectile.height, 226, 0f, 0f, 100, new Color(Main.rand.Next(20, 100), 204, 250), 1f);
Main.dust[d].scale += (float)Main.rand.Next(50) * 0.01f;
Main.dust[d].noGravity = true;
Main.dust[d].position = Projectile.Center;
@@ -180,13 +180,11 @@ namespace CalamityMod.Projectiles.Rogue
public override bool PreDraw(ref Color lightColor)
{
//Just gonna use Dom's work on Heavenly Gale, tried to do a new one myself but I barely understand the .fx files and how they work, might revist it again eventually - Shade
if (LightningDrawer is null)
LightningDrawer = new PrimitiveTrail(PrimitiveWidthFunction, PrimitiveColorFunction, PrimitiveTrail.RigidPointRetreivalFunction, GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"]);
GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"].UseImage1("Images/Misc/Perlin");
GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"].Apply();
LightningDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.3f - Main.screenPosition, 10);
PrimitiveSet.Prepare(Projectile.oldPos, new(PrimitiveWidthFunction, PrimitiveColorFunction, (_) => Projectile.Size * 0.3f, false,
shader: GameShaders.Misc["CalamityMod:HeavenlyGaleLightningArc"]), 10);
return false;
}
+2 -6
View File
@@ -1,4 +1,5 @@
using System;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Weapons.Rogue;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
@@ -15,7 +16,6 @@ namespace CalamityMod.Projectiles.Rogue
public class WulfrumKnifeProj : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Rogue";
internal PrimitiveTrail TrailDrawer;
internal Color PrimColorMult = Color.White;
public override string Texture => "CalamityMod/Items/Weapons/Rogue/WulfrumKnife";
@@ -127,16 +127,12 @@ namespace CalamityMod.Projectiles.Rogue
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]);
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(Request<Texture2D>("CalamityMod/ExtraTextures/Trails/BasicTrail"));
CalamityUtils.DrawChromaticAberration(Vector2.UnitX, 1f, delegate (Vector2 offset, Color colorMod)
{
PrimColorMult = colorMod;
TrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition + offset, 30);
PrimitiveSet.Prepare(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size + offset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30);
});
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using CalamityMod.DataStructures;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -28,8 +29,6 @@ namespace CalamityMod.Projectiles.Summon
public static readonly SoundStyle ZapSound = SoundID.Item94 with { Volume = SoundID.Item94.Volume * 0.5f };
public static readonly SoundStyle SlapSound = new("CalamityMod/Sounds/Custom/WetSlap", 4);
internal PrimitiveTrail TrailRenderer;
public List<VerletSimulatedSegment> Segments;
public Player Owner => Main.player[Projectile.owner];
public ref float Initialized => ref Projectile.ai[0];
@@ -238,13 +237,9 @@ namespace CalamityMod.Projectiles.Summon
public override bool PreDraw(ref Color lightColor)
{
if (TrailRenderer is null)
TrailRenderer = new PrimitiveTrail(PrimWidthFunction, PrimColorFunction);
Vector2[] segmentPositions = Segments.Select(x => x.position).ToArray();
TrailRenderer.Draw(segmentPositions, -Main.screenPosition, 66);
PrimitiveSet.Prepare(segmentPositions, new(PrimWidthFunction, PrimColorFunction), 66);
Texture2D tex = Request<Texture2D>(Texture).Value;
+4 -6
View File
@@ -1,4 +1,5 @@
using System;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Weapons.Summon;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -12,7 +13,6 @@ namespace CalamityMod.Projectiles.Summon
public class CosmilampBeam : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Summon";
internal PrimitiveTrail TrailDrawer;
public ref float Timer => ref Projectile.ai[0];
@@ -105,15 +105,13 @@ namespace CalamityMod.Projectiles.Summon
public override bool PreDraw(ref Color lightColor)
{
// Initialize the trail drawer.
TrailDrawer ??= new(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]);
Projectile.localAI[0] = 0f;
GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak"));
TrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition, 42);
var primSet = PrimitiveSet.Prepare(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 42);
Projectile.localAI[0] = 1f;
TrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition, 42);
if (primSet.HasValue)
primSet.Value.Render();
return false;
}
}
+2 -5
View File
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Linq;
using CalamityMod.Graphics.Primitives;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
@@ -11,7 +12,6 @@ namespace CalamityMod.Projectiles.Summon
public class DaedalusLightning : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Summon";
internal PrimitiveTrail LightningDrawer;
public const int MaximumBranchingIterations = 3;
public const float LightningTurnRandomnessFactor = 1.7f;
@@ -137,10 +137,7 @@ namespace CalamityMod.Projectiles.Summon
}
public override bool PreDraw(ref Color lightColor)
{
if (LightningDrawer is null)
LightningDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, PrimitiveTrail.RigidPointRetreivalFunction);
LightningDrawer.Draw(Projectile.oldPos.Where(oldPos => oldPos != Vector2.Zero), Projectile.Size * 0.5f - Main.screenPosition, 300);
PrimitiveSet.Prepare(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f, false), 90);
return false;
}
#endregion
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Weapons.Summon;
using CalamityMod.Projectiles.Boss;
using Microsoft.Xna.Framework;
@@ -17,10 +18,6 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms
public ref float Time => ref Projectile.ai[1];
public PrimitiveTrail LightningDrawer;
public PrimitiveTrail LightningBackgroundDrawer;
public override string Texture => "CalamityMod/Projectiles/Boss/AresTeslaOrb";
public override void SetStaticDefaults()
@@ -113,17 +110,12 @@ namespace CalamityMod.Projectiles.Summon.SmallAresArms
public override bool PreDraw(ref Color lightColor)
{
if (LightningDrawer is null)
LightningDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, PrimitiveTrail.RigidPointRetreivalFunction);
if (LightningBackgroundDrawer is null)
LightningBackgroundDrawer = new PrimitiveTrail(BackgroundWidthFunction, BackgroundColorFunction, PrimitiveTrail.RigidPointRetreivalFunction);
Projectile orbToAttachTo = GetOrbToAttachTo();
if (orbToAttachTo != null)
{
List<Vector2> arcPoints = AresTeslaOrb.DetermineElectricArcPoints(Projectile.Center, orbToAttachTo.Center, 117);
LightningBackgroundDrawer.Draw(arcPoints, -Main.screenPosition, 90);
LightningDrawer.Draw(arcPoints, -Main.screenPosition, 90);
PrimitiveSet.Prepare(arcPoints, new(BackgroundWidthFunction, BackgroundColorFunction, smoothen: false), 90);
PrimitiveSet.Prepare(arcPoints, new(WidthFunction, ColorFunction, smoothen: false), 90);
}
lightColor.R = (byte)(255 * Projectile.Opacity);
+4 -6
View File
@@ -2,6 +2,7 @@
using System.IO;
using CalamityMod.Buffs.Summon;
using CalamityMod.CalPlayer;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Accessories;
using CalamityMod.Items.Weapons.Summon;
using CalamityMod.Particles;
@@ -44,7 +45,6 @@ namespace CalamityMod.Projectiles.Summon
}
}
internal PrimitiveTrail TrailDrawer;
internal Color PrimColorMult;
public Player healedPlayer;
@@ -150,7 +150,7 @@ namespace CalamityMod.Projectiles.Summon
{
Vector2 direction = Main.rand.NextVector2CircularEdge(1f, 1f);
Dust wishyDust = Dust.NewDustPerfect(Projectile.Center + direction * Main.rand.NextFloat(1f, 8f), 229, Alpha: 100, Scale: Main.rand.NextFloat(1f, 1.4f));
Dust wishyDust = Dust.NewDustPerfect(Projectile.Center + direction * Main.rand.NextFloat(1f, 8f), 229, Alpha : 100, Scale: Main.rand.NextFloat(1f, 1.4f));
wishyDust.noGravity = true;
wishyDust.noLight = true;
wishyDust.velocity = direction * Main.rand.NextFloat(2f, 4);
@@ -160,7 +160,7 @@ namespace CalamityMod.Projectiles.Summon
Projectile.soundDelay = NewSoundDelay;
ShootTimer = ShootDelay;
Initialized++;
Initialized ++;
}
if (Owner.Calamity().mouseRight && Owner.HeldItem.type == ModContent.ItemType<WulfrumController>())
@@ -464,8 +464,6 @@ namespace CalamityMod.Projectiles.Summon
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]);
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ZapTrail"));
Vector2[] drawPos = new Vector2[] { Projectile.Center, Projectile.Center, healedPlayer.Center + (Projectile.Center - healedPlayer.Center) * 0.5f + Vector2.UnitY * 40f, healedPlayer.Center, healedPlayer.Center };
@@ -473,7 +471,7 @@ namespace CalamityMod.Projectiles.Summon
CalamityUtils.DrawChromaticAberration(Vector2.UnitX, 1.8f, delegate (Vector2 offset, Color colorMod)
{
PrimColorMult = colorMod;
TrailDrawer.Draw(drawPos, -Main.screenPosition + offset, 30);
PrimitiveSet.Prepare(drawPos, new(WidthFunction, ColorFunction, (_) => offset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30);
});
Main.spriteBatch.End();
+2 -6
View File
@@ -1,4 +1,5 @@
using System;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -39,7 +40,6 @@ namespace CalamityMod.Projectiles.Summon
public static float HomingRange = 350;
public static float HomingAngle = MathHelper.PiOver4 * 1f;
internal PrimitiveTrail TrailDrawer;
internal Color PrimColorMult = Color.White;
public override void SetStaticDefaults()
@@ -180,16 +180,12 @@ namespace CalamityMod.Projectiles.Summon
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]);
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ZapTrail"));
CalamityUtils.DrawChromaticAberration(Vector2.UnitX, 1.5f, delegate (Vector2 offset, Color colorMod)
{
PrimColorMult = colorMod;
TrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition + offset, 30);
PrimitiveSet.Prepare(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + offset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30);
});
Main.spriteBatch.End();
+6 -9
View File
@@ -1,4 +1,5 @@
using System;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Weapons.Magic;
using CalamityMod.Particles;
using Microsoft.Xna.Framework;
@@ -39,7 +40,6 @@ namespace CalamityMod.Projectiles.Summon
public static float HomingRange = 250;
public static float HomingAngle = MathHelper.PiOver4 * 1.65f;
internal PrimitiveTrail TrailDrawer;
internal Color PrimColorMult = Color.White;
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
@@ -111,7 +111,7 @@ namespace CalamityMod.Projectiles.Summon
if (Projectile.timeLeft == 140)
{
Projectile.rotation = Projectile.velocity.ToRotation();
Target = null;
}
else
@@ -124,7 +124,7 @@ namespace CalamityMod.Projectiles.Summon
if (Target != null)
{
float distanceFromTarget = (Target.Center - Projectile.Center).Length();
Projectile.rotation = Projectile.rotation.AngleTowards((Target.Center - Projectile.Center).ToRotation(), 0.07f * (float)Math.Pow((1 - distanceFromTarget / HomingRange), 2));
Projectile.rotation = Projectile.rotation.AngleTowards((Target.Center - Projectile.Center).ToRotation(), 0.07f * (float)Math.Pow(( 1 - distanceFromTarget / HomingRange), 2));
}
Projectile.velocity *= 0.983f;
@@ -166,7 +166,7 @@ namespace CalamityMod.Projectiles.Summon
Vector2 velocity = Projectile.velocity.SafeNormalize(Vector2.UnitY).RotatedByRandom(MathHelper.Pi / 6f) * Main.rand.NextFloat(4, 10);
GeneralParticleHandler.SpawnParticle(new TechyHoloysquareParticle(center, velocity, Main.rand.NextFloat(1f, 2f), Main.rand.NextBool() ? new Color(99, 255, 229) : new Color(25, 132, 247), 25));
}
}
}
@@ -179,7 +179,7 @@ namespace CalamityMod.Projectiles.Summon
internal float WidthFunction(float completionRatio)
{
return 6.4f;
return 6.4f;
}
public override bool PreDraw(ref Color lightColor)
@@ -187,15 +187,12 @@ namespace CalamityMod.Projectiles.Summon
Main.spriteBatch.End();
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
if (TrailDrawer is null)
TrailDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, specialShader: GameShaders.Misc["CalamityMod:TrailStreak"]);
GameShaders.Misc["CalamityMod:TrailStreak"].SetShaderTexture(Request<Texture2D>("CalamityMod/ExtraTextures/Trails/BasicTrail"));
CalamityUtils.DrawChromaticAberration(Vector2.UnitX, 0.5f, delegate (Vector2 offset, Color colorMod)
{
PrimColorMult = colorMod;
TrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition + offset, 30);
PrimitiveSet.Prepare(Projectile.oldPos, new(WidthFunction, ColorFunction, (_) => Projectile.Size * 0.5f + offset, shader: GameShaders.Misc["CalamityMod:TrailStreak"]), 30);
});
Main.spriteBatch.End();
+2 -5
View File
@@ -1,4 +1,5 @@
using CalamityMod.DataStructures;
using CalamityMod.Graphics.Primitives;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -16,7 +17,6 @@ namespace CalamityMod.Projectiles.Typeless
public ref float Variant => ref Projectile.ai[1];
public const int UpwardFlyTime = 24;
public const int RedirectTime = 12;
public PrimitiveTrail FlameTrailDrawer = null;
public override string Texture => "CalamityMod/Projectiles/Typeless/GemTechYellowGem";
@@ -139,9 +139,6 @@ namespace CalamityMod.Projectiles.Typeless
public override bool PreDraw(ref Color lightColor)
{
if (FlameTrailDrawer is null)
FlameTrailDrawer = new PrimitiveTrail(TrailWidth, TrailColor, null, GameShaders.Misc["CalamityMod:ImpFlameTrail"]);
// Prepare the flame trail shader with its map texture.
GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak"));
@@ -174,7 +171,7 @@ namespace CalamityMod.Projectiles.Typeless
Main.EntitySpriteDraw(texture, drawPosition, null, Projectile.GetAlpha(Color.White), Projectile.rotation, origin, Projectile.scale, SpriteEffects.None, 0);
if (Projectile.ai[0] > UpwardFlyTime + RedirectTime)
FlameTrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition, 71);
PrimitiveSet.Prepare(Projectile.oldPos, new(TrailWidth, TrailColor, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 71);
return false;
}
+3 -6
View File
@@ -1,4 +1,5 @@
using Microsoft.Xna.Framework;
using CalamityMod.Graphics.Primitives;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Graphics.Shaders;
@@ -10,7 +11,6 @@ namespace CalamityMod.Projectiles.Typeless
public class MythrilFlare : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Typeless";
public PrimitiveTrail FlameTrailDrawer = null;
public ref float Time => ref Projectile.ai[0];
public const int AttackDelay = 22;
@@ -93,12 +93,9 @@ namespace CalamityMod.Projectiles.Typeless
public override bool PreDraw(ref Color lightColor)
{
if (FlameTrailDrawer is null)
FlameTrailDrawer = new PrimitiveTrail(TrailWidth, TrailColor, null, GameShaders.Misc["CalamityMod:ImpFlameTrail"]);
// Prepare the flame trail shader with its map texture.
GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/EternityStreak"));
FlameTrailDrawer.Draw(Projectile.oldPos, Projectile.Size * 0.5f - Main.screenPosition, 74);
PrimitiveSet.Prepare(Projectile.oldPos, new(TrailWidth, TrailColor, (_) => Projectile.Size * 0.5f, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 74);
return false;
}
+3 -7
View File
@@ -1,5 +1,6 @@
using System;
using System.IO;
using CalamityMod.Graphics.Primitives;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
@@ -20,7 +21,6 @@ namespace CalamityMod.Projectiles.Typeless
}
public ref float Time => ref Projectile.ai[1];
public Player Owner => Main.player[Projectile.owner];
public PrimitiveTrail FlameTrailDrawer = null;
public override void SetStaticDefaults()
{
Main.projFrames[Projectile.type] = 12;
@@ -186,7 +186,7 @@ namespace CalamityMod.Projectiles.Typeless
SoundEngine.PlaySound(SoundID.DD2_KoboldExplosion, Projectile.Center);
for (int i = 0; i < 40; i++)
{
Dust explosion = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, DustID.RainbowMk2);
Dust explosion = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, 267);
explosion.velocity = Main.rand.NextVector2Circular(4f, 4f);
explosion.color = Color.Red;
explosion.scale = 1.35f;
@@ -229,10 +229,6 @@ namespace CalamityMod.Projectiles.Typeless
{
Main.spriteBatch.EnterShaderRegion();
// Initialize the flame trail drawer.
if (FlameTrailDrawer is null)
FlameTrailDrawer = new PrimitiveTrail(FlameTrailWidthFunction, FlameTrailColorFunction, null, GameShaders.Misc["CalamityMod:ImpFlameTrail"]);
// Prepare the flame trail shader with its map texture.
GameShaders.Misc["CalamityMod:ImpFlameTrail"].SetShaderTexture(ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/Trails/ScarletDevilStreak"));
@@ -268,7 +264,7 @@ namespace CalamityMod.Projectiles.Typeless
Vector2 trailOffset = Projectile.Size * 0.5f;
trailOffset += (Projectile.rotation + MathHelper.PiOver2).ToRotationVector2() * 20f;
FlameTrailDrawer.Draw(Projectile.oldPos, trailOffset - Main.screenPosition, 61);
PrimitiveSet.Prepare(Projectile.oldPos, new(FlameTrailWidthFunction, FlameTrailColorFunction, (_) => trailOffset, shader: GameShaders.Misc["CalamityMod:ImpFlameTrail"]), 61);
}
Main.spriteBatch.ExitShaderRegion();
+4 -9
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using CalamityMod.Graphics.Primitives;
using CalamityMod.Items.Accessories;
using CalamityMod.Items.Materials;
using CalamityMod.Particles;
@@ -20,7 +21,6 @@ namespace CalamityMod.Projectiles.Typeless
{
public new string LocalizationCategory => "Projectiles.Typeless";
public Player Owner => Main.player[Projectile.owner];
internal PrimitiveTrail TrailRenderer;
public HookState State
{
@@ -164,7 +164,7 @@ namespace CalamityMod.Projectiles.Typeless
continue;
OnGrapple(worldPos, x, y);
break;
}
@@ -231,16 +231,11 @@ namespace CalamityMod.Projectiles.Typeless
public override bool PreDraw(ref Color lightColor)
{
if (TrailRenderer is null)
TrailRenderer = new PrimitiveTrail(PrimWidthFunction, PrimColorFunction);
Vector2[] segmentPositions = new Vector2[] { Projectile.Center, Owner.Center };
Vector2[] segmentPositions = new Vector2[] {Projectile.Center, Owner.Center };
if (State == HookState.Grappling)
segmentPositions = Owner.GetModPlayer<WulfrumPackPlayer>().Segments.Select(x => x.position).ToArray();
TrailRenderer.Draw(segmentPositions, -Main.screenPosition, 30);
PrimitiveSet.Prepare(new List<Vector2>(segmentPositions) { Owner.Center }, new(PrimWidthFunction, PrimColorFunction), 30);
Texture2D texture = TextureAssets.Projectile[Type].Value;