1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-24 21:48:35 +01:00

Compare commits

...

7 commits

4 changed files with 96 additions and 75 deletions

View file

@ -1,7 +1,9 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using MLEM.Extensions;
using MLEM.Graphics; using MLEM.Graphics;
using MLEM.Startup; using MLEM.Startup;
using MLEM.Textures;
namespace Demos { namespace Demos {
/// <summary> /// <summary>
@ -58,10 +60,12 @@ namespace Demos {
} }
// the texture region supplied to the AutoTiling method should only encompass the first filler tile's location and size // the texture region supplied to the AutoTiling method should only encompass the first filler tile's location and size
AutoTiling.DrawAutoTile(this.SpriteBatch, new Vector2(x + 1, y + 1) * TileSize, this.texture, new Rectangle(0, 0, TileSize, TileSize), ConnectsTo, Color.White); AutoTiling.DrawAutoTile(this.SpriteBatch, new Vector2(x + 1, y + 1) * TileSize, new TextureRegion(this.texture, 0, 0, TileSize, TileSize), ConnectsTo, Color.White);
// when drawing extended auto-tiles, the same rules apply, but the source texture layout is different // when drawing extended auto-tiles, the same rules apply, but the source texture layout is different
AutoTiling.DrawExtendedAutoTile(this.SpriteBatch, new Vector2(x + 8, y + 1) * TileSize, this.texture, new Rectangle(0, TileSize * 2, TileSize, TileSize), ConnectsTo, Color.White); var background = new TextureRegion(this.texture, 0, TileSize * 2, TileSize, TileSize);
var overlay = new TextureRegion(this.texture, background.Area.OffsetCopy(new Point(TileSize, 0)));
AutoTiling.DrawExtendedAutoTile(this.SpriteBatch, new Vector2(x + 8, y + 1) * TileSize, background, overlay, ConnectsTo, Color.White, Color.White);
} }
} }
this.SpriteBatch.End(); this.SpriteBatch.End();

View file

