Move HairDye Shader Binding to each item class
This commit is contained in:
1 parent
57aff17ac5
commit
33fe2f58ed
5 files changed
+86
-27
No files matched your search
@@ -421,29 +421,6 @@ namespace CalamityMod
|
||||
CalamityMod.Instance.AddBossHeadTexture(chadPrimeIconPath, -1);
|
||||
chadPrimeIcon = ModContent.GetModBossHeadSlot(chadPrimeIconPath);
|
||||
|
||||
// TODO -- Is this not possible to place in ModItem.Load or ModItem.SetStaticDefaults ?
|
||||
// Centralizing hair dye shaders like this seems absurdly stiff
|
||||
GameShaders.Hair.BindShader(ModContent.ItemType<AdrenalineHairDye>(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => Color.Lerp(player.hairColor, new Color(0, 255, 171), ((float)player.Calamity().adrenaline / (float)player.Calamity().adrenalineMax))));
|
||||
GameShaders.Hair.BindShader(ModContent.ItemType<RageHairDye>(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => Color.Lerp(player.hairColor, new Color(255, 83, 48), ((float)player.Calamity().rage / (float)player.Calamity().rageMax))));
|
||||
GameShaders.Hair.BindShader(ModContent.ItemType<WingTimeHairDye>(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) =>
|
||||
{
|
||||
float flightTimeInterpolant = player.wingTime / player.wingTimeMax;
|
||||
if (player.mount.Active)
|
||||
flightTimeInterpolant = 1f;
|
||||
else if (float.IsInfinity(flightTimeInterpolant) || float.IsNaN(flightTimeInterpolant))
|
||||
flightTimeInterpolant = 0f;
|
||||
|
||||
return Color.Lerp(player.hairColor, new Color(139, 205, 255), flightTimeInterpolant);
|
||||
}));
|
||||
GameShaders.Hair.BindShader(ModContent.ItemType<StealthHairDye>(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) =>
|
||||
{
|
||||
float stealthInterpolant = player.Calamity().rogueStealth / player.Calamity().rogueStealthMax;
|
||||
if (float.IsInfinity(stealthInterpolant) || float.IsNaN(stealthInterpolant))
|
||||
stealthInterpolant = 0f;
|
||||
|
||||
return Color.Lerp(player.hairColor, new Color(186, 85, 211), stealthInterpolant);
|
||||
}));
|
||||
|
||||
InvasionProgressUIManager.LoadGUIs();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using Terraria;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.GameContent.Dyes;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
@@ -7,6 +10,22 @@ namespace CalamityMod.Items.Dyes.HairDye
|
||||
public class AdrenalineHairDye : ModItem, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Items.Dyes";
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
if (!Main.dedServ)
|
||||
{
|
||||
GameShaders.Hair.BindShader(Type, new LegacyHairShaderData().UseLegacyMethod(UpdateHairDye));
|
||||
}
|
||||
}
|
||||
|
||||
private static Color UpdateHairDye(Player player, Color newColor, ref bool lighting)
|
||||
{
|
||||
var calPlayer = player.Calamity();
|
||||
var adrenalineP = calPlayer.adrenaline / calPlayer.adrenalineMax;
|
||||
return Color.Lerp(player.hairColor, new Color(0, 255, 171), adrenalineP);
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.width = 20;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using Terraria;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.GameContent.Dyes;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
@@ -7,6 +10,22 @@ namespace CalamityMod.Items.Dyes.HairDye
|
||||
public class RageHairDye : ModItem, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Items.Dyes";
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
if (!Main.dedServ)
|
||||
{
|
||||
GameShaders.Hair.BindShader(Type, new LegacyHairShaderData().UseLegacyMethod(UpdateHairDye));
|
||||
}
|
||||
}
|
||||
|
||||
private static Color UpdateHairDye(Player player, Color newColor, ref bool lighting)
|
||||
{
|
||||
var calPlayer = player.Calamity();
|
||||
var rageP = calPlayer.rage / calPlayer.rageMax;
|
||||
return Color.Lerp(player.hairColor, new Color(255, 83, 48), rageP);
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.width = 20;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using Terraria;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.GameContent.Dyes;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
@@ -7,6 +10,25 @@ namespace CalamityMod.Items.Dyes.HairDye
|
||||
public class StealthHairDye : ModItem, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Items.Dyes";
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
if (!Main.dedServ)
|
||||
{
|
||||
GameShaders.Hair.BindShader(Type, new LegacyHairShaderData().UseLegacyMethod(UpdateHairDye));
|
||||
}
|
||||
}
|
||||
|
||||
private static Color UpdateHairDye(Player player, Color newColor, ref bool lighting)
|
||||
{
|
||||
float stealthP = player.Calamity().rogueStealth / player.Calamity().rogueStealthMax;
|
||||
|
||||
if (float.IsInfinity(stealthP) || float.IsNaN(stealthP))
|
||||
stealthP = 0f;
|
||||
|
||||
return Color.Lerp(player.hairColor, new Color(186, 85, 211), stealthP);
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.width = 20;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using Terraria;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.GameContent.Dyes;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
@@ -7,6 +10,25 @@ namespace CalamityMod.Items.Dyes.HairDye
|
||||
public class WingTimeHairDye : ModItem, ILocalizedModType
|
||||
{
|
||||
public new string LocalizationCategory => "Items.Dyes";
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
if (!Main.dedServ)
|
||||
{
|
||||
GameShaders.Hair.BindShader(Type, new LegacyHairShaderData().UseLegacyMethod(UpdateHairDye));
|
||||
}
|
||||
}
|
||||
|
||||
private static Color UpdateHairDye(Player player, Color newColor, ref bool lighting)
|
||||
{
|
||||
float wingP = player.wingTime / player.wingTimeMax;
|
||||
|
||||
if (player.mount.Active) wingP = 1f;
|
||||
else if (float.IsInfinity(wingP) || float.IsNaN(wingP)) wingP = 0f;
|
||||
|
||||
return Color.Lerp(player.hairColor, new Color(139, 205, 255), wingP);
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.width = 20;
|
||||
|
||||
Reference in new issue
Block a user