Syringes are recolored according to the color of the contained medical item. Closes #256

This commit is contained in:
Joonas Rikkonen
2018-03-01 11:25:37 +02:00
parent 9f6868eaaa
commit 55a5e9e968
4 changed files with 28 additions and 2 deletions

View File

@@ -462,7 +462,7 @@ namespace Barotrauma
if (item == null || !drawItem) return;
item.Sprite.Draw(spriteBatch, new Vector2(rect.X + rect.Width / 2, rect.Y + rect.Height / 2), item.Color);
item.Sprite.Draw(spriteBatch, new Vector2(rect.X + rect.Width / 2, rect.Y + rect.Height / 2), item.GetSpriteColor());
}
}
}

View File

@@ -18,10 +18,28 @@ namespace Barotrauma
get { return prefab.GetActiveSprite(condition); }
}
public Color GetSpriteColor()
{
Color color = spriteColor;
if (prefab.UseContainedSpriteColor && ownInventory != null)
{
for (int i = 0; i < ownInventory.Items.Length; i++)
{
if (ownInventory.Items[i] != null)
{
color = ownInventory.Items[i].spriteColor;
break;
}
}
}
return color;
}
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
{
if (!Visible) return;
Color color = (IsSelected && editing) ? color = Color.Red : spriteColor;
Color color = (IsSelected && editing) ? Color.Red : GetSpriteColor();
if (isHighlighted) color = Color.Orange;
Sprite activeSprite = prefab.sprite;

View File

@@ -8,6 +8,7 @@
price="50"
canuseonself="true"
cargocontainername="Chemical Crate"
usecontainedspritecolor="true"
description="Injection is often a much more effective method of administering drugs than taking them orally.">
<Sprite texture ="med.png" sourcerect="0,0,25,5" depth="0.6"/>

View File

@@ -150,6 +150,13 @@ namespace Barotrauma
private set;
}
[Serialize(false, false)]
public bool UseContainedSpriteColor
{
get;
private set;
}
public bool CanSpriteFlipX
{
get { return canSpriteFlipX; }