diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 8d4f7591bc..f1a18e4577 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -5693,12 +5693,6 @@ namespace CalamityMod.CalPlayer Player.waist = (sbyte)EquipLoader.GetEquipSlot(Mod, "DaedalusBreastplate", EquipType.Waist); } - if (Player.body == EquipLoader.GetEquipSlot(Mod, "DemonshadeBreastplate", EquipType.Body)) - { - //Use an extra front layers to have the players arms draw above the shoulderpads that droop - Player.front = (sbyte)EquipLoader.GetEquipSlot(Mod, "DemonshadeBreastplate", EquipType.Front); - } - bool victideBreastplateVisible = Player.body == EquipLoader.GetEquipSlot(Mod, "VictideBreastplate", EquipType.Body); //Give the player faulds if either the body armor or the leggings are equipped if (victideBreastplateVisible || Player.legs == EquipLoader.GetEquipSlot(Mod, "VictideGreaves", EquipType.Legs)) diff --git a/CalPlayer/DrawLayers/BodyBulkLayer.cs b/CalPlayer/DrawLayers/BodyBulkLayer.cs index b8fc7e7a33..fa3543838d 100644 --- a/CalPlayer/DrawLayers/BodyBulkLayer.cs +++ b/CalPlayer/DrawLayers/BodyBulkLayer.cs @@ -22,12 +22,17 @@ namespace CalamityMod.CalPlayer.DrawLayers return; Player drawPlayer = drawInfo.drawPlayer; - int bodyItem = drawPlayer.armor[1].type; + Item bodyItem = drawPlayer.armor[1]; if (drawPlayer.armor[11].type > ItemID.None) - bodyItem = drawPlayer.armor[11].type; + bodyItem = drawPlayer.armor[11]; - if (ModContent.GetModItem(bodyItem) is IBulkyArmor chestplateBulkDrawer) + if (ModContent.GetModItem(bodyItem.type) is IBulkyArmor chestplateBulkDrawer) { + string equipSlotName = chestplateBulkDrawer.EquipSlotName(drawPlayer) != "" ? chestplateBulkDrawer.EquipSlotName(drawPlayer) : bodyItem.ModItem.Name; + int equipSlot = EquipLoader.GetEquipSlot(Mod, equipSlotName, EquipType.Body); + if (drawPlayer.body != equipSlot) + return; + int dyeShader = drawPlayer.dye?[1].dye ?? 0; Vector2 drawPosition = drawInfo.Position - Main.screenPosition; diff --git a/CalPlayer/DrawLayers/FrontArmOverShoulderpadLayer.cs b/CalPlayer/DrawLayers/FrontArmOverShoulderpadLayer.cs new file mode 100644 index 0000000000..cda0f5d872 --- /dev/null +++ b/CalPlayer/DrawLayers/FrontArmOverShoulderpadLayer.cs @@ -0,0 +1,60 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ID; +using Terraria.DataStructures; +using Terraria.ModLoader; + +namespace CalamityMod.CalPlayer.DrawLayers +{ + + //Draws the front arm of the armor over the shoulderpad when walking. + public class FrontARmOverShoulderpadLayer : PlayerDrawLayer + { + public override Position GetDefaultPosition() => new AfterParent(PlayerDrawLayers.ArmOverItem); + + public override bool GetDefaultVisibility(PlayerDrawSet drawInfo) => drawInfo.shadow == 0f || !drawInfo.drawPlayer.dead; + + protected override void Draw(ref PlayerDrawSet drawInfo) + { + Player drawPlayer = drawInfo.drawPlayer; + Item bodyItem = drawPlayer.armor[1]; + if (drawPlayer.armor[11].type > ItemID.None) + bodyItem = drawPlayer.armor[11]; + + if (ModContent.GetModItem(bodyItem.type) is IDrawArmOverShoulderpad frontArmDrawer) + { + string equipSlotName = frontArmDrawer.EquipSlotName(drawPlayer) != "" ? frontArmDrawer.EquipSlotName(drawPlayer) : bodyItem.ModItem.Name; + int equipSlot = EquipLoader.GetEquipSlot(Mod, equipSlotName, EquipType.Body); + if (drawPlayer.body != equipSlot) + return; + + + int dyeShader = drawPlayer.dye?[1].dye ?? 0; + Vector2 drawPosition = drawInfo.Position - Main.screenPosition; + + // Using drawPlayer to get width & height and such is perfectly fine, on the other hand. Just center everything + drawPosition += new Vector2((drawPlayer.width - drawPlayer.bodyFrame.Width) / 2f, drawPlayer.height - drawPlayer.bodyFrame.Height + 4f); + + //Convert to int to remove the jitter. + drawPosition = new Vector2((int)drawPosition.X, (int)drawPosition.Y); + + //Some dispalcements + drawPosition += drawPlayer.bodyPosition + drawInfo.bodyVect; + + //Grab the extension texture + Texture2D extraPieceTexture = ModContent.Request(frontArmDrawer.FrontArmTexture).Value; + + //Get the frame of the extension based on the players body frame + Rectangle frame = extraPieceTexture.Frame(1, 20, 0, drawPlayer.bodyFrame.Y / drawPlayer.bodyFrame.Height); + + DrawData pieceDrawData = new DrawData(extraPieceTexture, drawPosition, frame, drawInfo.colorArmorBody, drawPlayer.fullRotation, drawInfo.bodyVect, 1f, drawInfo.playerEffect, 0) + { + shader = dyeShader + }; + drawInfo.DrawDataCache.Add(pieceDrawData); + + } + } + } +} diff --git a/CalPlayer/DrawLayers/HatExtensionLayer.cs b/CalPlayer/DrawLayers/HatExtensionLayer.cs index 9fc472b4b1..9c1a8e5141 100644 --- a/CalPlayer/DrawLayers/HatExtensionLayer.cs +++ b/CalPlayer/DrawLayers/HatExtensionLayer.cs @@ -24,7 +24,7 @@ namespace CalamityMod.CalPlayer.DrawLayers if (ModContent.GetModItem(headItem.type) is IExtendedHat extendedHatDrawer) { - string equipSlotName = extendedHatDrawer.EquipSlotName(drawPlayer) != "" ? extendedHatDrawer.EquipSlotName(drawPlayer) : headItem.Name; + string equipSlotName = extendedHatDrawer.EquipSlotName(drawPlayer) != "" ? extendedHatDrawer.EquipSlotName(drawPlayer) : headItem.ModItem.Name; int equipSlot = EquipLoader.GetEquipSlot(Mod, equipSlotName, EquipType.Head); if (extendedHatDrawer.PreDrawExtension(drawInfo) && !drawInfo.drawPlayer.dead && equipSlot == drawPlayer.head) diff --git a/CalPlayer/DrawLayers/IBulkyArmor.cs b/CalPlayer/DrawLayers/IBulkyArmor.cs index ce7f54a912..cc8abac148 100644 --- a/CalPlayer/DrawLayers/IBulkyArmor.cs +++ b/CalPlayer/DrawLayers/IBulkyArmor.cs @@ -1,5 +1,6 @@ using Microsoft.Xna.Framework; using Terraria.DataStructures; +using Terraria; /// /// Interface that can be used by chestplates to appear extra bulky, by drawing partly over the players helmet with an extra layer @@ -11,4 +12,10 @@ public interface IBulkyArmor /// This should be the same size as a regular equipped sprite (20 x 560 in 1x1) /// string BulkTexture { get; } + + /// + /// The name of the equip slot for the item. If left empty, the equip slot that is looked for will use the name of the item. + /// Useful if you have multiple body textures you need to add bulk to. + /// + string EquipSlotName(Player drawPlayer) => ""; } diff --git a/CalPlayer/DrawLayers/IDrawArmOverShoulderpad.cs b/CalPlayer/DrawLayers/IDrawArmOverShoulderpad.cs new file mode 100644 index 0000000000..6864017b3b --- /dev/null +++ b/CalPlayer/DrawLayers/IDrawArmOverShoulderpad.cs @@ -0,0 +1,21 @@ +using Microsoft.Xna.Framework; +using Terraria.DataStructures; +using Terraria; + +/// +/// Interface that can be used by chestplates that need their front arm (when walking) to go over the shoulderpads +/// +public interface IDrawArmOverShoulderpad +{ + /// + /// The texture of the part that goes above the shoulderpads + /// This should be the same size as a regular equipped sprite (20 x 560 in 1x1) + /// + string FrontArmTexture { get; } + + /// + /// The name of the equip slot for the item. If left empty, the equip slot that is looked for will use the name of the item. + /// Useful if you have multiple head textures you need to extend. + /// + string EquipSlotName(Player drawPlayer) => ""; +} diff --git a/Items/Accessories/Vanity/AbandonedWulfrumHelmet.cs b/Items/Accessories/Vanity/AbandonedWulfrumHelmet.cs index 535cc44168..e88d21a1bc 100644 --- a/Items/Accessories/Vanity/AbandonedWulfrumHelmet.cs +++ b/Items/Accessories/Vanity/AbandonedWulfrumHelmet.cs @@ -105,6 +105,8 @@ namespace CalamityMod.Items.Accessories.Vanity { Player.legs = EquipLoader.GetEquipSlot(Mod, "AbandonedWulfrumHelmet", EquipType.Legs); Player.body = EquipLoader.GetEquipSlot(Mod, "AbandonedWulfrumHelmet", EquipType.Body); + + Player.HideAccessories(); } } } diff --git a/Items/Armor/Demonshade/DemonshadeBreastplate.cs b/Items/Armor/Demonshade/DemonshadeBreastplate.cs index e7e84c325c..0f6c5940a1 100644 --- a/Items/Armor/Demonshade/DemonshadeBreastplate.cs +++ b/Items/Armor/Demonshade/DemonshadeBreastplate.cs @@ -8,15 +8,10 @@ using Terraria.ID; namespace CalamityMod.Items.Armor.Demonshade { [AutoloadEquip(EquipType.Body)] - public class DemonshadeBreastplate : ModItem + public class DemonshadeBreastplate : ModItem, IDrawArmOverShoulderpad { - public override void Load() - { - if (Main.netMode != NetmodeID.Server) - { - EquipLoader.AddEquipTexture(Mod, "CalamityMod/Items/Armor/Demonshade/DemonshadeBreastplate_Arms", EquipType.Front, this); - } - } + public string FrontArmTexture => "CalamityMod/Items/Armor/Demonshade/DemonshadeBreastplate_Arms"; + public override void SetStaticDefaults() { diff --git a/Items/Materials/WulfrumMetalScrap.cs b/Items/Materials/WulfrumMetalScrap.cs index b4006539c5..897f32cfb6 100644 --- a/Items/Materials/WulfrumMetalScrap.cs +++ b/Items/Materials/WulfrumMetalScrap.cs @@ -26,6 +26,7 @@ namespace CalamityMod.Items.Materials Item.maxStack = 999; Item.value = Item.sellPrice(copper: 80); Item.rare = ItemRarityID.Blue; + Item.ammo = Item.type; } public override void OnSpawn(IEntitySource source) diff --git a/Items/Weapons/Summon/WulfrumController.cs b/Items/Weapons/Summon/WulfrumController.cs index d68542410d..f0639599a7 100644 --- a/Items/Weapons/Summon/WulfrumController.cs +++ b/Items/Weapons/Summon/WulfrumController.cs @@ -87,6 +87,7 @@ namespace CalamityMod.Items.Weapons.Summon if (buffingDrones > 0) { Player.lifeRegen += (int)((1 + Math.Log(buffingDrones) * 2) * 3); + Player.statDefense += buffingDrones * 3; buffingDrones = 0; } diff --git a/Utilities/PlayerUtils.cs b/Utilities/PlayerUtils.cs index 1174e4e6a2..b03abda8b6 100644 --- a/Utilities/PlayerUtils.cs +++ b/Utilities/PlayerUtils.cs @@ -619,6 +619,33 @@ namespace CalamityMod } #endregion + #region visual layers + public static void HideAccessories(this Player player, bool hideHeadAccs = true, bool hideBodyAccs = true, bool hideLegAccs = true, bool hideShield = true) + { + if (hideHeadAccs) + player.face = -1; + + if (hideBodyAccs) + { + player.handon = -1; + player.handoff = -1; + + player.back = -1; + player.front = -1; + player.neck = -1; + } + + if (hideLegAccs) + { + player.shoe = -1; + player.waist = -1; + } + + if (hideShield) + player.shield = -1; + } + #endregion + /// /// Makes the given player send the given packet to all appropriate receivers.
/// If server is false, the packet is sent only to the multiplayer host.