using Microsoft.Xna.Framework; using Terraria.Graphics.Shaders; namespace CalamityMod.Graphics.Primitives { /// /// Contains all the various options to use when creating a primitive trail. New members can be added freely without breaking existing implementations. /// public readonly struct PrimitiveSettings { #region Delegates /// /// A delegate to dynamically determine the width of the trail at each position. /// /// The current position along the trail as a 0-1 interlopant value. /// The width for the current point. public delegate float VertexWidthFunction(float trailLengthInterpolant); /// /// A delegate to dynamically determine the color of the trail at each position. /// /// The current position along the trail as a 0-1 interlopant value. /// The color for the current point. public delegate Color VertexColorFunction(float trailLengthInterpolant); /// /// A delegate to dynamically determine the offset of the trail at each position. /// /// The current position along the trail as a 0-1 interlopant value. /// The offset for the current point. public delegate Vector2 VertexOffsetFunction(float trailLengthInterpolant); #endregion #region Instance Fields /// /// Used to determine the width of each vertex. /// public readonly VertexWidthFunction WidthFunction; /// /// Used to determine the color of each vertex. /// public readonly VertexColorFunction ColorFunction; /// /// Used to offset each position when generating them. /// public readonly VertexOffsetFunction OffsetFunction; /// /// Whether to use smoothening when generating the vertex positions from the provided ones Recommended to be on by default. /// public readonly bool Smoothen; /// /// Whether to pixelate the primitives. Recommended to be on by default. /// public readonly bool Pixelate; /// /// Whether to use unscaled perspective matrices when rendering the primitives. Recommended only when the system is being used outside of its typical context /// i.e. rendering primitives in the background via a CustomSky. /// public readonly bool UseUnscaledMatrices; /// /// The shader to apply when rendering. /// public readonly MiscShaderData Shader; /// /// 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. /// public readonly (Vector2, Vector2)? InitialVertexPositionsOverride; #endregion /// /// Contains all the various options to use when creating a primitive trail. /// /// Used to determine the width of each vertex. /// Used to determine the color of each vertex. /// Used to offset each position when generating them. /// Whether to use smoothening when generating the vertex positions from the provided ones. Recommended to be enabled. /// Whether to pixelate the primitives. Recommended to be enabled if the effect was designed with this in mind. /// The shader to apply when rendering the primitives. /// Whether to use unscaled perspective matrices when rendering primitives. Recommended when using this system outside of its typical context; i.e. rendering primitives in the background via a CustomSky. /// 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. public PrimitiveSettings(VertexWidthFunction widthFunction, VertexColorFunction colorFunction, VertexOffsetFunction offsetFunction = null, bool smoothen = true, bool pixelate = false, MiscShaderData shader = null, bool useUnscaledMatrices = false, (Vector2, Vector2)? initialVertexPositionsOverride = null) { WidthFunction = widthFunction; ColorFunction = colorFunction; OffsetFunction = offsetFunction; Smoothen = smoothen; Pixelate = pixelate; Shader = shader; UseUnscaledMatrices = useUnscaledMatrices; InitialVertexPositionsOverride = initialVertexPositionsOverride; } } }