diff --git a/MLEM/Graphics/AutoTiling.cs b/MLEM/Graphics/AutoTiling.cs index ec3576e..1958df6 100644 --- a/MLEM/Graphics/AutoTiling.cs +++ b/MLEM/Graphics/AutoTiling.cs @@ -82,16 +82,16 @@ namespace MLEM.Graphics { var orig = origin ?? Vector2.Zero; var sc = scale ?? Vector2.One; var od = layerDepth + overlayDepthOffset; - var (p1, r1, p2, r2, p3, r3, p4, r4) = CalculateExtendedAutoTile(pos, textureRegion, connectsTo, sc); + var (r1, r2, r3, r4) = CalculateExtendedAutoTile(pos, textureRegion, connectsTo, sc); batch.Draw(texture, pos, textureRegion, backgroundColor, 0, orig, sc, SpriteEffects.None, layerDepth); if (r1 != Rectangle.Empty) - batch.Draw(texture, p1, r1, overlayColor, 0, orig, sc, SpriteEffects.None, od); + batch.Draw(texture, pos, r1, overlayColor, 0, orig, sc, SpriteEffects.None, od); if (r2 != Rectangle.Empty) - batch.Draw(texture, p2, r2, overlayColor, 0, orig, sc, SpriteEffects.None, od); + batch.Draw(texture, pos, r2, overlayColor, 0, orig, sc, SpriteEffects.None, od); if (r3 != Rectangle.Empty) - batch.Draw(texture, p3, r3, overlayColor, 0, orig, sc, SpriteEffects.None, od); + batch.Draw(texture, pos, r3, overlayColor, 0, orig, sc, SpriteEffects.None, od); if (r4 != Rectangle.Empty) - batch.Draw(texture, p4, r4, overlayColor, 0, orig, sc, SpriteEffects.None, od); + batch.Draw(texture, pos, r4, overlayColor, 0, orig, sc, SpriteEffects.None, od); } /// @@ -99,16 +99,16 @@ namespace MLEM.Graphics { var orig = origin ?? Vector2.Zero; var sc = scale ?? Vector2.One; var od = layerDepth + overlayDepthOffset; - var (p1, r1, p2, r2, p3, r3, p4, r4) = CalculateExtendedAutoTile(pos, textureRegion, connectsTo, sc); + var (r1, r2, r3, r4) = CalculateExtendedAutoTile(pos, textureRegion, connectsTo, sc); batch.Add(texture, pos, textureRegion, backgroundColor, 0, orig, sc, SpriteEffects.None, layerDepth); if (r1 != Rectangle.Empty) - batch.Add(texture, p1, r1, overlayColor, 0, orig, sc, SpriteEffects.None, od); + batch.Add(texture, pos, r1, overlayColor, 0, orig, sc, SpriteEffects.None, od); if (r2 != Rectangle.Empty) - batch.Add(texture, p2, r2, overlayColor, 0, orig, sc, SpriteEffects.None, od); + batch.Add(texture, pos, r2, overlayColor, 0, orig, sc, SpriteEffects.None, od); if (r3 != Rectangle.Empty) - batch.Add(texture, p3, r3, overlayColor, 0, orig, sc, SpriteEffects.None, od); + batch.Add(texture, pos, r3, overlayColor, 0, orig, sc, SpriteEffects.None, od); if (r4 != Rectangle.Empty) - batch.Add(texture, p4, r4, overlayColor, 0, orig, sc, SpriteEffects.None, od); + batch.Add(texture, pos, r4, overlayColor, 0, orig, sc, SpriteEffects.None, od); } private static (Vector2, Rectangle, Vector2, Rectangle, Vector2, Rectangle, Vector2, Rectangle) CalculateAutoTile(Vector2 pos, Rectangle textureRegion, ConnectsTo connectsTo, Vector2 scale) { @@ -120,10 +120,8 @@ namespace MLEM.Graphics { var xUr = up && right ? connectsTo(1, -1) ? 0 : 4 : right ? 1 : up ? 3 : 2; var xDl = down && left ? connectsTo(-1, 1) ? 0 : 4 : left ? 1 : down ? 3 : 2; var xDr = down && right ? connectsTo(1, 1) ? 0 : 4 : right ? 1 : down ? 3 : 2; - var (w, h) = textureRegion.Size; var (w2, h2) = new Point(w / 2, h / 2); - return ( new Vector2(pos.X, pos.Y), new Rectangle(textureRegion.X + xUl * w, textureRegion.Y, w2, h2), new Vector2(pos.X + w2 * scale.X, pos.Y), new Rectangle(textureRegion.X + w2 + xUr * w, textureRegion.Y, w2, h2), @@ -131,7 +129,7 @@ namespace MLEM.Graphics { new Vector2(pos.X + w2 * scale.X, pos.Y + h2 * scale.Y), new Rectangle(textureRegion.X + w2 + xDr * w, textureRegion.Y + h2, w2, h2)); } - private static (Vector2, Rectangle, Vector2, Rectangle, Vector2, Rectangle, Vector2, Rectangle) CalculateExtendedAutoTile(Vector2 pos, Rectangle textureRegion, ConnectsTo connectsTo, Vector2 scale) { + private static (Rectangle, Rectangle, Rectangle, Rectangle) CalculateExtendedAutoTile(Vector2 pos, Rectangle textureRegion, ConnectsTo connectsTo, Vector2 scale) { var up = connectsTo(0, -1); var down = connectsTo(0, 1); var left = connectsTo(-1, 0); @@ -140,15 +138,12 @@ namespace MLEM.Graphics { var xUr = up && right ? connectsTo(1, -1) ? -1 : 14 : right ? 2 : up ? 10 : 6; var xDl = down && left ? connectsTo(-1, 1) ? -1 : 15 : left ? 3 : down ? 11 : 7; var xDr = down && right ? connectsTo(1, 1) ? -1 : 16 : right ? 4 : down ? 12 : 8; - var (w, h) = textureRegion.Size; - var (w2, h2) = new Point(w / 2, h / 2); - return ( - new Vector2(pos.X, pos.Y), xUl < 0 ? Rectangle.Empty : new Rectangle(textureRegion.X + xUl * w, textureRegion.Y, w2, h2), - new Vector2(pos.X + w2 * scale.X, pos.Y), xUr < 0 ? Rectangle.Empty : new Rectangle(textureRegion.X + w2 + xUr * w, textureRegion.Y, w2, h2), - new Vector2(pos.X, pos.Y + h2 * scale.Y), xDl < 0 ? Rectangle.Empty : new Rectangle(textureRegion.X + xDl * w, textureRegion.Y + h2, w2, h2), - new Vector2(pos.X + w2 * scale.X, pos.Y + h2 * scale.Y), xDr < 0 ? Rectangle.Empty : new Rectangle(textureRegion.X + w2 + xDr * w, textureRegion.Y + h2, w2, h2)); + xUl < 0 ? Rectangle.Empty : new Rectangle(textureRegion.X + xUl * w, textureRegion.Y, w, h), + xUr < 0 ? Rectangle.Empty : new Rectangle(textureRegion.X + xUr * w, textureRegion.Y, w, h), + xDl < 0 ? Rectangle.Empty : new Rectangle(textureRegion.X + xDl * w, textureRegion.Y, w, h), + xDr < 0 ? Rectangle.Empty : new Rectangle(textureRegion.X + xDr * w, textureRegion.Y, w, h)); } ///