diff --git a/Barotrauma/BarotraumaClient/Source/Characters/Limb.cs b/Barotrauma/BarotraumaClient/Source/Characters/Limb.cs index 63811fdd4..a84ee186a 100644 --- a/Barotrauma/BarotraumaClient/Source/Characters/Limb.cs +++ b/Barotrauma/BarotraumaClient/Source/Characters/Limb.cs @@ -88,15 +88,19 @@ namespace Barotrauma Vector2 origin = wearable.Sprite.Origin; if (body.Dir == -1.0f) origin.X = wearable.Sprite.SourceRect.Width - origin.X; + + float depth = wearable.Sprite.Depth; - float depth = sprite.Depth - 0.000001f; - - if (wearable.DepthLimb != LimbType.None) + if (wearable.InheritLimbDepth) { - Limb depthLimb = character.AnimController.GetLimb(wearable.DepthLimb); - if (depthLimb != null) + depth = sprite.Depth - 0.000001f; + if (wearable.DepthLimb != LimbType.None) { - depth = depthLimb.sprite.Depth - 0.000001f; + Limb depthLimb = character.AnimController.GetLimb(wearable.DepthLimb); + if (depthLimb != null) + { + depth = depthLimb.sprite.Depth - 0.000001f; + } } } diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Wearable.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Wearable.cs index 73c776303..bee47f0bc 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Wearable.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Wearable.cs @@ -8,18 +8,19 @@ namespace Barotrauma.Items.Components { class WearableSprite { - public Sprite Sprite; - public bool HideLimb; - public LimbType DepthLimb; + public readonly Sprite Sprite; + public readonly bool HideLimb; + public readonly bool InheritLimbDepth; + public readonly LimbType DepthLimb; - public Wearable WearableComponent; + public readonly Wearable WearableComponent; - public WearableSprite(Wearable item, Sprite sprite, bool hideLimb, LimbType depthLimb = LimbType.None) + public WearableSprite(Wearable item, Sprite sprite, bool hideLimb, bool inheritLimbDepth = true, LimbType depthLimb = LimbType.None) { WearableComponent = item; Sprite = sprite; HideLimb = hideLimb; - + InheritLimbDepth = inheritLimbDepth; DepthLimb = depthLimb; } } @@ -88,9 +89,10 @@ namespace Barotrauma.Items.Components spritePath = Path.GetDirectoryName( item.Prefab.ConfigFile)+"/"+spritePath; var sprite = new Sprite(subElement, "", spritePath); - wearableSprites[i] = new WearableSprite(this, sprite, ToolBox.GetAttributeBool(subElement, "hidelimb", false), - (LimbType)Enum.Parse(typeof(LimbType), - ToolBox.GetAttributeString(subElement, "depthlimb", "None"), true)); + wearableSprites[i] = new WearableSprite(this, sprite, + ToolBox.GetAttributeBool(subElement, "hidelimb", false), + ToolBox.GetAttributeBool(subElement, "inheritlimbdepth", true), + (LimbType)Enum.Parse(typeof(LimbType), ToolBox.GetAttributeString(subElement, "depthlimb", "None"), true)); limbType[i] = (LimbType)Enum.Parse(typeof(LimbType), ToolBox.GetAttributeString(subElement, "limb", "Head"), true);