public void OnRemovedFromRender() { bool flag1; IMyEntity entity = this.m_gridRender.Entity; if (entity != null) { flag1 = !entity.MarkedForClose; } else { IMyEntity local1 = entity; flag1 = false; } bool flag = flag1; object cellsUpdateLock = this.m_cellsUpdateLock; lock (cellsUpdateLock) { foreach (KeyValuePair <Vector3I, MyCubeGridRenderCell> pair in this.m_cells) { MyCubeGridRenderCell instance = pair.Value; instance.OnRemovedFromRender(); if (flag) { this.m_dirtyCells.Add(instance); } } } }
public void AddCubePart(MyCubePart part) { Vector3 translation = part.InstanceData.Translation; MyCubeGridRenderCell orAddCell = this.GetOrAddCell(translation, true); orAddCell.AddCubePart(part); this.m_dirtyCells.Add(orAddCell); }
public void RemoveEdgeInfo(Vector3 point0, Vector3 point1, MySlimBlock owner) { Vector3 pos = (point0 + point1) * 0.5f; MyCubeGridRenderCell orAddCell = this.GetOrAddCell(pos, true); if (orAddCell.RemoveEdgeInfo(this.CalculateEdgeHash(point0, point1), owner)) { this.m_dirtyCells.Add(orAddCell); } }
public void RemoveCubePart(MyCubePart part) { Vector3 translation = part.InstanceData.Translation; MyCubeGridRenderCell orAddCell = this.GetOrAddCell(ref translation, false); if ((orAddCell != null) && orAddCell.RemoveCubePart(part)) { this.m_dirtyCells.Add(orAddCell); } }
public void AddEdgeInfo(ref Vector3 point0, ref Vector3 point1, ref Vector3 normal0, ref Vector3 normal1, Color color, MySlimBlock owner) { Vector3 pos = (point0 + point1) * 0.5f; Vector3I edgeDirection = Vector3I.Round((point0 - point1) / this.m_gridRender.GridSize); MyCubeGridRenderCell orAddCell = this.GetOrAddCell(pos, true); if (orAddCell.AddEdgeInfo(this.CalculateEdgeHash(point0, point1), new MyEdgeInfo(ref pos, ref edgeDirection, ref normal0, ref normal1, ref color, MyStringHash.GetOrCompute(owner.BlockDefinition.EdgeType)), owner)) { this.m_dirtyCells.Add(orAddCell); } }
internal MyCubeGridRenderCell GetCell(Vector3 pos) { Vector3I cellPos = Vector3I.Round((pos - m_basePos) / (SplitCellCubeCount * m_gridRender.GridSize)); MyCubeGridRenderCell result; if (!m_cells.TryGetValue(cellPos, out result)) { result = new MyCubeGridRenderCell(m_gridRender); result.DebugName = cellPos.ToString(); m_cells[cellPos] = result; } return(result); }
internal MyCubeGridRenderCell GetOrAddCell(ref Vector3 pos, bool create = true) { Vector3I vectori; MyCubeGridRenderCell cell; Vector3I.Round(ref (pos - this.m_basePos) / (30f * this.m_gridRender.GridSize), out vectori); if (!this.m_cells.TryGetValue(vectori, out cell) && create) { object cellLock = this.m_cellLock; lock (cellLock) { MyCubeGridRenderCell cell1 = new MyCubeGridRenderCell(this.m_gridRender); cell1.DebugName = vectori.ToString(); cell = cell1; this.m_cells.TryAdd(vectori, cell); } } return(cell); }
internal MyCubeGridRenderCell GetCell(Vector3 pos) { Vector3I cellPos = Vector3I.Round((pos - m_basePos) / (SplitCellCubeCount * m_gridRender.GridSize)); MyCubeGridRenderCell result; if (!m_cells.TryGetValue(cellPos, out result)) { result = new MyCubeGridRenderCell(m_gridRender); result.DebugName = cellPos.ToString(); m_cells[cellPos] = result; } return result; }