| 
						 
							
							
							
						 
					 | 
				
			
			 | 
			 | 
			
				@ -1,38 +1,46 @@
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				using CliFx;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				using CliFx.Attributes;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				using IConsole = CliFx.Infrastructure.IConsole;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				using System.CommandLine;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				namespace KeepersCompound.Lightmapper;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				internal static class Program
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				class Program
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				{
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    public static async Task<int> Main() =>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        await new CliApplicationBuilder().AddCommandsFromThisAssembly().Build().RunAsync();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				[Command(Description = "Compute lightmaps for a NewDark .MIS/.COW")]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				public class LightCommand : ICommand
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    private static void Main(string[] args)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    [CommandParameter(0, Description = "The path to the root Thief installation.")]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    public required string InstallPath { get; init; }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    [CommandParameter(1, Description = "The folder name of the fan mission. For OMs this is blank.")]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    public required string CampaignName { get; init; }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    [CommandParameter(2, Description = "The name of the mission file including extension.")]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    public required string MissionName { get; init; }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    [CommandOption("output", 'o', Description = "Name of output file excluding extension.")]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    public string OutputName { get; init; } = "kc_lit";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    [CommandOption("multiSampling", 'm', Description = "Enables multi-sampled shadows. Higher quality but slower.")]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    public bool MultiSampling { get; init; } = false;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        var installPathArg = new Argument<string>(
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            "installPath",
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            "The path to the root Thief installation.");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        var campaignNameArg = new Argument<string>(
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            "campaignName",
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            "The folder name of the fan mission. For OMs this is blank.");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        var missionNameArg = new Argument<string>(
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            "missionName",
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            "The name of the mission file including extension.");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        var outputFileOption = new Option<string>(
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            ["-o", "--output"],
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            () => "kc_lit",
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            "Name of output file excluding extension.");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        var multiSamplingOption = new Option<bool>(
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            "--multiSampling",
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            () => false,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            "Enables multi-sampled shadows. Higher quality but slower.");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    public ValueTask ExecuteAsync(IConsole console)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        var rootCommand = new RootCommand("Compute lightmaps for a NewDark .MIS/.COW");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        rootCommand.AddArgument(installPathArg);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        rootCommand.AddArgument(campaignNameArg);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        rootCommand.AddArgument(missionNameArg);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        rootCommand.AddOption(outputFileOption);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        rootCommand.AddOption(multiSamplingOption);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        rootCommand.SetHandler((installPath, campaignName, missionName, outputFile, multiSampling) =>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            Timing.Reset();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        var lightMapper = new LightMapper(InstallPath, CampaignName, MissionName);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        lightMapper.Light(MultiSampling);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        lightMapper.Save(OutputName);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            var lightMapper = new LightMapper(installPath, campaignName, missionName);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            lightMapper.Light(multiSampling);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            lightMapper.Save(outputFile);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            Timing.LogAll();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        return default;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }, installPathArg, campaignNameArg, missionNameArg, outputFileOption, multiSamplingOption);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        rootCommand.Invoke(args);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 |