/// <summary> /// Constructor /// </summary> /// <param name="arn"></param> public SimWorldService(SimEngine se) { // set engine this.simEngine = se; // populate obstacles this.Obstacles = new Dictionary <SimObstacleId, SimObstacle>(); }
/// <summary> /// Constructor /// </summary> /// <param name="arn"></param> public SimWorldService(SimEngine se) { // set engine this.simEngine = se; // populate obstacles this.Obstacles = new Dictionary<SimObstacleId, SimObstacle>(); }
/// <summary> /// Constructor /// </summary> public Simulation(string[] args) { // setup the editor InitializeComponent(); #region Handle Events // change grid size this.gridSizeToolStripComboBox.SelectedIndexChanged += new EventHandler(gridSizeToolStripComboBox_SelectedIndexChanged); // properties redraw this.SimulatorPropertyGrid.PropertyValueChanged += new PropertyValueChangedEventHandler(SimulatorPropertyGrid_PropertyValueChanged); // track vehicles this.trackVehiclesComboBox.SelectedIndexChanged += new EventHandler(trackVehiclesComboBox_SelectedIndexChanged); this.simulationSpeedComboBox.SelectedIndexChanged += new EventHandler(simulationSpeedComboBox_SelectedIndexChanged); #endregion // make sure we are not in design mode if (!this.DesignMode) { // list of clients this.clientHandler = new ClientHandler(); // create sim engine this.simEngine = new SimEngine(this.SimulatorPropertyGrid, this); // assign to the sim settings SimEngineSettings.simForm = this; // initialize comms this.communicator = new Communicator(this); this.communicator.RunMaintenance(); #region File Handling // check to see if we started up with a file if (args.Length >= 1) { // get the file name string fileName = args[0]; // retrieve the document extension string ext = Path.GetExtension(fileName); // check if it is an editor file if (ext == ".rdt") { // open the file OpenSimulatorFromFile(fileName); // notify SimulatorOutput.WriteLine("Opened Simulator File: " + fileName + " upon startup"); // redraw this.Invalidate(true); } } #endregion } }
/// <summary> /// Restore from a saved editor save /// </summary> /// <param name="es"></param> private void Restore(SimulatorSave es) { // restore the editor this.gridSizeToolStripComboBox.SelectedIndex = es.GridSizeIndex; this.arbiterRoads = es.ArbiterRoads; this.simEngine = es.SimEngine; this.simEngine.simulationMain = this; this.simEngine.SetPropertyGrid(this.SimulatorPropertyGrid); this.defaultMissionDescription = es.Mission; // restore the display this.roadDisplay1.LoadSave(es.displaySave); // attempt to rehash the clients this.clientHandler.ReBindAll(this.simEngine.Vehicles); }