Fixed demonshade arms getting drawn over stuff

This commit is contained in:
IbanPlay committed 2022-07-12 18:54:51 +02:00
1 parent 6dbbb8965a
commit d305715d04
11 files changed
+131 -18

No files matched your search

-6
View File
@@ -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))
+8 -3
View File
@@ -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;
@@ -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<Texture2D>(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);
}
}
}
}
+1 -1
View File
@@ -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)
+7
View File
@@ -1,5 +1,6 @@
using Microsoft.Xna.Framework;
using Terraria.DataStructures;
using Terraria;
/// <summary>
/// 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)
/// </summary>
string BulkTexture { get; }
/// <summary>
/// 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.
/// </summary>
string EquipSlotName(Player drawPlayer) => "";
}
@@ -0,0 +1,21 @@
using Microsoft.Xna.Framework;
using Terraria.DataStructures;
using Terraria;
/// <summary>
/// Interface that can be used by chestplates that need their front arm (when walking) to go over the shoulderpads
/// </summary>
public interface IDrawArmOverShoulderpad
{
/// <summary>
/// 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)
/// </summary>
string FrontArmTexture { get; }
/// <summary>
/// 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.
/// </summary>
string EquipSlotName(Player drawPlayer) => "";
}
@@ -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();
}
}
}
@@ -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()
{
+1
View File
@@ -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)
@@ -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;
}
+27
View File
@@ -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
/// <summary>
/// Makes the given player send the given packet to all appropriate receivers.<br />
/// If server is false, the packet is sent only to the multiplayer host.<br />