more refactoring
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Michele Scandura 2021-09-09 10:58:05 +01:00
parent 34863a9984
commit 09c32c605e
2 changed files with 39 additions and 123 deletions

View file

@ -0,0 +1,37 @@
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");
}
}
}
}