wabbajack/Wabbajack.Compiler/CompilationSteps/IgnoreOtherProfiles.cs

35 lines
1.2 KiB
C#
Raw Normal View History

2021-09-27 12:42:46 +00:00
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
2021-09-27 12:42:46 +00:00
using Wabbajack.DTOs;
using Wabbajack.DTOs.Directives;
using Wabbajack.Paths;
2021-09-27 12:42:46 +00:00
namespace Wabbajack.Compiler.CompilationSteps
{
public class IgnoreOtherProfiles : ACompilationStep
{
2020-03-28 18:22:53 +00:00
private readonly IEnumerable<AbsolutePath> _profiles;
private readonly MO2Compiler _mo2Compiler;
2020-03-28 18:22:53 +00:00
private AbsolutePath _modProfilesFolder;
public IgnoreOtherProfiles(ACompiler compiler) : base(compiler)
{
_mo2Compiler = (MO2Compiler) compiler;
2021-09-27 12:42:46 +00:00
_modProfilesFolder = _mo2Compiler._settings.Source.Combine("profiles");
2021-09-27 12:42:46 +00:00
_profiles = _mo2Compiler._settings.SelectedProfiles
2020-03-28 18:22:53 +00:00
.Select(p => _modProfilesFolder.Combine(p))
.ToList();
}
public override async ValueTask<Directive?> Run(RawSourceFile source)
{
2020-03-28 18:22:53 +00:00
if (!source.AbsolutePath.InFolder(_modProfilesFolder)) return null;
if (_profiles.Any(profile => source.AbsolutePath.InFolder(profile))) return null;
var c = source.EvolveTo<IgnoredDirectly>();
c.Reason = "File not for selected profiles";
return c;
}
}
2021-09-27 12:42:46 +00:00
}