2020-01-07 00:24:33 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Alphaleonis.Win32.Filesystem;
|
|
|
|
|
using Wabbajack.Common;
|
|
|
|
|
|
|
|
|
|
namespace Wabbajack.Lib.CompilationSteps
|
|
|
|
|
{
|
|
|
|
|
public class IgnoreGameFilesIfGameFolderFilesExist : ACompilationStep
|
|
|
|
|
{
|
|
|
|
|
private readonly bool _gameFolderFilesExists;
|
2020-03-25 12:47:25 +00:00
|
|
|
|
private readonly AbsolutePath _gameFolder;
|
2020-01-07 00:24:33 +00:00
|
|
|
|
|
|
|
|
|
public IgnoreGameFilesIfGameFolderFilesExist(ACompiler compiler) : base(compiler)
|
|
|
|
|
{
|
2020-03-25 12:47:25 +00:00
|
|
|
|
_gameFolderFilesExists = ((MO2Compiler)compiler).MO2Folder.Combine(Consts.GameFolderFilesDir).IsDirectory;
|
2020-01-07 00:24:33 +00:00
|
|
|
|
_gameFolder = compiler.GamePath;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-09 18:14:05 +00:00
|
|
|
|
public override async ValueTask<Directive?> Run(RawSourceFile source)
|
2020-01-07 00:24:33 +00:00
|
|
|
|
{
|
|
|
|
|
if (_gameFolderFilesExists)
|
|
|
|
|
{
|
2020-03-25 12:47:25 +00:00
|
|
|
|
if (source.AbsolutePath.InFolder(_gameFolder))
|
2020-01-07 00:24:33 +00:00
|
|
|
|
{
|
|
|
|
|
var result = source.EvolveTo<IgnoredDirectly>();
|
|
|
|
|
result.Reason = $"Ignoring game files because {Consts.GameFolderFilesDir} exists";
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override IState GetState()
|
|
|
|
|
{
|
|
|
|
|
return new State();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class State : IState
|
|
|
|
|
{
|
|
|
|
|
public ICompilationStep CreateStep(ACompiler compiler)
|
|
|
|
|
{
|
|
|
|
|
return new IgnoreGameFilesIfGameFolderFilesExist(compiler);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|