mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Add AssetPassFilterDrop
Planning to use this to drop .svg files from SS14's resources folder. Tiny opt.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user