diff --git a/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs b/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs index 15b86415c..97d940495 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Inventory.cs @@ -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()); } } } diff --git a/Barotrauma/BarotraumaClient/Source/Items/Item.cs b/Barotrauma/BarotraumaClient/Source/Items/Item.cs index d8e8e476e..2fb00ca42 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/Item.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/Item.cs @@ -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; diff --git a/Barotrauma/BarotraumaShared/Content/Items/Medical/medical.xml b/Barotrauma/BarotraumaShared/Content/Items/Medical/medical.xml index 3690426d6..80b7dc920 100644 --- a/Barotrauma/BarotraumaShared/Content/Items/Medical/medical.xml +++ b/Barotrauma/BarotraumaShared/Content/Items/Medical/medical.xml @@ -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."> diff --git a/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs b/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs index 711fb23b2..41def44fd 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs @@ -150,6 +150,13 @@ namespace Barotrauma private set; } + [Serialize(false, false)] + public bool UseContainedSpriteColor + { + get; + private set; + } + public bool CanSpriteFlipX { get { return canSpriteFlipX; }