JD2022-TU1/main/tools/apps/Packager/Tasks/PrepareUpdateCooking.cs

39 lines
No EOL
1.5 KiB
C#

using System.IO;
using JD.Core.ProjectManaging;
namespace Packager.Tasks
{
public class PrepareUpdateCooking : Task
{
[Input("Asset Files List", IOCardinality.Multi, IOType.File)]
public ReferenceList AssetsList { get; set; }
public PrepareUpdateCooking()
{
AssetsList = new ReferenceList();
}
protected override void StartInternal(Parameters.BuildConfiguration profile, cookerWrapper cooker)
{
foreach (var file in AssetsList)
{
var fileName = Path.GetFileNameWithoutExtension(file); //World+JD2015+_UI+screens+wall+main
var actualFilePath = fileName.Replace('+', '/'); // //World/JD2015/_UI/screens/wall/main
var dirInfo = new DirectoryInfo(actualFilePath);
var actualFileName = dirInfo.Name;
var contents = File.ReadAllLines(file);
//Modifying the first line which needs to be replaced with original asset location.
//as cooker requires the original assets which are referenced in gameconfig and cache
var tempFilePath = contents[0];
contents[0] = contents[0].Replace(fileName.ToLower(), actualFileName);
File.WriteAllLines(file, contents);
var fullPath = DataPath.GetAbsolutePath(tempFilePath.Replace('/', '\\'));
File.Delete(fullPath);
}
}
}
}