-
Notifications
You must be signed in to change notification settings - Fork 418
Expand file tree
/
Copy pathParallaxOutput.cs
More file actions
41 lines (33 loc) · 1.12 KB
/
ParallaxOutput.cs
File metadata and controls
41 lines (33 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System.Collections.Generic;
using System.IO;
using Robust.Shared.ContentPack;
using Robust.Shared.Utility;
namespace Content.MapRenderer;
/// <summary>
/// Helper class for collecting the files used for parallax output
/// </summary>
public sealed class ParallaxOutput
{
public const string OutputDirectory = "_parallax";
public readonly HashSet<ResPath> FilesToCopy = [];
private readonly string _outputPath;
/// <summary>
/// Helper class for collecting the files used for parallax output
/// </summary>
public ParallaxOutput(string outputPath)
{
_outputPath = outputPath;
Directory.CreateDirectory(Path.Combine(_outputPath, OutputDirectory));
}
public string ReferenceResourceFile(IResourceManager resourceManager, ResPath path)
{
var fileName = Path.Combine(OutputDirectory, path.Filename);
if (FilesToCopy.Add(path))
{
using var file = resourceManager.ContentFileRead(path);
using var target = File.Create(Path.Combine(_outputPath, fileName));
file.CopyTo(target);
}
return fileName;
}
}