static void Main() { AssetSystem.LoadEvents(); var disk = new FileSystem { CurrentDirectory = @"C:\Depot\bb\ualbion" }; var baseExchange = AssetSystem.SetupSimple(disk, AssetMapping.Global, "Base"); var testExchange = AssetSystem.SetupSimple(disk, AssetMapping.Global, "UATestDev"); var repackedExchange = AssetSystem.SetupSimple(disk, AssetMapping.Global, "Repacked"); InitialiseAssets(); var assets = new Dictionary <AssetId, object> { [AssetId.FromUInt32(PaletteCommon.Id)] = PaletteCommon, [Palette1Id] = Palette1, [Tileset1.Tileset.Id] = Tileset1.Tileset, [(SpriteId)Tileset1.TilesetGfx.Id] = Tileset1.TilesetGfx, }; void Merge(Dictionary <AssetId, object> newAssets) { foreach (var kvp in newAssets) { assets[kvp.Key] = kvp.Value; } } Merge(JumpMap.Build((Map)300, (Map)100, 5, 5)); Merge(NpcMap.Build((Map)301)); Merge(FlagTestMap.Build((Map)100)); (object?asset, AssetInfo?info) LoaderFunc(AssetId id, string lang) => assets.TryGetValue(id, out var asset) ? (asset, new AssetInfo(new Dictionary <string, object> { { AssetProperty.PaletteId, Palette1Id.Id } })) : (null, null); // Create 3D lab graphics // Create 3D lab data // Create item data // Create player graphics //Tileset1.TilesetGfx.ToBitmap().Dump(); testExchange.Resolve <IModApplier>().SaveAssets(LoaderFunc, () => { }, assets.Keys.ToHashSet(), null, null); repackedExchange.Resolve <IModApplier>().SaveAssets(LoaderFunc, () => { }, assets.Keys.ToHashSet(), null, null); Console.WriteLine("Done"); }
static void Main(string[] args) { #if DEBUG PerfTracker.IsTracing = true; #endif PerfTracker.StartupEvent("Entered main"); AssetSystem.LoadEvents(); PerfTracker.StartupEvent("Built event parsers"); var commandLine = new CommandLineOptions(args); if (commandLine.Mode == ExecutionMode.Exit) { return; } PerfTracker.StartupEvent($"Running as {commandLine.Mode}"); var disk = new FileSystem(); var jsonUtil = new FormatJsonUtil(); var baseDir = ConfigUtil.FindBasePath(disk); if (baseDir == null) { throw new InvalidOperationException("No base directory could be found."); } PerfTracker.StartupEvent($"Found base directory {baseDir}"); if (commandLine.Mode == ExecutionMode.ConvertAssets) { using var converter = new AssetConverter( AssetMapping.Global, disk, jsonUtil, commandLine.ConvertFrom, commandLine.ConvertTo); converter.Convert( commandLine.DumpIds, commandLine.DumpAssetTypes, commandLine.ConvertFilePattern); return; } var(exchange, services) = AssetSystem.SetupAsync(baseDir, AssetMapping.Global, disk, jsonUtil).Result; IRenderPass mainPass = null; if (commandLine.NeedsEngine) { mainPass = BuildEngine(commandLine, exchange); } services.Add(new StdioConsoleReader()); var assets = exchange.Resolve <IAssetManager>(); AutodetectLanguage(exchange, assets); switch (commandLine.Mode) // ConvertAssets handled above as it requires a specialised asset system setup { case ExecutionMode.Game: Albion.RunGame(exchange, services, mainPass, baseDir, commandLine); break; case ExecutionMode.BakeIsometric: IsometricTest.Run(exchange, commandLine); break; case ExecutionMode.DumpData: PerfTracker.BeginFrame(); // Don't need to show verbose startup logging while dumping var tf = new TextFormatter(); exchange.Attach(tf); var parsedIds = commandLine.DumpIds?.Select(AssetId.Parse).ToArray(); if ((commandLine.DumpFormats & DumpFormats.Json) != 0) { var dumper = new DumpJson(); exchange.Attach(dumper); dumper.Dump(baseDir, commandLine.DumpAssetTypes, parsedIds); dumper.Remove(); } if ((commandLine.DumpFormats & DumpFormats.Text) != 0) { var dumper = new DumpText(); exchange.Attach(dumper); dumper.Dump(baseDir, commandLine.DumpAssetTypes, parsedIds); dumper.Remove(); } if ((commandLine.DumpFormats & DumpFormats.Png) != 0) { var dumper = new DumpGraphics(commandLine.DumpFormats); exchange.Attach(dumper); dumper.Dump(baseDir, commandLine.DumpAssetTypes, parsedIds); dumper.Remove(); } if ((commandLine.DumpFormats & DumpFormats.Annotated) != 0) { var dumper = new DumpAnnotated(); exchange.Attach(dumper); dumper.Dump(baseDir, commandLine.DumpAssetTypes, parsedIds); dumper.Remove(); } //if ((commandLine.DumpFormats & DumpFormats.Tiled) != 0) // DumpTiled.Dump(baseDir, assets, commandLine.DumpAssetTypes, parsedIds); break; case ExecutionMode.Exit: break; } Console.WriteLine("Exiting"); exchange.Dispose(); }