Use a single method with optional parameters for drawing tiled textures.

This commit is contained in:
itchyOwl
2018-04-06 11:54:41 +03:00
parent e89fa0dc5c
commit b86b8cd377
10 changed files with 45 additions and 153 deletions
@@ -129,7 +129,7 @@ namespace Barotrauma
{
backgroundTop.SourceRect = new Rectangle((int)backgroundPos.X, (int)backgroundPos.Y, 1024, (int)Math.Min(-backgroundPos.Y, 1024));
backgroundTop.DrawTiled(spriteBatch, Vector2.Zero, new Vector2(GameMain.GraphicsWidth, Math.Min(-backgroundPos.Y, GameMain.GraphicsHeight)),
Vector2.Zero, level.BackgroundColor);
color: level.BackgroundColor);
}
if (backgroundPos.Y > -1024)
{
@@ -137,7 +137,7 @@ namespace Barotrauma
background.DrawTiled(spriteBatch,
(backgroundPos.Y < 0) ? new Vector2(0.0f, (int)-backgroundPos.Y) : Vector2.Zero,
new Vector2(GameMain.GraphicsWidth, (int)Math.Ceiling(1024 - backgroundPos.Y)),
Vector2.Zero, level.BackgroundColor);
color: level.BackgroundColor);
}
}
@@ -174,7 +174,8 @@ namespace Barotrauma
while (offsetS.Y <= -srcRect.Height * scale) offsetS.Y += srcRect.Height * scale;
while (offsetS.Y > 0.0f) offsetS.Y -= srcRect.Height * scale;
dustParticles.DrawTiled(spriteBatch, origin + offsetS, new Vector2(cam.WorldView.Width - offsetS.X, cam.WorldView.Height - offsetS.Y), Vector2.Zero, srcRect, Color.White * alpha, new Vector2(scale));
dustParticles.DrawTiled(spriteBatch, origin + offsetS, new Vector2(cam.WorldView.Width - offsetS.X, cam.WorldView.Height - offsetS.Y),
sourceRect: srcRect, color: Color.White * alpha, textureScale: new Vector2(scale));
}
spriteBatch.End();
@@ -74,7 +74,7 @@ namespace Barotrauma
Rectangle prevScissorRect = GameMain.Instance.GraphicsDevice.ScissorRectangle;
GameMain.Instance.GraphicsDevice.ScissorRectangle = rect;
iceTexture.DrawTiled(spriteBatch, new Vector2(rect.X, rect.Y), new Vector2(rect.Width, rect.Height), Vector2.Zero, Color.White * 0.8f);
iceTexture.DrawTiled(spriteBatch, new Vector2(rect.X, rect.Y), new Vector2(rect.Width, rect.Height), color: Color.White * 0.8f);
foreach (LocationConnection connection in connections)
{
@@ -133,7 +133,7 @@ namespace Barotrauma
spriteBatch,
new Vector2(rect.X + drawOffset.X, -(rect.Y + drawOffset.Y)),
new Vector2(rect.Width, rect.Height),
color, Point.Zero);
color: color);
}
}
@@ -175,8 +175,9 @@ namespace Barotrauma
spriteBatch,
new Vector2(sections[i].rect.X + drawOffset.X, -(sections[i].rect.Y + drawOffset.Y)),
new Vector2(sections[i].rect.Width, sections[i].rect.Height),
color,
textureOffset, depth);
color: color,
startOffset: textureOffset,
depth: depth);
}
}
@@ -32,7 +32,7 @@ namespace Barotrauma
newRect = Submarine.AbsRect(placePosition, placeSize);
}
sprite.DrawTiled(spriteBatch, new Vector2(newRect.X, -newRect.Y), new Vector2(newRect.Width, newRect.Height), Color.White);
sprite.DrawTiled(spriteBatch, new Vector2(newRect.X, -newRect.Y), new Vector2(newRect.Width, newRect.Height));
GUI.DrawRectangle(spriteBatch, new Rectangle(newRect.X - GameMain.GraphicsWidth, -newRect.Y, newRect.Width + GameMain.GraphicsWidth * 2, newRect.Height), Color.White);
GUI.DrawRectangle(spriteBatch, new Rectangle(newRect.X, -newRect.Y - GameMain.GraphicsHeight, newRect.Width, newRect.Height + GameMain.GraphicsHeight * 2), Color.White);