Пример #1
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            LoggerSetup();

            EntityLoader loader = new EntityLoader();

            loader.LoadFromFile(filePath);

            List <DisplayableElement> displayableGrid  = EntityDisplayConverter.ToDisplayableElements(loader.grid.SelectMany(node => node).ToList <IPosition>());
            List <DisplayableElement> displayableRooms = EntityDisplayConverter.ToDisplayableElements(loader.rooms.ToList <IPosition>());
            SimulationForm            simulationForm   = new SimulationForm(displayableGrid, displayableRooms);

            SimulationController controller = new SimulationController(simulationForm, loader.grid, loader.movableEntities, loader.rooms);

            Console.WriteLine("Starting Setup:");
            Console.WriteLine("Seed file: {0}", filePath);
            Console.WriteLine("Simulation with {0} people", loader.movableEntities.Count);

            // close event from the GUI
            simulationForm.onCloseEvent += (object sender, EventArgs e) => controller.Dispose();
            // close event from the console
            AppDomain.CurrentDomain.ProcessExit += new EventHandler((object sender, EventArgs e) => controller.Dispose());

            Thread controllerThread = new Thread(controller.start);

            simulationForm.onShowEvent += new EventHandler((object sender, EventArgs e) => controllerThread.Start());

            Application.Run(simulationForm);
        }
 /// <summary>
 /// Tears down the LevelController in a safe manner. In particular it safely disposes of the simulation's thread.
 /// After it executes, it should be safe to instantiate another LevelController in its place.
 /// </summary>
 public void Dispose()
 {
     _simulationController.Dispose();
     _cursorTracker.Dispose();
     _cameraController.Dispose();
     _colorMapView.Dispose();
     _particleMapView.Dispose();
     _latLongGridView.Dispose();
 }