@ -147,20 +147,20 @@ namespace MLEM.Extensions {
} }
/// <inheritdoc cref="StaticSpriteBatch.Add(Texture2D,Rectangle,Rectangle?,Color,float,Vector2,SpriteEffects,float)"/> /// <inheritdoc cref="StaticSpriteBatch.Add(Texture2D,Rectangle,Rectangle?,Color,float,Vector2,SpriteEffects,float)"/>
public static void Add(this StaticSpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, SpriteEffects effects, float layerDepth) { public static StaticSpriteBatch.Item Add(this StaticSpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, SpriteEffects effects, float layerDepth) {
var source = sourceRectangle ?? new Rectangle(0, 0, texture.Width, texture.Height); var source = sourceRectangle ?? new Rectangle(0, 0, texture.Width, texture.Height);
var scale = new Vector2(1F / source.Width, 1F / source.Height) * destinationRectangle.Size; var scale = new Vector2(1F / source.Width, 1F / source.Height) * destinationRectangle.Size;
batch.Add(texture, destinationRectangle.Location, sourceRectangle, color, rotation, origin, scale, effects, layerDepth); return batch.Add(texture, destinationRectangle.Location, sourceRectangle, color, rotation, origin, scale, effects, layerDepth);
} }
/// <inheritdoc cref="StaticSpriteBatch.Add(Texture2D,Rectangle,Rectangle?,Color)"/> /// <inheritdoc cref="StaticSpriteBatch.Add(Texture2D,Rectangle,Rectangle?,Color)"/>
public static void Add(this StaticSpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Rectangle? sourceRectangle, Color color) { public static StaticSpriteBatch.Item Add(this StaticSpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Rectangle? sourceRectangle, Color color) {
batch.Add(texture, destinationRectangle, sourceRectangle, color, 0, Vector2.Zero, SpriteEffects.None, 0); return batch.Add(texture, destinationRectangle, sourceRectangle, color, 0, Vector2.Zero, SpriteEffects.None, 0);
} }
/// <inheritdoc cref="StaticSpriteBatch.Add(Texture2D,Rectangle,Color)"/> /// <inheritdoc cref="StaticSpriteBatch.Add(Texture2D,Rectangle,Color)"/>
public static void Add(this StaticSpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Color color) { public static StaticSpriteBatch.Item Add(this StaticSpriteBatch batch, Texture2D texture, RectangleF destinationRectangle, Color color) {
batch.Add(texture, destinationRectangle, null, color); return batch.Add(texture, destinationRectangle, null, color);
} }
private static void AutoDispose(SpriteBatch batch, Texture2D texture) { private static void AutoDispose(SpriteBatch batch, Texture2D texture) {

View file

@ -1,5 +1,7 @@
using System.Collections.Generic;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using MLEM.Textures;
namespace MLEM.Graphics { namespace MLEM.Graphics {
/// <summary> /// <summary>
@ -24,42 +26,46 @@ namespace MLEM.Graphics {
/// </summary> /// </summary>
/// <param name="batch">The sprite batch to use for drawing.</param> /// <param name="batch">The sprite batch to use for drawing.</param>
/// <param name="pos">The position to draw at.</param> /// <param name="pos">The position to draw at.</param>
/// <param name="texture">The texture to use for drawing.</param> /// <param name="texture">The texture to use for drawing, with the area set to the first texture region, as described in the summary.</param>
/// <param name="textureRegion">The location of the first texture region, as described in the summary.</param>
/// <param name="connectsTo">A function that determines whether two positions should connect.</param> /// <param name="connectsTo">A function that determines whether two positions should connect.</param>
/// <param name="color">The color to draw with.</param> /// <param name="color">The color to draw with.</param>
/// <param name="origin">The origin to draw from.</param> /// <param name="origin">The origin to draw from.</param>
/// <param name="scale">The scale to draw with.</param> /// <param name="scale">The scale to draw with.</param>
/// <param name="layerDepth">The layer depth to draw with.</param> /// <param name="layerDepth">The layer depth to draw with.</param>
public static void DrawAutoTile(SpriteBatch batch, Vector2 pos, Texture2D texture, Rectangle textureRegion, ConnectsTo connectsTo, Color color, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0) { public static void DrawAutoTile(SpriteBatch batch, Vector2 pos, TextureRegion texture, ConnectsTo connectsTo, Color color, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0) {
var orig = origin ?? Vector2.Zero; var orig = origin ?? Vector2.Zero;
var sc = scale ?? Vector2.One; var sc = scale ?? Vector2.One;
var (p1, r1, p2, r2, p3, r3, p4, r4) = CalculateAutoTile(pos, textureRegion, connectsTo, sc); var (p1, r1, p2, r2, p3, r3, p4, r4) = CalculateAutoTile(pos, texture.Area, connectsTo, sc);
batch.Draw(texture, p1, r1, color, 0, orig, sc, SpriteEffects.None, layerDepth); batch.Draw(texture.Texture, p1, r1, color, 0, orig, sc, SpriteEffects.None, layerDepth);
batch.Draw(texture, p2, r2, color, 0, orig, sc, SpriteEffects.None, layerDepth); batch.Draw(texture.Texture, p2, r2, color, 0, orig, sc, SpriteEffects.None, layerDepth);
batch.Draw(texture, p3, r3, color, 0, orig, sc, SpriteEffects.None, layerDepth); batch.Draw(texture.Texture, p3, r3, color, 0, orig, sc, SpriteEffects.None, layerDepth);
batch.Draw(texture, p4, r4, color, 0, orig, sc, SpriteEffects.None, layerDepth); batch.Draw(texture.Texture, p4, r4, color, 0, orig, sc, SpriteEffects.None, layerDepth);
} }
/// <inheritdoc cref="DrawAutoTile"/> /// <inheritdoc cref="DrawAutoTile"/>
public static void AddAutoTile(StaticSpriteBatch batch, Vector2 pos, Texture2D texture, Rectangle textureRegion, ConnectsTo connectsTo, Color color, float rotation = 0, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0) { public static void AddAutoTile(StaticSpriteBatch batch, Vector2 pos, TextureRegion texture, ConnectsTo connectsTo, Color color, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, ICollection<StaticSpriteBatch.Item> items = null) {
var orig = origin ?? Vector2.Zero; var orig = origin ?? Vector2.Zero;
var sc = scale ?? Vector2.One; var sc = scale ?? Vector2.One;
var (p1, r1, p2, r2, p3, r3, p4, r4) = CalculateAutoTile(pos, textureRegion, connectsTo, sc); var (p1, r1, p2, r2, p3, r3, p4, r4) = CalculateAutoTile(pos, texture.Area, connectsTo, sc);
batch.Add(texture, p1, r1, color, 0, orig, sc, SpriteEffects.None, layerDepth); var a1 = batch.Add(texture.Texture, p1, r1, color, 0, orig, sc, SpriteEffects.None, layerDepth);
batch.Add(texture, p2, r2, color, 0, orig, sc, SpriteEffects.None, layerDepth); var a2 = batch.Add(texture.Texture, p2, r2, color, 0, orig, sc, SpriteEffects.None, layerDepth);
batch.Add(texture, p3, r3, color, 0, orig, sc, SpriteEffects.None, layerDepth); var a3 = batch.Add(texture.Texture, p3, r3, color, 0, orig, sc, SpriteEffects.None, layerDepth);
batch.Add(texture, p4, r4, color, 0, orig, sc, SpriteEffects.None, layerDepth); var a4 = batch.Add(texture.Texture, p4, r4, color, 0, orig, sc, SpriteEffects.None, layerDepth);
if (items != null) {
items.Add(a1);
items.Add(a2);
items.Add(a3);
items.Add(a4);
}
} }
/// <summary> /// <summary>
/// This method allows for a tiled texture to be drawn in an auto-tiling mode. /// This method allows for a tiled texture to be drawn in an auto-tiling mode.
/// This allows, for example, a grass patch on a tilemap to have nice looking edges that transfer over into a path without any hard edges between tiles. /// This allows, for example, a grass patch on a tilemap to have nice looking edges that transfer over into a path without any hard edges between tiles.
/// ///
/// This method is a more complex version of <see cref="DrawAutoTile"/> that overlays separate border textures on a base texture, which also allows for non-rectangular texture areas to be used easily. /// This method is a more complex version of <see cref="DrawAutoTile"/> that overlays separate border textures on a background texture region, which also allows for non-rectangular texture areas to be used easily.
/// For auto-tiling in this way to work, the tiles have to be laid out as follows: 17 tiles aligned horizontally within the texture file, with the following information: /// For auto-tiling in this way to work, the overlay sections have to be laid out as follows: 16 sections aligned horizontally within the texture file, with the following information:
/// <list type="number"> /// <list type="number">
/// <item><description>The texture used for filling big areas</description></item>
/// <item><description>The texture used for straight, horizontal borders, with the borders facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right</description></item> /// <item><description>The texture used for straight, horizontal borders, with the borders facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right</description></item>
/// <item><description>The texture used for outer corners, with the corners facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right</description></item> /// <item><description>The texture used for outer corners, with the corners facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right</description></item>
/// <item><description>The texture used for straight, vertical borders, with the borders facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right</description></item> /// <item><description>The texture used for straight, vertical borders, with the borders facing away from the center, split up into four parts: top left, then top right, then bottom left, then bottom right</description></item>
@ -69,42 +75,58 @@ namespace MLEM.Graphics {
/// </summary> /// </summary>
/// <param name="batch">The sprite batch to use for drawing.</param> /// <param name="batch">The sprite batch to use for drawing.</param>
/// <param name="pos">The position to draw at.</param> /// <param name="pos">The position to draw at.</param>
/// <param name="texture">The texture to use for drawing.</param> /// <param name="backgroundTexture">The background region, or null to skip drawing a background.</param>
/// <param name="textureRegion">The location of the first texture region, as described in the summary.</param> /// <param name="overlayTexture">The first overlay region, as described in the summary.</param>
/// <param name="connectsTo">A function that determines whether two positions should connect.</param> /// <param name="connectsTo">A function that determines whether two positions should connect.</param>
/// <param name="color">The color to draw with.</param> /// <param name="backgroundColor">The color to draw the texture used for filling big areas with.</param>
/// <param name="overlayColor">The color to draw border and corner textures with.</param>
/// <param name="origin">The origin to draw from.</param> /// <param name="origin">The origin to draw from.</param>
/// <param name="scale">The scale to draw with.</param> /// <param name="scale">The scale to draw with.</param>
/// <param name="layerDepth">The layer depth to draw with.</param> /// <param name="layerDepth">The layer depth to draw with.</param>
public static void DrawExtendedAutoTile(SpriteBatch batch, Vector2 pos, Texture2D texture, Rectangle textureRegion, ConnectsTo connectsTo, Color color, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0) { /// <param name="overlayDepthOffset">An optional depth offset from <paramref name="layerDepth"/> that the overlay should be drawn with</param>
public static void DrawExtendedAutoTile(SpriteBatch batch, Vector2 pos, TextureRegion backgroundTexture, TextureRegion overlayTexture, ConnectsTo connectsTo, Color backgroundColor, Color overlayColor, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, float overlayDepthOffset = 0) {
var orig = origin ?? Vector2.Zero; var orig = origin ?? Vector2.Zero;
var sc = scale ?? Vector2.One; var sc = scale ?? Vector2.One;
var (p1, r1, p2, r2, p3, r3, p4, r4) = CalculateExtendedAutoTile(pos, textureRegion, connectsTo, sc); var od = layerDepth + overlayDepthOffset;
batch.Draw(texture, pos, textureRegion, color, 0, orig, sc, SpriteEffects.None, layerDepth); var (r1, r2, r3, r4) = CalculateExtendedAutoTile(pos, overlayTexture.Area, connectsTo, sc);
if (backgroundTexture != null)
batch.Draw(backgroundTexture, pos, backgroundColor, 0, orig, sc, SpriteEffects.None, layerDepth);
if (r1 != Rectangle.Empty) if (r1 != Rectangle.Empty)
batch.Draw(texture, p1, r1, color, 0, orig, sc, SpriteEffects.None, layerDepth); batch.Draw(overlayTexture.Texture, pos, r1, overlayColor, 0, orig, sc, SpriteEffects.None, od);
if (r2 != Rectangle.Empty) if (r2 != Rectangle.Empty)
batch.Draw(texture, p2, r2, color, 0, orig, sc, SpriteEffects.None, layerDepth); batch.Draw(overlayTexture.Texture, pos, r2, overlayColor, 0, orig, sc, SpriteEffects.None, od);
if (r3 != Rectangle.Empty) if (r3 != Rectangle.Empty)
batch.Draw(texture, p3, r3, color, 0, orig, sc, SpriteEffects.None, layerDepth); batch.Draw(overlayTexture.Texture, pos, r3, overlayColor, 0, orig, sc, SpriteEffects.None, od);
if (r4 != Rectangle.Empty) if (r4 != Rectangle.Empty)
batch.Draw(texture, p4, r4, color, 0, orig, sc, SpriteEffects.None, layerDepth); batch.Draw(overlayTexture.Texture, pos, r4, overlayColor, 0, orig, sc, SpriteEffects.None, od);
} }
/// <inheritdoc cref="DrawExtendedAutoTile"/> /// <inheritdoc cref="DrawExtendedAutoTile"/>
public static void AddExtendedAutoTile(StaticSpriteBatch batch, Vector2 pos, Texture2D texture, Rectangle textureRegion, ConnectsTo connectsTo, Color color, float rotation = 0, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0) { public static void AddExtendedAutoTile(StaticSpriteBatch batch, Vector2 pos, TextureRegion backgroundTexture, TextureRegion overlayTexture, ConnectsTo connectsTo, Color backgroundColor, Color overlayColor, Vector2? origin = null, Vector2? scale = null, float layerDepth = 0, float overlayDepthOffset = 0, ICollection<StaticSpriteBatch.Item> items = null) {
var orig = origin ?? Vector2.Zero; var orig = origin ?? Vector2.Zero;
var sc = scale ?? Vector2.One; var sc = scale ?? Vector2.One;
var (p1, r1, p2, r2, p3, r3, p4, r4) = CalculateExtendedAutoTile(pos, textureRegion, connectsTo, sc); var od = layerDepth + overlayDepthOffset;
batch.Add(texture, pos, textureRegion, color, 0, orig, sc, SpriteEffects.None, layerDepth); var (r1, r2, r3, r4) = CalculateExtendedAutoTile(pos, overlayTexture.Area, connectsTo, sc);
if (r1 != Rectangle.Empty) if (backgroundTexture != null) {
batch.Add(texture, p1, r1, color, 0, orig, sc, SpriteEffects.None, layerDepth); var background = batch.Add(backgroundTexture, pos, backgroundColor, 0, orig, sc, SpriteEffects.None, layerDepth);
if (r2 != Rectangle.Empty) items?.Add(background);
batch.Add(texture, p2, r2, color, 0, orig, sc, SpriteEffects.None, layerDepth); }
if (r3 != Rectangle.Empty) if (r1 != Rectangle.Empty) {
batch.Add(texture, p3, r3, color, 0, orig, sc, SpriteEffects.None, layerDepth); var o1 = batch.Add(overlayTexture.Texture, pos, r1, overlayColor, 0, orig, sc, SpriteEffects.None, od);
if (r4 != Rectangle.Empty) items?.Add(o1);
batch.Add(texture, p4, r4, color, 0, orig, sc, SpriteEffects.None, layerDepth); }
if (r2 != Rectangle.Empty) {
var o2 = batch.Add(overlayTexture.Texture, pos, r2, overlayColor, 0, orig, sc, SpriteEffects.None, od);
items?.Add(o2);
}
if (r3 != Rectangle.Empty) {
var o3 = batch.Add(overlayTexture.Texture, pos, r3, overlayColor, 0, orig, sc, SpriteEffects.None, od);
items?.Add(o3);
}
if (r4 != Rectangle.Empty) {
var o4 = batch.Add(overlayTexture.Texture, pos, r4, overlayColor, 0, orig, sc, SpriteEffects.None, od);
items?.Add(o4);
}
} }
private static (Vector2, Rectangle, Vector2, Rectangle, Vector2, Rectangle, Vector2, Rectangle) CalculateAutoTile(Vector2 pos, Rectangle textureRegion, ConnectsTo connectsTo, Vector2 scale) { private static (Vector2, Rectangle, Vector2, Rectangle, Vector2, Rectangle, Vector2, Rectangle) CalculateAutoTile(Vector2 pos, Rectangle textureRegion, ConnectsTo connectsTo, Vector2 scale) {
@ -116,10 +138,8 @@ namespace MLEM.Graphics {
var xUr = up && right ? connectsTo(1, -1) ? 0 : 4 : right ? 1 : up ? 3 : 2; 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 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 xDr = down && right ? connectsTo(1, 1) ? 0 : 4 : right ? 1 : down ? 3 : 2;
var (w, h) = textureRegion.Size; var (w, h) = textureRegion.Size;
var (w2, h2) = new Point(w / 2, h / 2); var (w2, h2) = new Point(w / 2, h / 2);
return ( return (
new Vector2(pos.X, pos.Y), new Rectangle(textureRegion.X + xUl * w, textureRegion.Y, w2, h2), 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), new Vector2(pos.X + w2 * scale.X, pos.Y), new Rectangle(textureRegion.X + w2 + xUr * w, textureRegion.Y, w2, h2),
@ -127,24 +147,21 @@ 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)); 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 up = connectsTo(0, -1);
var down = connectsTo(0, 1); var down = connectsTo(0, 1);
var left = connectsTo(-1, 0); var left = connectsTo(-1, 0);
var right = connectsTo(1, 0); var right = connectsTo(1, 0);
var xUl = up && left ? connectsTo(-1, -1) ? -1 : 13 : left ? 1 : up ? 9 : 5; var xUl = up && left ? connectsTo(-1, -1) ? -1 : 12 : left ? 0 : up ? 8 : 4;
var xUr = up && right ? connectsTo(1, -1) ? -1 : 14 : right ? 2 : up ? 10 : 6; var xUr = up && right ? connectsTo(1, -1) ? -1 : 13 : right ? 1 : up ? 9 : 5;
var xDl = down && left ? connectsTo(-1, 1) ? -1 : 15 : left ? 3 : down ? 11 : 7; var xDl = down && left ? connectsTo(-1, 1) ? -1 : 14 : left ? 2 : down ? 10 : 6;
var xDr = down && right ? connectsTo(1, 1) ? -1 : 16 : right ? 4 : down ? 12 : 8; var xDr = down && right ? connectsTo(1, 1) ? -1 : 15 : right ? 3 : down ? 11 : 7;
var (w, h) = textureRegion.Size; var (w, h) = textureRegion.Size;
var (w2, h2) = new Point(w / 2, h / 2);
return ( return (
new Vector2(pos.X, pos.Y), xUl < 0 ? Rectangle.Empty : new Rectangle(textureRegion.X + xUl * w, textureRegion.Y, w2, h2), xUl < 0 ? Rectangle.Empty : new Rectangle(textureRegion.X + xUl * w, textureRegion.Y, w, h),
new Vector2(pos.X + w2 * scale.X, pos.Y), xUr < 0 ? Rectangle.Empty : new Rectangle(textureRegion.X + w2 + xUr * w, textureRegion.Y, w2, h2), xUr < 0 ? Rectangle.Empty : new Rectangle(textureRegion.X + xUr * w, textureRegion.Y, w, h),
new Vector2(pos.X, pos.Y + h2 * scale.Y), xDl < 0 ? Rectangle.Empty : new Rectangle(textureRegion.X + xDl * w, textureRegion.Y + h2, w2, h2), xDl < 0 ? Rectangle.Empty : new Rectangle(textureRegion.X + xDl * w, textureRegion.Y, w, h),
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)); xDr < 0 ? Rectangle.Empty : new Rectangle(textureRegion.X + xDr * w, textureRegion.Y, w, h));
} }
/// <summary> /// <summary>

View file

@ -173,38 +173,38 @@ namespace MLEM.Textures {
} }
/// <inheritdoc cref="StaticSpriteBatch.Add(Texture2D, Vector2, Rectangle?, Color, float, Vector2, Vector2, SpriteEffects, float)"/> /// <inheritdoc cref="StaticSpriteBatch.Add(Texture2D, Vector2, Rectangle?, Color, float, Vector2, Vector2, SpriteEffects, float)"/>
public static void Add(this StaticSpriteBatch batch, TextureRegion texture, Vector2 position, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth) { public static StaticSpriteBatch.Item Add(this StaticSpriteBatch batch, TextureRegion texture, Vector2 position, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth) {
batch.Add(texture.Texture, position, texture.Area, color, rotation, origin + texture.PivotPixels, scale, effects, layerDepth); return batch.Add(texture.Texture, position, texture.Area, color, rotation, origin + texture.PivotPixels, scale, effects, layerDepth);
} }
/// <inheritdoc cref="StaticSpriteBatch.Add(Texture2D, Vector2, Rectangle?, Color, float, Vector2, Vector2, SpriteEffects, float)"/> /// <inheritdoc cref="StaticSpriteBatch.Add(Texture2D, Vector2, Rectangle?, Color, float, Vector2, Vector2, SpriteEffects, float)"/>
public static void Add(this StaticSpriteBatch batch, TextureRegion texture, Vector2 position, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) { public static StaticSpriteBatch.Item Add(this StaticSpriteBatch batch, TextureRegion texture, Vector2 position, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effects, float layerDepth) {
batch.Add(texture, position, color, rotation, origin, new Vector2(scale), effects, layerDepth); return batch.Add(texture, position, color, rotation, origin, new Vector2(scale), effects, layerDepth);
} }
/// <inheritdoc cref="StaticSpriteBatch.Add(Texture2D, Vector2, Rectangle?, Color, float, Vector2, Vector2, SpriteEffects, float)"/> /// <inheritdoc cref="StaticSpriteBatch.Add(Texture2D, Vector2, Rectangle?, Color, float, Vector2, Vector2, SpriteEffects, float)"/>
public static void Add(this StaticSpriteBatch batch, TextureRegion texture, Rectangle destinationRectangle, Color color, float rotation, Vector2 origin, SpriteEffects effects, float layerDepth) { public static StaticSpriteBatch.Item Add(this StaticSpriteBatch batch, TextureRegion texture, Rectangle destinationRectangle, Color color, float rotation, Vector2 origin, SpriteEffects effects, float layerDepth) {
batch.Add(texture.Texture, destinationRectangle, texture.Area, color, rotation, origin + texture.PivotPixels, effects, layerDepth); return batch.Add(texture.Texture, destinationRectangle, texture.Area, color, rotation, origin + texture.PivotPixels, effects, layerDepth);
} }
/// <inheritdoc cref="StaticSpriteBatch.Add(Texture2D, Vector2, Rectangle?, Color, float, Vector2, Vector2, SpriteEffects, float)"/> /// <inheritdoc cref="StaticSpriteBatch.Add(Texture2D, Vector2, Rectangle?, Color, float, Vector2, Vector2, SpriteEffects, float)"/>
public static void Add(this StaticSpriteBatch batch, TextureRegion texture, RectangleF destinationRectangle, Color color, float rotation, Vector2 origin, SpriteEffects effects, float layerDepth) { public static StaticSpriteBatch.Item Add(this StaticSpriteBatch batch, TextureRegion texture, RectangleF destinationRectangle, Color color, float rotation, Vector2 origin, SpriteEffects effects, float layerDepth) {
batch.Add(texture.Texture, destinationRectangle, texture.Area, color, rotation, origin + texture.PivotPixels, effects, layerDepth); return batch.Add(texture.Texture, destinationRectangle, texture.Area, color, rotation, origin + texture.PivotPixels, effects, layerDepth);
} }
/// <inheritdoc cref="StaticSpriteBatch.Add(Texture2D, Vector2, Rectangle?, Color, float, Vector2, Vector2, SpriteEffects, float)"/> /// <inheritdoc cref="StaticSpriteBatch.Add(Texture2D, Vector2, Rectangle?, Color, float, Vector2, Vector2, SpriteEffects, float)"/>
public static void Add(this StaticSpriteBatch batch, TextureRegion texture, Vector2 position, Color color) { public static StaticSpriteBatch.Item Add(this StaticSpriteBatch batch, TextureRegion texture, Vector2 position, Color color) {
batch.Add(texture, position, color, 0, Vector2.Zero, Vector2.One, SpriteEffects.None, 0); return batch.Add(texture, position, color, 0, Vector2.Zero, Vector2.One, SpriteEffects.None, 0);
} }
/// <inheritdoc cref="StaticSpriteBatch.Add(Texture2D, Vector2, Rectangle?, Color, float, Vector2, Vector2, SpriteEffects, float)"/> /// <inheritdoc cref="StaticSpriteBatch.Add(Texture2D, Vector2, Rectangle?, Color, float, Vector2, Vector2, SpriteEffects, float)"/>
public static void Add(this StaticSpriteBatch batch, TextureRegion texture, Rectangle destinationRectangle, Color color) { public static StaticSpriteBatch.Item Add(this StaticSpriteBatch batch, TextureRegion texture, Rectangle destinationRectangle, Color color) {
batch.Add(texture, destinationRectangle, color, 0, Vector2.Zero, SpriteEffects.None, 0); return batch.Add(texture, destinationRectangle, color, 0, Vector2.Zero, SpriteEffects.None, 0);
} }
/// <inheritdoc cref="StaticSpriteBatch.Add(Texture2D, Vector2, Rectangle?, Color, float, Vector2, Vector2, SpriteEffects, float)"/> /// <inheritdoc cref="StaticSpriteBatch.Add(Texture2D, Vector2, Rectangle?, Color, float, Vector2, Vector2, SpriteEffects, float)"/>
public static void Add(this StaticSpriteBatch batch, TextureRegion texture, RectangleF destinationRectangle, Color color) { public static StaticSpriteBatch.Item Add(this StaticSpriteBatch batch, TextureRegion texture, RectangleF destinationRectangle, Color color) {
batch.Add(texture, destinationRectangle, color, 0, Vector2.Zero, SpriteEffects.None, 0); return batch.Add(texture, destinationRectangle, color, 0, Vector2.Zero, SpriteEffects.None, 0);
} }
} }