Many refactors and minor changes. idk.

This commit is contained in:
2019-04-08 23:58:27 -05:00
parent 4d4d46ad1b
commit 3e5b838abe
13 changed files with 465 additions and 60 deletions

View File

@@ -39,13 +39,8 @@ namespace RecrownedAthenaeum.SpecialTypes
this.bottom = bottom;
this.top = top;
sourcePatches = GenerateSourcesPatches();
}
private Rectangle[] GenerateSourcesPatches()
{
Rectangle[] patches =
{
{
new Rectangle(0, 0, left, bottom),
new Rectangle(left, 0, textureRegion.Width - left - right, bottom),
new Rectangle(textureRegion.Width - right, 0, right, bottom),
@@ -62,7 +57,9 @@ namespace RecrownedAthenaeum.SpecialTypes
patches[i].X += textureRegion.X;
patches[i].Y += textureRegion.Y;
}
return patches;
sourcePatches = patches;
}
private Rectangle[] GenenerateDestinationRectangles(int width, int height)
@@ -122,7 +119,11 @@ namespace RecrownedAthenaeum.SpecialTypes
public void Draw(ConsistentSpriteBatch spriteBatch, Rectangle destination, Color color, float rotation = 0, Vector2 origin = default(Vector2))
{
if (rotation != 0) throw new NotImplementedException("Ninepatches can't be rotated.");
if (origin != default(Vector2)) throw new NotImplementedException("Ninepatches can't have origin changed (hint: use the destination rectangle to shift and position).");
if (origin != default(Vector2))
{
destination.X -= (int)origin.X;
destination.Y -= (int)origin.Y;
}
Draw(spriteBatch, color, destination);
}
}