Snowflake/RPG.GameCore/Resources/LocalResourceProvider.cs

28 lines
887 B
C#

using System.Text.Json;
namespace RPG.GameCore.Resources;
internal class LocalResourceProvider : IResourceProvider
{
private const string DataPath = "data/";
private const string LevelFloorSubdirectory = "Config/LevelOutput/Floor/";
private const string ExcelSubdirectory = "Config/ExcelBinOutput/";
public IEnumerable<string> EnumerateAllLevelFloorAssets()
{
return Directory.EnumerateFiles(DataPath + LevelFloorSubdirectory);
}
public JsonDocument GetExcelTableJson(string file)
{
return GetJsonAsset(string.Concat(DataPath, ExcelSubdirectory, file));
}
public JsonDocument GetJsonAsset(string file)
{
if (!file.StartsWith(DataPath)) file = string.Concat(DataPath, file);
using FileStream fileStream = new(file, FileMode.Open, FileAccess.Read);
return JsonDocument.Parse(fileStream);
}
}