public override void RecomputeOreDeposits() { long start = MyPerformanceCounter.ElapsedTicks; DepositCell deposit = null; ClearOreDeposits(); for (int cellIndex = 0; cellIndex < m_materialCells.Length; ++cellIndex) { if (deposit == null) { deposit = new DepositCell(this); } deposit.Recompute(cellIndex); if (deposit.TotalRareOreContent > 0) { AddDepositCell(deposit); deposit = null; } } long end = MyPerformanceCounter.ElapsedTicks; MySandboxGame.Log.WriteLine(string.Format("MyOreDeposits.Recompute: {0} ms", MyPerformanceCounter.TicksToMs(end - start))); AssertCheckOreDeposits(); }
private DepositCell ComputeAndAddDepositCell(int cellIndex) { DepositCell ret = new DepositCell(this); ret.Recompute(cellIndex); AddDepositCell(ret); return(ret); }
public void ChangeOreDepositMaterial(MyVoxelMaterialDefinition oldMaterial, MyVoxelMaterialDefinition newMaterial, ref Vector3I voxelCoord) { int content = GetContent(ref voxelCoord); // if there is no content in voxel, then do nothing if (content == MyVoxelConstants.VOXEL_CONTENT_EMPTY) { return; } Vector3I cellCoord; ComputeCellCoord(ref voxelCoord, out cellCoord); DepositCell oreDepositCell = GetOreDepositCell(ref cellCoord) as DepositCell; // if new material is ore, then we must add it to ore deposit cell if (newMaterial.IsRare) { if (oreDepositCell == null) { oreDepositCell = ComputeAndAddDepositCell(ref cellCoord); } else { oreDepositCell.AddOreContent(newMaterial, content); } } // if old material is ore, then we must remove it from ore deposit cell if (oldMaterial.IsRare && oreDepositCell != null) { oreDepositCell.AddOreContent(oldMaterial, -content); if (oreDepositCell.TotalRareOreContent <= 0) { RemoveOreDepositCell(ref cellCoord); } } }
public override void RecomputeOreDeposits() { long start = MyPerformanceCounter.ElapsedTicks; DepositCell deposit = null; ClearOreDeposits(); for (int cellIndex = 0; cellIndex < m_materialCells.Length; ++cellIndex) { if (deposit == null) deposit = new DepositCell(this); deposit.Recompute(cellIndex); if (deposit.TotalRareOreContent > 0) { AddDepositCell(deposit); deposit = null; } } long end = MyPerformanceCounter.ElapsedTicks; MySandboxGame.Log.WriteLine(string.Format("MyOreDeposits.Recompute: {0} ms", MyPerformanceCounter.TicksToMs(end - start))); AssertCheckOreDeposits(); }
private void AddDepositCell(DepositCell cell) { Debug.Assert(!OreDepositsMutable.ContainsKey(cell.CellIndex)); OreDepositsMutable[cell.CellIndex] = cell; }
private DepositCell ComputeAndAddDepositCell(int cellIndex) { DepositCell ret = new DepositCell(this); ret.Recompute(cellIndex); AddDepositCell(ret); return ret; }