Small optimization: items have a list of components that have to be drawn

This commit is contained in:
Regalis
2016-05-24 21:17:38 +03:00
parent ed529052a2
commit b4af92ace2
13 changed files with 111 additions and 86 deletions
@@ -7,7 +7,7 @@ using Microsoft.Xna.Framework.Graphics;
namespace Barotrauma.Items.Components
{
class ItemContainer : ItemComponent
class ItemContainer : ItemComponent, IDrawableComponent
{
public const int MaxInventoryCount = 4;
@@ -29,7 +29,11 @@ namespace Barotrauma.Items.Components
public bool HideItems
{
get { return hideItems; }
set { hideItems = value; }
set
{
hideItems = value;
Drawable = !hideItems;
}
}
private bool hideItems;
@@ -160,10 +164,8 @@ namespace Barotrauma.Items.Components
}
}
public override void Draw(SpriteBatch spriteBatch, bool editing = false)
public void Draw(SpriteBatch spriteBatch, bool editing = false)
{
base.Draw(spriteBatch, editing);
if (hideItems || (item.body != null && !item.body.Enabled)) return;
Vector2 transformedItemPos = itemPos;