Energy Shield now properly draws per player
This commit is contained in:
1 parent
66a1f5c311
commit
cbd1446bde
7 files changed
+283
-265
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria;
|
||||
|
||||
namespace CalamityMod.DataStructures
|
||||
{
|
||||
@@ -14,6 +15,11 @@ namespace CalamityMod.DataStructures
|
||||
public const float SpongeShieldDepth = 4f;
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Owner of this Renderer Item
|
||||
/// </summary>
|
||||
public Player OwnerPlayer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The draw depth of the renderer. This is used to draw them in descending order; higher values are drawn first.
|
||||
/// </summary>
|
||||
|
||||
@@ -44,8 +44,13 @@ namespace CalamityMod.Graphics.Renderers.CalamityRenderers
|
||||
|
||||
public override void Unload()
|
||||
{
|
||||
Targets?.Clear();
|
||||
Targets = null;
|
||||
|
||||
Dyes?.Clear();
|
||||
Dyes = null;
|
||||
|
||||
RenderersToDrawThisFrame?.Clear();
|
||||
RenderersToDrawThisFrame = null;
|
||||
}
|
||||
#endregion
|
||||
@@ -61,7 +66,8 @@ namespace CalamityMod.Graphics.Renderers.CalamityRenderers
|
||||
if (armorItem.ModItem is not IDyeableShaderRenderer drawer)
|
||||
return;
|
||||
|
||||
// Store the dye in the slot.
|
||||
// Store the dye and player in the slot.
|
||||
drawer.OwnerPlayer = self;
|
||||
Dyes[drawer] = GameShaders.Armor.GetShaderFromItemId(dyeItem.type);
|
||||
}
|
||||
|
||||
@@ -149,7 +155,10 @@ namespace CalamityMod.Graphics.Renderers.CalamityRenderers
|
||||
|
||||
#region Updates/Drawing
|
||||
// Clear the list at the beginning of each update, to ensure its only populated by correct ones.
|
||||
public override void PreUpdate() => RenderersToDrawThisFrame?.Clear();
|
||||
public override void PreUpdate()
|
||||
{
|
||||
RenderersToDrawThisFrame?.Clear();
|
||||
}
|
||||
|
||||
public override void DrawToTarget(SpriteBatch spriteBatch)
|
||||
{
|
||||
@@ -171,9 +180,6 @@ namespace CalamityMod.Graphics.Renderers.CalamityRenderers
|
||||
// Swap to the assosiated target and call the interface method.
|
||||
target.SwapTo();
|
||||
renderer.DrawDyeableShader(spriteBatch);
|
||||
|
||||
// TODO: Dye will applied as first dye item it found on "server" (aka player index 0's dye)
|
||||
// - This should be fixed but can't figure out good way to fix this in clean way
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +189,7 @@ namespace CalamityMod.Graphics.Renderers.CalamityRenderers
|
||||
return;
|
||||
|
||||
// Leave if nothing to draw.
|
||||
if (!RenderersToDrawThisFrame.Any())
|
||||
if (RenderersToDrawThisFrame.Count <= 0)
|
||||
return;
|
||||
|
||||
foreach (var renderer in RenderersToDrawThisFrame)
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace CalamityMod.Items.Accessories
|
||||
public static int ShieldDurabilityMax = 25;
|
||||
|
||||
// Interface stuff.
|
||||
public Player OwnerPlayer { get; set; }
|
||||
public float RenderDepth => IDyeableShaderRenderer.ProfanedSoulShieldDepth;
|
||||
|
||||
public bool ShouldDrawDyeableShader
|
||||
@@ -59,7 +60,7 @@ namespace CalamityMod.Items.Accessories
|
||||
ItemID.Sets.AnimatesAsSoul[Type] = true;
|
||||
}
|
||||
|
||||
public void DrawDyeableShader(SpriteBatch spriteBatch) => DrawProfanedSoulShields();
|
||||
public void DrawDyeableShader(SpriteBatch spriteBatch) => DrawProfanedSoulShields(OwnerPlayer);
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
@@ -106,82 +107,82 @@ namespace CalamityMod.Items.Accessories
|
||||
|
||||
// Complex drawcode which draws Profaned Soul shields on ALL players who have it available. Supposedly.
|
||||
// This is applied as IL (On hook) which draws right before Inferno Ring.
|
||||
internal static void DrawProfanedSoulShields()
|
||||
internal static void DrawProfanedSoulShields(Player player)
|
||||
{
|
||||
foreach (Player player in Main.ActivePlayers)
|
||||
if (player is null)
|
||||
return;
|
||||
|
||||
if (player.outOfRange || player.dead)
|
||||
return;
|
||||
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
|
||||
if (modPlayer.drawnAnyShieldThisFrame)
|
||||
return;
|
||||
|
||||
if (modPlayer.drawingParameters.ProfanedShieldCharge <= 0.0f)
|
||||
return;
|
||||
|
||||
// Scale the shield is drawn at.
|
||||
// The "i" parameter is to make different player's shields not be perfectly synced.
|
||||
int i = player.whoAmI;
|
||||
float scale = 0.15f + 0.03f * (0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 0.5f + i * 0.2f));
|
||||
float visualShieldStrength = modPlayer.drawingParameters.ProfanedShieldCharge;
|
||||
Color shieldColor = modPlayer.drawingParameters.ProfanedShieldColor;
|
||||
|
||||
// The scale used for the noise overlay polygons also grows and shrinks
|
||||
// This is intentionally out of sync with the shield, and intentionally desynced per player
|
||||
// Don't put this anywhere less than 0.25f or higher than 1f. The higher it is, the denser / more zoomed out the noise overlay is.
|
||||
float noiseScale = MathHelper.Lerp(0.4f, 0.8f, MathF.Sin(Main.GlobalTimeWrappedHourly * 0.3f) * 0.5f + 0.5f);
|
||||
|
||||
// Define shader parameters
|
||||
Effect shieldEffect = Filters.Scene["CalamityMod:RoverDriveShield"].GetShader().Shader;
|
||||
shieldEffect.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 0.058f); // Scrolling speed of polygonal overlay
|
||||
shieldEffect.Parameters["blowUpPower"].SetValue(2.8f);
|
||||
shieldEffect.Parameters["blowUpSize"].SetValue(0.4f);
|
||||
shieldEffect.Parameters["noiseScale"].SetValue(noiseScale);
|
||||
|
||||
// Shield opacity multiplier slightly changes, this is independent of current shield strength
|
||||
float baseShieldOpacity = 0.9f + 0.1f * MathF.Sin(Main.GlobalTimeWrappedHourly * 1.95f);
|
||||
float minShieldStrengthOpacityMultiplier = 0.5f;
|
||||
float finalShieldOpacity = baseShieldOpacity * MathHelper.Lerp(minShieldStrengthOpacityMultiplier, 1f, visualShieldStrength);
|
||||
finalShieldOpacity *= CalamityClientConfig.Instance.EnergyShieldOpacity;
|
||||
|
||||
shieldEffect.Parameters["shieldOpacity"].SetValue(finalShieldOpacity);
|
||||
shieldEffect.Parameters["shieldEdgeBlendStrenght"].SetValue(4f);
|
||||
|
||||
Color primaryEdgeColor = new Color(230, 199, 102) * 0.8f;
|
||||
Color secondaryEdgeColor = new Color(249, 231, 217) * 0.8f;
|
||||
Color edgeColor = CalamityUtils.MulticolorLerp(Main.GlobalTimeWrappedHourly * 0.2f, primaryEdgeColor, secondaryEdgeColor);
|
||||
|
||||
// Define shader parameters for shield color
|
||||
shieldEffect.Parameters["shieldColor"].SetValue(shieldColor.ToVector3());
|
||||
shieldEffect.Parameters["shieldEdgeColor"].SetValue(edgeColor.ToVector3());
|
||||
|
||||
var matrix = Main.GameViewMatrix.TransformationMatrix;
|
||||
Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, shieldEffect, matrix, () =>
|
||||
{
|
||||
if (player.outOfRange || player.dead)
|
||||
continue;
|
||||
// Fetch shield heat overlay texture (this is the neutrons fed to the shader)
|
||||
HeatTex ??= ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons2");
|
||||
Vector2 pos = player.MountedCenter + player.gfxOffY * Vector2.UnitY - Main.screenPosition;
|
||||
Texture2D tex = HeatTex.Value;
|
||||
Main.spriteBatch.Draw(tex, pos, null, Color.White, 0, tex.Size() / 2f, scale, 0, 0);
|
||||
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
//The border circle MUST be drawn after otherwise it becomes visually fucked.
|
||||
float shieldScale = scale * 1.75f;
|
||||
Texture2D shieldTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleOpenCircle").Value;
|
||||
Rectangle shieldFrame = shieldTexture.Frame();
|
||||
Vector2 origin = shieldFrame.Size() * 0.5f;
|
||||
Main.spriteBatch.End();
|
||||
|
||||
if (modPlayer.drawnAnyShieldThisFrame)
|
||||
continue;
|
||||
|
||||
if (modPlayer.drawingParameters.ProfanedShieldCharge <= 0.0f)
|
||||
continue;
|
||||
|
||||
// Scale the shield is drawn at.
|
||||
// The "i" parameter is to make different player's shields not be perfectly synced.
|
||||
int i = player.whoAmI;
|
||||
float scale = 0.15f + 0.03f * (0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 0.5f + i * 0.2f));
|
||||
float visualShieldStrength = modPlayer.drawingParameters.ProfanedShieldCharge;
|
||||
Color shieldColor = modPlayer.drawingParameters.ProfanedShieldColor;
|
||||
|
||||
// The scale used for the noise overlay polygons also grows and shrinks
|
||||
// This is intentionally out of sync with the shield, and intentionally desynced per player
|
||||
// Don't put this anywhere less than 0.25f or higher than 1f. The higher it is, the denser / more zoomed out the noise overlay is.
|
||||
float noiseScale = MathHelper.Lerp(0.4f, 0.8f, MathF.Sin(Main.GlobalTimeWrappedHourly * 0.3f) * 0.5f + 0.5f);
|
||||
|
||||
// Define shader parameters
|
||||
Effect shieldEffect = Filters.Scene["CalamityMod:RoverDriveShield"].GetShader().Shader;
|
||||
shieldEffect.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 0.058f); // Scrolling speed of polygonal overlay
|
||||
shieldEffect.Parameters["blowUpPower"].SetValue(2.8f);
|
||||
shieldEffect.Parameters["blowUpSize"].SetValue(0.4f);
|
||||
shieldEffect.Parameters["noiseScale"].SetValue(noiseScale);
|
||||
|
||||
// Shield opacity multiplier slightly changes, this is independent of current shield strength
|
||||
float baseShieldOpacity = 0.9f + 0.1f * MathF.Sin(Main.GlobalTimeWrappedHourly * 1.95f);
|
||||
float minShieldStrengthOpacityMultiplier = 0.5f;
|
||||
float finalShieldOpacity = baseShieldOpacity * MathHelper.Lerp(minShieldStrengthOpacityMultiplier, 1f, visualShieldStrength);
|
||||
finalShieldOpacity *= CalamityClientConfig.Instance.EnergyShieldOpacity;
|
||||
|
||||
shieldEffect.Parameters["shieldOpacity"].SetValue(finalShieldOpacity);
|
||||
shieldEffect.Parameters["shieldEdgeBlendStrenght"].SetValue(4f);
|
||||
|
||||
Color primaryEdgeColor = new Color(230, 199, 102) * 0.8f;
|
||||
Color secondaryEdgeColor = new Color(249, 231, 217) * 0.8f;
|
||||
Color edgeColor = CalamityUtils.MulticolorLerp(Main.GlobalTimeWrappedHourly * 0.2f, primaryEdgeColor, secondaryEdgeColor);
|
||||
|
||||
// Define shader parameters for shield color
|
||||
shieldEffect.Parameters["shieldColor"].SetValue(shieldColor.ToVector3());
|
||||
shieldEffect.Parameters["shieldEdgeColor"].SetValue(edgeColor.ToVector3());
|
||||
|
||||
var matrix = Main.GameViewMatrix.TransformationMatrix;
|
||||
Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, shieldEffect, matrix, () =>
|
||||
{
|
||||
// Fetch shield heat overlay texture (this is the neutrons fed to the shader)
|
||||
HeatTex ??= ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons2");
|
||||
Vector2 pos = player.MountedCenter + player.gfxOffY * Vector2.UnitY - Main.screenPosition;
|
||||
Texture2D tex = HeatTex.Value;
|
||||
Main.spriteBatch.Draw(tex, pos, null, Color.White, 0, tex.Size() / 2f, scale, 0, 0);
|
||||
|
||||
//The border circle MUST be drawn after otherwise it becomes visually fucked.
|
||||
float shieldScale = scale * 1.75f;
|
||||
Texture2D shieldTexture = ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleOpenCircle").Value;
|
||||
Rectangle shieldFrame = shieldTexture.Frame();
|
||||
Vector2 origin = shieldFrame.Size() * 0.5f;
|
||||
Main.spriteBatch.End();
|
||||
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
|
||||
Main.spriteBatch.Draw(shieldTexture, pos, shieldFrame, shieldColor * 0.5f, player.fullRotation, origin, shieldScale, SpriteEffects.None, 0f);
|
||||
Main.spriteBatch.Draw(shieldTexture, pos, shieldFrame, secondaryEdgeColor * 0.5f, player.fullRotation, origin, shieldScale * 0.95f, SpriteEffects.None, 0f);
|
||||
Main.spriteBatch.Draw(shieldTexture, pos, shieldFrame, shieldColor * 0.5f, player.fullRotation, origin, shieldScale, SpriteEffects.None, 0f);
|
||||
Main.spriteBatch.Draw(shieldTexture, pos, shieldFrame, secondaryEdgeColor * 0.5f, player.fullRotation, origin, shieldScale * 0.95f, SpriteEffects.None, 0f);
|
||||
Main.spriteBatch.End();
|
||||
});
|
||||
modPlayer.drawnAnyShieldThisFrame = true;
|
||||
}
|
||||
Main.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix);
|
||||
Main.spriteBatch.Draw(shieldTexture, pos, shieldFrame, shieldColor * 0.5f, player.fullRotation, origin, shieldScale, SpriteEffects.None, 0f);
|
||||
Main.spriteBatch.Draw(shieldTexture, pos, shieldFrame, secondaryEdgeColor * 0.5f, player.fullRotation, origin, shieldScale * 0.95f, SpriteEffects.None, 0f);
|
||||
Main.spriteBatch.Draw(shieldTexture, pos, shieldFrame, shieldColor * 0.5f, player.fullRotation, origin, shieldScale, SpriteEffects.None, 0f);
|
||||
Main.spriteBatch.Draw(shieldTexture, pos, shieldFrame, secondaryEdgeColor * 0.5f, player.fullRotation, origin, shieldScale * 0.95f, SpriteEffects.None, 0f);
|
||||
Main.spriteBatch.End();
|
||||
});
|
||||
modPlayer.drawnAnyShieldThisFrame = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,8 +33,8 @@ namespace CalamityMod.Items.Accessories
|
||||
public const int maxPscAnimTime = 120;
|
||||
|
||||
// Interface stuff.
|
||||
public Player OwnerPlayer { get; set; }
|
||||
public float RenderDepth => IDyeableShaderRenderer.ProfanedSoulShieldDepth;
|
||||
|
||||
public bool ShaderIsDyeable => false;
|
||||
|
||||
public bool ShouldDrawDyeableShader
|
||||
@@ -65,7 +65,7 @@ namespace CalamityMod.Items.Accessories
|
||||
Empowered //psc but no other minions, healer guardian functionality, inherits all other functionality (except vanity) and goes even further beyond, any remaining attack changes are here
|
||||
}
|
||||
|
||||
public void DrawDyeableShader(SpriteBatch spriteBatch) => ProfanedSoulArtifact.DrawProfanedSoulShields();
|
||||
public void DrawDyeableShader(SpriteBatch spriteBatch) => ProfanedSoulArtifact.DrawProfanedSoulShields(OwnerPlayer);
|
||||
|
||||
internal static ProfanedSoulCrystalState GetPscStateFor(Player player, bool ignoreNoBuffs = false)
|
||||
{
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace CalamityMod.Items.Accessories
|
||||
public static int ShieldDefenseBoost = 10;
|
||||
|
||||
// Interface stuff.
|
||||
public Player OwnerPlayer { get; set; }
|
||||
public float RenderDepth => IDyeableShaderRenderer.RoverDriveDepth;
|
||||
|
||||
public bool ShouldDrawDyeableShader
|
||||
@@ -103,65 +104,66 @@ namespace CalamityMod.Items.Accessories
|
||||
// This is applied as IL (On hook) which draws right before Inferno Ring.
|
||||
public void DrawDyeableShader(SpriteBatch spriteBatch)
|
||||
{
|
||||
foreach (Player player in Main.ActivePlayers)
|
||||
var player = OwnerPlayer;
|
||||
if (player is null)
|
||||
return;
|
||||
|
||||
if (player.outOfRange || player.dead)
|
||||
return;
|
||||
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
if (modPlayer.drawnAnyShieldThisFrame)
|
||||
return;
|
||||
|
||||
if (modPlayer.drawingParameters.RoverShieldCharge <= 0.0f)
|
||||
return;
|
||||
|
||||
// The shield very gently grows and shrinks
|
||||
float scale = 0.15f + 0.03f * (0.5f + 0.5f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 0.5f + player.whoAmI * 0.2f));
|
||||
// If in vanity, the shield is always projected as if it's at full strength.
|
||||
float shieldStrength = modPlayer.drawingParameters.RoverShieldCharge;
|
||||
|
||||
// Noise scale also grows and shrinks, although out of sync with the shield
|
||||
float noiseScale = MathHelper.Lerp(0.4f, 0.8f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * 0.3f) * 0.5f + 0.5f);
|
||||
|
||||
// Define shader parameters
|
||||
Effect shieldEffect = Filters.Scene["CalamityMod:RoverDriveShield"].GetShader().Shader;
|
||||
shieldEffect.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 0.24f);
|
||||
shieldEffect.Parameters["blowUpPower"].SetValue(2.5f);
|
||||
shieldEffect.Parameters["blowUpSize"].SetValue(0.5f);
|
||||
shieldEffect.Parameters["noiseScale"].SetValue(noiseScale);
|
||||
|
||||
// Shield opacity multiplier slightly changes, this is independent of current shield strength
|
||||
float baseShieldOpacity = 0.9f + 0.1f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 2f);
|
||||
float finalShieldOpacity = baseShieldOpacity * (0.5f + 0.5f * shieldStrength);
|
||||
finalShieldOpacity *= CalamityClientConfig.Instance.EnergyShieldOpacity;
|
||||
|
||||
shieldEffect.Parameters["shieldOpacity"].SetValue(finalShieldOpacity);
|
||||
shieldEffect.Parameters["shieldEdgeBlendStrenght"].SetValue(4f);
|
||||
|
||||
// Get the shield color.
|
||||
Color blueTint = new Color(51, 102, 255);
|
||||
Color cyanTint = new Color(71, 202, 255);
|
||||
Color wulfGreen = new Color(194, 255, 67) * 0.8f;
|
||||
Color edgeColor = CalamityUtils.MulticolorLerp(Main.GlobalTimeWrappedHourly * 0.2f, blueTint, cyanTint, wulfGreen);
|
||||
Color shieldColor = blueTint;
|
||||
|
||||
|
||||
// Define shader parameters for shield color
|
||||
shieldEffect.Parameters["shieldColor"].SetValue(shieldColor.ToVector3());
|
||||
shieldEffect.Parameters["shieldEdgeColor"].SetValue(edgeColor.ToVector3());
|
||||
|
||||
var matrix = Main.GameViewMatrix.TransformationMatrix;
|
||||
Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, shieldEffect, matrix, () =>
|
||||
{
|
||||
if (player.outOfRange || player.dead)
|
||||
continue;
|
||||
// Fetch shield noise overlay texture (this is the techy overlay fed to the shader)
|
||||
NoiseTex ??= ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/TechyNoise");
|
||||
Vector2 pos = player.MountedCenter + player.gfxOffY * Vector2.UnitY - Main.screenPosition;
|
||||
Texture2D tex = NoiseTex.Value;
|
||||
spriteBatch.Draw(tex, pos, null, Color.White, 0, tex.Size() / 2f, scale, 0, 0);
|
||||
});
|
||||
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
if (modPlayer.drawnAnyShieldThisFrame)
|
||||
continue;
|
||||
|
||||
if (modPlayer.drawingParameters.RoverShieldCharge <= 0.0f)
|
||||
continue;
|
||||
|
||||
// The shield very gently grows and shrinks
|
||||
float scale = 0.15f + 0.03f * (0.5f + 0.5f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 0.5f + player.whoAmI * 0.2f));
|
||||
// If in vanity, the shield is always projected as if it's at full strength.
|
||||
float shieldStrength = modPlayer.drawingParameters.RoverShieldCharge;
|
||||
|
||||
// Noise scale also grows and shrinks, although out of sync with the shield
|
||||
float noiseScale = MathHelper.Lerp(0.4f, 0.8f, (float)Math.Sin(Main.GlobalTimeWrappedHourly * 0.3f) * 0.5f + 0.5f);
|
||||
|
||||
// Define shader parameters
|
||||
Effect shieldEffect = Filters.Scene["CalamityMod:RoverDriveShield"].GetShader().Shader;
|
||||
shieldEffect.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 0.24f);
|
||||
shieldEffect.Parameters["blowUpPower"].SetValue(2.5f);
|
||||
shieldEffect.Parameters["blowUpSize"].SetValue(0.5f);
|
||||
shieldEffect.Parameters["noiseScale"].SetValue(noiseScale);
|
||||
|
||||
// Shield opacity multiplier slightly changes, this is independent of current shield strength
|
||||
float baseShieldOpacity = 0.9f + 0.1f * (float)Math.Sin(Main.GlobalTimeWrappedHourly * 2f);
|
||||
float finalShieldOpacity = baseShieldOpacity * (0.5f + 0.5f * shieldStrength);
|
||||
finalShieldOpacity *= CalamityClientConfig.Instance.EnergyShieldOpacity;
|
||||
|
||||
shieldEffect.Parameters["shieldOpacity"].SetValue(finalShieldOpacity);
|
||||
shieldEffect.Parameters["shieldEdgeBlendStrenght"].SetValue(4f);
|
||||
|
||||
// Get the shield color.
|
||||
Color blueTint = new Color(51, 102, 255);
|
||||
Color cyanTint = new Color(71, 202, 255);
|
||||
Color wulfGreen = new Color(194, 255, 67) * 0.8f;
|
||||
Color edgeColor = CalamityUtils.MulticolorLerp(Main.GlobalTimeWrappedHourly * 0.2f, blueTint, cyanTint, wulfGreen);
|
||||
Color shieldColor = blueTint;
|
||||
|
||||
|
||||
// Define shader parameters for shield color
|
||||
shieldEffect.Parameters["shieldColor"].SetValue(shieldColor.ToVector3());
|
||||
shieldEffect.Parameters["shieldEdgeColor"].SetValue(edgeColor.ToVector3());
|
||||
|
||||
var matrix = Main.GameViewMatrix.TransformationMatrix;
|
||||
Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, shieldEffect, matrix, () =>
|
||||
{
|
||||
// Fetch shield noise overlay texture (this is the techy overlay fed to the shader)
|
||||
NoiseTex ??= ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/TechyNoise");
|
||||
Vector2 pos = player.MountedCenter + player.gfxOffY * Vector2.UnitY - Main.screenPosition;
|
||||
Texture2D tex = NoiseTex.Value;
|
||||
spriteBatch.Draw(tex, pos, null, Color.White, 0, tex.Size() / 2f, scale, 0, 0);
|
||||
});
|
||||
|
||||
modPlayer.drawnAnyShieldThisFrame = true;
|
||||
}
|
||||
modPlayer.drawnAnyShieldThisFrame = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ namespace CalamityMod.Items.Accessories
|
||||
public static int ShieldActiveDefense = 30;
|
||||
public static float ShieldActiveDamageReduction = 0.1f;
|
||||
|
||||
public Player OwnerPlayer { get; set; }
|
||||
public float RenderDepth => IDyeableShaderRenderer.SpongeShieldDepth;
|
||||
|
||||
public bool ShouldDrawDyeableShader
|
||||
@@ -169,72 +170,73 @@ namespace CalamityMod.Items.Accessories
|
||||
// This is applied as IL (On hook) which draws right before Inferno Ring.
|
||||
public void DrawDyeableShader(SpriteBatch spriteBatch)
|
||||
{
|
||||
foreach (Player player in Main.ActivePlayers)
|
||||
var player = OwnerPlayer;
|
||||
if (player is null)
|
||||
return;
|
||||
|
||||
if (player.outOfRange || player.dead)
|
||||
return;
|
||||
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
if (modPlayer.drawnAnyShieldThisFrame)
|
||||
return;
|
||||
|
||||
if (modPlayer.drawingParameters.SpongeShieldCharge <= 0.0f)
|
||||
return;
|
||||
|
||||
// Scale the shield is drawn at. The Sponge shield gently grows and shrinks; it should be largely imperceptible.
|
||||
// The "i" parameter is to make different player's shields not be perfectly synced.
|
||||
int i = player.whoAmI;
|
||||
float baseScale = 0.155f;
|
||||
float maxExtraScale = 0.025f;
|
||||
float extraScalePulseInterpolant = MathF.Pow(4f, MathF.Sin(Main.GlobalTimeWrappedHourly * 0.791f + i) - 1);
|
||||
float scale = baseScale + maxExtraScale * extraScalePulseInterpolant;
|
||||
float visualShieldStrength = modPlayer.drawingParameters.SpongeShieldCharge;
|
||||
|
||||
// The scale used for the noise overlay also grows and shrinks
|
||||
// This is intentionally out of sync with the shield, and intentionally desynced per player
|
||||
// Don't put this anywhere less than 0.15f or higher than 0.75f. The higher it is, the denser / more zoomed out the noise overlay is.
|
||||
// Changing this too quickly and/or too much makes the noise grow and shrink visibly, so be careful with that.
|
||||
float noiseScale = MathHelper.Lerp(0.28f, 0.38f, 0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 0.347f + i));
|
||||
|
||||
// Define shader parameters
|
||||
Effect shieldEffect = Filters.Scene["CalamityMod:RoverDriveShield"].GetShader().Shader;
|
||||
shieldEffect.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 0.0813f); // Scrolling speed of polygonal overlay
|
||||
shieldEffect.Parameters["blowUpPower"].SetValue(3f);
|
||||
shieldEffect.Parameters["blowUpSize"].SetValue(0.56f);
|
||||
shieldEffect.Parameters["noiseScale"].SetValue(noiseScale);
|
||||
|
||||
// Shield opacity multiplier slightly changes, this is independent of current shield strength
|
||||
float baseShieldOpacity = 0.9f + 0.1f * MathF.Sin(Main.GlobalTimeWrappedHourly * 1.95f);
|
||||
float minShieldStrengthOpacityMultiplier = 0.25f;
|
||||
float finalShieldOpacity = baseShieldOpacity * MathHelper.Lerp(minShieldStrengthOpacityMultiplier, 1f, visualShieldStrength);
|
||||
finalShieldOpacity *= CalamityClientConfig.Instance.EnergyShieldOpacity;
|
||||
|
||||
shieldEffect.Parameters["shieldOpacity"].SetValue(finalShieldOpacity);
|
||||
shieldEffect.Parameters["shieldEdgeBlendStrenght"].SetValue(4f);
|
||||
|
||||
Color shieldColor = new Color(24, 156, 204); // #189CCC
|
||||
Color primaryEdgeColor = shieldColor;
|
||||
Color secondaryEdgeColor = new Color(34, 224, 227); // #22E0E3
|
||||
|
||||
// Final shield edge color, which lerps about
|
||||
Color edgeColor = CalamityUtils.MulticolorLerp(Main.GlobalTimeWrappedHourly * 0.2f, primaryEdgeColor, secondaryEdgeColor);
|
||||
|
||||
// Define shader parameters for shield color
|
||||
shieldEffect.Parameters["shieldColor"].SetValue(shieldColor.ToVector3());
|
||||
shieldEffect.Parameters["shieldEdgeColor"].SetValue(edgeColor.ToVector3());
|
||||
|
||||
var matrix = Main.GameViewMatrix.TransformationMatrix;
|
||||
Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, shieldEffect, matrix, () =>
|
||||
{
|
||||
if (player.outOfRange || player.dead)
|
||||
continue;
|
||||
// Fetch shield noise overlay texture (this is the polygons fed to the shader)
|
||||
NoiseTex ??= ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons");
|
||||
Vector2 pos = player.MountedCenter + player.gfxOffY * Vector2.UnitY - Main.screenPosition;
|
||||
Texture2D tex = NoiseTex.Value;
|
||||
Main.spriteBatch.Draw(tex, pos, null, Color.White, 0, tex.Size() / 2f, scale, 0, 0);
|
||||
});
|
||||
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
if (modPlayer.drawnAnyShieldThisFrame)
|
||||
continue;
|
||||
|
||||
if (modPlayer.drawingParameters.SpongeShieldCharge <= 0.0f)
|
||||
continue;
|
||||
|
||||
// Scale the shield is drawn at. The Sponge shield gently grows and shrinks; it should be largely imperceptible.
|
||||
// The "i" parameter is to make different player's shields not be perfectly synced.
|
||||
int i = player.whoAmI;
|
||||
float baseScale = 0.155f;
|
||||
float maxExtraScale = 0.025f;
|
||||
float extraScalePulseInterpolant = MathF.Pow(4f, MathF.Sin(Main.GlobalTimeWrappedHourly * 0.791f + i) - 1);
|
||||
float scale = baseScale + maxExtraScale * extraScalePulseInterpolant;
|
||||
float visualShieldStrength = modPlayer.drawingParameters.SpongeShieldCharge;
|
||||
|
||||
// The scale used for the noise overlay also grows and shrinks
|
||||
// This is intentionally out of sync with the shield, and intentionally desynced per player
|
||||
// Don't put this anywhere less than 0.15f or higher than 0.75f. The higher it is, the denser / more zoomed out the noise overlay is.
|
||||
// Changing this too quickly and/or too much makes the noise grow and shrink visibly, so be careful with that.
|
||||
float noiseScale = MathHelper.Lerp(0.28f, 0.38f, 0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 0.347f + i));
|
||||
|
||||
// Define shader parameters
|
||||
Effect shieldEffect = Filters.Scene["CalamityMod:RoverDriveShield"].GetShader().Shader;
|
||||
shieldEffect.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 0.0813f); // Scrolling speed of polygonal overlay
|
||||
shieldEffect.Parameters["blowUpPower"].SetValue(3f);
|
||||
shieldEffect.Parameters["blowUpSize"].SetValue(0.56f);
|
||||
shieldEffect.Parameters["noiseScale"].SetValue(noiseScale);
|
||||
|
||||
// Shield opacity multiplier slightly changes, this is independent of current shield strength
|
||||
float baseShieldOpacity = 0.9f + 0.1f * MathF.Sin(Main.GlobalTimeWrappedHourly * 1.95f);
|
||||
float minShieldStrengthOpacityMultiplier = 0.25f;
|
||||
float finalShieldOpacity = baseShieldOpacity * MathHelper.Lerp(minShieldStrengthOpacityMultiplier, 1f, visualShieldStrength);
|
||||
finalShieldOpacity *= CalamityClientConfig.Instance.EnergyShieldOpacity;
|
||||
|
||||
shieldEffect.Parameters["shieldOpacity"].SetValue(finalShieldOpacity);
|
||||
shieldEffect.Parameters["shieldEdgeBlendStrenght"].SetValue(4f);
|
||||
|
||||
Color shieldColor = new Color(24, 156, 204); // #189CCC
|
||||
Color primaryEdgeColor = shieldColor;
|
||||
Color secondaryEdgeColor = new Color(34, 224, 227); // #22E0E3
|
||||
|
||||
// Final shield edge color, which lerps about
|
||||
Color edgeColor = CalamityUtils.MulticolorLerp(Main.GlobalTimeWrappedHourly * 0.2f, primaryEdgeColor, secondaryEdgeColor);
|
||||
|
||||
// Define shader parameters for shield color
|
||||
shieldEffect.Parameters["shieldColor"].SetValue(shieldColor.ToVector3());
|
||||
shieldEffect.Parameters["shieldEdgeColor"].SetValue(edgeColor.ToVector3());
|
||||
|
||||
var matrix = Main.GameViewMatrix.TransformationMatrix;
|
||||
Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, shieldEffect, matrix, () =>
|
||||
{
|
||||
// Fetch shield noise overlay texture (this is the polygons fed to the shader)
|
||||
NoiseTex ??= ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons");
|
||||
Vector2 pos = player.MountedCenter + player.gfxOffY * Vector2.UnitY - Main.screenPosition;
|
||||
Texture2D tex = NoiseTex.Value;
|
||||
Main.spriteBatch.Draw(tex, pos, null, Color.White, 0, tex.Size() / 2f, scale, 0, 0);
|
||||
});
|
||||
|
||||
modPlayer.drawnAnyShieldThisFrame = true;
|
||||
}
|
||||
modPlayer.drawnAnyShieldThisFrame = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,8 +33,8 @@ namespace CalamityMod.Items.Armor.LunicCorps
|
||||
public static int TotalShieldRechargeTime = CalamityUtils.SecondsToFrames(2);
|
||||
|
||||
// Interface stuff.
|
||||
public Player OwnerPlayer { get; set; }
|
||||
public float RenderDepth => IDyeableShaderRenderer.HaloShieldDepth;
|
||||
|
||||
public bool ShaderIsDyeable => false;
|
||||
|
||||
public bool ShouldDrawDyeableShader
|
||||
@@ -109,70 +109,71 @@ namespace CalamityMod.Items.Armor.LunicCorps
|
||||
// This is applied as IL (On hook) which draws right before Inferno Ring.
|
||||
public void DrawDyeableShader(SpriteBatch spriteBatch)
|
||||
{
|
||||
foreach (Player player in Main.ActivePlayers)
|
||||
var player = OwnerPlayer;
|
||||
if (player is null)
|
||||
return;
|
||||
|
||||
if (player.outOfRange || player.dead)
|
||||
return;
|
||||
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
if (modPlayer.drawnAnyShieldThisFrame)
|
||||
return;
|
||||
|
||||
if (modPlayer.drawingParameters.LunicShieldCharge <= 0.0f)
|
||||
return;
|
||||
|
||||
// Scale the shield is drawn at. The Lunic Corps shield sticks very close to the body to mimic Halo and occasionally pulses.
|
||||
// The "i" parameter is to make different player's shields not be perfectly synced.
|
||||
int i = player.whoAmI;
|
||||
float baseScale = 0.11f;
|
||||
float maxExtraScale = 0.013f;
|
||||
float extraScalePulseInterpolant = MathF.Pow(12f, MathF.Sin(Main.GlobalTimeWrappedHourly * 1.6f + i) - 1);
|
||||
float scale = baseScale + maxExtraScale * extraScalePulseInterpolant;
|
||||
float visualShieldStrength = modPlayer.drawingParameters.LunicShieldCharge;
|
||||
|
||||
// The scale used for the noise overlay polygons also grows and shrinks
|
||||
// This is intentionally out of sync with the shield, and intentionally desynced per player
|
||||
// Don't put this anywhere less than 0.25f or higher than 1f. The higher it is, the denser / more zoomed out the noise overlay is.
|
||||
float noiseScale = MathHelper.Lerp(0.65f, 0.75f, 0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 0.87f + i));
|
||||
|
||||
// Define shader parameters
|
||||
Effect shieldEffect = Filters.Scene["CalamityMod:RoverDriveShield"].GetShader().Shader;
|
||||
shieldEffect.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 0.058f); // Scrolling speed of polygonal overlay
|
||||
shieldEffect.Parameters["blowUpPower"].SetValue(2.8f);
|
||||
shieldEffect.Parameters["blowUpSize"].SetValue(0.4f);
|
||||
shieldEffect.Parameters["noiseScale"].SetValue(noiseScale);
|
||||
|
||||
// Shield opacity multiplier slightly changes, this is independent of current shield strength
|
||||
float baseShieldOpacity = 0.9f + 0.1f * MathF.Sin(Main.GlobalTimeWrappedHourly * 1.95f);
|
||||
float minShieldStrengthOpacityMultiplier = 0.5f;
|
||||
float finalShieldOpacity = baseShieldOpacity * MathHelper.Lerp(minShieldStrengthOpacityMultiplier, 1f, visualShieldStrength);
|
||||
finalShieldOpacity *= CalamityClientConfig.Instance.EnergyShieldOpacity;
|
||||
|
||||
shieldEffect.Parameters["shieldOpacity"].SetValue(finalShieldOpacity);
|
||||
shieldEffect.Parameters["shieldEdgeBlendStrenght"].SetValue(4f);
|
||||
|
||||
// Lunic Corps shields are not team specific
|
||||
Color shieldColor = new Color(201, 180, 129);
|
||||
Color primaryEdgeColor = new Color(232, 212, 175);
|
||||
Color secondaryEdgeColor = new Color(237, 205, 145);
|
||||
Color edgeColor = CalamityUtils.MulticolorLerp(Main.GlobalTimeWrappedHourly * 0.2f, primaryEdgeColor, secondaryEdgeColor);
|
||||
|
||||
// Define shader parameters for shield color
|
||||
shieldEffect.Parameters["shieldColor"].SetValue(shieldColor.ToVector3());
|
||||
shieldEffect.Parameters["shieldEdgeColor"].SetValue(edgeColor.ToVector3());
|
||||
|
||||
var matrix = Main.GameViewMatrix.TransformationMatrix;
|
||||
Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, shieldEffect, matrix, () =>
|
||||
{
|
||||
if (player.outOfRange || player.dead)
|
||||
continue;
|
||||
// Fetch shield noise overlay texture (this is the polygons fed to the shader)
|
||||
NoiseTex ??= ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/VoronoiShapes2");
|
||||
Vector2 pos = player.MountedCenter + player.gfxOffY * Vector2.UnitY - Main.screenPosition;
|
||||
Texture2D tex = NoiseTex.Value;
|
||||
spriteBatch.Draw(tex, pos, null, Color.White, 0, tex.Size() / 2f, scale, 0, 0);
|
||||
});
|
||||
|
||||
CalamityPlayer modPlayer = player.Calamity();
|
||||
if (modPlayer.drawnAnyShieldThisFrame)
|
||||
continue;
|
||||
|
||||
if (modPlayer.drawingParameters.LunicShieldCharge <= 0.0f)
|
||||
continue;
|
||||
|
||||
// Scale the shield is drawn at. The Lunic Corps shield sticks very close to the body to mimic Halo and occasionally pulses.
|
||||
// The "i" parameter is to make different player's shields not be perfectly synced.
|
||||
int i = player.whoAmI;
|
||||
float baseScale = 0.11f;
|
||||
float maxExtraScale = 0.013f;
|
||||
float extraScalePulseInterpolant = MathF.Pow(12f, MathF.Sin(Main.GlobalTimeWrappedHourly * 1.6f + i) - 1);
|
||||
float scale = baseScale + maxExtraScale * extraScalePulseInterpolant;
|
||||
float visualShieldStrength = modPlayer.drawingParameters.LunicShieldCharge;
|
||||
|
||||
// The scale used for the noise overlay polygons also grows and shrinks
|
||||
// This is intentionally out of sync with the shield, and intentionally desynced per player
|
||||
// Don't put this anywhere less than 0.25f or higher than 1f. The higher it is, the denser / more zoomed out the noise overlay is.
|
||||
float noiseScale = MathHelper.Lerp(0.65f, 0.75f, 0.5f + 0.5f * MathF.Sin(Main.GlobalTimeWrappedHourly * 0.87f + i));
|
||||
|
||||
// Define shader parameters
|
||||
Effect shieldEffect = Filters.Scene["CalamityMod:RoverDriveShield"].GetShader().Shader;
|
||||
shieldEffect.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly * 0.058f); // Scrolling speed of polygonal overlay
|
||||
shieldEffect.Parameters["blowUpPower"].SetValue(2.8f);
|
||||
shieldEffect.Parameters["blowUpSize"].SetValue(0.4f);
|
||||
shieldEffect.Parameters["noiseScale"].SetValue(noiseScale);
|
||||
|
||||
// Shield opacity multiplier slightly changes, this is independent of current shield strength
|
||||
float baseShieldOpacity = 0.9f + 0.1f * MathF.Sin(Main.GlobalTimeWrappedHourly * 1.95f);
|
||||
float minShieldStrengthOpacityMultiplier = 0.5f;
|
||||
float finalShieldOpacity = baseShieldOpacity * MathHelper.Lerp(minShieldStrengthOpacityMultiplier, 1f, visualShieldStrength);
|
||||
finalShieldOpacity *= CalamityClientConfig.Instance.EnergyShieldOpacity;
|
||||
|
||||
shieldEffect.Parameters["shieldOpacity"].SetValue(finalShieldOpacity);
|
||||
shieldEffect.Parameters["shieldEdgeBlendStrenght"].SetValue(4f);
|
||||
|
||||
// Lunic Corps shields are not team specific
|
||||
Color shieldColor = new Color(201, 180, 129);
|
||||
Color primaryEdgeColor = new Color(232, 212, 175);
|
||||
Color secondaryEdgeColor = new Color(237, 205, 145);
|
||||
Color edgeColor = CalamityUtils.MulticolorLerp(Main.GlobalTimeWrappedHourly * 0.2f, primaryEdgeColor, secondaryEdgeColor);
|
||||
|
||||
// Define shader parameters for shield color
|
||||
shieldEffect.Parameters["shieldColor"].SetValue(shieldColor.ToVector3());
|
||||
shieldEffect.Parameters["shieldEdgeColor"].SetValue(edgeColor.ToVector3());
|
||||
|
||||
var matrix = Main.GameViewMatrix.TransformationMatrix;
|
||||
Main.spriteBatch.SafeBegin(SpriteSortMode.Immediate, BatchSetting.Additive, shieldEffect, matrix, () =>
|
||||
{
|
||||
// Fetch shield noise overlay texture (this is the polygons fed to the shader)
|
||||
NoiseTex ??= ModContent.Request<Texture2D>("CalamityMod/ExtraTextures/GreyscaleGradients/VoronoiShapes2");
|
||||
Vector2 pos = player.MountedCenter + player.gfxOffY * Vector2.UnitY - Main.screenPosition;
|
||||
Texture2D tex = NoiseTex.Value;
|
||||
spriteBatch.Draw(tex, pos, null, Color.White, 0, tex.Size() / 2f, scale, 0, 0);
|
||||
});
|
||||
|
||||
modPlayer.drawnAnyShieldThisFrame = true;
|
||||
}
|
||||
modPlayer.drawnAnyShieldThisFrame = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user