minor change for the dispose exception for disposables.

This commit is contained in:
2019-01-12 23:40:52 -06:00
parent bfdc36a3e2
commit edd2e94a6a
2 changed files with 8 additions and 8 deletions

View File

@@ -44,7 +44,7 @@ namespace RecrownedAthenaeum.Render
public void Begin(PrimitiveType primitiveType)
{
if (began) throw new InvalidOperationException("Begin is being called twice before being ended.");
if (disposed) throw new ObjectDisposedException(typeof(PrimitiveBatch).Name);
if (disposed) throw new ObjectDisposedException(this.GetType().Name);
this.primitiveType = primitiveType;
verticesPerPrimitive = 0;
switch (primitiveType)
@@ -63,7 +63,7 @@ namespace RecrownedAthenaeum.Render
/// </summary>
public void End()
{
if (disposed) throw new ObjectDisposedException(typeof(PrimitiveBatch).Name);
if (disposed) throw new ObjectDisposedException(this.GetType().Name);
if (!began) throw new InvalidOperationException("Begin must be called before ending.");
Flush();
@@ -77,7 +77,7 @@ namespace RecrownedAthenaeum.Render
public void AddVertex(Vector2 vertex, Color color)
{
if (!began) throw new InvalidOperationException("Begin needs to be called before adding vertex.");
if (disposed) throw new ObjectDisposedException(typeof(PrimitiveBatch).Name);
if (disposed) throw new ObjectDisposedException(this.GetType().Name);
if (bufferPosition + verticesPerPrimitive >= MaxVertices && (bufferPosition % MaxVertices == 0))
{
if (primitiveType != PrimitiveType.LineStrip && primitiveType != PrimitiveType.TriangleStrip)
@@ -99,7 +99,7 @@ namespace RecrownedAthenaeum.Render
public void Flush()
{
if (!began) throw new InvalidOperationException("Begin needs to be called before flushing.");
if (disposed) throw new ObjectDisposedException(typeof(PrimitiveBatch).Name);
if (disposed) throw new ObjectDisposedException(this.GetType().Name);
if (bufferPosition == 0) return;
graphicsDevice.DrawUserPrimitives(primitiveType, vertices.ToArray(), 0, bufferPosition / verticesPerPrimitive);
@@ -121,7 +121,7 @@ namespace RecrownedAthenaeum.Render
}
else
{
throw new ObjectDisposedException(typeof(PrimitiveBatch).Name);
if (disposed) throw new ObjectDisposedException(this.GetType().Name);
}
}
}