Esempio n. 1
0
 private void bEntitiesImport_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog dialog = new OpenFileDialog()) {
         dialog.Filter = "Entity container (*.pcon)|*.pcon";
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             using (FrmResourceImport dialog2 = new FrmResourceImport()) {
                 if (dialog2.ShowDialog() == DialogResult.OK)
                 {
                     EntityContainer container = EncoderUtil.Decode <EntityContainer>(dialog.FileName, EditorEngine.Instance.GraphicsDevice);
                     foreach (EntityTemplate template in container.All())
                     {
                         template.ID = EditorEngine.Instance.World.EntityTemplateFactory.AllocateID();
                     }
                     if (dialog2.Mode == 0)
                     {
                         EditorEngine.Instance.World.EntityContainer.Clear();
                     }
                     foreach (EntityTemplate template in container.All())
                     {
                         EditorEngine.Instance.World.EntityContainer.Add(template);
                     }
                     ReloadEntityList();
                 }
             }
         }
     }
 }