forked from Misaki/GhostEngine
35 lines
1.0 KiB
C#
35 lines
1.0 KiB
C#
using Ghost.Data.Services;
|
|
|
|
namespace Ghost.Editor.Core.AssetHandle;
|
|
|
|
public static partial class AssetDatabase
|
|
{
|
|
private static FileSystemWatcher? _watcher;
|
|
|
|
private static readonly Dictionary<Guid, string> _assetPathLookup = new();
|
|
|
|
public static DirectoryInfo? AssetsDirectory
|
|
{
|
|
get;
|
|
private set;
|
|
}
|
|
|
|
internal static void Initialize()
|
|
{
|
|
if (ProjectService.CurrentProject.Metadata == null)
|
|
{
|
|
throw new InvalidOperationException("Project metadata is not initialized. Ensure that the project is loaded before accessing the AssetDatabase.");
|
|
}
|
|
|
|
AssetsDirectory = new DirectoryInfo(Path.Combine(Path.GetDirectoryName(ProjectService.CurrentProject.Path)!, ProjectService.ASSETS_FOLDER));
|
|
_watcher = new FileSystemWatcher
|
|
{
|
|
Path = AssetsDirectory.FullName,
|
|
IncludeSubdirectories = true,
|
|
EnableRaisingEvents = true
|
|
};
|
|
|
|
InitializeAssetHandle();
|
|
InitializeMetaData();
|
|
}
|
|
} |