using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;

namespace Sledgemapper
{
    internal class SpriteSheet
    {
        internal Texture2D Texture;
        internal Dictionary<String, Rectangle> index;

        public void LoadContent(ContentManager content, string spriteIndex, string texture)
        {
            index = content.Load<Dictionary<String, Rectangle>>(spriteIndex);
            Texture = content.Load<Texture2D>(texture);
        }

        internal Rectangle? SourceRectangle(string spriteName)
        {
            Rectangle r;
            bool hasValue = index.TryGetValue(spriteName, out r);

            if (hasValue)
            {
                return r;
            }
            else
            {
                throw new Exception("value doesn't exist");
            }
        }
    }


}
