using Robust.Packaging.AssetProcessing; using Robust.Packaging.AssetProcessing.Passes; namespace Robust.Packaging; /// /// Standard asset graph for packaging server files. Extend by wiring things up to , , and . /// /// /// /// This graph has two inputs: one for "core" server files such as the main engine executable, and another for resource files. /// /// /// If you want to add extra passes to run before preset passes, depend them on the relevant input pass, with a before of the relevant preset pass. /// /// /// See the following graph (Mermaid syntax) to understand this asset graph: /// /// /// flowchart LR /// InputCore --> PresetPassesCore /// PresetPassesCore --1--> NormalizeTextCore /// NormalizeTextCore --> Output /// PresetPassesCore --2--> Output /// InputResources --> PresetPassesResources /// PresetPassesResources --1--> AudioMetadata /// PresetPassesResources --2--> DropAudioFiles /// PresetPassesResources --3--> NormalizeTextResources /// PresetPassesResources --4--> PrefixResources /// AudioMetadata --> PrefixResources /// NormalizeTextResources --> PrefixResources /// PrefixResources --> Output /// /// public sealed class RobustServerAssetGraph { public AssetPassPipe Output { get; } /// /// Input pass for core server files, such as Robust.Server.exe. /// /// public AssetPassPipe InputCore { get; } public AssetPassPipe PresetPassesCore { get; } /// /// Normalizes text files in core files. /// public AssetPassNormalizeText NormalizeTextCore { get; } /// /// Input pass for server resource files. Everything that will go into Resources/. /// /// /// Do not prefix file paths with Resources/, the asset pass will automatically remap them. /// /// public AssetPassPipe InputResources { get; } public AssetPassPipe PresetPassesResources { get; } public AssetPassAudioMetadata AudioMetadata { get; } /// /// Used to drop all files in the Audio/ directory. /// /// /// /// Most audio files are actually removed by . /// This pass cleans up stuff like attribution files and soundfonts in Audio/MidiCustom. /// /// public AssetPassFilterDrop DropAudioFiles { get; } /// /// Normalizes text files in resources. /// public AssetPassNormalizeText NormalizeTextResources { get; } /// /// Responsible for putting resources into the "Resources/" folder. /// public AssetPassPrefix PrefixResources { get; } /// /// Collection of all passes in this preset graph. /// public IReadOnlyCollection AllPasses { get; } /// Should inputs be run in parallel. Should only be turned off for debugging. public RobustServerAssetGraph(bool parallel = true) { Output = new AssetPassPipe { Name = "RobustServerAssetGraphOutput", CheckDuplicates = true }; // // Core files // // The code injecting the list of source files is assumed to be pretty single-threaded. // We use a parallelizing input to break out all the work on files coming in onto multiple threads. InputCore = new AssetPassPipe { Name = "RobustServerAssetGraphInputCore", Parallelize = parallel }; PresetPassesCore = new AssetPassPipe { Name = "RobustServerAssetGraphPresetPassesCore" }; NormalizeTextCore = new AssetPassNormalizeText { Name = "RobustServerAssetGraphNormalizeTextCore" }; PresetPassesCore.AddDependency(InputCore); NormalizeTextCore.AddDependency(PresetPassesCore).AddBefore(Output); Output.AddDependency(PresetPassesCore); Output.AddDependency(NormalizeTextCore); // // Resource files // // Ditto about parallelizing InputResources = new AssetPassPipe { Name = "RobustServerAssetGraphInputResources", Parallelize = parallel }; PresetPassesResources = new AssetPassPipe { Name = "RobustServerAssetGraphPresetPassesResources" }; NormalizeTextResources = new AssetPassNormalizeText { Name = "RobustServerAssetGraphNormalizeTextResources" }; AudioMetadata = new AssetPassAudioMetadata { Name = "RobustServerAssetGraphAudioMetadata" }; DropAudioFiles = new AssetPassFilterDrop(p => p.Path.StartsWith("Audio/")) { Name = "RobustServerAssetGraphDropAudioFiles" }; PrefixResources = new AssetPassPrefix("Resources/") { Name = "RobustServerAssetGraphPrefixResources" }; PresetPassesResources.AddDependency(InputResources); AudioMetadata.AddDependency(PresetPassesResources).AddBefore(DropAudioFiles); DropAudioFiles.AddDependency(PresetPassesResources).AddBefore(NormalizeTextResources); NormalizeTextResources.AddDependency(PresetPassesResources).AddBefore(PrefixResources); PrefixResources.AddDependency(PresetPassesResources); PrefixResources.AddDependency(AudioMetadata); PrefixResources.AddDependency(NormalizeTextResources); Output.AddDependency(PrefixResources); AllPasses = new AssetPass[] { Output, InputCore, PresetPassesCore, NormalizeTextCore, InputResources, PresetPassesResources, NormalizeTextResources, AudioMetadata, PrefixResources, DropAudioFiles }; } }