Possibility to use a sprite for the bar cooldown
This commit is contained in:
1 parent
a5d074e532
commit
f0f786ab92
10 files changed
+83
-9
No files matched your search
@@ -948,7 +948,6 @@ namespace CalamityMod.CalPlayer
|
||||
|
||||
// Cooldowns and timers
|
||||
|
||||
|
||||
foreach (CooldownIndicator cd in Cooldowns)
|
||||
{
|
||||
if (cd.CanTickDown(player))
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace CalamityMod.Effects
|
||||
public static Effect RancorMagicCircleShader;
|
||||
public static Effect BasicTintShader;
|
||||
public static Effect CircularBarShader;
|
||||
public static Effect CircularBarSpriteShader;
|
||||
public static Effect DoGDisintegrationShader;
|
||||
public static Effect ArtAttackTrailShader;
|
||||
public static Effect CircularAoETelegraph;
|
||||
@@ -58,6 +59,7 @@ namespace CalamityMod.Effects
|
||||
RancorMagicCircleShader = CalamityMod.Instance.GetEffect("Effects/RancorMagicCircle");
|
||||
BasicTintShader = CalamityMod.Instance.GetEffect("Effects/BasicTint");
|
||||
CircularBarShader = CalamityMod.Instance.GetEffect("Effects/CircularBarShader");
|
||||
CircularBarSpriteShader = CalamityMod.Instance.GetEffect("Effects/CircularBarSpriteShader");
|
||||
DoGDisintegrationShader = CalamityMod.Instance.GetEffect("Effects/DoGDisintegration");
|
||||
ArtAttackTrailShader = CalamityMod.Instance.GetEffect("Effects/ArtAttackTrail");
|
||||
CircularAoETelegraph = CalamityMod.Instance.GetEffect("Effects/CircularAoETelegraph");
|
||||
@@ -88,6 +90,7 @@ namespace CalamityMod.Effects
|
||||
GameShaders.Misc["CalamityMod:RancorMagicCircle"] = new MiscShaderData(new Ref<Effect>(RancorMagicCircleShader), "ShieldPass");
|
||||
GameShaders.Misc["CalamityMod:BasicTint"] = new MiscShaderData(new Ref<Effect>(BasicTintShader), "TintPass");
|
||||
GameShaders.Misc["CalamityMod:CircularBarShader"] = new MiscShaderData(new Ref<Effect>(CircularBarShader), "Pass0");
|
||||
GameShaders.Misc["CalamityMod:CircularBarSpriteShader"] = new MiscShaderData(new Ref<Effect>(CircularBarSpriteShader), "Pass0");
|
||||
GameShaders.Misc["CalamityMod:DoGDisintegration"] = new MiscShaderData(new Ref<Effect>(DoGDisintegrationShader), "DisintegrationPass");
|
||||
GameShaders.Misc["CalamityMod:ArtAttack"] = new MiscShaderData(new Ref<Effect>(ArtAttackTrailShader), "TrailPass");
|
||||
GameShaders.Misc["CalamityMod:CircularAoETelegraph"] = new MiscShaderData(new Ref<Effect>(CircularAoETelegraph), "TelegraphPass");
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
sampler uImage0 : register(s0);
|
||||
sampler uImage1 : register(s1);
|
||||
float3 uColor;
|
||||
float3 uSecondaryColor;
|
||||
float uOpacity;
|
||||
float uSaturation; //Saturation is being used as completion here
|
||||
float uRotation;
|
||||
float uTime;
|
||||
float4 uSourceRect;
|
||||
float2 uWorldPosition;
|
||||
float uDirection;
|
||||
float3 uLightSource;
|
||||
float2 uImageSize0;
|
||||
float2 uImageSize1;
|
||||
|
||||
float4 MainPS(float2 coords : TEXCOORD0) : COLOR
|
||||
{
|
||||
//this is the center of the sprite, coords work from 0 - 1
|
||||
float2 center = float2(0.5, 0.5);
|
||||
//get the vector between them
|
||||
float2 between = coords - center;
|
||||
//get the length
|
||||
float newLength = length(between);
|
||||
|
||||
|
||||
float angle = atan2(between.x, between.y) + 3.1415926;
|
||||
//get the progress of the angle
|
||||
float anglePercent = angle / 6.28318531;
|
||||
|
||||
//if we are below the progress point, return the pixel at the coords specified
|
||||
if (anglePercent < uSaturation)
|
||||
{
|
||||
float4 barColor = tex2D(uImage0, coords);
|
||||
float opacity = uOpacity * barColor.a;
|
||||
return float4(barColor.rbg, opacity);
|
||||
}
|
||||
|
||||
float4 subBarColor = tex2D(uImage1, coords);
|
||||
float subOpacity = uOpacity * subBarColor.a;
|
||||
return float4(subBarColor.rbg, subOpacity);
|
||||
}
|
||||
|
||||
|
||||
technique Technique1
|
||||
{
|
||||
pass Pass0
|
||||
{
|
||||
PixelShader = compile ps_2_0 MainPS();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 145 B After Width: | Height: | Size: 100 B |
@@ -96,17 +96,29 @@ namespace CalamityMod.UI.CooldownIndicators
|
||||
/// </summary>
|
||||
public virtual void CustomDrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) { }
|
||||
|
||||
/// <summary>
|
||||
/// The texture of the charge bar. If set to a different texture path than the bar base, and if UseCustomDraw is set to false , it will be used as the ring around the cooldown icon
|
||||
/// Please keep this sprite 44x44 (In 2x2)
|
||||
/// </summary>
|
||||
public virtual string ChargeBarTexture => "CalamityMod/UI/CooldownIndicators/BarBase";
|
||||
|
||||
/// <summary>
|
||||
/// The texture under the charge bar. Will be used if ChargeBarTexture is set to an actual texture. Leave this as is to have nothing below the charge bar texture
|
||||
/// Please keep this sprite 44x44 (In 2x2)
|
||||
/// </summary>
|
||||
public virtual string ChargeBarBackTexture => "CalamityMod/UI/CooldownIndicators/BarBase";
|
||||
|
||||
/// <summary>
|
||||
/// Method used to determine the color of the outline around the icon, and the overlay that goes above the icon in compact mode
|
||||
/// </summary>
|
||||
public virtual Color OutlineColor => Color.White;
|
||||
/// <summary>
|
||||
/// The color of the bar as it starts going around the icon
|
||||
/// The color of the bar as it starts going around the icon. Only used if no charge bar texture is provided
|
||||
/// </summary>
|
||||
public virtual Color CooldownColorStart => Color.Gray;
|
||||
|
||||
/// <summary>
|
||||
/// The color of the bar as it finishes going around the icon
|
||||
/// The color of the bar as it finishes going around the icon. Only used if no charge bar texture is provided
|
||||
/// </summary>
|
||||
public virtual Color CooldownColorEnd => Color.White;
|
||||
|
||||
@@ -115,12 +127,22 @@ namespace CalamityMod.UI.CooldownIndicators
|
||||
/// </summary>
|
||||
public virtual void ApplyBarShaders(float opacity)
|
||||
{
|
||||
GameShaders.Misc["CalamityMod:CircularBarShader"].UseOpacity(opacity);
|
||||
GameShaders.Misc["CalamityMod:CircularBarShader"].UseSaturation(1 - Completion);
|
||||
GameShaders.Misc["CalamityMod:CircularBarShader"].UseColor(CooldownColorStart);
|
||||
GameShaders.Misc["CalamityMod:CircularBarShader"].UseSecondaryColor(CooldownColorEnd);
|
||||
GameShaders.Misc["CalamityMod:CircularBarShader"].Apply();
|
||||
if (ChargeBarTexture == "CalamityMod/UI/CooldownIndicators/BarBase")
|
||||
{
|
||||
GameShaders.Misc["CalamityMod:CircularBarShader"].UseOpacity(opacity);
|
||||
GameShaders.Misc["CalamityMod:CircularBarShader"].UseSaturation(1 - Completion);
|
||||
GameShaders.Misc["CalamityMod:CircularBarShader"].UseColor(CooldownColorStart);
|
||||
GameShaders.Misc["CalamityMod:CircularBarShader"].UseSecondaryColor(CooldownColorEnd);
|
||||
GameShaders.Misc["CalamityMod:CircularBarShader"].Apply();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
GameShaders.Misc["CalamityMod:CircularBarSpriteShader"].SetShaderTexture(ModContent.GetTexture(ChargeBarBackTexture));
|
||||
GameShaders.Misc["CalamityMod:CircularBarSpriteShader"].UseOpacity(opacity);
|
||||
GameShaders.Misc["CalamityMod:CircularBarSpriteShader"].UseSaturation(1 - Completion);
|
||||
GameShaders.Misc["CalamityMod:CircularBarSpriteShader"].Apply();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace CalamityMod.UI.CooldownIndicators
|
||||
{
|
||||
Texture2D sprite = ModContent.GetTexture(cooldown.Texture);
|
||||
Texture2D outline = ModContent.GetTexture(cooldown.TextureOutline);
|
||||
Texture2D barBase = ModContent.GetTexture("CalamityMod/UI/CooldownIndicators/BarBase");
|
||||
Texture2D barBase = ModContent.GetTexture(cooldown.ChargeBarTexture);
|
||||
|
||||
//Draw the ring
|
||||
if (!CompactIcons)
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 328 B |
Binary file not shown.
|
After Width: | Height: | Size: 196 B |
Binary file not shown.
|
After Width: | Height: | Size: 152 B |
Reference in new issue
Block a user