コード例 #1
0
ファイル: EditorForm.cs プロジェクト: aszpreece/SoupV2
        public void OpenEntity(EntityDefinition e)
        {
            CurrentEntityDefinition = e;
            soupGraphicControl1.CurrentSimulation = new EntityEditorSimulation(DefaultSimulationSettings.GetSettings(), new EntityDefinitionDatabase());
            soupGraphicControl1.CurrentSimulation.InitGraphics(soupGraphicControl1.GraphicsDevice, soupGraphicControl1.Editor.Content);

            if (CurrentEntityDefinition is null)
            {
                // Default entity
                CurrentEntity = soupGraphicControl1
                                .CurrentSimulation
                                .EntityManager
                                .AddEntityFromDefinition("Soupling", soupGraphicControl1.CurrentSimulation.JsonSettings, "Soupling");
            }
            else
            {
                CurrentEntity = Entity.FromDefinition(CurrentEntityDefinition, soupGraphicControl1.CurrentSimulation.JsonSettings);
                soupGraphicControl1
                .CurrentSimulation
                .EntityManager
                .AddDeserializedEntity(CurrentEntity);
            }

            TreeNode root = new TreeNode("");

            treeView1.Nodes.Clear();
            treeView1.Nodes.Add(root);
            BuildTree(CurrentEntity, root);
        }
コード例 #2
0
        static void HeadlessSimulation(Options options)
        {
            if (options.StatFilePath is null || options.SettingsPath is null)
            {
                Console.WriteLine("Must provide 'statoutfile' and 'config'");
                return;
            }

            bool error = false;
            SimulationSettings       settings = DefaultSimulationSettings.GetSettings();
            EntityDefinitionDatabase database = new EntityDefinitionDatabase();

            if (!(options.SettingsPath is null))
            {
                try
                {
                    settings = LocalStorage.LoadSettingsFile(options.SettingsPath);
                }
                catch (Exception)
                {
                    error = true;
                    Console.WriteLine("Failed to load settings file.");
                }
            }
            if (!(options.SettingsPath is null))
            {
                try
                {
                    database = LocalStorage.GetDefinitionDatabase(options.EntityFolderPath);
                }
                catch (Exception)
                {
                    error = true;
                    Console.WriteLine("Failed to load entity definition database folder.");
                }
            }
            if (error)
            {
                return;
            }

            Simulation simulation = new Simulation(settings, database);

            simulation.SetUp();
        }