Clean up a bit.
This commit is contained in:
@@ -111,41 +111,33 @@ namespace Barotrauma
|
|||||||
Vector2 scale = textureScale ?? Vector2.One;
|
Vector2 scale = textureScale ?? Vector2.One;
|
||||||
depth = depth ?? this.depth;
|
depth = depth ?? this.depth;
|
||||||
|
|
||||||
|
Rectangle texPerspective = rect;
|
||||||
|
texPerspective.Location += startOffset.Value;
|
||||||
targetSize = targetSize / scale;
|
targetSize = targetSize / scale;
|
||||||
|
|
||||||
//how many times the texture needs to be drawn on the x-axis
|
//how many times the texture needs to be drawn on the x-axis
|
||||||
int xTiles = (int)Math.Ceiling(targetSize.X / rect.Width);
|
int xTiles = (int)Math.Ceiling(targetSize.X / rect.Width);
|
||||||
//how many times the texture needs to be drawn on the y-axis
|
//how many times the texture needs to be drawn on the y-axis
|
||||||
int yTiles = (int)Math.Ceiling(targetSize.Y / rect.Height);
|
int yTiles = (int)Math.Ceiling(targetSize.Y / rect.Height);
|
||||||
|
|
||||||
Rectangle texPerspective = rect;
|
|
||||||
texPerspective.Location += startOffset.Value;
|
|
||||||
while (texPerspective.X >= rect.Right)
|
|
||||||
texPerspective.X = rect.X + (texPerspective.X - rect.Right);
|
|
||||||
while (texPerspective.Y >= rect.Bottom)
|
|
||||||
texPerspective.Y = rect.Y + (texPerspective.Y - rect.Bottom);
|
|
||||||
|
|
||||||
float top = pos.Y;
|
float top = pos.Y;
|
||||||
texPerspective.Height = (int)Math.Min(targetSize.Y, rect.Height);
|
|
||||||
|
|
||||||
for (int y = 0; y < yTiles; y++)
|
for (int y = 0; y < yTiles; y++)
|
||||||
{
|
{
|
||||||
float movementY = texPerspective.Height * scale.Y;
|
float movementY = texPerspective.Height * scale.Y;
|
||||||
texPerspective.Height = Math.Min((int)(targetSize.Y - texPerspective.Height * y), texPerspective.Height);
|
texPerspective.Height = Math.Min((int)(targetSize.Y - texPerspective.Height * y), texPerspective.Height);
|
||||||
|
|
||||||
float left = pos.X;
|
float left = pos.X;
|
||||||
texPerspective.Width = (int)Math.Min(targetSize.X, rect.Width);
|
texPerspective.Width = (int)Math.Min(targetSize.X, rect.Width);
|
||||||
|
|
||||||
for (int x = 0; x < xTiles; x++)
|
for (int x = 0; x < xTiles; x++)
|
||||||
{
|
{
|
||||||
float movementX = texPerspective.Width * scale.X;
|
float movementX = texPerspective.Width * scale.X;
|
||||||
texPerspective.Width = Math.Min((int)(targetSize.X - texPerspective.Width * x), texPerspective.Width);
|
texPerspective.Width = Math.Min((int)(targetSize.X - texPerspective.Width * x), texPerspective.Width);
|
||||||
|
|
||||||
spriteBatch.Draw(texture, new Vector2(left, top), texPerspective, color.Value, rotation, Vector2.Zero, scale, effects, depth.Value);
|
spriteBatch.Draw(texture, new Vector2(left, top), texPerspective, color.Value, rotation, Vector2.Zero, scale, effects, depth.Value);
|
||||||
|
if (texPerspective.X + movementX >= rect.Right)
|
||||||
if (texPerspective.X + movementX >= rect.Right) texPerspective.X = rect.X;
|
{
|
||||||
|
texPerspective.X = rect.X;
|
||||||
|
}
|
||||||
left += movementX;
|
left += movementX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (texPerspective.Y + movementY >= rect.Bottom)
|
if (texPerspective.Y + movementY >= rect.Bottom)
|
||||||
{
|
{
|
||||||
texPerspective.Y = rect.Y;
|
texPerspective.Y = rect.Y;
|
||||||
|
|||||||
Reference in New Issue
Block a user