Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Draw()

void Terraria.GameContent.UI.ResourceSets.ResourceDrawSettings.Draw ( SpriteBatch spriteBatch,
ref bool isHovered )
inline

Definition at line 27 of file ResourceDrawSettings.cs.

28 {
29 int elementCount = ElementCount;
30 Vector2 topLeftAnchor = TopLeftAnchor;
31 Point value = Main.MouseScreen.ToPoint();
32 for (int i = 0; i < elementCount; i++)
33 {
35 GetTextureMethod(elementIndex, ElementIndexOffset, ElementIndexOffset + elementCount - 1, out var texture, out var drawOffset, out var drawScale, out var sourceRect);
36 Rectangle rectangle = texture.Frame();
37 if (sourceRect.HasValue)
38 {
39 rectangle = sourceRect.Value;
40 }
41 Vector2 position = topLeftAnchor + drawOffset;
43 Rectangle rectangle2 = rectangle;
44 rectangle2.X += (int)(position.X - origin.X);
45 rectangle2.Y += (int)(position.Y - origin.Y);
46 if (rectangle2.Contains(value))
47 {
48 isHovered = true;
49 }
50 spriteBatch.Draw(texture.Value, position, rectangle, Color.White, 0f, origin, drawScale, SpriteEffects.None, 0f);
51 topLeftAnchor += OffsetPerDraw + rectangle.Size() * OffsetPerDrawByTexturePercentile;
52 }
53 }
void Draw(Texture2D texture, Vector2 position, Color color)
bool Contains(int x, int y)
Definition Rectangle.cs:92

References Microsoft.Xna.Framework.Rectangle.Contains(), Microsoft.Xna.Framework.Graphics.SpriteBatch.Draw(), Terraria.GameContent.UI.ResourceSets.ResourceDrawSettings.ElementCount, Terraria.GameContent.UI.ResourceSets.ResourceDrawSettings.ElementIndexOffset, Terraria.GameContent.UI.ResourceSets.ResourceDrawSettings.GetTextureMethod, Terraria.Main.MouseScreen, Terraria.GameContent.UI.ResourceSets.ResourceDrawSettings.OffsetPerDraw, Terraria.GameContent.UI.ResourceSets.ResourceDrawSettings.OffsetPerDrawByTexturePercentile, Terraria.GameContent.UI.ResourceSets.ResourceDrawSettings.OffsetSpriteAnchor, Terraria.GameContent.UI.ResourceSets.ResourceDrawSettings.OffsetSpriteAnchorByTexturePercentile, Terraria.GameContent.UI.ResourceSets.ResourceDrawSettings.TopLeftAnchor, Microsoft.Xna.Framework.Color.White, Microsoft.Xna.Framework.Vector2.X, and Microsoft.Xna.Framework.Vector2.Y.

Referenced by Terraria.GameContent.UI.ResourceSets.HorizontalBarsPlayerResourcesDisplaySet.Draw(), Terraria.GameContent.UI.ResourceSets.FancyClassicPlayerResourcesDisplaySet.DrawLifeBar(), and Terraria.GameContent.UI.ResourceSets.FancyClassicPlayerResourcesDisplaySet.DrawManaBar().