Syringes are recolored according to the color of the contained medical item. Closes #256
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
@@ -150,6 +150,13 @@ namespace Barotrauma
|
||||
private set;
|
||||
}
|
||||
|
||||
[Serialize(false, false)]
|
||||
public bool UseContainedSpriteColor
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public bool CanSpriteFlipX
|
||||
{
|
||||
get { return canSpriteFlipX; }
|
||||
|
||||
Reference in New Issue
Block a user