This commit is contained in:
Andrew Marheine committed 2022-01-20 06:19:33 -06:00
commit de07009013
3 files changed
+3 -63

No files matched your search

-4
View File
@@ -48,8 +48,6 @@ namespace CalamityMod.ILEditing
IL.Terraria.Player.QuickMana += ApplyManaBurnIfNeeded;
IL.Terraria.Player.ItemCheck += ApplyManaBurnIfNeeded;
IL.Terraria.Player.AddBuff += AllowBuffTimeStackingForManaBurn;
IL.Terraria.Main.DoDraw += DrawFusableParticles;
IL.Terraria.Main.DoDraw += DrawAshParticles;
On.Terraria.Main.DrawInterface += DrawGeneralParticles;
On.Terraria.Main.SetDisplayMode += ResetRenderTargetSizes;
IL.Terraria.Main.DrawTiles += DrawCustomLava;
@@ -123,8 +121,6 @@ namespace CalamityMod.ILEditing
IL.Terraria.Player.QuickMana -= ApplyManaBurnIfNeeded;
IL.Terraria.Player.ItemCheck -= ApplyManaBurnIfNeeded;
IL.Terraria.Player.AddBuff -= AllowBuffTimeStackingForManaBurn;
IL.Terraria.Main.DoDraw -= DrawFusableParticles;
IL.Terraria.Main.DoDraw -= DrawAshParticles;
On.Terraria.Main.DrawInterface -= DrawGeneralParticles;
On.Terraria.Main.SetDisplayMode -= ResetRenderTargetSizes;
IL.Terraria.Main.DrawTiles -= DrawCustomLava;
+2 -46
View File
@@ -492,58 +492,14 @@ namespace CalamityMod.ILEditing
}
#endregion Fire Cursor Effect for the Calamity Accessory
#region Fusable Particle Rendering
private static void DrawFusableParticles(ILContext il)
{
ILCursor cursor = new ILCursor(il);
// Over NPCs but before Projectiles.
if (!cursor.TryGotoNext(c => c.MatchCallOrCallvirt<Main>("SortDrawCacheWorms")))
{
LogFailure("Fusable Particle Rendering", "Could not locate the SortDrawCacheWorms reference method to attach to.");
return;
}
cursor.EmitDelegate<Action>(() => FusableParticleManager.RenderAllFusableParticles(FusableParticleRenderLayer.OverNPCsBeforeProjectiles));
// Over Players.
if (!cursor.TryGotoNext(MoveType.After, c => c.MatchCallOrCallvirt<Main>("DrawPlayers")))
{
LogFailure("Fusable Particle Rendering", "Could not locate the DrawPlayers reference method to attach to.");
return;
}
cursor.EmitDelegate<Action>(() => FusableParticleManager.RenderAllFusableParticles(FusableParticleRenderLayer.OverPlayers));
// Over Water.
if (!cursor.TryGotoNext(c => c.MatchCallOrCallvirt<MoonlordDeathDrama>("DrawWhite")))
{
LogFailure("Fusable Particle Rendering", "Could not locate the DrawWhite reference method to attach to.");
return;
}
cursor.EmitDelegate<Action>(() => FusableParticleManager.RenderAllFusableParticles(FusableParticleRenderLayer.OverWater));
}
#endregion Fusable Particle Rendering
#region Ash Particle Rendering
private static void DrawAshParticles(ILContext il)
{
ILCursor cursor = new ILCursor(il);
// Over NPCs but before Projectiles.
if (!cursor.TryGotoNext(c => c.MatchCallOrCallvirt<Main>("DrawDust")))
{
LogFailure("Ash Particle Rendering", "Could not locate the DrawDust reference method to attach to.");
return;
}
cursor.EmitDelegate<Action>(DeathAshParticle.DrawAll);
}
#endregion Ash Particle Rendering
#region General Particle Rendering
private static void DrawGeneralParticles(On.Terraria.Main.orig_DrawInterface orig, Main self, GameTime gameTime)
{
FusableParticleManager.RenderAllFusableParticles();
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, default, null, null, Main.GameViewMatrix.ZoomMatrix);
GeneralParticleHandler.DrawAllParticles(Main.spriteBatch);
Main.spriteBatch.End();
DeathAshParticle.DrawAll();
orig(self, gameTime);
}
+1 -13
View File
@@ -104,7 +104,7 @@ namespace CalamityMod.Particles
/// <summary>
/// Renders each cached <see cref="FusableParticleRenderCollection"/> instance with its connecting shader.
/// </summary>
internal static void RenderAllFusableParticles(FusableParticleRenderLayer renderLayer)
internal static void RenderAllFusableParticles()
{
// Don't attempt to render anything serverside or on the menu.
if (Main.netMode == NetmodeID.Server || Main.gameMenu)
@@ -118,17 +118,8 @@ namespace CalamityMod.Particles
if (particleSet.Particles.Count <= 0)
continue;
// Ignore particle sets of incompatible render layers.
// They will be drawn later when appropriate.
if (renderLayer != particleSet.RenderLayer)
continue;
bool needsRestartAtEnd = renderLayer == FusableParticleRenderLayer.OverWater;
List<RenderTarget2D> backgroundTargets = particleSet.GetBackgroundTargets;
if (needsRestartAtEnd)
Main.spriteBatch.End();
// Restart the sprite batch. This must be done with an immediate sort mode since a shader is going to be applied.
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
@@ -164,9 +155,6 @@ namespace CalamityMod.Particles
}
Main.spriteBatch.End();
if (needsRestartAtEnd)
Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
}
}