(2fc766fe5) Add support for wearable item variants. Not used yet. Not synced (not sure if it should).

This commit is contained in:
Joonas Rikkonen
2019-04-15 13:42:37 +03:00
parent 70a92425d0
commit fe235eb37a
7 changed files with 27 additions and 32 deletions
@@ -66,6 +66,8 @@ namespace Barotrauma
public LightComponent LightComponent { get; set; }
public int Variant { get; private set; }
private Gender _gender;
/// <summary>
/// None = Any/Not Defined -> no effect.
@@ -112,10 +114,11 @@ namespace Barotrauma
/// <summary>
/// Note: this constructor cannot initialize automatically, because the gender is unknown at this point. We only know it when the item is equipped.
/// </summary>
public WearableSprite(XElement subElement, Wearable wearable)
public WearableSprite(XElement subElement, Wearable wearable, int variant = 1)
{
Type = WearableType.Item;
WearableComponent = wearable;
Variant = Math.Max(variant, 1);
SpritePath = ParseSpritePath(subElement.GetAttributeString("texture", string.Empty));
SourceElement = subElement;
}
@@ -131,6 +134,7 @@ namespace Barotrauma
{
SpritePath = SpritePath.Replace("[GENDER]", (_gender == Gender.Female) ? "female" : "male");
}
SpritePath = SpritePath.Replace("[VARIANT]", Variant.ToString());
if (Sprite != null)
{
Sprite.Remove();