Exemplo n.º 1
0
        private void RemoveDecal(Vector3I position, List <MyDecalPartIdentity> decals, int index, ref MyCube cube)
        {
            MyDecalPartIdentity decal = decals[index];

            MyDecals.RemoveDecal(decal.DecalId);

            if (cube == null)
            {
                bool found = m_gridRender.CubeGrid.TryGetCube(position, out cube);
                if (!found)
                {
                    return;
                }
            }

            if (decal.CubePartIndex != -1)
            {
                var part = cube.Parts[decal.CubePartIndex];
                var cell = GetCell(position);
                cell.RemoveCubePartDecal(part, decal.DecalId);
            }
        }
Exemplo n.º 2
0
        public void AddDecal(Vector3I position, MyCubeGrid.MyCubeGridHitInfo gridHitInfo, uint decalId)
        {
            MyCube cube;

            if (this.m_gridRender.CubeGrid.TryGetCube(position, out cube))
            {
                if (gridHitInfo.CubePartIndex != -1)
                {
                    MyCubePart part = cube.Parts[gridHitInfo.CubePartIndex];
                    this.GetOrAddCell(part.InstanceData.Translation, true).AddCubePartDecal(part, decalId);
                }
                ConcurrentQueue <MyDecalPartIdentity> orAdd = this.m_cubeDecals.GetOrAdd(position, x => new ConcurrentQueue <MyDecalPartIdentity>());
                if (orAdd.Count > 30)
                {
                    this.RemoveDecal(position, orAdd, cube);
                }
                MyDecalPartIdentity item = new MyDecalPartIdentity {
                    DecalId       = decalId,
                    CubePartIndex = gridHitInfo.CubePartIndex
                };
                orAdd.Enqueue(item);
            }
        }