using CustomNPCFramework.Framework.Enums;
using CustomNPCFramework.Framework.Graphics.TextureGroups;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
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
{
///
/// Used to handle loading different textures and handling opperations on those textures.
///
public class AssetSheet
{
///
/// Used to hold the textures for the AssetSheet.
///
public TextureGroups.TextureGroup textures;
///
/// Used to hold the info for the paths to these textures.
///
public AssetInfo assetInfo;
///
/// The path to this assetinfo.json file
///
public string path;
///
/// The soruce rectangle for the current texture to draw.
///
public Rectangle currentAsset;
public int index;
///
/// Constructor.
///
/// The asset info file to be read in or created. Holds path information.
/// The path to the assetinfo file.
/// The direction to set the animation.
public AssetSheet(AssetInfo info,string path,Direction direction=Direction.down)
{
this.assetInfo = info;
this.textures = new TextureGroup(info,path,direction);
try
{
this.path = Class1.getShortenedDirectory(path);
}
catch(Exception err)
{
this.path = path;
}
this.index = 0;
}
///
/// Get the path to the current texture.
///
///
public virtual KeyValuePair getPathTexturePair()
{
return new KeyValuePair(this.path, this.textures.currentTexture.currentTexture);
}
///
/// Used just to get a copy of this asset sheet.
///
public virtual AssetSheet clone()
{
var asset = new AssetSheet(this.assetInfo,(string)this.path.Clone());
return asset;
}
///
/// Sets the textures for this sheet to face left.
///
public virtual void setLeft()
{
this.textures.setLeft();
}
///
/// Sets the textures for this sheet to face up.
///
public virtual void setUp()
{
this.textures.setUp();
}
///
/// Sets the textures for this sheet to face down.
///
public virtual void setDown()
{
this.textures.setDown();
}
///
/// Sets the textures for this sheet to face left.
///
public virtual void setRight()
{
this.textures.setRight();
}
///
/// Get the current animation texture.
///
///
public virtual Texture2DExtended getCurrentSpriteTexture()
{
return this.textures.currentTexture.currentTexture;
}
///
/// Get the specific texture depending on the direction and animation type.
///
///
///
///
public virtual Texture2DExtended getTexture(Direction direction,AnimationType type)
{
return this.textures.getTextureFromAnimation(type).getTextureFromDirection(direction);
}
}
}