2019-12-18 14:25:43 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
2019-12-04 01:26:26 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2019-12-18 14:25:43 +00:00
|
|
|
|
using Wabbajack.Common;
|
2019-11-04 12:47:41 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack.Lib.CompilationSteps
|
|
|
|
|
{
|
|
|
|
|
public class IncludeVortexDeployment : ACompilationStep
|
|
|
|
|
{
|
|
|
|
|
public IncludeVortexDeployment(ACompiler compiler) : base(compiler)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-04 01:26:26 +00:00
|
|
|
|
public override async ValueTask<Directive> Run(RawSourceFile source)
|
2019-11-04 12:47:41 +00:00
|
|
|
|
{
|
2019-12-18 14:25:43 +00:00
|
|
|
|
var l = new List<string> {"vortex.deployment.msgpack", "vortex.deployment.json"};
|
|
|
|
|
if (!l.Any(a => source.Path.Contains(a))) return null;
|
2019-11-04 12:47:41 +00:00
|
|
|
|
var inline = source.EvolveTo<InlineFile>();
|
|
|
|
|
inline.SourceDataID = _compiler.IncludeFile(File.ReadAllBytes(source.AbsolutePath));
|
2019-12-18 14:25:43 +00:00
|
|
|
|
if (!source.Path.Contains("vortex.deployment.json"))
|
|
|
|
|
return inline;
|
|
|
|
|
|
|
|
|
|
var path = source.Path;
|
|
|
|
|
if (!path.StartsWith(Consts.GameFolderFilesDir))
|
|
|
|
|
return inline;
|
|
|
|
|
|
|
|
|
|
path = path.Substring(Consts.GameFolderFilesDir.Length + 1);
|
|
|
|
|
path = $"{Consts.ManualGameFilesDir}\\{path}";
|
|
|
|
|
inline.To = path;
|
|
|
|
|
|
2019-11-04 12:47:41 +00:00
|
|
|
|
return inline;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override IState GetState()
|
|
|
|
|
{
|
|
|
|
|
return new State();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class State : IState
|
|
|
|
|
{
|
|
|
|
|
public ICompilationStep CreateStep(ACompiler compiler)
|
|
|
|
|
{
|
|
|
|
|
return new IncludeVortexDeployment(compiler);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|