using Raylib_cs;

namespace Tiles;

public class Tile
{
    public string Name { get; private set; } = string.Empty;
    public Image Image { get; private set; }
    public Texture2D Texture { get; private set; }

    public Tile(string name, string pathToImage)
    {
        Name = name;
        Image = LoadImage(pathToImage);
        Texture = LoadTexture(Image);
    }

    private Image LoadImage(string path)
    {
        try
        {
            Image img = Raylib.LoadImage(path);
            return img;
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
            throw;
        }
    }

    private Texture2D LoadTexture(Image img)
    {
        return Raylib.LoadTextureFromImage(img);
    }
}