using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace RecrownedAthenaeum.Render { /// /// A that keeps it's settings through begin and end unless manually changed either by the or through changing the fields. Note that changing the fields while the batch has begun will not take effect until the next time the batch is started. /// public class ConsistentSpriteBatch : SpriteBatch { /// /// How to blend the colors. Uses 's default if not set before or during call. /// Changes will only take effect on call. /// public BlendState BlendState; /// /// The state of sampler to use for the spritebatch. Uses 's default if not set before or during call. /// Changes will only take effect on call. /// public SamplerState SamplerState; /// /// The state of the depth-stencil buffer. Uses 's defaultdefault if not set before or during call. /// Changes will only take effect on call. /// public DepthStencilState DepthStencilState; /// /// The state of rasterizer to use. Uses 's default if not set before or during call. /// Changes will only take effect on call. /// public RasterizerState RasterizerState; /// /// An effect to apply to the batch. Uses 's default if not set before or during call. /// Changes will only take effect on call. /// public Effect Effect; /// /// A matrix to be applied to transform the sprites geometry. An identity matrix is used if not provided before or during call. /// Changes will only take effect on call. /// public Matrix? TransformMatrix; /// /// Creates a consistent sprite batch with default values. /// /// The graphics device to use to create a . public ConsistentSpriteBatch(GraphicsDevice graphicsDevice) : base(graphicsDevice) { } /// /// Begins the consistent sprite batch. /// /// Defines the spritebatch's method of sorting the items in each batch. Uses 's default. /// How to blend the colors. Uses 's default if not set and field is also not set. /// The state of sampler to use for the spritebatch. Uses 's default if not set and field is also not set. /// What type of rasterization to use. Uses 's default if not set and field is also not set. /// What type of rasterization to use. Uses 's default if not set and field is also not set. /// An effect to apply to the batch. Uses 's default if not set and field is also not set. /// A matrix to be applied to transform the sprites geometry. An identity is used if not provided. public new void Begin(SpriteSortMode sortMode = SpriteSortMode.Deferred, BlendState blendState = null, SamplerState samplerState = null, DepthStencilState depthStencilState = null, RasterizerState rasterizerState = null, Effect effect = null, Matrix? transformMatrix = null) { if (blendState != null) this.BlendState = blendState; if (samplerState != null) this.SamplerState = samplerState; if (depthStencilState != null) this.DepthStencilState = depthStencilState; if (rasterizerState != null) this.RasterizerState = rasterizerState; if (effect != null) this.Effect = effect; if (transformMatrix != null) this.TransformMatrix = transformMatrix; base.Begin( sortMode: sortMode, blendState: blendState, samplerState: samplerState, depthStencilState: depthStencilState, rasterizerState: rasterizerState, effect: effect, transformMatrix: transformMatrix); } } }