21 protected SourceFileModel? Model;
22 public abstract string TemplateSubfolder {
get; }
24 public virtual void Generate(AbsolutePath templatesPath, AbsolutePath currentFolder,
string name)
26 CheckInsideSourceFolder(currentFolder);
28 Model = GetModelFromArguments(currentFolder, name) with {
29 CppIncludePath = Path.GetRelativePath(Model!.Module.Folder, currentFolder)
31 .Replace(
"public",
"",
true,
null)
32 .Replace(
"private",
"",
true,
null)
36 if(!(templatesPath / TemplateSubfolder).DirectoryExists())
37 templatesPath = DefaultTemplateFolder;
39 var sourceTemplateDir = templatesPath / TemplateSubfolder;
40 var cppDstDir = currentFolder.ToString().Replace(
"public",
"private",
true,
null);
42 if(Model.Plugin !=
null)
43 Log.Debug($
"Plugin: {Model.Plugin.Folder}");
45 Log.Debug($
"Module: {Model.Module.Folder}");
47 Directory.EnumerateFiles(sourceTemplateDir,
"*.sbncpp").ForEach(f =>
50 (RelativePath) Path.GetFileName(f),
51 (AbsolutePath) cppDstDir,
56 var hDstDir = currentFolder.ToString().Replace(
"private",
"public",
true,
null);
57 Directory.EnumerateFiles(sourceTemplateDir,
"*.sbnh").ForEach(f =>
60 (RelativePath) Path.GetFileName(f),
61 (AbsolutePath) hDstDir,
67 public virtual SourceFileModel GetModelFromArguments(AbsolutePath currentFolder,
string name)
77 $
"{currentFolder} is not inside a Module. Unreal Engine requires all source files to be contained inside a Module in a Source folder."
83 protected void CheckInsideSourceFolder(AbsolutePath currentFolder)
85 if(!currentFolder.ToString().Contains(
"Source", StringComparison.InvariantCultureIgnoreCase))
87 throw new InvalidOperationException(
88 $
"{currentFolder} doesn't contain a Source folder. Unreal Engine requires all source files to be contained inside a Module in a Source folder."