using System.Collections.Generic; using CustomNPCFramework.Framework.Enums; using CustomNPCFramework.Framework.Graphics.TextureGroups; using Microsoft.Xna.Framework; using StardustCore.UIUtilities; 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 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 source rectangle for the current texture to draw. public Rectangle currentAsset; public int index; /// Construct an instance. /// The asset info file to be read in or created. Holds path information. /// The relative path to the assetinfo file. /// The direction to set the animation. public AssetSheet(AssetInfo info, string relativeDirPath, Direction direction = Direction.down) { this.assetInfo = info; this.textures = new TextureGroup(info, relativeDirPath, direction); this.path = relativeDirPath; 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. /// The facing direction. /// The animation type. public virtual Texture2DExtended getTexture(Direction direction, AnimationType type) { return this.textures.getTextureFromAnimation(type).getTextureFromDirection(direction); } } }