From 45607f40a509bcc9a81065b41d8f7639182d81f9 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 7 Aug 2019 00:32:48 +0200 Subject: [PATCH] added scale and other stuff to auto tiles --- MLEM/MLEM.csproj | 2 +- MLEM/Misc/AutoTiling.cs | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/MLEM/MLEM.csproj b/MLEM/MLEM.csproj index b32cf5a..ed87f4a 100644 --- a/MLEM/MLEM.csproj +++ b/MLEM/MLEM.csproj @@ -10,7 +10,7 @@ https://github.com/Ellpeck/MLEM https://github.com/Ellpeck/MLEM https://github.com/Ellpeck/MLEM/blob/master/LICENSE - 1.0.6 + 1.0.7 diff --git a/MLEM/Misc/AutoTiling.cs b/MLEM/Misc/AutoTiling.cs index c423cdf..3d558ee 100644 --- a/MLEM/Misc/AutoTiling.cs +++ b/MLEM/Misc/AutoTiling.cs @@ -4,7 +4,10 @@ using Microsoft.Xna.Framework.Graphics; namespace MLEM.Misc { public class AutoTiling { - public static void DrawAutoTile(SpriteBatch batch, Vector2 pos, Texture2D texture, Rectangle textureRegion, ConnectsTo connectsTo, Color color) { + public static void DrawAutoTile(SpriteBatch batch, Vector2 pos, Texture2D texture, Rectangle textureRegion, ConnectsTo connectsTo, Color color, float rotation = 0, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0) { + var org = origin ?? Vector2.Zero; + var sc = scale ?? Vector2.One; + var up = connectsTo(0, -1); var down = connectsTo(0, 1); var left = connectsTo(-1, 0); @@ -18,10 +21,10 @@ namespace MLEM.Misc { var (x, y) = pos; var (sizeX, sizeY) = textureRegion.Size; var (halfSizeX, halfSizeY) = new Point(sizeX / 2, sizeY / 2); - batch.Draw(texture, new Vector2(x, y), new Rectangle(textureRegion.X + 0 + xUl * sizeX, textureRegion.Y + 0, halfSizeX, halfSizeY), color); - batch.Draw(texture, new Vector2(x + 0.5F * sizeX, y), new Rectangle(textureRegion.X + halfSizeX + xUr * sizeX, textureRegion.Y + 0, halfSizeX, halfSizeY), color); - batch.Draw(texture, new Vector2(x, y + 0.5F * sizeY), new Rectangle(textureRegion.X + xDl * sizeX, textureRegion.Y + halfSizeY, halfSizeX, halfSizeY), color); - batch.Draw(texture, new Vector2(x + 0.5F * sizeX, y + 0.5F * sizeY), new Rectangle(textureRegion.X + halfSizeX + xDr * sizeX, textureRegion.Y + halfSizeY, halfSizeX, halfSizeY), color); + batch.Draw(texture, new Vector2(x, y), new Rectangle(textureRegion.X + 0 + xUl * sizeX, textureRegion.Y + 0, halfSizeX, halfSizeY), color, rotation, org, sc, SpriteEffects.None, layerDepth); + batch.Draw(texture, new Vector2(x + 0.5F * sizeX, y), new Rectangle(textureRegion.X + halfSizeX + xUr * sizeX, textureRegion.Y + 0, halfSizeX, halfSizeY), color, rotation, org, sc, SpriteEffects.None, layerDepth); + batch.Draw(texture, new Vector2(x, y + 0.5F * sizeY), new Rectangle(textureRegion.X + xDl * sizeX, textureRegion.Y + halfSizeY, halfSizeX, halfSizeY), color, rotation, org, sc, SpriteEffects.None, layerDepth); + batch.Draw(texture, new Vector2(x + 0.5F * sizeX, y + 0.5F * sizeY), new Rectangle(textureRegion.X + halfSizeX + xDr * sizeX, textureRegion.Y + halfSizeY, halfSizeX, halfSizeY), color, rotation, org, sc, SpriteEffects.None, layerDepth); } public delegate bool ConnectsTo(int xOff, int yOff);