Code/General/ResourceExtensions.cs
using Sandbox;
namespace ExtendedBox.General;
public static class ResourceExtensions
{
public static bool IsActuallyValid(this Resource? gameResource)
{
if(!gameResource.IsValid())
return false;
if(gameResource.IsEmbedded())
return true;
if(gameResource.ResourcePath is null)
return true;
return FileSystem.Mounted.FileExists(gameResource.ResourcePath);
}
public static bool IsEmbedded(this Resource resource)
{
if(resource.EmbeddedResource.HasValue)
return true;
if(string.IsNullOrWhiteSpace(resource.ResourcePath))
return true;
return false;
}
}