Calamity's flame is dyeable now
This commit is contained in:
1 parent
224d4e48ba
commit
f52098685b
5 files changed
+76
-16
No files matched your search
@@ -49,7 +49,6 @@ using CalamityMod.NPCs.SupremeCalamitas;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Projectiles.BaseProjectiles;
|
||||
using CalamityMod.Projectiles.Boss;
|
||||
using CalamityMod.Projectiles.Environment;
|
||||
using CalamityMod.Projectiles.Melee;
|
||||
using CalamityMod.Projectiles.Ranged;
|
||||
using CalamityMod.Projectiles.Rogue;
|
||||
@@ -58,6 +57,7 @@ using CalamityMod.Projectiles.Typeless;
|
||||
using CalamityMod.UI;
|
||||
using CalamityMod.World;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
using Terraria.Audio;
|
||||
using Terraria.Chat;
|
||||
@@ -1090,6 +1090,8 @@ namespace CalamityMod.CalPlayer
|
||||
|
||||
public FluidField ProfanedMoonlightAuroraDrawer;
|
||||
|
||||
public ArmorShaderData CalamityFireDyeShader = null;
|
||||
|
||||
public Vector2 FireDrawerPosition;
|
||||
|
||||
public int monolithAccursedShader = 0;
|
||||
@@ -3273,6 +3275,9 @@ namespace CalamityMod.CalPlayer
|
||||
#region PreUpdate
|
||||
public override void PreUpdate()
|
||||
{
|
||||
// Reset the Calamity shader.
|
||||
CalamityFireDyeShader = null;
|
||||
|
||||
if (HasCustomDash && UsedDash.IsOmnidirectional)
|
||||
Player.maxFallSpeed = 50f;
|
||||
|
||||
@@ -5395,7 +5400,7 @@ namespace CalamityMod.CalPlayer
|
||||
if (totalMoonlightDyes > 0)
|
||||
{
|
||||
// Initialize the aurora drawer.
|
||||
int size = 425;
|
||||
int size = 340;
|
||||
FluidFieldManager.AdjustSizeRelativeToGraphicsQuality(ref size);
|
||||
|
||||
float scale = MathHelper.Max(Main.screenWidth, Main.screenHeight) / size * 0.4f;
|
||||
@@ -5403,7 +5408,7 @@ namespace CalamityMod.CalPlayer
|
||||
ProfanedMoonlightAuroraDrawer = FluidFieldManager.CreateField(size, scale, 0.1f, 50f, 0.992f);
|
||||
|
||||
int sourceArea = (int)Math.Ceiling(6f / ProfanedMoonlightAuroraDrawer.Scale) + 1;
|
||||
ProfanedMoonlightAuroraDrawer.ShouldUpdate = Player.miscCounter % 4 == 0;
|
||||
ProfanedMoonlightAuroraDrawer.ShouldUpdate = Player.miscCounter % 2 == 0;
|
||||
ProfanedMoonlightAuroraDrawer.UpdateAction = () =>
|
||||
{
|
||||
// Aurora Count does not scale to save on resources if you have a lot of dyes
|
||||
|
||||
@@ -24,6 +24,8 @@ namespace CalamityMod.FluidSimulation
|
||||
|
||||
internal FluidFieldState ColorField;
|
||||
|
||||
internal RenderTarget2D OutputTarget;
|
||||
|
||||
public float Viscosity;
|
||||
|
||||
public float DiffusionFactor;
|
||||
@@ -85,6 +87,8 @@ namespace CalamityMod.FluidSimulation
|
||||
|
||||
DivergenceField = new(Main.instance.GraphicsDevice, Size, Size, true, SurfaceFormat.Vector4, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents);
|
||||
DivergencePoissonField = new(Main.instance.GraphicsDevice, Size, Size, true, SurfaceFormat.Vector4, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents);
|
||||
|
||||
OutputTarget = new(Main.instance.GraphicsDevice, Size, Size, true, SurfaceFormat.Color, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents);
|
||||
}
|
||||
|
||||
internal void ApplyThingToTarget(RenderTarget2D currentField, Action shaderPreparationsAction)
|
||||
@@ -239,6 +243,7 @@ namespace CalamityMod.FluidSimulation
|
||||
|
||||
UpdateVelocityFields();
|
||||
UpdateDensityFields();
|
||||
UpdateOutputTarget();
|
||||
|
||||
ShouldSkipDivergenceClearingStep = false;
|
||||
}
|
||||
@@ -265,6 +270,20 @@ namespace CalamityMod.FluidSimulation
|
||||
CalculateAdvection(ColorField.PreviousState, ColorField.NextState, VelocityField.NextState, true);
|
||||
}
|
||||
|
||||
public void UpdateOutputTarget()
|
||||
{
|
||||
Main.instance.GraphicsDevice.SetRenderTarget(OutputTarget);
|
||||
Main.instance.GraphicsDevice.Clear(Color.Transparent);
|
||||
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, Main.Rasterizer, null, Matrix.Identity);
|
||||
Main.instance.GraphicsDevice.Textures[5] = ColorField.NextState;
|
||||
CalamityShaders.FluidShaders.CurrentTechnique.Passes["DrawFluidPass"].Apply();
|
||||
Main.spriteBatch.Draw(DensityField.NextState, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 1f, 0, 0f);
|
||||
Main.spriteBatch.End();
|
||||
|
||||
Main.instance.GraphicsDevice.SetRenderTarget(null);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Prevent disposing twice.
|
||||
@@ -280,6 +299,7 @@ namespace CalamityMod.FluidSimulation
|
||||
VelocityField?.Dispose();
|
||||
ColorField?.Dispose();
|
||||
DensityField?.Dispose();
|
||||
OutputTarget?.Dispose();
|
||||
}
|
||||
|
||||
public void CreateSource(int x, int y, float density, Color color, Vector2 velocity)
|
||||
@@ -291,19 +311,21 @@ namespace CalamityMod.FluidSimulation
|
||||
|
||||
ColorField.PendingChanges.Enqueue(new PixelQueueValue(pos, color));
|
||||
|
||||
VelocityField.PendingChanges.Enqueue(new(pos, new Vector4(velocity.X, velocity.Y, 0f, 0f)));
|
||||
if (velocity != Vector2.Zero)
|
||||
VelocityField.PendingChanges.Enqueue(new(pos, new Vector4(velocity.X, velocity.Y, 0f, 0f)));
|
||||
DensityField.PendingChanges.Enqueue(new PixelQueueValue(pos, new Color(density, 0f, 0f)));
|
||||
}
|
||||
|
||||
public void Draw(Vector2 drawPosition, bool needsToCallEnd, Matrix drawPerspective, Matrix previousPerspective)
|
||||
public void Draw(Vector2 drawPosition, bool needsToCallEnd, Matrix drawPerspective, Matrix previousPerspective, Action<RenderTarget2D> shaderPreparations = null)
|
||||
{
|
||||
if (needsToCallEnd)
|
||||
Main.spriteBatch.End();
|
||||
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, Main.Rasterizer, null, drawPerspective);
|
||||
Main.instance.GraphicsDevice.Textures[5] = ColorField.NextState;
|
||||
CalamityShaders.FluidShaders.CurrentTechnique.Passes["DrawFluidPass"].Apply();
|
||||
Main.spriteBatch.Draw(DensityField.NextState, drawPosition, null, Color.White, 0f, DensityField.NextState.Size() * 0.5f, Scale, 0, 0f);
|
||||
|
||||
shaderPreparations?.Invoke(OutputTarget);
|
||||
|
||||
Main.spriteBatch.Draw(OutputTarget, drawPosition, null, Color.White, 0f, OutputTarget.Size() * 0.5f, Scale, 0, 0f);
|
||||
Main.spriteBatch.End();
|
||||
|
||||
if (needsToCallEnd)
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.FluidSimulation
|
||||
{
|
||||
public static class FluidFieldManager
|
||||
public class FluidFieldManager : ModSystem
|
||||
{
|
||||
internal static List<FluidField> Fields = new();
|
||||
|
||||
@@ -44,5 +45,15 @@ namespace CalamityMod.FluidSimulation
|
||||
field.Update();
|
||||
Main.GameViewMatrix.Zoom = old;
|
||||
}
|
||||
|
||||
public override void OnModUnload()
|
||||
{
|
||||
Main.QueueMainThreadAction(() =>
|
||||
{
|
||||
// The dispose method automatically pops fields from the list.
|
||||
while (Fields.Count > 0)
|
||||
Fields[0].Dispose();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,6 +68,7 @@ namespace CalamityMod.ILEditing
|
||||
// TODO -- This should be unnecessary. There is now a TML hook for platform collision for ModNPCs.
|
||||
On.Terraria.NPC.Collision_DecideFallThroughPlatforms += EnableCalamityBossPlatformCollision;
|
||||
IL.Terraria.Wiring.HitWireSingle += AddTwinklersToStatue;
|
||||
On.Terraria.Player.UpdateItemDye += FindCalamityItemDyeShader;
|
||||
|
||||
// Mana Burn
|
||||
IL.Terraria.Player.QuickHeal += ConditionallyReplaceManaSickness;
|
||||
@@ -183,6 +184,9 @@ namespace CalamityMod.ILEditing
|
||||
On.Terraria.WorldGen.CloseDoor -= CloseDoor_LabDoorOverride;
|
||||
On.Terraria.Item.AffixName -= IncorporateEnchantmentInAffix;
|
||||
On.Terraria.Projectile.NewProjectile_IEntitySource_float_float_float_float_int_int_float_int_float_float -= IncorporateMinionExplodingCountdown;
|
||||
On.Terraria.NPC.Collision_DecideFallThroughPlatforms -= EnableCalamityBossPlatformCollision;
|
||||
IL.Terraria.Wiring.HitWireSingle -= AddTwinklersToStatue;
|
||||
On.Terraria.Player.UpdateItemDye -= FindCalamityItemDyeShader;
|
||||
|
||||
// Mana Burn
|
||||
IL.Terraria.Player.QuickHeal -= ConditionallyReplaceManaSickness;
|
||||
|
||||
@@ -552,7 +552,7 @@ namespace CalamityMod.ILEditing
|
||||
// If the blazing mouse is actually going to do damage, draw an indicator aura.
|
||||
if (!Main.mapFullscreen)
|
||||
{
|
||||
int size = 450;
|
||||
int size = 370;
|
||||
FluidFieldManager.AdjustSizeRelativeToGraphicsQuality(ref size);
|
||||
|
||||
float scale = MathHelper.Max(Main.screenWidth, Main.screenHeight) / size;
|
||||
@@ -566,10 +566,10 @@ namespace CalamityMod.ILEditing
|
||||
|
||||
int x = (int)((drawPosition.X - firePosition.X) / calamityFireDrawer.Scale);
|
||||
int y = (int)((drawPosition.Y - firePosition.Y) / calamityFireDrawer.Scale);
|
||||
int horizontalArea = (int)Math.Ceiling(5f / calamityFireDrawer.Scale);
|
||||
int verticalArea = (int)Math.Ceiling(5f / calamityFireDrawer.Scale);
|
||||
int horizontalArea = (int)Math.Ceiling(8f / calamityFireDrawer.Scale);
|
||||
int verticalArea = (int)Math.Ceiling(8f / calamityFireDrawer.Scale);
|
||||
|
||||
calamityFireDrawer.ShouldUpdate = player.miscCounter % 4 == 0;
|
||||
calamityFireDrawer.ShouldUpdate = player.miscCounter % 2 == 0;
|
||||
calamityFireDrawer.UpdateAction = () =>
|
||||
{
|
||||
Color color = Color.Lerp(Color.Red, Color.Orange, (float)Math.Sin(Main.GlobalTimeWrappedHourly * 6f) * 0.5f + 0.5f);
|
||||
@@ -590,7 +590,7 @@ namespace CalamityMod.ILEditing
|
||||
}
|
||||
UIManagementSystem.PreviousMouseWorld = Main.MouseWorld;
|
||||
|
||||
velocity = velocity.SafeNormalize(-Vector2.UnitY).RotatedBy(offsetAngle) * 0.2f;
|
||||
velocity = velocity.SafeNormalize(-Vector2.UnitY).RotatedBy(offsetAngle) * 3f;
|
||||
|
||||
// Add a tiny bit of randomness to the velocity.
|
||||
// Chaos in the advection calculations should result in different flames being made over time, instead of a
|
||||
@@ -598,11 +598,18 @@ namespace CalamityMod.ILEditing
|
||||
velocity *= Main.rand.NextFloat(0.9f, 1.1f);
|
||||
|
||||
for (int j = -verticalArea; j <= verticalArea; j++)
|
||||
player.Calamity().CalamityFireDrawer.CreateSource(x + size / 2 + i, y + size / 2 + j, 1f, color, velocity);
|
||||
player.Calamity().CalamityFireDrawer.CreateSource(x + size / 2 + i, y + size / 2 + j, 1f, color, i == 0 && j == 0 ? velocity : Vector2.Zero);
|
||||
}
|
||||
};
|
||||
|
||||
calamityFireDrawer.Draw(firePosition, true, Main.UIScaleMatrix, Main.UIScaleMatrix);
|
||||
calamityFireDrawer.Draw(firePosition, true, Main.UIScaleMatrix, Main.UIScaleMatrix, output =>
|
||||
{
|
||||
var armorShader = player.Calamity().CalamityFireDyeShader;
|
||||
if (armorShader is null)
|
||||
return;
|
||||
|
||||
armorShader.Apply(null, new(output, Vector2.Zero, Color.White));
|
||||
});
|
||||
}
|
||||
|
||||
Main.spriteBatch.Draw(TextureAssets.Cursors[cursorIndex].Value, drawPosition, null, desaturatedCursorColor, 0f, Vector2.Zero, Main.cursorScale, SpriteEffects.None, 0f);
|
||||
@@ -1012,6 +1019,7 @@ namespace CalamityMod.ILEditing
|
||||
cursor.Emit<CalamityGlobalNPC>(OpCodes.Call, "get_TaxesToCollectLimit");
|
||||
}
|
||||
#endregion Make Tax Collector Worth it
|
||||
|
||||
#region Foreground tiles drawing
|
||||
private static void DrawForegroundStuff(On.Terraria.Main.orig_DrawGore orig, Main self)
|
||||
{
|
||||
@@ -1130,5 +1138,15 @@ namespace CalamityMod.ILEditing
|
||||
mp.hookCache = -1;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Find Calamity Item Dye Shader
|
||||
|
||||
internal static void FindCalamityItemDyeShader(On.Terraria.Player.orig_UpdateItemDye orig, Player self, bool isNotInVanitySlot, bool isSetToHidden, Item armorItem, Item dyeItem)
|
||||
{
|
||||
orig(self, isNotInVanitySlot, isSetToHidden, armorItem, dyeItem);
|
||||
if (armorItem.type == ModContent.ItemType<Calamity>())
|
||||
self.Calamity().CalamityFireDyeShader = GameShaders.Armor.GetShaderFromItemId(dyeItem.type);
|
||||
}
|
||||
#endregion Find Calamity Item Dye Shader
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user