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

51 lines
1.6 KiB
C#

using System;
using System.ComponentModel;
using System.IO;
using Packager.Parameters;
namespace Packager.Tasks
{
[DisplayName(@"Generate DLC descriptor")]
[Description("Bundles the DLC descriptor file. The package is identified by its type (audio, banner, ...) and the scene that is cooked.")]
public class GenDlcDescriptorTask : Task
{
[Input("Map List", IOCardinality.Multi, IOType.File)]
public ReferenceList MapList { get; set; }
[Input("Package Type", IOCardinality.Single, IOType.String, Flags = InputFlags.Optional)]
public SingleReference PackageType { get; set; }
[Output("DLC desc file", IOType.File)]
public ReferenceList DlcDescFile = new ReferenceList();
public GenDlcDescriptorTask()
{
MapList = new ReferenceList();
PackageType = new SingleReference();
}
public override bool NeedCooker { get { return true; } }
protected override void StartInternal(BuildConfiguration profile, cookerWrapper cooker)
{
var packType = PackageType.Value;
if (MapList.Count != 1)
{
throw new Exception("Shall have only one scene");
}
foreach (var map in MapList)
{
var packName = Path.GetFileNameWithoutExtension(map);
var destFile = TaskOutputFolder + "\\dlcdescriptor.ckd";
var returnValue = cooker.generateDlcDescriptor(destFile, packName, packType);
DlcDescFile.Add(destFile);
ErrorCode = returnValue ? 0 : -1;
}
}
}
}