void CreateNewBlockOrderDefinition() { if (!designFileTarget.HasBlocks) { Debug.LogError($"{TuxLog.Prefix} Tried to make block order definition file, but no block variables have been defined!"); return; } BlockOrderDefinition newBlockOrderDefinition = CreateInstance <BlockOrderDefinition>(); try { string savePath = Path.GetDirectoryName(path: AssetDatabase.GetAssetPath(Selection.activeObject)) + "/New Block Order Definition.asset"; string uniqueSavePath = EditorGuiHelper.GetUniqueName(savePath); AssetDatabase.CreateAsset(newBlockOrderDefinition, uniqueSavePath); AssetDatabase.SaveAssets(); } catch (ArgumentNullException) { Debug.LogError($"{TuxLog.Prefix} Could not create BlockOrderDefinition. There is probably an error in variable definitions."); } EditorUtility.FocusProjectWindow(); Selection.activeObject = newBlockOrderDefinition; if (designFileTarget == null) { throw new NullReferenceException("DesignFileNull"); } newBlockOrderDefinition.Init(designFileTarget); List <BlockOrderDefinition> orders = designFileTarget.GetBlockOrderConfigurations; orders.Add(newBlockOrderDefinition); }
BaseBlockTable GetBlockOrderTableFromOrderConfigs(int orderChosenIndex) { if (orderChosenIndex > orderConfigs.Count - 1) { throw new IndexOutOfRangeException($"IndexInBlock chosen is {orderChosenIndex}, but count is {orderConfigs.Count}"); } BlockOrderDefinition chosenBlockOrderDefinition = orderConfigs[orderChosenIndex]; if (chosenBlockOrderDefinition.Randomize && currentOrderedTableIndex == orderChosenIndex) { return(currentOrderedTable); } DataTable orderedTable = baseBlockTable.Clone(); foreach (int index in chosenBlockOrderDefinition.IndexOrder) { orderedTable.ImportRow(baseBlockTable.Rows[index]); } BaseBlockTable blockOrderTable = new BaseBlockTable(orderedTable); currentOrderedTable = blockOrderTable; currentOrderedTableIndex = orderChosenIndex; return(blockOrderTable); }