diff --git a/Items/Weapons/Melee/ArkoftheAncients.cs b/Items/Weapons/Melee/ArkoftheAncients.cs index 663f8361be..ed8d9af9ce 100644 --- a/Items/Weapons/Melee/ArkoftheAncients.cs +++ b/Items/Weapons/Melee/ArkoftheAncients.cs @@ -122,7 +122,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void NetRecieve(BinaryReader reader) { - Charge = reader.ReadInt32(); + Charge = reader.ReadSingle(); } public override void AddRecipes() diff --git a/Items/Weapons/Melee/ArkoftheCosmos.cs b/Items/Weapons/Melee/ArkoftheCosmos.cs index 0ba0c10516..8417c8b408 100644 --- a/Items/Weapons/Melee/ArkoftheCosmos.cs +++ b/Items/Weapons/Melee/ArkoftheCosmos.cs @@ -200,7 +200,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void NetRecieve(BinaryReader reader) { - Charge = reader.ReadInt32(); + Charge = reader.ReadSingle(); } public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) diff --git a/Items/Weapons/Melee/ArkoftheElements.cs b/Items/Weapons/Melee/ArkoftheElements.cs index a5b3c540ee..1ce84b2305 100644 --- a/Items/Weapons/Melee/ArkoftheElements.cs +++ b/Items/Weapons/Melee/ArkoftheElements.cs @@ -193,7 +193,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void NetRecieve(BinaryReader reader) { - Charge = reader.ReadInt32(); + Charge = reader.ReadSingle(); } public override void AddRecipes() diff --git a/Items/Weapons/Melee/BiomeBlade.cs b/Items/Weapons/Melee/BiomeBlade.cs index f1ca44057a..425f17f5b4 100644 --- a/Items/Weapons/Melee/BiomeBlade.cs +++ b/Items/Weapons/Melee/BiomeBlade.cs @@ -56,8 +56,8 @@ namespace CalamityMod.Items.Weapons.Melee Tooltip.SetDefault("FUNCTION_DESC\n" + "Hold down RMB while standing still on flat ground to attune the weapon to the powers of the surrounding biome\n" + "Using RMB otherwise switches between the current attunement and an extra stored one\n" + - "Main attunement : None\n" + - "Secondary attunement: None\n"); //Theres potential for flavor text as well but im not a writer + "Main Attunement : [None]\n" + + "Secondary Attunement: [None]\n"); //Theres potential for flavor text as well but im not a writer } public override void ModifyTooltips(List list) @@ -68,49 +68,35 @@ namespace CalamityMod.Items.Weapons.Melee if (player is null) return; - foreach (TooltipLine l in list) + var effectDescTooltip = list.FirstOrDefault(x => x.Name == "Tooltip0" && x.mod == "Terraria"); + var mainAttunementTooltip = list.FirstOrDefault(x => x.Name == "Tooltip3" && x.mod == "Terraria"); + var secondaryAttunementTooltip = list.FirstOrDefault(x => x.Name == "Tooltip4" && x.mod == "Terraria"); + + //Default stuff + effectDescTooltip.text = "Does nothing..yet"; + effectDescTooltip.overrideColor = new Color(163, 163, 163); + + mainAttunementTooltip.text = "Main Attunement : [None]"; + mainAttunementTooltip.overrideColor = new Color(163, 163, 163); + + secondaryAttunementTooltip.text = "Secondary Attunement : [None]"; + secondaryAttunementTooltip.overrideColor = new Color(163, 163, 163); + + //If theres a main attunement + if (mainAttunement != null) { - if (l.text.StartsWith("FUNCTION_DESC")) - { - if (mainAttunement != null) - { - l.overrideColor = mainAttunement.tooltipColor; - l.text = mainAttunement.function_description; - } - else - { - l.overrideColor = new Color(163, 163, 163); - l.text = "Does nothing.. yet"; - } - } + effectDescTooltip.text = mainAttunement.function_description; + effectDescTooltip.overrideColor = mainAttunement.tooltipColor; - if (l.text.StartsWith("Main attunement")) - { - if (mainAttunement != null) - { - l.overrideColor = mainAttunement.tooltipColor; - l.text = "Main Attumenent : [" + mainAttunement.name + "]"; - } - else - { - l.overrideColor = new Color(163, 163, 163); - l.text = "Main Attumenent : [None]"; - } - } + mainAttunementTooltip.text = "Main Attumenent : [" + mainAttunement.name + "]"; + mainAttunementTooltip.overrideColor = mainAttunement.tooltipColor; + } - if (l.text.StartsWith("Secondary attunement")) - { - if (secondaryAttunement != null) - { - l.overrideColor = Color.Lerp(secondaryAttunement.tooltipColor, Color.Gray, 0.5f); - l.text = "Secondary Attumenent : [" + secondaryAttunement.name + "]"; - } - else - { - l.overrideColor = new Color(163, 163, 163); - l.text = "Secondary Attumenent : [None]"; - } - } + //If theres a secondary attunement + if (secondaryAttunement != null) + { + secondaryAttunementTooltip.text = "Secondary Attumenent : [" + secondaryAttunement.name + "]"; + secondaryAttunementTooltip.overrideColor = Color.Lerp(secondaryAttunement.tooltipColor, Color.Gray, 0.5f); } } diff --git a/Items/Weapons/Melee/FourSeasonsGalaxia.cs b/Items/Weapons/Melee/FourSeasonsGalaxia.cs index 0f26323437..f8a22b82bf 100644 --- a/Items/Weapons/Melee/FourSeasonsGalaxia.cs +++ b/Items/Weapons/Melee/FourSeasonsGalaxia.cs @@ -79,7 +79,6 @@ namespace CalamityMod.Items.Weapons.Melee { DisplayName.SetDefault("Galaxia"); Tooltip.SetDefault("FUNCTION_DESC\n" + - "FUNCTION_EXTRA\n" + "FUNCTION_PASSIVE\n" + "Upgrading the sword let it break free from its earthly boundaries. You now have access to every single attunement at all times!\n" + "Use RMB to cycle the sword's attunement forward or backwards depending on the position of your cursor\n" + @@ -97,86 +96,31 @@ namespace CalamityMod.Items.Weapons.Melee if (player is null) return; - foreach (TooltipLine l in list) + var effectDescTooltip = list.FirstOrDefault(x => x.Name == "Tooltip0" && x.mod == "Terraria"); + var passiveDescTooltip = list.FirstOrDefault(x => x.Name == "Tooltip1" && x.mod == "Terraria"); + var mainAttunementTooltip = list.FirstOrDefault(x => x.Name == "Tooltip4" && x.mod == "Terraria"); + var blessingTooltip = list.FirstOrDefault(x => x.Name == "Tooltip5" && x.mod == "Terraria"); + + //Default stuff gets skipped here. MainAttunement is set to true in SafeCheckAttunements() above + + //.. but just in case + if (mainAttunement == null) { - if (l.text == null) - continue; - - if (l.text.StartsWith("FUNCTION_DESC")) - { - if (mainAttunement != null) - { - l.overrideColor = mainAttunement.tooltipColor; - l.text = mainAttunement.function_description; - } - else //Fake the existence of a main attunement - { - l.overrideColor = Attunement.attunementArray[(int)AttunementID.Phoenix].tooltipColor; - l.text = Attunement.attunementArray[(int)AttunementID.Phoenix].function_description; - } - continue; - } - - if (l.text.StartsWith("FUNCTION_EXTRA")) - { - if (mainAttunement != null) - { - l.overrideColor = mainAttunement.tooltipColor; - l.text = mainAttunement.function_description_extra; - } - else - { - l.overrideColor = Attunement.attunementArray[(int)AttunementID.Phoenix].tooltipColor; - l.text = Attunement.attunementArray[(int)AttunementID.Phoenix].function_description_extra; - } - continue; - } - - if (l.text.StartsWith("FUNCTION_PASSIVE")) - { - if (mainAttunement != null) - { - l.overrideColor = mainAttunement.tooltipPassiveColor; - l.text = mainAttunement.passive_description; - } - else - { - l.overrideColor = Attunement.attunementArray[(int)AttunementID.Phoenix].tooltipPassiveColor; - l.text = Attunement.attunementArray[(int)AttunementID.Phoenix].passive_description; - } - continue; - } - - if (l.text.StartsWith("Active Attunement")) - { - if (mainAttunement != null) - { - l.overrideColor = Color.Lerp(mainAttunement.tooltipColor, mainAttunement.tooltipColor2, 0.5f + (float)Math.Sin(Main.GlobalTime) * 0.5f); - l.text = "Active Attumenent : [" + mainAttunement.name + "]"; - } - else - { - l.overrideColor = Attunement.attunementArray[(int)AttunementID.Phoenix].tooltipColor; - l.text = "Active Attumenent : [" + Attunement.attunementArray[(int)AttunementID.Phoenix].name + "]"; - } - continue; - } - - if (l.text.StartsWith("Passive Blessing")) - { - if (mainAttunement != null) - { - l.overrideColor = mainAttunement.tooltipPassiveColor; - l.text = "Passive Blessing : [" + mainAttunement.passive_name + "]"; - } - else - { - l.overrideColor = Attunement.attunementArray[(int)AttunementID.Phoenix].tooltipPassiveColor; - l.text = "Passive Blessing : ["+ Attunement.attunementArray[(int)AttunementID.Phoenix].passive_name + "]"; - } - continue; - } + CalamityMod.Instance.Logger.Error("No main attunement on galaxia, couldn't edit its tooltip properly. How the hell did that happen."); + return; } + + effectDescTooltip.text = mainAttunement.function_description + "\n" + mainAttunement.function_description_extra; + effectDescTooltip.overrideColor = mainAttunement.tooltipColor; + + passiveDescTooltip.text = mainAttunement.passive_description; + passiveDescTooltip.overrideColor = mainAttunement.tooltipPassiveColor; + + mainAttunementTooltip.text = "Active Attumenent : [" + mainAttunement.name + "]"; + mainAttunementTooltip.overrideColor = Color.Lerp(mainAttunement.tooltipColor, mainAttunement.tooltipColor2, 0.5f + (float)Math.Sin(Main.GlobalTime) * 0.5f); + + blessingTooltip.text = "Passive Blessing : [" + mainAttunement.passive_name + "]"; + blessingTooltip.overrideColor = mainAttunement.tooltipPassiveColor; } #endregion diff --git a/Items/Weapons/Melee/OmegaBiomeBlade.cs b/Items/Weapons/Melee/OmegaBiomeBlade.cs index c07f9eb1d0..bc8109b92a 100644 --- a/Items/Weapons/Melee/OmegaBiomeBlade.cs +++ b/Items/Weapons/Melee/OmegaBiomeBlade.cs @@ -97,12 +97,11 @@ namespace CalamityMod.Items.Weapons.Melee { DisplayName.SetDefault("True Biome Blade"); Tooltip.SetDefault("FUNCTION_DESC\n" + - "FUNCTION_EXTRA\n" + "FUNCTION_PASSIVE\n" + "Holding down RMB for 2 seconds attunes the weapon to the powers of the surrounding biome\n" + "Using RMB for a shorter period of time switches your active and passive attunements around\n" + - "Active attunement : None\n" + - "Passive attunement: None\n"); + "Active Attunement : None\n" + + "Passive Attunement: None\n"); } #region tooltip editing @@ -114,85 +113,43 @@ namespace CalamityMod.Items.Weapons.Melee if (player is null) return; - foreach (TooltipLine l in list) + + var effectDescTooltip = list.FirstOrDefault(x => x.Name == "Tooltip0" && x.mod == "Terraria"); + var passiveDescTooltip = list.FirstOrDefault(x => x.Name == "Tooltip1" && x.mod == "Terraria"); + var mainAttunementTooltip = list.FirstOrDefault(x => x.Name == "Tooltip4" && x.mod == "Terraria"); + var secondaryAttunementTooltip = list.FirstOrDefault(x => x.Name == "Tooltip5" && x.mod == "Terraria"); + + //Default stuff + effectDescTooltip.text = "Does nothing..yet\nIt seems that upgrading the blade expanded the scope of the previous attunements"; + effectDescTooltip.overrideColor = new Color(163, 163, 163); + + passiveDescTooltip.text = "Your secondary attunement can now provide passive bonuses"; + passiveDescTooltip.overrideColor = new Color(163, 163, 163); + + mainAttunementTooltip.text = "Active Attumenent : [None]"; + mainAttunementTooltip.overrideColor = new Color(163, 163, 163); + + secondaryAttunementTooltip.text = "Passive Attunement : [None]"; + secondaryAttunementTooltip.overrideColor = new Color(163, 163, 163); + + //If theres a main attunement + if (mainAttunement != null) { - if (l.text == null) - continue; + effectDescTooltip.text = mainAttunement.function_description + "\n" + mainAttunement.function_description_extra; + effectDescTooltip.overrideColor = mainAttunement.tooltipColor; - if (l.text.StartsWith("FUNCTION_DESC")) - { - if (mainAttunement != null) - { - l.overrideColor = mainAttunement.tooltipColor; - l.text = mainAttunement.function_description; - } - else - { - l.overrideColor = new Color(163, 163, 163); - l.text = "Does nothing.. yet"; - } - continue; - } + mainAttunementTooltip.text = "Active Attumenent : [" + mainAttunement.name + "]"; + mainAttunementTooltip.overrideColor = Color.Lerp(mainAttunement.tooltipColor, mainAttunement.tooltipColor2, 0.5f + (float)Math.Sin(Main.GlobalTime) * 0.5f); + } - if (l.text.StartsWith("FUNCTION_EXTRA")) - { - if (mainAttunement != null) - { - l.overrideColor = mainAttunement.tooltipColor; - l.text = mainAttunement.function_description_extra; - } - else - { - l.overrideColor = new Color(163, 163, 163); - l.text = "It seems that upgrading the blade expanded the scope of the previous attunements"; - } - continue; - } + //If theres a secondary attunement + if (secondaryAttunement != null) + { + passiveDescTooltip.text = secondaryAttunement.passive_description; + passiveDescTooltip.overrideColor = secondaryAttunement.tooltipColor; - if (l.text.StartsWith("FUNCTION_PASSIVE")) - { - if (secondaryAttunement != null) - { - l.overrideColor = secondaryAttunement.tooltipColor; - l.text = secondaryAttunement.passive_description; - } - else - { - l.overrideColor = new Color(163, 163, 163); - l.text = "Your secondary attunement can now provide passive bonuses"; - } - continue; - } - - if (l.text.StartsWith("Active attunement")) - { - if (mainAttunement != null) - { - l.overrideColor = Color.Lerp(mainAttunement.tooltipColor, mainAttunement.tooltipColor2, 0.5f + (float)Math.Sin(Main.GlobalTime) * 0.5f); - l.text = "Active Attumenent : [" + mainAttunement.name + "]"; - } - else - { - l.overrideColor = new Color(163, 163, 163); - l.text = "Active Attumenent : [None]"; - } - continue; - } - - if (l.text.StartsWith("Passive attunement")) - { - if (secondaryAttunement != null) - { - l.overrideColor = Color.Lerp(Color.Lerp(secondaryAttunement.tooltipColor, secondaryAttunement.tooltipColor2, 0.5f + (float)Math.Sin(Main.GlobalTime) * 0.5f), Color.Gray, 0.5f); - l.text = "Passive Attumenent : [" + secondaryAttunement.name + "]"; - } - else - { - l.overrideColor = new Color(163, 163, 163); - l.text = "Passive Attumenent : [None]"; - } - continue; - } + secondaryAttunementTooltip.text = "Passive Attumenent : [" + secondaryAttunement.name + "]"; + secondaryAttunementTooltip.overrideColor = Color.Lerp(Color.Lerp(secondaryAttunement.tooltipColor, secondaryAttunement.tooltipColor2, 0.5f + (float)Math.Sin(Main.GlobalTime) * 0.5f), Color.Gray, 0.5f); } } diff --git a/Items/Weapons/Melee/TrueArkoftheAncients.cs b/Items/Weapons/Melee/TrueArkoftheAncients.cs index ae8bd409dc..80ec1f70f1 100644 --- a/Items/Weapons/Melee/TrueArkoftheAncients.cs +++ b/Items/Weapons/Melee/TrueArkoftheAncients.cs @@ -155,7 +155,7 @@ namespace CalamityMod.Items.Weapons.Melee public override void NetRecieve(BinaryReader reader) { - Charge = reader.ReadInt32(); + Charge = reader.ReadSingle(); } public override void AddRecipes() diff --git a/Items/Weapons/Melee/TrueBiomeBlade.cs b/Items/Weapons/Melee/TrueBiomeBlade.cs index 47b183b042..35fbb9c39c 100644 --- a/Items/Weapons/Melee/TrueBiomeBlade.cs +++ b/Items/Weapons/Melee/TrueBiomeBlade.cs @@ -80,11 +80,10 @@ namespace CalamityMod.Items.Weapons.Melee { DisplayName.SetDefault("Biome Blade"); Tooltip.SetDefault("FUNCTION_DESC\n" + - "FUNCTION_EXTRA\n" + "Hold down RMB while standing still on flat ground to attune the weapon to the powers of the surrounding biome\n" + "Using RMB otherwise switches between the current attunement and an extra stored one\n" + - "Main attunement : None\n" + - "Secondary attunement: None\n"); //Theres potential for flavor text as well but im not a writer + "Main Attunement : [None]\n" + + "Secondary Attunement: [None]\n"); //Theres potential for flavor text as well but im not a writer } #region tooltip editing @@ -97,66 +96,37 @@ namespace CalamityMod.Items.Weapons.Melee if (player is null) return; - foreach (TooltipLine l in list) + var effectDescTooltip = list.FirstOrDefault(x => x.Name == "Tooltip0" && x.mod == "Terraria"); + var mainAttunementTooltip = list.FirstOrDefault(x => x.Name == "Tooltip3" && x.mod == "Terraria"); + var secondaryAttunementTooltip = list.FirstOrDefault(x => x.Name == "Tooltip4" && x.mod == "Terraria"); + + //Default stuff + effectDescTooltip.text = "Does nothing..yet\nRepairing the blade seems to have improved its attuning capacities"; + effectDescTooltip.overrideColor = new Color(163, 163, 163); + + mainAttunementTooltip.text = "Main Attunement : [None]"; + mainAttunementTooltip.overrideColor = new Color(163, 163, 163); + + secondaryAttunementTooltip.text = "Secondary Attunement : [None]"; + secondaryAttunementTooltip.overrideColor = new Color(163, 163, 163); + + //If theres a main attunement + if (mainAttunement != null) { - if (l.text.StartsWith("FUNCTION_DESC")) - { - if (mainAttunement != null) - { - l.overrideColor = mainAttunement.tooltipColor; - l.text = mainAttunement.function_description; - } - else - { - l.overrideColor = new Color(163, 163, 163); - l.text = "Does nothing.. yet"; - } - } + effectDescTooltip.text = mainAttunement.function_description + "\n" + mainAttunement.function_description_extra ; + effectDescTooltip.overrideColor = mainAttunement.tooltipColor; - if (l.text.StartsWith("FUNCTION_EXTRA")) - { - if (mainAttunement != null) - { - l.overrideColor = mainAttunement.tooltipColor; - l.text = mainAttunement.function_description_extra; - } - else - { - l.overrideColor = new Color(163, 163, 163); - l.text = "Repairing the blade seems to have improved its attuning capacities"; - } - } + mainAttunementTooltip.text = "Main Attumenent : [" + mainAttunement.name + "]"; + mainAttunementTooltip.overrideColor = mainAttunement.tooltipColor; + } - if (l.text.StartsWith("Main attunement")) - { - if (mainAttunement != null) - { - l.overrideColor = mainAttunement.tooltipColor; - l.text = "Main Attumenent : [" + mainAttunement.name + "]"; - } - else - { - l.overrideColor = new Color(163, 163, 163); - l.text = "Main Attumenent : [None]"; - } - } - - if (l.text.StartsWith("Secondary attunement")) - { - if (secondaryAttunement != null) - { - l.overrideColor = Color.Lerp(secondaryAttunement.tooltipColor, Color.Gray, 0.5f); - l.text = "Secondary Attumenent : [" + secondaryAttunement.name + "]"; - } - else - { - l.overrideColor = new Color(163, 163, 163); - l.text = "Secondary Attumenent : [None]"; - } - } + //If theres a secondary attunement + if (secondaryAttunement != null) + { + secondaryAttunementTooltip.text = "Secondary Attumenent : [" + secondaryAttunement.name + "]"; + secondaryAttunementTooltip.overrideColor = Color.Lerp(secondaryAttunement.tooltipColor, Color.Gray, 0.5f); } } - #endregion public override void SetDefaults()