Client LuaCsForBarotrauma
BarotraumaClient/ClientSource/Items/Components/Ladder.cs
1 using Microsoft.Xna.Framework;
2 using Microsoft.Xna.Framework.Graphics;
3 using System.Xml.Linq;
4 
6 {
7  partial class Ladder : ItemComponent, IDrawableComponent
8  {
9  public float BackgroundSpriteDepth
10  {
11  get { return item.GetDrawDepth() + 0.05f; }
12  }
13 
14  public Vector2 DrawSize
15  {
16  //use the extents of the item as the draw size
17  get { return Vector2.Zero; }
18  }
19 
20  private Sprite backgroundSprite;
21 
22  public void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth = -1, Color? overrideColor = null)
23  {
24  if (backgroundSprite == null) { return; }
25 
26  backgroundSprite.DrawTiled(spriteBatch,
27  new Vector2(item.DrawPosition.X - item.Rect.Width / 2 * item.Scale, -(item.DrawPosition.Y + item.Rect.Height / 2)) - backgroundSprite.Origin * item.Scale,
28  new Vector2(backgroundSprite.size.X * item.Scale, item.Rect.Height),
29  color: overrideColor ?? item.Color,
30  textureScale: Vector2.One * item.Scale,
31  depth: BackgroundSpriteDepth);
32  }
33 
34  partial void InitProjSpecific(ContentXElement element)
35  {
36  var backgroundSpriteElement = element.GetChildElement("backgroundsprite");
37  if (backgroundSpriteElement != null)
38  {
39  backgroundSprite = new Sprite(backgroundSpriteElement);
40  }
41  }
42 
43  partial void RemoveProjSpecific()
44  {
45  backgroundSprite?.Remove();
46  backgroundSprite = null;
47  }
48  }
49 }
ContentXElement? GetChildElement(string name)
virtual Vector2 DrawPosition
Definition: Entity.cs:51
void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth=-1, Color? overrideColor=null)
void DrawTiled(ISpriteBatch spriteBatch, Vector2 position, Vector2 targetSize, float rotation=0f, Vector2? origin=null, Color? color=null, Vector2? startOffset=null, Vector2? textureScale=null, float? depth=null, SpriteEffects? spriteEffects=null)