public static void GenerateCacheEntities <TEntity, TCollection>(IReadOnlyList <TEntity> entities, IReadOnlyList <string> names, IReadOnlyList <string> groups = null) where TEntity : struct, IComponentData, IDataName { var em = World.DefaultGameObjectInjectionWorld.EntityManager; for (var cursor = 0; cursor < names.Count; cursor++) { var entity = entities[cursor]; entity.SetName(names[cursor]); if (entity.GroupType()) { entity.SetGroup(groups[cursor]); } em.SetComponentData(em.CreateEntity(typeof(TEntity)), entity); } FileUnpacker.GetCollector <TCollection>(); }
private async Task FillList(string filePath, CryptoClass crypto) { CancellationToken token; try { CancellationTokenSource tokenSource = new CancellationTokenSource(); token = tokenSource.Token; progressBar = new Progress(); progressBar.ProgressBar1.IsIndeterminate = true; progressBar.Show(); progressBar.Closing += (object sender, CancelEventArgs e) => { tokenSource.Cancel(); }; EventRaiser.OnFileNameChange += Unpacker_OnProgressFileNameEvent; EventRaiser.OnProgressChange += Unpacker_OnProgressPercentEvent; unpacker = await Task.Run(() => new FileUnpacker(filePath, crypto, token)); Stream unpackerStream = unpacker.UnpackStream(unpacker.fileDatas[0]); ListInit(filePath); } catch (NotAnOOFPackException) { progressBar?.Close(); MessageBox.Show("Invalid or corrupted OOF Pack!", "OOF GUI", MessageBoxButton.OK, MessageBoxImage.Warning); } catch (InvalidHeaderException e) { progressBar?.Close(); MessageBox.Show("Corrupted OOF Pack! " + e.Message, "OOF GUI", MessageBoxButton.OK, MessageBoxImage.Warning); } catch (ThreadAbortException) { progressBar?.Close(); } catch (EncryptedException) { progressBar?.Close(); OpenFileDialog selectKeyDialog = SelectKeyDialog("Your Pack seems to be encrypted! Please select a Keyfile to decrypt it."); if (selectKeyDialog != null && selectKeyDialog.ShowDialog().Value) { await FillList(filePath, new CryptoClass(selectKeyDialog.FileName)); } } catch (IncorrectKeyException) { progressBar?.Close(); OpenFileDialog selectKeyDialog = SelectKeyDialog("The Key seems to be wrong or corrupted. Please select the correct decryption keyfile!"); if (selectKeyDialog != null && selectKeyDialog.ShowDialog().Value) { await FillList(filePath, new CryptoClass(selectKeyDialog.FileName)); } } catch (Exception e) { progressBar?.Close(); MessageBox.Show("Something went wrong! " + e.Message, "OOF GUI", MessageBoxButton.OK, MessageBoxImage.Error); } finally { progressBar?.Close(); } }