RustToDust/client/ClientAssets.cs

42 lines
1,006 B
C#
Raw Permalink Normal View History

using System;
using System.IO;
using Godot;
using RustToDust.Core;
namespace RustToDust.Client;
internal static class ClientAssets
{
private static bool _registered;
internal static void EnsureAssetsRootRegistered()
{
if (_registered)
{
return;
}
_registered = true;
if (OS.HasFeature("template"))
{
string exeAssets = Path.Combine(OS.GetExecutablePath().GetBaseDir(), "assets");
if (Directory.Exists(exeAssets))
{
AssetPathResolver.RegisterAssetsRoot(exeAssets);
return;
}
}
string baseAssets = Path.Combine(AppContext.BaseDirectory, "assets");
if (Directory.Exists(baseAssets))
{
AssetPathResolver.RegisterAssetsRoot(baseAssets);
}
}
internal static string LocateAssetsDirectory()
{
EnsureAssetsRootRegistered();
return AssetPathResolver.LocateAssetsRoot();
}
}