public int GenerateSprites(string path, PixelVisionEngine targetGame) { var count = 0; var filePath = WorkspacePath.Parse(path); var srcPath = filePath.AppendDirectory("SpriteBuilder"); var fileData = new Dictionary <string, byte[]>(); if (Exists(srcPath)) { // Get all the files in the folder var files = from file in GetEntities(srcPath) where file.GetExtension() == ".png" select file; foreach (var file in files) { var name = file.EntityName.Substring(0, file.EntityName.Length - file.GetExtension().Length); var bytes = OpenFile(file, FileAccess.Read).ReadAllBytes(); if (fileData.ContainsKey(name)) { fileData[name] = bytes; } else { fileData.Add(name, bytes); } count++; // Console.WriteLine("Parse File " + name); } try { // TODO exporting sprites doesn't work if (locator.GetService(typeof(ExportService).FullName) is ExportService exportService) { exportService.ExportSpriteBuilder(path + "sb-sprites.lua", targetGame, fileData); // exportService.StartExport(); } } catch (Exception e) { // TODO this needs to go through the error system? Console.WriteLine(e); throw; } } return(count); }
/// <summary> /// Activate is the beginning of the chip's life cycle. /// This allows the chip to gain a reference to the engine /// itself. This allows chips to talk back to the engine /// as well as to each other through the engine's exposed APIs. /// </summary> /// <param name="parent">A reference to the engine.</param> public virtual void Activate(PixelVisionEngine parent) { engine = parent; active = true; Configure(); }
/// <summary> /// The ChipManager constructor requires a reference to the engine for /// correctly activating its chips. /// </summary> /// <param name="engine">A reference to the engine.</param> public ChipManager(PixelVisionEngine engine) { this.engine = engine; }