port existing uses
This commit is contained in:
1 parent
8afc649fac
commit
f237ac77ad
6 files changed
+32
-12
No files matched your search
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using CalamityMod.Enums;
|
||||
using CalamityMod.Utilities.Daybreak;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
@@ -88,9 +89,17 @@ namespace CalamityMod.Graphics.Renderers
|
||||
if (!renderer.ShouldDraw)
|
||||
continue;
|
||||
|
||||
var matrix = Main.GameViewMatrix.TransformationMatrix;
|
||||
using (new CalamityUtils.SpritebatchScope(Main.spriteBatch, SpriteSortMode.Deferred, BatchSetting.AlphaBlend, null, matrix, true))
|
||||
using (Main.spriteBatch.Scope())
|
||||
{
|
||||
Main.spriteBatch.Begin(
|
||||
SpriteSortMode.Deferred,
|
||||
BlendState.AlphaBlend,
|
||||
SamplerState.PointClamp,
|
||||
DepthStencilState.None,
|
||||
Main.Rasterizer,
|
||||
null,
|
||||
Main.GameViewMatrix.TransformationMatrix
|
||||
);
|
||||
renderer.MainTarget.SwapTo(Color.Transparent);
|
||||
renderer.DrawToTarget(Main.spriteBatch);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ using CalamityMod.Systems;
|
||||
using CalamityMod.Systems.Graphic.PixelationSystem;
|
||||
using CalamityMod.Systems.Mechanic;
|
||||
using CalamityMod.Tiles;
|
||||
using CalamityMod.Utilities.Daybreak;
|
||||
using CalamityMod.Walls;
|
||||
using CalamityMod.Walls.UnsafeWalls;
|
||||
using CalamityMod.Waterfalls;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CalamityMod.Utilities.Daybreak;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
@@ -35,8 +36,18 @@ namespace CalamityMod.Systems
|
||||
graphicsDevice.Clear(Color.Transparent);
|
||||
|
||||
|
||||
using (new CalamityUtils.SpritebatchScope(Main.spriteBatch, SpriteSortMode.Immediate, BatchSetting.AlphaBlend, null, Matrix.Identity))
|
||||
using (Main.spriteBatch.Scope())
|
||||
{
|
||||
Main.spriteBatch.Begin(
|
||||
SpriteSortMode.Immediate,
|
||||
BlendState.AlphaBlend,
|
||||
SamplerState.PointClamp,
|
||||
DepthStencilState.None,
|
||||
Main.Rasterizer,
|
||||
null,
|
||||
Matrix.Identity
|
||||
);
|
||||
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
var drawPos = SideFlagsToPositionInSheet((byte)i);
|
||||
@@ -58,6 +69,8 @@ namespace CalamityMod.Systems
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Main.spriteBatch.End();
|
||||
}
|
||||
|
||||
// TODO: [SAFEACTION] bandaid fix
|
||||
|
||||
@@ -40,11 +40,6 @@ internal readonly struct SpriteBatchScope : IDisposable
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (spriteBatch.beginCalled)
|
||||
{
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
if (oldState.HasValue)
|
||||
{
|
||||
spriteBatch.Begin(oldState.Value);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace CalamityMod
|
||||
{
|
||||
[Obsolete("Use SpriteBatchParameters/SpriteBatchSnapshot")]
|
||||
public class BatchSetting(BlendState blend, SamplerState sampler, DepthStencilState depthStencil, RasterizerState rasterizer)
|
||||
{
|
||||
public readonly BlendState blendState = blend;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using CalamityMod.Utilities.Daybreak;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
@@ -51,12 +52,11 @@ namespace CalamityMod
|
||||
if (spriteBatch is null)
|
||||
return;
|
||||
|
||||
spriteBatch.GetParameters(out var parameters);
|
||||
spriteBatch.End();
|
||||
spriteBatch.End(out var ss);
|
||||
|
||||
spriteBatch.Begin(sortMode, settings.blendState, settings.samplerState, settings.depthStencilState, settings.rasterizerState ?? Main.Rasterizer, effect, transformMatrix);
|
||||
batchCallback?.Invoke();
|
||||
spriteBatch.Restart(parameters);
|
||||
spriteBatch.Restart(ss);
|
||||
}
|
||||
|
||||
[Obsolete("This is violative of spritebatch's control flow and will eventually be removed")]
|
||||
|
||||
Reference in new issue
Block a user