Add AssetPassFilterDrop

Planning to use this to drop .svg files from SS14's resources folder. Tiny opt.
This commit is contained in:
PJB3005
2024-12-09 00:27:13 +01:00
parent 89fcd1dd2b
commit 0559339143
2 changed files with 19 additions and 0 deletions

View File

@@ -40,6 +40,7 @@ END TEMPLATE-->
### New features
* Added stack-like functions to `ValueList<T>` and added an `AddRange(ReadOnlySpan<T>)` overload.
* Added new `AssetPassFilterDrop`.
### Bugfixes

View File

@@ -0,0 +1,18 @@
namespace Robust.Packaging.AssetProcessing.Passes;
/// <summary>
/// Asset pass that drops all files that match a predicate. Files that do not match are ignored.
/// </summary>
public sealed class AssetPassFilterDrop(Func<AssetFile, bool> predicate) : AssetPass
{
public Func<AssetFile, bool> Predicate { get; } = predicate;
protected override AssetFileAcceptResult AcceptFile(AssetFile file)
{
// Just do nothing with the file so it gets discarded.
if (Predicate(file))
return AssetFileAcceptResult.Consumed;
return base.AcceptFile(file);
}
}