From d867dd6c176bb7a3367fe3e4da8733a6c548cba2 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Tue, 27 Feb 2018 23:04:54 +0200 Subject: [PATCH] Diving suits are rendered in front of all items (diving masks, goggles, etc aren't drawn on top of the suit). Items that are being held take the depth of the wearable sprite on the hand into account. Closes #290 --- .../BarotraumaClient/Source/Items/Item.cs | 14 ++++++++++-- .../Content/Items/Diving/divinggear.xml | 22 +++++++++---------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Items/Item.cs b/Barotrauma/BarotraumaClient/Source/Items/Item.cs index 9b14eff13..d8e8e476e 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Item.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Item.cs @@ -81,11 +81,21 @@ namespace Barotrauma { if (holdable.Picker.SelectedItems[0] == this) { - depth = holdable.Picker.AnimController.GetLimb(LimbType.RightHand).sprite.Depth + 0.000001f; + Limb holdLimb = holdable.Picker.AnimController.GetLimb(LimbType.RightHand); + depth = holdLimb.sprite.Depth + 0.000001f; + foreach (WearableSprite wearableSprite in holdLimb.WearingItems) + { + if (!wearableSprite.InheritLimbDepth && wearableSprite.Sprite != null) depth = Math.Min(wearableSprite.Sprite.Depth, depth); + } } else if (holdable.Picker.SelectedItems[1] == this) { - depth = holdable.Picker.AnimController.GetLimb(LimbType.LeftArm).sprite.Depth - 0.000001f; + Limb holdLimb = holdable.Picker.AnimController.GetLimb(LimbType.LeftArm); + depth = holdLimb.sprite.Depth - 0.000001f; + foreach (WearableSprite wearableSprite in holdLimb.WearingItems) + { + if (!wearableSprite.InheritLimbDepth && wearableSprite.Sprite != null) depth = Math.Max(wearableSprite.Sprite.Depth, depth); + } } } body.Draw(spriteBatch, selectedSprite, color, depth); diff --git a/Barotrauma/BarotraumaShared/Content/Items/Diving/divinggear.xml b/Barotrauma/BarotraumaShared/Content/Items/Diving/divinggear.xml index 21c5e897e..b207683a0 100644 --- a/Barotrauma/BarotraumaShared/Content/Items/Diving/divinggear.xml +++ b/Barotrauma/BarotraumaShared/Content/Items/Diving/divinggear.xml @@ -83,22 +83,22 @@ - + - - + + - - + + - - + + - - + + - - + +