Small optimization: items have a list of components that have to be drawn
This commit is contained in:
@@ -12,6 +12,11 @@ using System.Globalization;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
interface IDrawableComponent
|
||||
{
|
||||
void Draw(SpriteBatch spriteBatch, bool editing);
|
||||
}
|
||||
|
||||
class ItemSound
|
||||
{
|
||||
public readonly Sound Sound;
|
||||
@@ -104,6 +109,28 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
private bool drawable = true;
|
||||
|
||||
public bool Drawable
|
||||
{
|
||||
get { return drawable; }
|
||||
set
|
||||
{
|
||||
if (value == drawable) return;
|
||||
drawable = value;
|
||||
if (drawable)
|
||||
{
|
||||
if (!item.drawableComponents.Contains(this as IDrawableComponent))
|
||||
item.drawableComponents.Add(this as IDrawableComponent);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.drawableComponents.Remove(this as IDrawableComponent);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[HasDefaultValue(false, false)]
|
||||
public bool CanBePicked
|
||||
{
|
||||
@@ -430,7 +457,10 @@ namespace Barotrauma.Items.Components
|
||||
/// <summary>a Character has dropped the item</summary>
|
||||
public virtual void Drop(Character dropper) { }
|
||||
|
||||
public virtual void Draw(SpriteBatch spriteBatch, bool editing = false) { }
|
||||
//public virtual void Draw(SpriteBatch spriteBatch, bool editing = false)
|
||||
//{
|
||||
// item.drawableComponents = Array.FindAll(item.drawableComponents, i => i != this);
|
||||
//}
|
||||
|
||||
public virtual void DrawHUD(SpriteBatch spriteBatch, Character character) { }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user