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

◆ Draw() [2/3]

DrawResult Terraria.Map.MapOverlayDrawContext.Draw ( Texture2D texture,
Vector2 position,
Color color,
SpriteFrame frame,
float scaleIfNotSelected,
float scaleIfSelected,
Alignment alignment )
inline

Definition at line 60 of file MapOverlayDrawContext.cs.

61 {
62 position = (position - _mapPosition) * _mapScale + _mapOffset;
63 if (_clippingRect.HasValue && !_clippingRect.Value.Contains(position.ToPoint()))
64 {
65 return DrawResult.Culled;
66 }
67 Rectangle sourceRectangle = frame.GetSourceRectangle(texture);
68 Vector2 vector = sourceRectangle.Size() * alignment.OffsetMultiplier;
69 Vector2 position2 = position;
70 float num = _drawScale * scaleIfNotSelected;
71 Vector2 vector2 = position - vector * num;
72 bool num2 = new Rectangle((int)vector2.X, (int)vector2.Y, (int)((float)sourceRectangle.Width * num), (int)((float)sourceRectangle.Height * num)).Contains(Main.MouseScreen.ToPoint());
73 float scale = num;
74 if (num2)
75 {
76 scale = _drawScale * scaleIfSelected;
77 }
78 Main.spriteBatch.Draw(texture, position2, sourceRectangle, color, 0f, vector, scale, SpriteEffects.None, 0f);
79 return new DrawResult(num2);
80 }
bool Contains(int x, int y)
Definition Rectangle.cs:92
Rectangle GetSourceRectangle(Texture2D texture)

References Terraria.Map.MapOverlayDrawContext._clippingRect, Terraria.Map.MapOverlayDrawContext._drawScale, Terraria.Map.MapOverlayDrawContext._mapOffset, Terraria.Map.MapOverlayDrawContext._mapPosition, Terraria.Map.MapOverlayDrawContext._mapScale, Microsoft.Xna.Framework.Rectangle.Contains(), Terraria.Map.MapOverlayDrawContext.DrawResult.Culled, Terraria.DataStructures.SpriteFrame.GetSourceRectangle(), Microsoft.Xna.Framework.Rectangle.Height, Terraria.Main.MouseScreen, Terraria.UI.Alignment.OffsetMultiplier, Terraria.Main.spriteBatch, Microsoft.Xna.Framework.Rectangle.Width, Microsoft.Xna.Framework.Vector2.X, and Microsoft.Xna.Framework.Vector2.Y.