using CustomNPCFramework.Framework.Enums;
using Microsoft.Xna.Framework.Graphics;
using StardewModdingAPI;
using StardustCore.UIUtilities;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CustomNPCFramework.Framework.Graphics
{
///
/// A class that's used to hold textures for different directions.
///
public class DirectionalTexture
{
///
/// The left texture for this group.
///
public Texture2DExtended leftTexture;
///
/// The right texture for this group.
///
public Texture2DExtended rightTexture;
///
/// The down textiure for this group.
///
public Texture2DExtended downTexture;
///
/// The up texture for this group.
///
public Texture2DExtended upTexture;
///
/// The current texture for this group.
///
public Texture2DExtended currentTexture;
///
/// Constructor.
///
/// The left texture to use.
/// The right texture to use.
/// The up texture to use.
/// The down texture to use.
/// The direction texture for the sprite to face.
public DirectionalTexture(Texture2DExtended left, Texture2DExtended right, Texture2DExtended up, Texture2DExtended down, Direction direction=Direction.down)
{
this.leftTexture = left;
this.rightTexture = right;
this.upTexture = up;
this.downTexture = down;
if (direction == Direction.left) this.currentTexture = leftTexture;
if (direction == Direction.right) this.currentTexture = rightTexture;
if (direction == Direction.up) this.currentTexture = upTexture;
if (direction == Direction.down) this.currentTexture = downTexture;
}
public DirectionalTexture(IModHelper helper ,NamePairings info, string path, Direction direction = Direction.down)
{
new Texture2DExtended(helper, Class1.Manifest, path);
string leftString= Class1.getShortenedDirectory(Path.Combine(path, info.leftString + ".png")).Remove(0, 1);
string rightString = Class1.getShortenedDirectory(Path.Combine(path, info.rightString + ".png")).Remove(0, 1);
string upString = Class1.getShortenedDirectory(Path.Combine(path, info.upString + ".png")).Remove(0, 1);
string downString = Class1.getShortenedDirectory(Path.Combine(path, info.downString + ".png")).Remove(0, 1);
this.leftTexture = new Texture2DExtended(helper, Class1.Manifest, leftString);
this.rightTexture = new Texture2DExtended(helper, Class1.Manifest, rightString);
this.upTexture = new Texture2DExtended(helper, Class1.Manifest, upString);
this.downTexture = new Texture2DExtended(helper, Class1.Manifest, downString);
if (direction == Direction.left) this.currentTexture = leftTexture;
if (direction == Direction.right) this.currentTexture = rightTexture;
if (direction == Direction.up) this.currentTexture = upTexture;
if (direction == Direction.down) this.currentTexture = downTexture;
}
///
/// Sets the direction of this current texture to left.
///
public void setLeft()
{
this.currentTexture = leftTexture;
}
///
/// Sets the direction of this current texture to up.
///
public void setUp()
{
this.currentTexture = upTexture;
}
///
/// Sets the direction of this current texture to down.
///
public void setDown()
{
this.currentTexture = downTexture;
}
///
/// Sets the direction of this current texture to right.
///
public void setRight()
{
this.currentTexture = rightTexture;
}
///
/// Gets the texture from this texture group depending on the direction.
///
///
///
public virtual Texture2DExtended getTextureFromDirection(Direction direction)
{
if (direction == Direction.left) return this.leftTexture;
if (direction == Direction.right) return this.rightTexture;
if (direction == Direction.up) return this.upTexture;
if (direction == Direction.down) return this.downTexture;
return null;
}
}
}