public void TestVMFImportExport() { // Create a new JSON adapter VMFAdapter adapter = new VMFAdapter("testinput.vmf", 64, 64); // Setup: Create a NailsMap NailsMap map = adapter.Import(); // Export the map adapter.Export(map); // Import the map var newMap = adapter.Import(); // Compare Assert.IsNotNull(newMap); NailsCube cube = newMap.GetCube(0, 0, 0); Assert.IsNotNull(cube); Assert.AreEqual("TestStyle", cube.StyleName); cube = newMap.GetCube(0, 1, 0); Assert.IsNotNull(cube); Assert.AreEqual("TestStyle", cube.StyleName); cube = newMap.GetCube(1, 1, 0); Assert.IsNotNull(cube); Assert.AreEqual("TestStyle", cube.StyleName); }
/** * Main method given command line options. * <author>1upD</author> */ private static void RunOptionsAndReturnExitCode(Options opts) { try { // Read agents from XML file NailsConfig config = NailsConfig.ReadConfiguration(opts.InputFileName); // Create a new nails map NailsMap nailsMap = new NailsMap(); AlifeMap alifeMap = new NailsAlifeMap(nailsMap); alifeMap.Agents = config.Agents; // Run the simulation AlifeSimulation.Simulate(ref alifeMap, opts.Lifetime); // Write out to a file VMFAdapter vmfAdapter = new VMFAdapter(filename: opts.OutputFileName, horizontal_scale: opts.HorizontalScale, vertical_scale: opts.VerticalScale, config: config); vmfAdapter.Export(nailsMap); } catch (Exception e) { log.Fatal("NailsCmd caught fatal exception: ", e); } }