From eb323bea01e0791051330accc2f9b03998f043d6 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 12 Nov 2021 18:35:10 +0100 Subject: [PATCH] only allow clearing a static sprite batch when batching --- MLEM/Misc/StaticSpriteBatch.cs | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/MLEM/Misc/StaticSpriteBatch.cs b/MLEM/Misc/StaticSpriteBatch.cs index 7def0ea..39cc795 100644 --- a/MLEM/Misc/StaticSpriteBatch.cs +++ b/MLEM/Misc/StaticSpriteBatch.cs @@ -7,7 +7,7 @@ using MLEM.Extensions; namespace MLEM.Misc { /// /// A static sprite batch is a variation of that keeps all batched items in a , allowing for them to be drawn multiple times. - /// To add items to a static sprite batch, use to clear currently batched items, to begin batching, Add and its various overloads to add batch items, to remove them again, and to end batching. + /// To add items to a static sprite batch, use to begin batching, to clear currently batched items, Add and its various overloads to add batch items, to remove them again, and to end batching. /// To draw the batched items, call . /// public class StaticSpriteBatch : IDisposable { @@ -43,7 +43,6 @@ namespace MLEM.Misc { /// /// Begins batching. /// Call this method before calling Add or any of its overloads. - /// Note that, if was not called, items that are batched will be appended to the existing batch. /// /// Thrown if this batch is currently batching already public void BeginBatch() { @@ -109,19 +108,6 @@ namespace MLEM.Misc { } } - /// - /// Clears the batch, removing all currently batched vertices. - /// After this operation, will return 0. - /// - /// Thrown if this batch is currently batching - public void ClearBatch() { - if (this.batching) - throw new InvalidOperationException("Cannot clear while batching"); - this.vertices.Clear(); - this.texture = null; - this.batchChanged = true; - } - /// /// Draws this batch's content onto the 's current render target (or the back buffer) with the given settings. /// Note that this method should not be called while a regular is currently active. @@ -340,6 +326,19 @@ namespace MLEM.Misc { return false; } + /// + /// Clears the batch, removing all currently batched vertices. + /// After this operation, will return 0. + /// + /// Thrown if this method is called before was called + public void ClearBatch() { + if (!this.batching) + throw new InvalidOperationException("Not batching"); + this.vertices.Clear(); + this.texture = null; + this.batchChanged = true; + } + /// public void Dispose() { this.spriteEffect.Dispose();