wabbajack/Wabbajack.Lib/CompilationSteps/IncludeDummyESPs.cs

45 lines
1.3 KiB
C#
Raw Normal View History

using System.Threading.Tasks;
using Alphaleonis.Win32.Filesystem;
using Newtonsoft.Json;
2020-03-25 12:47:25 +00:00
using Wabbajack.Common;
namespace Wabbajack.Lib.CompilationSteps
{
public class IncludeDummyESPs : ACompilationStep
{
public IncludeDummyESPs(ACompiler compiler) : base(compiler)
{
}
public override async ValueTask<Directive> Run(RawSourceFile source)
{
2020-03-25 12:47:25 +00:00
if (source.AbsolutePath.Extension != Consts.ESP &&
source.AbsolutePath.Extension != Consts.ESM) return null;
2020-03-25 12:47:25 +00:00
var bsa = source.AbsolutePath.ReplaceExtension(Consts.BSA);
2020-04-01 19:11:34 +00:00
var bsaTextures = source.AbsolutePath.AppendToName(" - Textures");
2020-03-25 12:47:25 +00:00
if (source.AbsolutePath.Size > 250 || !bsa.IsFile && !bsaTextures.IsFile) return null;
var inline = source.EvolveTo<InlineFile>();
2020-03-25 12:47:25 +00:00
inline.SourceDataID = await _compiler.IncludeFile(await source.AbsolutePath.ReadAllBytesAsync());
return inline;
}
public override IState GetState()
{
return new State();
}
[JsonObject("IncludeDummyESPs")]
public class State : IState
{
public ICompilationStep CreateStep(ACompiler compiler)
{
return new IncludeDummyESPs(compiler);
}
}
}
}