Пример #1
0
        private void AssertCheckOreDeposits()
        {
            foreach (var oreDeposit in OreDepositsMutable)
            {
                Debug.Assert(oreDeposit.Value.TotalRareOreContent > 0);
                Debug.Assert(oreDeposit.Value.GetOreWithContent().Count > 0);
            }

            Dictionary <byte, int> materialsByIndex = new Dictionary <byte, int>();

            for (int i = 0; i < m_materialCells.Length; ++i)
            {
                var contentCell  = m_contentCells[i];
                var materialCell = m_materialCells[i];
                if ((contentCell != null && contentCell.CellType == MyVoxelRangeType.EMPTY) ||
                    !materialCell.ContainsRareMaterial)
                {
                    Debug.Assert(!OreDepositsMutable.ContainsKey(i));
                }
                else
                {
                    for (int j = 0; j < MaterialCell.voxelsInCell; ++j)
                    {
                        var material = materialCell.GetMaterial(j);
                        var content  = (contentCell == null) ? MyVoxelConstants.VOXEL_CONTENT_FULL : contentCell.GetContent(j);
                        if (material.IsRare && content > 0)
                        {
                            int contentPresent;
                            materialsByIndex.TryGetValue(material.Index, out contentPresent);
                            contentPresent += content;
                            materialsByIndex[material.Index] = contentPresent;
                        }
                    }
                    if (materialsByIndex.Count > 0)
                    {
                        IMyDepositCell deposit;
                        if (OreDepositsMutable.TryGetValue(i, out deposit))
                        {
                            foreach (var entry in materialsByIndex)
                            {
                                var material = MyDefinitionManager.Static.GetVoxelMaterialDefinition(entry.Key);
                                Debug.Assert(deposit.GetOreWithContent().Contains(material));
                            }
                        }
                        else
                        {
                            Debug.Fail("Missing deposit cell when there is rare ore.");
                        }
                    }
                    else
                    {
                        Debug.Assert(!OreDepositsMutable.ContainsKey(i));
                    }
                    materialsByIndex.Clear();
                }
            }
        }
Пример #2
0
        private void RemoveOreDepositCell(int cellIndex)
        {
            IMyDepositCell oreDepositCell;

            if (OreDepositsMutable.TryGetValue(cellIndex, out oreDepositCell))
            {
                OreDepositsMutable.Remove(cellIndex);
            }
        }
Пример #3
0
        private IMyDepositCell GetOreDepositCell(int cellIndex, bool createIfNeeded = false)
        {
            IMyDepositCell cell;

            OreDepositsMutable.TryGetValue(cellIndex, out cell);
            if (createIfNeeded && cell == null)
            {
                cell = ComputeAndAddDepositCell(cellIndex);
            }
            return(cell);
        }
Пример #4
0
 private void AddDepositCell(DepositCell cell)
 {
     Debug.Assert(!OreDepositsMutable.ContainsKey(cell.CellIndex));
     OreDepositsMutable[cell.CellIndex] = cell;
 }
Пример #5
0
 public void ClearOreDeposits()
 {
     OreDepositsMutable.Clear();
 }