Option to make wearable sprites use the depth of the sprite instead of using the depth of the limb it's attached to

This commit is contained in:
Joonas Rikkonen
2017-08-10 18:19:06 +03:00
parent b70f6fb3ca
commit fd844fd696
2 changed files with 21 additions and 15 deletions

View File

@@ -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;
}
}
}

View File

@@ -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);